diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml index ecc289d09f38cc058e731b03a0b524277d159d29..e0910bedeba79a47ed09247932e3c526b57fe17f 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml @@ -79,7 +79,8 @@ portal.portal_selections.setSelectionParamsFor(\n # Calculate the payable/receivable quantity, using\n # Invoice_getRemainingTotalPayablePrice script.\n total_payable_price_details = \\\n - context.Invoice_getRemainingTotalPayablePrice(detailed=True)\n + context.Invoice_getRemainingTotalPayablePrice(detailed=True,\n + quantity=True)\n \n # if there\'s nothing more to pay, don\'t create an empty transaction\n if sum(total_payable_price_details.values()) == 0:\n diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml index ab0516c31d76683bf80df2ec335ac71edaa178ef..ac4ae0245531d3971bf3a4b0fe9935b5aef1afdc 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml @@ -76,6 +76,10 @@ only transactions in those states. By default it will use all but \'draft\', \n \n The `mirror_section_relative_url` parameter must be passed explicitly if the\n context invoice has multiple sections.\n +\n +If `quantity` parameter is true, this script will return the quantities in the\n +original transaction currency. If currencies on this invoice and the related\n +payments are not consistent, a ValueError is raised.\n """\n portal = context.getPortalObject()\n total_payable_price_per_node_section = dict()\n @@ -115,6 +119,7 @@ def getIsSourceMovementItemList(invoice):\n return movement_item_list\n \n \n +invoice_currency = context.getResource()\n # calculate the total price of this invoice (according to accounting\n # transaction lines)\n for is_source, line in getIsSourceMovementItemList(context):\n @@ -123,12 +128,18 @@ for is_source, line in getIsSourceMovementItemList(context):\n node_value = line.getSourceValue(portal_type=\'Account\')\n line_section = line.getSourceSection()\n mirror_section = line.getDestinationSection()\n - amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n + if quantity:\n + amount = -line.getQuantity()\n + else:\n + amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n else:\n node_value = line.getDestinationValue(portal_type=\'Account\')\n line_section = line.getDestinationSection()\n mirror_section = line.getSourceSection()\n - amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n + if quantity:\n + amount = line.getQuantity()\n + else:\n + amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n \n if at_date is None and line.getGroupingReference():\n continue\n @@ -185,18 +196,30 @@ for related_transaction in related_transaction_list:\n \n if at_date is None and line.getGroupingReference():\n continue\n +\n + if quantity:\n + if line.getResource() != invoice_currency:\n + raise ValueError("Unable to calculate"\n + ", related transaction %s uses different currency" %\n + line.getRelativeUrl())\n \n if related_transaction_is_source:\n node_value = line.getSourceValue(portal_type=\'Account\')\n line_section = line.getSourceSection()\n mirror_section = line.getDestinationSection()\n - amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n + if quantity:\n + amount = -line.getQuantity()\n + else:\n + amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n date = line.getStartDate().earliestTime()\n else:\n node_value = line.getDestinationValue(portal_type=\'Account\')\n line_section = line.getDestinationSection()\n mirror_section = line.getSourceSection()\n - amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n + if quantity:\n + amount = -line.getQuantity()\n + else:\n + amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n date = line.getStopDate().earliestTime()\n \n if node_value is not None:\n @@ -233,7 +256,7 @@ else:\n </item> <item> <key> <string>_params</string> </key> - <value> <string>detailed=0, at_date=None, account_id=None, simulation_state=None, mirror_section_relative_url=None</string> </value> + <value> <string>detailed=0, at_date=None, account_id=None, simulation_state=None, mirror_section_relative_url=None, quantity=False</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -253,7 +276,7 @@ else:\n <dictionary> <item> <key> <string>co_argcount</string> </key> - <value> <int>5</int> </value> + <value> <int>6</int> </value> </item> <item> <key> <string>co_varnames</string> </key> @@ -264,6 +287,7 @@ else:\n <string>account_id</string> <string>simulation_state</string> <string>mirror_section_relative_url</string> + <string>quantity</string> <string>_getattr_</string> <string>context</string> <string>portal</string> @@ -281,6 +305,7 @@ else:\n <string>str</string> <string>accounting_transaction_type_list</string> <string>getIsSourceMovementItemList</string> + <string>invoice_currency</string> <string>is_source</string> <string>line</string> <string>node_value</string> @@ -321,6 +346,7 @@ else:\n <none/> <none/> <none/> + <int>0</int> </tuple> </value> </item> diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index c659825d915589054405e7741f10247a60c53b42..b90f3750fe25b07f293ed4f29c46df647edaa9e6 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -1163 \ No newline at end of file +1164 \ No newline at end of file