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

generate differents transaction references based on the year.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18903 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 634e911f
...@@ -84,15 +84,18 @@ if transaction.getPortalType() == \'Sale Invoice Transaction\':\n ...@@ -84,15 +84,18 @@ if transaction.getPortalType() == \'Sale Invoice Transaction\':\n
\n \n
# Generate new values for Source Reference and Destination Reference.\n # Generate new values for Source Reference and Destination Reference.\n
if not transaction.getSourceReference():\n if not transaction.getSourceReference():\n
source_id_group = (\'accounting\', \'section\', source_section)\n year = transaction.getStartDate().year()\n
source_id_group = (\'accounting\', \'section\', source_section, year)\n
source_reference = transaction.generateNewId(id_group=source_id_group,\n source_reference = transaction.generateNewId(id_group=source_id_group,\n
default=1)\n default=1)\n
transaction.setSourceReference(source_reference)\n transaction.setSourceReference(\'%s-%s\' % (year, source_reference))\n
\n
if not transaction.getDestinationReference():\n if not transaction.getDestinationReference():\n
destination_id_group = (\'accounting\', \'section\', destination_section)\n year = transaction.getStopDate().year()\n
destination_id_group = (\'accounting\', \'section\', destination_section, year)\n
destination_reference = transaction.generateNewId(\n destination_reference = transaction.generateNewId(\n
id_group=destination_id_group, default=1)\n id_group=destination_id_group, default=1)\n
transaction.setDestinationReference(destination_reference)\n transaction.setDestinationReference(\'%s-%s\' % (year, destination_reference))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -149,6 +152,7 @@ if not transaction.getDestinationReference():\n ...@@ -149,6 +152,7 @@ if not transaction.getDestinationReference():\n
<string>destination_section</string> <string>destination_section</string>
<string>invoice_id_group</string> <string>invoice_id_group</string>
<string>invoice_reference</string> <string>invoice_reference</string>
<string>year</string>
<string>source_id_group</string> <string>source_id_group</string>
<string>source_reference</string> <string>source_reference</string>
<string>destination_id_group</string> <string>destination_id_group</string>
......
557 558
\ No newline at end of file \ No newline at end of file
...@@ -2962,17 +2962,28 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -2962,17 +2962,28 @@ class TestAccounting(ERP5TypeTestCase):
# clear all existing ids in portal ids # clear all existing ids in portal ids
if hasattr(self.portal.portal_ids, 'dict_ids'): if hasattr(self.portal.portal_ids, 'dict_ids'):
self.portal.portal_ids.dict_ids.clear() self.portal.portal_ids.dict_ids.clear()
accounting_transaction = self.createAccountingTransaction() accounting_transaction = self.createAccountingTransaction(
start_date=DateTime(2001, 01, 01),
stop_date=DateTime(2001, 01, 01))
self.portal.portal_workflow.doActionFor( self.portal.portal_workflow.doActionFor(
accounting_transaction, 'stop_action') accounting_transaction, 'stop_action')
self.assertEquals('1', accounting_transaction.getSourceReference()) self.assertEquals('2001-1', accounting_transaction.getSourceReference())
self.assertEquals('1', accounting_transaction.getDestinationReference()) self.assertEquals('2001-1', accounting_transaction.getDestinationReference())
other_transaction = self.createAccountingTransaction() other_transaction = self.createAccountingTransaction(
start_date=DateTime(2001, 01, 01),
stop_date=DateTime(2001, 01, 01))
other_transaction.setDestinationSectionValue(self.other_vendor) other_transaction.setDestinationSectionValue(self.other_vendor)
self.portal.portal_workflow.doActionFor(other_transaction, 'stop_action') self.portal.portal_workflow.doActionFor(other_transaction, 'stop_action')
self.assertEquals('2', other_transaction.getSourceReference()) self.assertEquals('2001-2', other_transaction.getSourceReference())
self.assertEquals('1', other_transaction.getDestinationReference()) self.assertEquals('2001-1', other_transaction.getDestinationReference())
next_year_transaction = self.createAccountingTransaction(
start_date=DateTime(2002, 01, 01),
stop_date=DateTime(2002, 01, 01))
self.portal.portal_workflow.doActionFor(next_year_transaction, 'stop_action')
self.assertEquals('2002-1', next_year_transaction.getSourceReference())
self.assertEquals('2002-1', next_year_transaction.getDestinationReference())
def test_suite(): def test_suite():
......
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