Commit 0831fb4a authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_accounting: Improve code to only consider the line that has source and...

erp5_accounting: Improve code to only consider the line that has source and destination section equal the transaction in context
parent 06f3ae0a
...@@ -78,12 +78,13 @@ for line in line_list:\n ...@@ -78,12 +78,13 @@ for line in line_list:\n
line.setQuantity(line_quantity)\n line.setQuantity(line_quantity)\n
total_quantity += line_quantity\n total_quantity += line_quantity\n
\n \n
abs_total_quantity = abs(round(total_quantity, precision))\n
# The total quantity should be zero with a little error, if simulation has been\n # The total quantity should be zero with a little error, if simulation has been\n
# completely applied, because the debit and the credit must be balanced. However,\n # completely applied, because the debit and the credit must be balanced. However,\n
# this is not the case, if the delivery is divergent, as the builder does not\n # this is not the case, if the delivery is divergent, as the builder does not\n
# adopt prevision automatically, when a conflict happens between the simulation\n # adopt prevision automatically, when a conflict happens between the simulation\n
# and user-entered values.\n # and user-entered values.\n
if abs(round(total_quantity, precision)) > 2 * resource.getBaseUnitQuantity():\n if abs_total_quantity > 2 * resource.getBaseUnitQuantity():\n
return\n return\n
\n \n
total_price = round(context.getTotalPrice(), precision)\n total_price = round(context.getTotalPrice(), precision)\n
...@@ -98,12 +99,13 @@ for line in line_list:\n ...@@ -98,12 +99,13 @@ for line in line_list:\n
account_type = context.getPortalObject().portal_categories.account_type\n account_type = context.getPortalObject().portal_categories.account_type\n
receivable_type = account_type.asset.receivable\n receivable_type = account_type.asset.receivable\n
payable_type = account_type.liability.payable\n payable_type = account_type.liability.payable\n
abs_total_quantity = abs(round(total_quantity, precision))\n
line_to_adjust = None\n line_to_adjust = None\n
\n \n
asset_line = None\n asset_line = None\n
for line, account_type_list in account_type_dict.iteritems():\n for line, account_type_list in account_type_dict.iteritems():\n
if receivable_type in account_type_list or payable_type in account_type_list:\n if receivable_type in account_type_list or payable_type in account_type_list:\n
if line.getSourceSection() == context.getSourceSection() and \\\n
line.getDestinationSection() == context.getDestinationSection():\n
asset_line = line\n asset_line = line\n
break\n break\n
\n \n
......
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