Commit b2255186 authored by Jérome Perrin's avatar Jérome Perrin

Ledger and grouping reference

Hey @Nicolas can you please take a look at all this ?

All this started when I realised we probably do not want to allow grouping reference to be set when we have transactions from different ledgers ( edda8b58 ) and then realized it would be required to allow choosing ledger in grouping fast input instead of just showing all ledgers together ( d1ecbe29 ).

The rest are small changes to move out complex logic from TALES to a script and small fixups.

Thanks

/reviewed-on !170
parents 25cd1201 dd0ceb8f
......@@ -6,11 +6,14 @@ For instance, we can refuse to group together lines for different order by retur
The returned value must be hashable.
"""
# By default we take into account mirror section.
# The rationale is that when using internal accounting transaction between
# By default we take into account ledger and mirror accounting.
# We consider ledger so that, by default we don't group lines from different ledger.
# This may be customized too, depending on how ledgers are used in customized implementations.
# We consider mirror accounting because that when using internal accounting transaction between
# two entities of the group, the grouping has to be valid for both sides
# (source_section & destination_section).
# This behavior was introduced in nexedi/erp5@f3bebea3 for compatibility,
# some old sites where accounting lines have been grouped together regardless of
# the mirror node can decide to ignore the mirror account.
......@@ -19,5 +22,5 @@ The returned value must be hashable.
# This can be achieved easily by customizing this script.
if source:
return context.getSource(portal_type='Account')
return context.getDestination(portal_type='Account')
return context.getLedger(), context.getSource(portal_type='Account')
return context.getLedger(), context.getDestination(portal_type='Account')
......@@ -3,18 +3,12 @@
portal = context.getPortalObject()
portal_types = portal.portal_types
accounting_type_list = portal.getPortalAccountingTransactionTypeList()
ledger_set = set()
for accounting_type in accounting_type_list:
try:
new_ledger_list = portal_types[accounting_type].getLedgerValueList([])
ledger_set = ledger_set.union(set(new_ledger_list))
except AttributeError:
# This portal type doesn't inherit from Delivery Type, thus we can pass
continue
ledger_item_list = context.Base_getPreferredCategoryChildItemList(
portal.portal_categories.ledger, base=True)
if len(ledger_set):
return [[ledger.getTranslatedTitle(), ledger.getRelativeUrl()] for ledger in list(ledger_set)]
for accounting_type in portal.getPortalAccountingTransactionTypeList():
ledger_set.update(portal_types[accounting_type].getLedgerList(base=True))
return ()
return [item for item in ledger_item_list if item[1] in ledger_set]
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>source=True</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -44,6 +44,10 @@ mirror_section = mirror_section or request.get('mirror_section')
if mirror_section:
search_kw['mirror_section_uid'] = portal.restrictedTraverse(
mirror_section).getUid()
ledger = ledger or request.get('ledger')
if ledger:
search_kw['ledger_uid'] = [
portal.portal_categories.restrictedTraverse(x).getUid() for x in ledger]
if grouping == 'grouping':
search_kw['grouping_reference'] = None
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection=None, grouping=\'grouping\', node=\'\', mirror_section=\'\', title=None, delivery_reference=None, debit_price=None, credit_price=None, date=None, **kw</string> </value>
<value> <string>selection=None, grouping=\'grouping\', node=\'\', mirror_section=\'\', ledger=\'\', title=None, delivery_reference=None, debit_price=None, credit_price=None, date=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -75,6 +75,7 @@
<list>
<string>your_node</string>
<string>your_mirror_section</string>
<string>your_ledger</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_ledger</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountModule_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -142,7 +142,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\',\'\')] + [(ledger.getTranslatedTitle(), ledger.getCategoryRelativeUrl(base=0)) for ledger in here.portal_types[here.getPortalType()].getLedgerValueList()]</string> </value>
<value> <string>context/Delivery_getLedgerItemList</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>ledger/test_accounting</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_accounting</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Test Accounting</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>ledger/test_accounting/test_ledger_1</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_ledger_1</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Test Ledger 1</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>ledger/test_accounting/test_ledger_2</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_ledger_2</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Test Ledger 2</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_group_dialog_ledger.html</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head><title>Using Ledger in Grouping Dialog</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Using Ledger in Grouping Dialog
</td></tr>
</thead><tbody tal:define="init_method string:AccountingZuite_createAccountingTransactionList?add_draft_transactions:int=0&add_related_payments:int=1&set_ledger:int=1">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/AccountingZuite_CommonTemplate/macros/init"/>
<tr>
<td>selectAndWait</td>
<td>select_module</td>
<td>Organisations</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Folder_show:method</td>
<td></td>
</tr>
<tr>
<td>type</td>
<!-- title -->
<td>//tr[@class='listbox-search-line']/th[2]/input</td>
<td>Client 1</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//input[@class="listbox-select-action"]</td>
<td></td>
</tr>
<!-- }}} -->
<!-- {{{ Select Client 1 Organisation and use grouping fast input -->
<tr>
<td>clickAndWait</td>
<td>link=Client 1</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//img[@alt='Grouping Reference Fast Input']</td>
<td></td>
</tr>
<!-- The mode should be 'grouping' by default -->
<tr>
<td>verifyValue</td>
<td>//input[@name='field_your_grouping' and @value='grouping']</td>
<td>on</td>
</tr>
<tr>
<td>verifyText</td>
<td>//label[contains(text(),"Total Selected Amount")]/../div[1]/</td>
<td>0.00</td>
</tr>
<tr>
<td>select</td>
<td>field_your_node</td>
<td>label=41 - Receivable</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>2 records</td>
</tr>
<!-- in test ledger 2, we have no transactions. -->
<tr>
<td>select</td>
<td>field_your_ledger</td>
<td>label=Test Accounting/Test Ledger 2</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>0 records</td>
</tr>
<!-- in test ledger 1, we have 2 transactions. -->
<tr>
<td>select</td>
<td>field_your_ledger</td>
<td>label=Test Accounting/Test Ledger 1</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>2 records</td>
</tr>
<!-- in test ledger 1 and 2, we have 2 transactions. -->
<tr>
<td>addSelection</td>
<td>field_your_ledger</td>
<td>label=Test Accounting/Test Ledger 1</td>
</tr>
<tr>
<td>addSelection</td>
<td>field_your_ledger</td>
<td>label=Test Accounting/Test Ledger 2</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>2 records</td>
</tr>
<!-- }}} -->
</tbody></table>
</body>
</html> <!-- vim: syntax=html foldmethod=marker
-->
\ No newline at end of file
......@@ -14,9 +14,9 @@ business_process = portal.portal_catalog.getResultValue(
portal_type='Business Process').getRelativeUrl()
# if the previous test didn't change input data, no need to recreate content
current_script_data_id = '%s_month_count_%s_draft_%s_state_%s_payment_%s' % (
current_script_data_id = '%s_month_count_%s_draft_%s_state_%s_payment_%s_leger_%s' % (
month_count, add_draft_transactions, transaction_state,
add_related_payments, script.getId())
add_related_payments, set_ledger, script.getId())
if accounting_module.getProperty('current_content_script',
'') == current_script_data_id:
......@@ -34,6 +34,18 @@ if 1:
raise ValueError("Do not run this on production !!!")
module.manage_delObjects(list(module.objectIds()))
# if `set_ledger`is true, allow all test ledgers in accounting types.
for accounting_type_id in portal.getPortalAccountingTransactionTypeList():
accounting_type = portal.portal_types[accounting_type_id]
accounting_type.edit(
ledger_value_list=list(portal.portal_categories.ledger.test_accounting.contentValues())
if set_ledger else ())
test_ledger_1 = test_ledger_2 = None
if set_ledger:
test_ledger_1 = portal.portal_categories.ledger.test_accounting.test_ledger_1
test_ledger_2 = portal.portal_categories.ledger.test_accounting.test_ledger_2
def getAccountByTitle(title):
account_list = [x.getObject().getRelativeUrl() for x in
portal.portal_catalog(portal_type='Account',
......@@ -97,6 +109,7 @@ for month in range(1, month_count + 1):
portal_type='Accounting Transaction',
source_section=section,
created_by_builder=1,
ledger_value=test_ledger_1,
start_date=default_date,
stop_date=default_date,
resource=euro_resource,
......@@ -135,6 +148,7 @@ for month in range(1, month_count + 1):
source=section,
destination=getOrganisationByTitle(client_title),
created_by_builder=1,
ledger_value=test_ledger_1,
start_date=default_date,
stop_date=default_date,
specialise=business_process,
......@@ -174,6 +188,7 @@ for month in range(1, month_count + 1):
source_section=section,
destination_section=getOrganisationByTitle(client_title),
created_by_builder=1,
ledger_value=test_ledger_1,
start_date=default_date + .1, # make sure this will be after the invoice
stop_date=default_date + .1,
resource=euro_resource,
......@@ -213,6 +228,7 @@ for month in range(1, month_count + 1):
destination_section=section,
source_section=getOrganisationByTitle('Supplier'),
created_by_builder=1,
ledger_value=test_ledger_1,
start_date=default_date-5, # In purchase invoice transaction, stop_date is accounting operation date.
stop_date=default_date,
specialise=business_process,
......@@ -248,6 +264,7 @@ if add_draft_transactions:
source_section=section,
destination_section=getOrganisationByTitle(client_title),
created_by_builder=1,
ledger_value=test_ledger_1,
start_date=default_date,
stop_date=default_date,
resource=euro_resource,
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>month_count=1, add_draft_transactions=1, transaction_state=\'validated\', add_related_payments=0, keep_grouping_reference=0</string> </value>
<value> <string>month_count=1, add_draft_transactions=1, transaction_state=\'validated\', add_related_payments=0, keep_grouping_reference=0, set_ledger=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -33,6 +33,8 @@ portal_categories/group/demo_group
portal_categories/group/demo_group/**
portal_categories/group/vendor
portal_categories/group/vendor/**
portal_categories/ledger/test_accounting
portal_categories/ledger/test_accounting/**
portal_categories/payment_mode/cash
portal_categories/payment_mode/check
portal_categories/role/client
......
"""Returns the possible ledger for this delivery.
This will return only ledgers allowed in the delivery type definition.
"""
portal = context.getPortalObject()
ledger_item_list = context.Base_getPreferredCategoryChildItemList(portal.portal_categories.ledger)
allowed_ledger_list = portal.portal_types[context.getPortalType()].getLedgerList()
return [('', '')] + [item for item in ledger_item_list if item[1] in allowed_ledger_list]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_getLedgerItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -26,6 +26,7 @@ Delivery Causality Assignment Movement Group | view
Delivery Tool | view
Delivery Type | action_view
Delivery Type | copy_roles
Delivery Type | delivery_view
Delivery Type | jump_property_sheets
Delivery Type | role_view
Delivery Type | translation_view
......
......@@ -118,7 +118,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\',\'\')] + [(ledger.getTranslatedTitle(), ledger.getCategoryRelativeUrl(base=0)) for ledger in here.portal_types[here.getPortalType()].getLedgerValueList()]</string> </value>
<value> <string>context/Delivery_getLedgerItemList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -118,7 +118,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\',\'\')] + [(ledger.getTranslatedTitle(), ledger.getCategoryRelativeUrl(base=0)) for ledger in here.portal_types[here.getPortalType()].getLedgerValueList()]</string> </value>
<value> <string>context/Delivery_getLedgerItemList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -241,6 +241,25 @@ class AccountingTestCase(ERP5TypeTestCase):
'erp5_configurator_standard_invoicing_template',
'erp5_simulation_test')
@UnrestrictedMethod
def setUpLedger(self):
# Create Ledger Categories
ledger_category = self.portal.portal_categories.ledger
ledger_accounting_category = ledger_category.get('accounting', None)
if ledger_accounting_category is None:
ledger_accounting_category = ledger_category.newContent(portal_type='Category', id='accounting')
if ledger_accounting_category.get('general', None) is None:
ledger_accounting_category.newContent(portal_type='Category', id='general')
if ledger_accounting_category.get('detailed', None) is None:
ledger_accounting_category.newContent(portal_type='Category', id='detailed')
if ledger_accounting_category.get('other', None) is None:
ledger_accounting_category.newContent(portal_type='Category', id='other')
# Allow some ledgers on the 'Sale Invoice Transaction' portal type
self.portal.portal_types['Sale Invoice Transaction'].edit(
ledger=['accounting/general', 'accounting/detailed'])
class TestAccounts(AccountingTestCase):
"""Tests Accounts.
......@@ -1169,24 +1188,6 @@ class TestClosingPeriod(AccountingTestCase):
self.assertEqual(None, pl_movement.getSourceTotalAssetPrice())
self.assertEqual(200., pl_movement.getDestinationCredit())
@UnrestrictedMethod
def setUpLedger(self):
# Create Ledger Categories
ledger_category = self.portal.portal_categories.ledger
ledger_accounting_category = ledger_category.get('accounting', None)
if ledger_accounting_category is None:
ledger_accounting_category = ledger_category.newContent(portal_type='Category', id='accounting')
if ledger_accounting_category.get('general', None) is None:
ledger_accounting_category.newContent(portal_type='Category', id='general')
if ledger_accounting_category.get('detailed', None) is None:
ledger_accounting_category.newContent(portal_type='Category', id='detailed')
if ledger_accounting_category.get('other', None) is None:
ledger_accounting_category.newContent(portal_type='Category', id='other')
# Allow some ledgers on the 'Sale Invoice Transaction' portal type
self.portal.portal_types['Sale Invoice Transaction'].edit(
ledger=['accounting/general', 'accounting/detailed'])
def test_createBalanceOnLedgerWithTransactionsWithNoLedger(self):
self.setUpLedger()
organisation_module = self.organisation_module
......@@ -3462,6 +3463,8 @@ class TestTransactions(AccountingTestCase):
invoice.stop()
self.assertTrue(invoice_line.getGroupingReference())
self.assertTrue(payment_line.getGroupingReference())
self.assertEqual(invoice_line.getGroupingReference(),
payment_line.getGroupingReference())
# the grouping date is set to the latest date of all grouped lines
self.assertEqual(DateTime(2012, 1, 3), invoice_line.getGroupingDate())
self.assertEqual(DateTime(2012, 1, 3), payment_line.getGroupingDate())
......@@ -3478,6 +3481,8 @@ class TestTransactions(AccountingTestCase):
invoice.stop()
self.assertTrue(invoice_line.getGroupingReference())
self.assertTrue(payment_line.getGroupingReference())
self.assertEqual(invoice_line.getGroupingReference(),
payment_line.getGroupingReference())
self.assertEqual(DateTime(2012, 1, 3), invoice_line.getGroupingDate())
self.assertEqual(DateTime(2012, 1, 3), payment_line.getGroupingDate())
......@@ -3525,6 +3530,8 @@ class TestTransactions(AccountingTestCase):
invoice.stop()
self.assertTrue(invoice_line.getGroupingReference())
self.assertTrue(payment_line.getGroupingReference())
self.assertEqual(invoice_line.getGroupingReference(),
payment_line.getGroupingReference())
# when restarting, grouping is removed
invoice.restart()
......@@ -3534,6 +3541,8 @@ class TestTransactions(AccountingTestCase):
invoice.stop()
self.assertTrue(invoice_line.getGroupingReference())
self.assertTrue(payment_line.getGroupingReference())
self.assertEqual(invoice_line.getGroupingReference(),
payment_line.getGroupingReference())
def test_automatically_setting_grouping_reference_only_related(self):
invoice = self._makeOne(
......@@ -3662,6 +3671,74 @@ class TestTransactions(AccountingTestCase):
for line in invoice.contentValues():
self.assertTrue(line.getGroupingReference())
def test_automatically_setting_grouping_reference_when_same_ledger(self):
self.setUpLedger()
invoice = self._makeOne(
title='First Invoice',
ledger_value=self.portal.portal_categories.ledger.accounting.general,
destination_section_value=self.organisation_module.client_1,
lines=(dict(source_value=self.account_module.goods_purchase,
source_debit=100),
dict(source_value=self.account_module.receivable,
source_credit=100,
id='line_for_grouping_reference',)))
invoice_line = invoice.line_for_grouping_reference
payment = self._makeOne(
title='First Invoice Payment',
portal_type='Payment Transaction',
simulation_state='delivered',
causality_value=invoice,
ledger_value=self.portal.portal_categories.ledger.accounting.general,
source_payment_value=self.section.newContent(
portal_type='Bank Account'),
destination_section_value=self.organisation_module.client_1,
lines=(dict(source_value=self.account_module.receivable,
id='line_for_grouping_reference',
source_debit=100),
dict(source_value=self.account_module.bank,
source_credit=100,)))
payment_line = payment.line_for_grouping_reference
invoice.stop()
self.assertTrue(invoice_line.getGroupingReference())
self.assertTrue(payment_line.getGroupingReference())
self.assertEqual(invoice_line.getGroupingReference(),
payment_line.getGroupingReference())
def test_not_automatically_setting_grouping_reference_when_different_ledger(self):
self.setUpLedger()
invoice = self._makeOne(
title='First Invoice',
ledger_value=self.portal.portal_categories.ledger.accounting.general,
destination_section_value=self.organisation_module.client_1,
lines=(dict(source_value=self.account_module.goods_purchase,
source_debit=100),
dict(source_value=self.account_module.receivable,
source_credit=100,
id='line_for_grouping_reference',)))
invoice_line = invoice.line_for_grouping_reference
payment = self._makeOne(
title='First Invoice Payment',
portal_type='Payment Transaction',
simulation_state='delivered',
causality_value=invoice,
ledger_value=self.portal.portal_categories.ledger.accounting.detailed,
source_payment_value=self.section.newContent(
portal_type='Bank Account'),
destination_section_value=self.organisation_module.client_1,
lines=(dict(source_value=self.account_module.receivable,
id='line_for_grouping_reference',
source_debit=100),
dict(source_value=self.account_module.bank,
source_credit=100,)))
payment_line = payment.line_for_grouping_reference
invoice.stop()
self.assertFalse(invoice_line.getGroupingReference())
self.assertFalse(payment_line.getGroupingReference())
def test_roundDebitCredit_raises_if_big_difference(self):
invoice = self._makeOne(
portal_type='Sale Invoice Transaction',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment