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

If account_id is passed explictly, use this account even if it's not payable|receivable.

If we have two invoices for two mirror sections, we can calculate the remaining price if we have a payment transaction, because mirror sections are differents

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17226 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e64e82f7
......@@ -115,10 +115,7 @@ def getIsSourceMovementItemList(invoice):\n
source on this movement\n
Handle the (very ad hoc) case of Balance Transfer Transactions\n
"""\n
if invoice.AccountingTransaction_isSourceView():\n
is_source = 1\n
else:\n
is_source = 0\n
is_source = invoice.AccountingTransaction_isSourceView()\n
movement_item_list = [(is_source, m) for m in invoice.getMovementList(\n
portal_type=portal.getPortalAccountingMovementTypeList())]\n
for btt in context.getCausalityRelatedValueList(\n
......@@ -132,6 +129,7 @@ def getIsSourceMovementItemList(invoice):\n
\n
return movement_item_list\n
\n
\n
# calculate the total price of this invoice (according to accounting\n
# transaction lines)\n
for is_source, line in getIsSourceMovementItemList(context):\n
......@@ -150,15 +148,17 @@ for is_source, line in getIsSourceMovementItemList(context):\n
if at_date is None and line.getGroupingReference():\n
continue\n
\n
if node_value is not None and \\\n
node_value.getAccountTypeId() in (\'payable\', \'receivable\'):\n
if node_value is not None:\n
if account_id is not None and node_value.getId() not in account_id:\n
continue\n
if account_id is None and node_value.getAccountTypeId() not in (\'payable\', \'receivable\'):\n
continue\n
key = (node_value.getRelativeUrl(), mirror_section)\n
total_payable_price_per_node_section[key] =\\\n
total_payable_price_per_node_section.get(key, 0) + amount\n
accounts_in_context.append(node_value)\n
\n
\n
related_transaction_list = context.getCausalityRelatedValueList(\n
portal_type=accounting_transaction_type_list)\n
\n
......@@ -180,11 +180,16 @@ for related_transaction in related_transaction_list:\n
continue\n
if other_invoice_is_source:\n
other_invoice_line_account = other_line.getSourceValue()\n
other_invoice_line_mirror_section = other_line.getDestinationSection()\n
else:\n
other_invoice_line_account = other_line.getDestinationValue()\n
other_invoice_line_mirror_section = other_line.getSourceSection()\n
\n
if other_invoice_line_account in accounts_in_context:\n
raise ValueError(\'Unable to calculate\')\n
# unless this line is for another mirror_section, we cannot calculate\n
if mirror_section_relative_url is None or \\\n
other_invoice_line_mirror_section == mirror_section_relative_url:\n
raise ValueError(\'Unable to calculate %s\' % context.getPath())\n
\n
related_transaction_is_source = related_transaction.\\\n
AccountingTransaction_isSourceView()\n
......@@ -207,8 +212,11 @@ for related_transaction in related_transaction_list:\n
amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n
date = line.getStopDate().earliestTime()\n
\n
if node_value is not None and \\\n
node_value.getAccountTypeId() in (\'payable\', \'receivable\'):\n
if node_value is not None:\n
if account_id is not None and node_value.getId() not in account_id:\n
continue\n
if account_id is None and node_value.getAccountTypeId() not in (\'payable\', \'receivable\'):\n
continue\n
if at_date and date > at_date:\n
continue\n
if node_value in accounts_in_context:\n
......@@ -313,6 +321,7 @@ else:\n
<string>other_invoice_is_source</string>
<string>other_line</string>
<string>other_invoice_line_account</string>
<string>other_invoice_line_mirror_section</string>
<string>ValueError</string>
<string>related_transaction_is_source</string>
<string>date</string>
......
446
\ No newline at end of file
449
\ 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