Commit 247bd840 authored by Jérome Perrin's avatar Jérome Perrin

Accounting: Do not allow grouping if mirror account does not match

The same grouping reference property is also used for mirror section, so if one side is doing grouping, the group must also be valid for the other side.
parent 7dc1abd6
...@@ -59,9 +59,8 @@ of related accounting transactions using causality.\n ...@@ -59,9 +59,8 @@ of related accounting transactions using causality.\n
\n \n
from Products.ERP5Type.Utils import int2letter\n from Products.ERP5Type.Utils import int2letter\n
\n \n
# this dict associates (node, section, mirror_section,\n # this dict associates (node, section, mirror_section, mirror_node, extra_grouping_parameter) to a list of\n
# extra_grouping_parameter) to a list of\n # accounting lines info (total_price, date and path)\n
# accounting lines info (total_price, date and path).\n
lines_per_node = {}\n lines_per_node = {}\n
\n \n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
...@@ -100,6 +99,7 @@ for line in accounting_transaction_line_value_list:\n ...@@ -100,6 +99,7 @@ for line in accounting_transaction_line_value_list:\n
(line.getSource(portal_type=\'Account\'),\n (line.getSource(portal_type=\'Account\'),\n
section_relative_url,\n section_relative_url,\n
line.getDestinationSection(),\n line.getDestinationSection(),\n
line.getDestination(portal_type=\'Account\'),\n
line.AccountingTransactionLine_getGroupingExtraParameterList(source=True),\n line.AccountingTransactionLine_getGroupingExtraParameterList(source=True),\n
), []).append(\n ), []).append(\n
dict(total_price=line.getSourceInventoriatedTotalAssetPrice() or 0,\n dict(total_price=line.getSourceInventoriatedTotalAssetPrice() or 0,\n
...@@ -117,6 +117,7 @@ for line in accounting_transaction_line_value_list:\n ...@@ -117,6 +117,7 @@ for line in accounting_transaction_line_value_list:\n
(line.getDestination(portal_type=\'Account\'),\n (line.getDestination(portal_type=\'Account\'),\n
section_relative_url,\n section_relative_url,\n
line.getSourceSection(),\n line.getSourceSection(),\n
line.getSource(portal_type=\'Account\'),\n
line.AccountingTransactionLine_getGroupingExtraParameterList(source=False),\n line.AccountingTransactionLine_getGroupingExtraParameterList(source=False),\n
), []).append(\n ), []).append(\n
dict(total_price=line.getDestinationInventoriatedTotalAssetPrice() or 0,\n dict(total_price=line.getDestinationInventoriatedTotalAssetPrice() or 0,\n
...@@ -124,7 +125,7 @@ for line in accounting_transaction_line_value_list:\n ...@@ -124,7 +125,7 @@ for line in accounting_transaction_line_value_list:\n
path=line.getRelativeUrl()))\n path=line.getRelativeUrl()))\n
\n \n
changed_line_list = []\n changed_line_list = []\n
for (node, section, mirror_section, extra_parameter), line_info_list in lines_per_node.items():\n for (node, section, mirror_section, mirror_node, extra_parameter), line_info_list in lines_per_node.items():\n
if node is None:\n if node is None:\n
continue\n continue\n
total_price = sum([l[\'total_price\'] for l in line_info_list])\n total_price = sum([l[\'total_price\'] for l in line_info_list])\n
...@@ -136,12 +137,14 @@ for (node, section, mirror_section, extra_parameter), line_info_list in lines_pe ...@@ -136,12 +137,14 @@ for (node, section, mirror_section, extra_parameter), line_info_list in lines_pe
if default_currency is not None:\n if default_currency is not None:\n
total_price = round(total_price, default_currency.getQuantityPrecision())\n total_price = round(total_price, default_currency.getQuantityPrecision())\n
if total_price == 0 or allow_grouping_with_different_quantity:\n if total_price == 0 or allow_grouping_with_different_quantity:\n
# we should include mirror node in the id_group, but this would reset\n
# id generators and generate grouping references that were already used.\n
id_group = (\'grouping_reference\', node, section, mirror_section)\n id_group = (\'grouping_reference\', node, section, mirror_section)\n
previous_default = context.portal_ids.getLastGeneratedId(id_group=id_group, default=0)\n previous_default = context.portal_ids.getLastGeneratedId(id_group=id_group, default=0)\n
grouping_reference = portal.portal_ids.generateNewId(id_generator=\'uid\',\n grouping_reference = portal.portal_ids.generateNewId(id_generator=\'uid\',\n
id_group=id_group,\n id_group=id_group,\n
default=previous_default + 1)\n default=previous_default + 1)\n
\n \n
# convert from int to letters\n # convert from int to letters\n
string_reference = int2letter(grouping_reference)\n string_reference = int2letter(grouping_reference)\n
\n \n
......
1547 1548
\ No newline at end of file \ No newline at end of file
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