Commit 4acd4a3a authored by Jérome Perrin's avatar Jérome Perrin

accounting: convert price script should handle the case where another section is defined on lines

Also fix some comments
parent 6c0b47e6
...@@ -50,28 +50,17 @@ ...@@ -50,28 +50,17 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""Convert the amounts used in the accounting transaction to the currency of the destination section\n
Script to convert the prices used in the transaction to the \n
currency of the destination section\n
form_id : Page that action is called from\n
\n
\n
"""\n """\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
#get the precision of the destination\n
precision = context.getDestinationSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n precision = context.getDestinationSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n
#Get all transaction lines of the transaction \n
line_list = context.contentValues(\n line_list = context.contentValues(\n
portal_type=portal.getPortalAccountingMovementTypeList())\n portal_type=portal.getPortalAccountingMovementTypeList())\n
"""\n
For each transaction line, calculate the price of the resource\n
(i.e. currency in which the transaction is being done) in the \n
context of the transaction line, add the resource, price_currency\n
and start_date categories \n
"""\n
\n \n
for line in line_list:\n for line in line_list:\n
section = line.getDestinationSectionValue()\n section = line.getDestinationSectionValue()\n
if section != context.getDestinationSectionValue():\n
continue\n
currency = line.getResourceValue()\n currency = line.getResourceValue()\n
if not exchange_rate:\n if not exchange_rate:\n
exchange_rate = currency.getPrice(context=line.asContext(\n exchange_rate = currency.getPrice(context=line.asContext(\n
......
...@@ -52,23 +52,18 @@ ...@@ -52,23 +52,18 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Script to convert the prices used in the transaction to the \n Script to convert the prices used in the transaction to the \n
currency of the destination section\n currency of the source section\n
"""\n """\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
#get the precision of the destination\n
precision = context.getSourceSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n precision = context.getSourceSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n
#Get all transaction lines of the transaction \n
line_list = context.contentValues(\n line_list = context.contentValues(\n
portal_type=portal.getPortalAccountingMovementTypeList())\n portal_type=portal.getPortalAccountingMovementTypeList())\n
"""\n \n
For each transaction line, calculate the price of the resource\n
(i.e. currency in which the transaction is being done) in the \n
context of the transaction line, add the resource, price_currency\n
and start_date categories \n
"""\n
\n \n
for line in line_list:\n for line in line_list:\n
section = line.getSourceSectionValue()\n section = line.getSourceSectionValue()\n
if section != context.getSourceSectionValue():\n
continue\n
currency = line.getResourceValue()\n currency = line.getResourceValue()\n
if not exchange_rate:\n if not exchange_rate:\n
exchange_rate = currency.getPrice(context=line.asContext(\n exchange_rate = currency.getPrice(context=line.asContext(\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