diff --git a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getBalanceExplanationReportSectionList.xml b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getBalanceExplanationReportSectionList.xml index 278d3bb0fccd8248d3f89208f02554e68b6550d0..a3998ee70b0dee4b34929ba68c087789a9af5e18 100644 --- a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getBalanceExplanationReportSectionList.xml +++ b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getBalanceExplanationReportSectionList.xml @@ -72,6 +72,7 @@ from Products.PythonScripts.standard import Object\n portal = context.getPortalObject()\n request = portal.REQUEST\n +precision = 2 # XXX M9 use hardcoded precision for now\n \n account = request.get(\'account\', \'\')\n at_date = request[\'at_date\']\n @@ -146,9 +147,10 @@ for account_value in account_value_list:\n transaction = brain.getObject().getParentValue()\n dunning_info = transaction.SaleInvoiceTransaction_getDunningInfo()\n \n - debit = max(brain.total_price, 0)\n + qty = round(brain.total_price, precision)\n + debit = max(qty, 0)\n total_debit += debit\n - credit = max(-brain.total_price, 0)\n + credit = max(-qty, 0)\n total_credit += credit\n \n movement_list.append(\n @@ -251,6 +253,7 @@ return report_section_list\n <string>context</string> <string>portal</string> <string>request</string> + <string>precision</string> <string>account</string> <string>_getitem_</string> <string>at_date</string> @@ -279,6 +282,8 @@ return report_section_list\n <string>brain</string> <string>transaction</string> <string>dunning_info</string> + <string>round</string> + <string>qty</string> <string>max</string> <string>debit</string> <string>credit</string> diff --git a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getJournalPerTransmissionSheetReportSectionList.xml b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getJournalPerTransmissionSheetReportSectionList.xml index 56fd163f2bb04bca98ccc005ca821c4f825f7495..7b83df214b940babb5c897d176623a8b675b1be6 100644 --- a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getJournalPerTransmissionSheetReportSectionList.xml +++ b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getJournalPerTransmissionSheetReportSectionList.xml @@ -75,6 +75,8 @@ request = context.REQUEST\n cache_storage = request.other\n portal = context.portal_url.getPortalObject()\n N_ = portal.Base_translateString\n +precision = 2 # XXX M9 uses EUR, so we hardcode 2 places for now\n +\n \n at_date = request[\'at_date\']\n from_date = request.get(\'from_date\', None) or at_date\n @@ -119,9 +121,24 @@ def getAccountClass(account_url):\n # fr / m9 / ${classe} / ...\n classe = account.getGap().split(\'/\')[2]\n # XXX this can raise with bad account. add a constraint checker on accounts\n + # XXX also this only work if you have only m9 installed. But anyway, it\'s\n + # not planned to support m9 and other accounting version on the same\n + # instance.\n account_class_cache[account_url] = classe\n return classe\n \n +origin_id_cache = {}\n +def getOriginId(origin_url):\n + try:\n + return origin_id_cache[origin_url]\n + except KeyError:\n + origin = portal.portal_categories.origin.restrictedTraverse(origin_url)\n + origin_id = origin.getId()\n + if origin_id in portal.portal_types.objectIds():\n + origin_id = \'\'\n + origin_id_cache[origin_url] = origin_id\n + return origin_id\n +\n for brain in simtool.getMovementHistoryList(\n from_date=from_date.earliestTime(),\n at_date=at_date.latestTime(),\n @@ -133,23 +150,32 @@ for brain in simtool.getMovementHistoryList(\n if payment_mode_url and not \\\n mvt.getPaymentMode(\'\').startswith(payment_mode_url):\n continue\n - origin = mvt.getOriginId()\n - sheet = mvt.getParentValue().getAggregateTitle(portal_type=\'Invoice Transmission Sheet\')\n +\n + origin = getOriginId(mvt.getOrigin())\n + sheet = mvt.getParentValue().getAggregateTitle(\n + portal_type=\'Invoice Transmission Sheet\')\n if brain.node_relative_url:\n # per account and origin\n account = per_account_and_origin_cache.setdefault(\n brain.node_relative_url, {})\n - qty = brain.total_price or 0\n - total = account.setdefault(origin, 0)\n - account[origin] = total + qty\n + qty = round(brain.total_price or 0, precision)\n + debit = max(qty, 0)\n + credit = max(-qty, 0)\n +\n + total_debit, total_credit = account.get(origin, (0, 0))\n + account[origin] = ( total_debit + debit, total_credit + credit )\n # per origin and sheet\n origin_cache = per_origin_and_sheet_cache.setdefault(origin, {})\n - total = origin_cache.get((sheet, brain.node_relative_url), 0)\n - origin_cache[(sheet, brain.node_relative_url)] = total + qty\n + total_debit, total_credit = origin_cache.get(\n + (sheet, brain.node_relative_url), (0, 0))\n + origin_cache[(sheet, brain.node_relative_url)] = \\\n + ( total_debit + debit,\n + total_credit + credit )\n # per account class\n cache = per_account_cache[getAccountClass(brain.node_relative_url)]\n - total = cache.get(brain.node_relative_url, 0)\n - cache[brain.node_relative_url] = total + qty\n + total_debit, total_credit = cache.get(brain.node_relative_url, (0, 0))\n + cache[brain.node_relative_url] = ( total_debit + debit,\n + total_credit + credit )\n \n report_section_list = [ ReportSection(\n title=N_(\'Transactions\'),\n @@ -237,6 +263,7 @@ return report_section_list\n <string>cache_storage</string> <string>portal</string> <string>N_</string> + <string>precision</string> <string>_getitem_</string> <string>at_date</string> <string>None</string> @@ -254,14 +281,21 @@ return report_section_list\n <string>per_account_cache</string> <string>account_class_cache</string> <string>getAccountClass</string> + <string>origin_id_cache</string> + <string>getOriginId</string> <string>_getiter_</string> <string>brain</string> <string>mvt</string> <string>origin</string> <string>sheet</string> <string>account</string> + <string>round</string> <string>qty</string> - <string>total</string> + <string>max</string> + <string>debit</string> + <string>credit</string> + <string>total_debit</string> + <string>total_credit</string> <string>_write_</string> <string>origin_cache</string> <string>cache</string> diff --git a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getM9AccountingTransactionLineList.xml b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getM9AccountingTransactionLineList.xml index 721baa4bd759b4f2ae875b0ca8c97c7a019c0ab8..3680fa45103e50a3b708d5dd393520f108248c37 100644 --- a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getM9AccountingTransactionLineList.xml +++ b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getM9AccountingTransactionLineList.xml @@ -73,17 +73,16 @@ line_list = []\n cache_storage = context.REQUEST.other\n selection_name = \'accounting_selection\'\n accounting_movement_type_list = context.getPortalAccountingMovementTypeList()\n +precision = 2 # XXX M9 uses EUR for now\n \n -stool = context.getPortalObject().portal_selections\n +portal = context.getPortalObject()\n +stool = portal.portal_selections\n selection = stool.getSelectionFor(selection_name)\n per_account_and_origin_cache = cache_storage.setdefault(\n \'m9_report_per_account_and_origin_summary\', {})\n per_origin_and_sheet_cache = cache_storage.setdefault(\n \'m9_report_per_origin_and_sheet_summary\', {})\n \n -simtool = context.portal_simulation\n -# FIXME: how to pass pass parameter in the selection without\n -# making them persistent ?\n context.REQUEST.other[\'src__\'] = 1\n context.REQUEST.other[\'no_limit\'] = 1\n context.REQUEST.other[\'search_result_keys\'] = [\'catalog.uid\']\n @@ -97,9 +96,21 @@ def getPaymentModeCodification(payment_mode):\n payment_mode_cache[payment_mode] = category_title\n return category_title\n \n +origin_id_cache = {}\n +def getOriginId(origin_url):\n + try:\n + return origin_id_cache[origin_url]\n + except KeyError:\n + origin = portal.portal_categories.origin.restrictedTraverse(origin_url)\n + origin_id = origin.getId()\n + if origin_id in portal.portal_types.objectIds():\n + origin_id = \'\'\n + origin_id_cache[origin_url] = origin_id\n + return origin_id\n +\n # call getMovementHistory by building a subquery with accounting module\n # selection\'s query, using the src__=1 trick from above\n -for brain in simtool.getMovementHistoryList(\n +for brain in portal.portal_simulation.getMovementHistoryList(\n where_expression="catalog.parent_uid IN (%s)" %\n stool.callSelectionFor(selection_name),\n section_category=selection.getParams().get(\'section_category\'),\n @@ -109,14 +120,18 @@ for brain in simtool.getMovementHistoryList(\n \n movement = brain.getObject()\n transaction = movement.getParentValue()\n - origin = transaction.getProperty(\'origin_id\')\n + origin = getOriginId(transaction.getProperty(\'origin\'))\n sheet = transaction.getProperty(\'aggregate_title\')\n payment_mode_codification = getPaymentModeCodification(\n transaction.getPaymentMode())\n + qty = round((brain.total_price or 0), precision)\n + debit = max(qty, 0)\n + credit = max(-qty, 0)\n \n obj = Object(\n parent_portal_type=transaction.getTranslatedPortalType(),\n - parent_int_index="%05d" % transaction.getIntIndex(0),\n + parent_int_index=transaction.getIntIndex() and\n + ("%05d" % transaction.getIntIndex()) or \'\',\n payment_mode_codification=payment_mode_codification,\n parent_aggregate_title=sheet,\n parent_origin_id=origin,\n @@ -125,25 +140,26 @@ for brain in simtool.getMovementHistoryList(\n section_uid=brain.section_uid,\n node_relative_url=brain.node_relative_url,\n getObject=brain.getObject,\n -# asContext=movement.asContext,\n -# asContext=lambda *args, **kw: movement, # optim ?\n -# Movement_getExplanationUrl=movement.Movement_getExplanationUrl,\n \n date=brain.date,\n - debit=max(brain.total_price, 0),\n - credit=max(-(brain.total_price or 0), 0), )\n + debit=debit,\n + credit=credit )\n line_list.append(obj)\n \n if brain.node_relative_url:\n # per account and origin\n account = per_account_and_origin_cache.setdefault(\n brain.node_relative_url, {})\n - total = account.setdefault(origin, 0)\n - account[origin] = total + (brain.total_price or 0)\n + total_debit, total_credit = account.get(origin, (0, 0))\n + account[origin] = ( total_debit + debit, total_credit + credit )\n + \n # per origin and sheet\n origin_cache = per_origin_and_sheet_cache.setdefault(origin, {})\n - total = origin_cache.setdefault((sheet, brain.node_relative_url), 0)\n - origin_cache[(sheet, brain.node_relative_url)] = total + (brain.total_price or 0)\n + total_debit, total_credit = origin_cache.get(\n + (sheet, brain.node_relative_url), (0, 0))\n + origin_cache[(sheet, brain.node_relative_url)] = (\n + total_debit + debit,\n + total_credit + credit )\n \n return line_list\n </string> </value> @@ -197,15 +213,18 @@ return line_list\n <string>cache_storage</string> <string>selection_name</string> <string>accounting_movement_type_list</string> + <string>precision</string> + <string>portal</string> <string>stool</string> <string>selection</string> <string>per_account_and_origin_cache</string> <string>per_origin_and_sheet_cache</string> - <string>simtool</string> <string>_write_</string> <string>None</string> <string>payment_mode_cache</string> <string>getPaymentModeCodification</string> + <string>origin_id_cache</string> + <string>getOriginId</string> <string>_getiter_</string> <string>brain</string> <string>movement</string> @@ -213,10 +232,15 @@ return line_list\n <string>origin</string> <string>sheet</string> <string>payment_mode_codification</string> + <string>round</string> + <string>qty</string> <string>max</string> + <string>debit</string> + <string>credit</string> <string>obj</string> <string>account</string> - <string>total</string> + <string>total_debit</string> + <string>total_credit</string> <string>origin_cache</string> </tuple> </value> diff --git a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountAndOriginSummaryLineList.xml b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountAndOriginSummaryLineList.xml index 3ce45f22c5e8e58cdfea2ae687708547e3395f49..9a5f584ad01f26cdec7b3215a9fed3059c1f3cf5 100644 --- a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountAndOriginSummaryLineList.xml +++ b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountAndOriginSummaryLineList.xml @@ -69,7 +69,7 @@ <item> <key> <string>_body</string> </key> <value> <string>from Products.PythonScripts.standard import Object\n -cache_storage = context.REQUEST.other\n +cache_storage = container.REQUEST.other\n line_list = []\n portal = context.getPortalObject()\n total_debit = 0\n @@ -82,10 +82,9 @@ account_list.sort()\n for account_url in account_list:\n values = account_cache[account_url]\n account_title = portal.restrictedTraverse(account_url).Account_getFormattedTitle()\n - for origin, total_price in values.items():\n - debit = max(total_price, 0)\n + \n + for origin, (debit, credit) in values.items():\n total_debit += debit\n - credit = -min(total_price, 0)\n total_credit += credit\n line_list.append(Object(uid=\'new_\',\n origin=origin,\n @@ -142,9 +141,10 @@ return line_list\n <string>Products.PythonScripts.standard</string> <string>Object</string> <string>_getattr_</string> - <string>context</string> + <string>container</string> <string>cache_storage</string> <string>line_list</string> + <string>context</string> <string>portal</string> <string>total_debit</string> <string>total_credit</string> @@ -156,10 +156,7 @@ return line_list\n <string>values</string> <string>account_title</string> <string>origin</string> - <string>total_price</string> - <string>max</string> <string>debit</string> - <string>min</string> <string>credit</string> <string>_write_</string> </tuple> diff --git a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountClassSummaryList.xml b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountClassSummaryList.xml index 0f327863a27379099bc078e64ab0f3b24979d0c3..9233dff27e62d06c901f26575a1e4cc2ba3b6f46 100644 --- a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountClassSummaryList.xml +++ b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerAccountClassSummaryList.xml @@ -81,10 +81,8 @@ account_list = account_cache.keys()\n account_list.sort()\n \n for account_url in account_list:\n - total_price = account_cache[account_url]\n - debit = round(max(total_price, 0), 2)\n + debit, credit = account_cache[account_url]\n total_debit += debit\n - credit = round(-min(total_price, 0), 2)\n total_credit += credit\n \n line_list.append(Object(uid=\'new_\',\n @@ -158,11 +156,7 @@ return line_list\n <string>account_list</string> <string>_getiter_</string> <string>account_url</string> - <string>total_price</string> - <string>round</string> - <string>max</string> <string>debit</string> - <string>min</string> <string>credit</string> <string>_write_</string> </tuple> diff --git a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerOriginAndSheetSummaryLineList.xml b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerOriginAndSheetSummaryLineList.xml index 63202b930b1053cf4b9c759251353de9c810e4ef..17c91dd40443049402926b95937e7499f6792656 100644 --- a/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerOriginAndSheetSummaryLineList.xml +++ b/bt5/erp5_accounting_l10n_fr_m9/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr_m9/AccountingTransactionModule_getPerOriginAndSheetSummaryLineList.xml @@ -69,7 +69,7 @@ <item> <key> <string>_body</string> </key> <value> <string>from Products.PythonScripts.standard import Object\n -cache_storage = context.REQUEST.other\n +cache_storage = container.REQUEST.other\n line_list = []\n portal = context.getPortalObject()\n total_debit = 0\n @@ -83,13 +83,9 @@ for origin in origin_list:\n values = origin_cache[origin]\n items = values.items()\n items.sort()\n - for (sheet, account_url), total_price in items:\n + for (sheet, account_url), (debit, credit) in items:\n account = portal.restrictedTraverse(account_url)\n -\n - # XXX assume a precision of 2 places, because we use EUR for M9\n - debit = round(max(total_price, 0), 2)\n total_debit += debit\n - credit = round(-min(total_price, 0), 2)\n total_credit += credit\n line_list.append(Object(uid=\'new_\',\n origin=origin,\n @@ -149,9 +145,10 @@ return line_list\n <string>Products.PythonScripts.standard</string> <string>Object</string> <string>_getattr_</string> - <string>context</string> + <string>container</string> <string>cache_storage</string> <string>line_list</string> + <string>context</string> <string>portal</string> <string>total_debit</string> <string>total_credit</string> @@ -164,13 +161,9 @@ return line_list\n <string>items</string> <string>sheet</string> <string>account_url</string> - <string>total_price</string> - <string>account</string> - <string>round</string> - <string>max</string> <string>debit</string> - <string>min</string> <string>credit</string> + <string>account</string> <string>_write_</string> </tuple> </value> diff --git a/bt5/erp5_accounting_l10n_fr_m9/bt/revision b/bt5/erp5_accounting_l10n_fr_m9/bt/revision index eb13855b7d70b04d6f04877df2cafe05de51a051..9d1ce53f8cc2ee2d55094091042b3fd02f9bd1ce 100644 --- a/bt5/erp5_accounting_l10n_fr_m9/bt/revision +++ b/bt5/erp5_accounting_l10n_fr_m9/bt/revision @@ -1 +1 @@ -79 \ No newline at end of file +82 \ No newline at end of file