[Erp5-report] r31059 jerome - in /erp5/trunk/bt5/erp5_accounting: SkinTemplateItem/portal_s...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Dec 4 09:13:14 CET 2009


Author: jerome
Date: Fri Dec  4 09:13:11 2009
New Revision: 31059

URL: http://svn.erp5.org?rev=31059&view=rev
Log:
Support multiple sections properly in accounting periods.

Modified:
    erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml
    erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.xml
    erp5/trunk/bt5/erp5_accounting/bt/revision

Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml?rev=31059&r1=31058&r2=31059&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml [utf8] Fri Dec  4 09:13:11 2009
@@ -76,179 +76,186 @@
 assert at_date\n
 \n
 section = context.getParentValue()\n
-section_uid = context.getParentUid()\n
 section_currency = section.getPriceCurrency()\n
 section_currency_precision = section.getPriceCurrencyValue().getQuantityPrecision()\n
-\n
-balance_transaction = portal.accounting_module.newContent(\n
-                        activate_kw=dict(tag=activity_tag),\n
-                        portal_type=\'Balance Transaction\',\n
-                        start_date=(at_date + 1).earliestTime(),\n
-                        title=context.getTitle() or Base_translateString(\'Balance Transaction\'),\n
-                        destination_section_value=section,\n
-                        resource=section_currency,\n
-                        causality_value=context)\n
-\n
-group_by_node_node_category_list = []\n
-group_by_mirror_section_node_category_list = []\n
-group_by_payment_node_category_list = []\n
-profit_and_loss_node_category_list = []\n
-\n
-node_category_list = portal.portal_categories\\\n
-            .account_type.getCategoryChildValueList()\n
-for node_category in node_category_list:\n
-  node_category_url = node_category.getRelativeUrl()\n
-  if node_category_url in (\n
-      \'account_type/asset/cash/bank\',):\n
-    group_by_payment_node_category_list.append(node_category_url)\n
-  elif node_category_url in (\n
-      \'account_type/asset/receivable\',\n
-      \'account_type/liability/payable\'):\n
-    group_by_mirror_section_node_category_list.append(node_category_url)\n
-  elif node_category_url in (\'account_type/income\', \'account_type/expense\'):\n
-    profit_and_loss_node_category_list.append(node_category_url)\n
-  else:\n
-    group_by_node_node_category_list.append(node_category_url)\n
-\n
-getInventoryList = portal.portal_simulation.getInventoryList\n
-\n
-inventory_param_dict = dict(section_uid=section_uid,\n
-                            simulation_state=(\'delivered\',),\n
-                            precision=section_currency_precision,\n
-                            portal_type=portal.getPortalAccountingMovementTypeList(),\n
-                            at_date=at_date.latestTime(),)\n
-                            \n
-section_currency_uid = context.getParentValue().getPriceCurrencyUid()\n
-\n
-profit_and_loss_quantity = 0\n
-line_count = 0\n
-\n
-for inventory in getInventoryList(\n
-        node_category_strict_membership=group_by_node_node_category_list,\n
-        group_by_node=1,\n
-        group_by_resource=1,\n
-        **inventory_param_dict):\n
+section_category = section.getGroup(base=True)\n
+\n
+# we use Base_getSectionUidListForSectionCategory as the only API to get the\n
+# organisation member of that "accounting entity"\n
+for section_uid in \\\n
+    portal.Base_getSectionUidListForSectionCategory(section_category):\n
   \n
-  total_price = roundCurrency(inventory.total_price or 0, section_currency)\n
-  quantity = roundCurrency(inventory.total_quantity or 0,\n
-                           inventory.resource_relative_url)\n
-  \n
-  if not total_price and not quantity:\n
-    continue\n
-  \n
-  line_count += 1\n
-  if inventory.resource_uid != section_currency_uid:\n
-    if inventory.node_relative_url == profit_and_loss_account:\n
-      raise ValueError(\'Using multiple currencies on profit and loss account \'\n
-                       \'is not supported\')\n
+  section = portal.portal_catalog.getObject(uid=section_uid)\n
+\n
+  balance_transaction = portal.accounting_module.newContent(\n
+                          activate_kw=dict(tag=activity_tag),\n
+                          portal_type=\'Balance Transaction\',\n
+                          start_date=(at_date + 1).earliestTime(),\n
+                          title=context.getTitle() or Base_translateString(\'Balance Transaction\'),\n
+                          destination_section_value=section,\n
+                          resource=section_currency,\n
+                          causality_value=context)\n
+\n
+  group_by_node_node_category_list = []\n
+  group_by_mirror_section_node_category_list = []\n
+  group_by_payment_node_category_list = []\n
+  profit_and_loss_node_category_list = []\n
+\n
+  node_category_list = portal.portal_categories\\\n
+              .account_type.getCategoryChildValueList()\n
+  for node_category in node_category_list:\n
+    node_category_url = node_category.getRelativeUrl()\n
+    if node_category_url in (\n
+        \'account_type/asset/cash/bank\',):\n
+      group_by_payment_node_category_list.append(node_category_url)\n
+    elif node_category_url in (\n
+        \'account_type/asset/receivable\',\n
+        \'account_type/liability/payable\'):\n
+      group_by_mirror_section_node_category_list.append(node_category_url)\n
+    elif node_category_url in (\'account_type/income\', \'account_type/expense\'):\n
+      profit_and_loss_node_category_list.append(node_category_url)\n
+    else:\n
+      group_by_node_node_category_list.append(node_category_url)\n
+\n
+  getInventoryList = portal.portal_simulation.getInventoryList\n
+\n
+  inventory_param_dict = dict(section_uid=section_uid,\n
+                              simulation_state=(\'delivered\',),\n
+                              precision=section_currency_precision,\n
+                              portal_type=portal.getPortalAccountingMovementTypeList(),\n
+                              at_date=at_date.latestTime(),)\n
+                              \n
+  section_currency_uid = context.getParentValue().getPriceCurrencyUid()\n
+\n
+  profit_and_loss_quantity = 0\n
+  line_count = 0\n
+\n
+  for inventory in getInventoryList(\n
+          node_category_strict_membership=group_by_node_node_category_list,\n
+          group_by_node=1,\n
+          group_by_resource=1,\n
+          **inventory_param_dict):\n
+    \n
+    total_price = roundCurrency(inventory.total_price or 0, section_currency)\n
+    quantity = roundCurrency(inventory.total_quantity or 0,\n
+                             inventory.resource_relative_url)\n
+    \n
+    if not total_price and not quantity:\n
+      continue\n
+    \n
+    line_count += 1\n
+    if inventory.resource_uid != section_currency_uid:\n
+      if inventory.node_relative_url == profit_and_loss_account:\n
+        raise ValueError(\'Using multiple currencies on profit and loss account \'\n
+                         \'is not supported\')\n
+      profit_and_loss_quantity += total_price\n
+      balance_transaction.newContent(\n
+          id=\'%03d\' % line_count,\n
+          portal_type=\'Balance Transaction Line\',\n
+          destination=inventory.node_relative_url,\n
+          resource=inventory.resource_relative_url,\n
+          quantity=quantity,\n
+          destination_total_asset_price=total_price)\n
+    else:\n
+      if total_price != quantity:\n
+        # If this fail for you, your accounting doesn\'t use currencies with\n
+        # consistency\n
+        raise ValueError(\'Different price: %s != %s \' % (\n
+                          total_price, quantity))\n
+      \n
+      if inventory.node_relative_url != profit_and_loss_account:\n
+        profit_and_loss_quantity += total_price\n
+        balance_transaction.newContent(\n
+          id=\'%03d\' % line_count,\n
+          portal_type=\'Balance Transaction Line\',\n
+          destination=inventory.node_relative_url,\n
+          quantity=total_price)\n
+\n
+      \n
+  for inventory in getInventoryList(\n
+          node_category_strict_membership=group_by_mirror_section_node_category_list,\n
+          group_by_node=1,\n
+          group_by_mirror_section=1,\n
+          group_by_resource=1,\n
+          **inventory_param_dict):\n
+\n
+    total_price = roundCurrency(inventory.total_price or 0, section_currency)\n
+    quantity = roundCurrency(inventory.total_quantity or 0,\n
+                             inventory.resource_relative_url)\n
+    \n
+    if not total_price and not quantity:\n
+      continue\n
     profit_and_loss_quantity += total_price\n
-    balance_transaction.newContent(\n
+    line_count += 1\n
+\n
+    if inventory.resource_uid != section_currency_uid:\n
+      balance_transaction.newContent(\n
+        id=\'%03d\' % line_count,\n
+        portal_type=\'Balance Transaction Line\',\n
+        destination=inventory.node_relative_url,\n
+        source_section_uid=inventory.mirror_section_uid,\n
+        resource=inventory.resource_relative_url,\n
+        quantity=quantity,\n
+        destination_total_asset_price=total_price)\n
+    else:\n
+      if total_price != quantity:\n
+        raise ValueError(\'Different price: %s != %s \' % (\n
+                          total_price, quantity))\n
+      balance_transaction.newContent(\n
+        id=\'%03d\' % line_count,\n
+        portal_type=\'Balance Transaction Line\',\n
+        destination=inventory.node_relative_url,\n
+        source_section_uid=inventory.mirror_section_uid,\n
+        quantity=total_price)\n
+\n
+\n
+  for inventory in getInventoryList(\n
+          node_category_strict_membership=group_by_payment_node_category_list,\n
+          group_by_node=1,\n
+          group_by_payment=1,\n
+          group_by_resource=1,\n
+          **inventory_param_dict):\n
+\n
+    total_price = roundCurrency(inventory.total_price or 0, section_currency)\n
+    quantity = roundCurrency(inventory.total_quantity or 0,\n
+                             inventory.resource_relative_url)\n
+    \n
+    if not total_price and not quantity:\n
+      continue\n
+    profit_and_loss_quantity += total_price\n
+    \n
+    line_count += 1\n
+\n
+    if inventory.resource_uid != section_currency_uid:\n
+      balance_transaction.newContent(\n
         id=\'%03d\' % line_count,\n
         portal_type=\'Balance Transaction Line\',\n
         destination=inventory.node_relative_url,\n
         resource=inventory.resource_relative_url,\n
         quantity=quantity,\n
+        destination_payment_uid=inventory.payment_uid,\n
         destination_total_asset_price=total_price)\n
-  else:\n
-    if total_price != quantity:\n
-      # If this fail for you, your accounting doesn\'t use currencies with\n
-      # consistency\n
-      raise ValueError(\'Different price: %s != %s \' % (\n
-                        total_price, quantity))\n
-    \n
-    if inventory.node_relative_url != profit_and_loss_account:\n
-      profit_and_loss_quantity += total_price\n
+    else:\n
+      if total_price != quantity:\n
+        raise ValueError(\'Different price: %s != %s \' % (\n
+                          total_price, quantity))\n
       balance_transaction.newContent(\n
         id=\'%03d\' % line_count,\n
         portal_type=\'Balance Transaction Line\',\n
         destination=inventory.node_relative_url,\n
+        destination_payment_uid=inventory.payment_uid,\n
         quantity=total_price)\n
 \n
-    \n
-for inventory in getInventoryList(\n
-        node_category_strict_membership=group_by_mirror_section_node_category_list,\n
-        group_by_node=1,\n
-        group_by_mirror_section=1,\n
-        group_by_resource=1,\n
-        **inventory_param_dict):\n
-\n
-  total_price = roundCurrency(inventory.total_price or 0, section_currency)\n
-  quantity = roundCurrency(inventory.total_quantity or 0,\n
-                           inventory.resource_relative_url)\n
-  \n
-  if not total_price and not quantity:\n
-    continue\n
-  profit_and_loss_quantity += total_price\n
-  line_count += 1\n
-\n
-  if inventory.resource_uid != section_currency_uid:\n
-    balance_transaction.newContent(\n
-      id=\'%03d\' % line_count,\n
-      portal_type=\'Balance Transaction Line\',\n
-      destination=inventory.node_relative_url,\n
-      source_section_uid=inventory.mirror_section_uid,\n
-      resource=inventory.resource_relative_url,\n
-      quantity=quantity,\n
-      destination_total_asset_price=total_price)\n
-  else:\n
-    if total_price != quantity:\n
-      raise ValueError(\'Different price: %s != %s \' % (\n
-                        total_price, quantity))\n
-    balance_transaction.newContent(\n
-      id=\'%03d\' % line_count,\n
-      portal_type=\'Balance Transaction Line\',\n
-      destination=inventory.node_relative_url,\n
-      source_section_uid=inventory.mirror_section_uid,\n
-      quantity=total_price)\n
-\n
-\n
-for inventory in getInventoryList(\n
-        node_category_strict_membership=group_by_payment_node_category_list,\n
-        group_by_node=1,\n
-        group_by_payment=1,\n
-        group_by_resource=1,\n
-        **inventory_param_dict):\n
-\n
-  total_price = roundCurrency(inventory.total_price or 0, section_currency)\n
-  quantity = roundCurrency(inventory.total_quantity or 0,\n
-                           inventory.resource_relative_url)\n
-  \n
-  if not total_price and not quantity:\n
-    continue\n
-  profit_and_loss_quantity += total_price\n
-  \n
-  line_count += 1\n
-\n
-  if inventory.resource_uid != section_currency_uid:\n
-    balance_transaction.newContent(\n
-      id=\'%03d\' % line_count,\n
-      portal_type=\'Balance Transaction Line\',\n
-      destination=inventory.node_relative_url,\n
-      resource=inventory.resource_relative_url,\n
-      quantity=quantity,\n
-      destination_payment_uid=inventory.payment_uid,\n
-      destination_total_asset_price=total_price)\n
-  else:\n
-    if total_price != quantity:\n
-      raise ValueError(\'Different price: %s != %s \' % (\n
-                        total_price, quantity))\n
-    balance_transaction.newContent(\n
-      id=\'%03d\' % line_count,\n
-      portal_type=\'Balance Transaction Line\',\n
-      destination=inventory.node_relative_url,\n
-      destination_payment_uid=inventory.payment_uid,\n
-      quantity=total_price)\n
-\n
-# add a final line for p&l\n
-balance_transaction.newContent(\n
-          id=\'%03d\' % (line_count + 1),\n
-          portal_type=\'Balance Transaction Line\',\n
-          destination=profit_and_loss_account,\n
-          quantity=-profit_and_loss_quantity)\n
-\n
-# and go to delivered state directly (the user is not supposed to edit this document)\n
-balance_transaction.stop()\n
-balance_transaction.deliver()\n
+  # add a final line for p&l\n
+  balance_transaction.newContent(\n
+            id=\'%03d\' % (line_count + 1),\n
+            portal_type=\'Balance Transaction Line\',\n
+            destination=profit_and_loss_account,\n
+            quantity=-profit_and_loss_quantity)\n
+\n
+  # and go to delivered state directly (the user is not supposed to edit this document)\n
+  balance_transaction.stop()\n
+  balance_transaction.deliver()\n
 \n
 # make sure this Accounting Period has an activity pending during the indexing\n
 # of the balance transaction.\n
@@ -303,16 +310,18 @@
                             <string>at_date</string>
                             <string>AssertionError</string>
                             <string>section</string>
-                            <string>section_uid</string>
                             <string>section_currency</string>
                             <string>section_currency_precision</string>
+                            <string>True</string>
+                            <string>section_category</string>
+                            <string>_getiter_</string>
+                            <string>section_uid</string>
                             <string>balance_transaction</string>
                             <string>group_by_node_node_category_list</string>
                             <string>group_by_mirror_section_node_category_list</string>
                             <string>group_by_payment_node_category_list</string>
                             <string>profit_and_loss_node_category_list</string>
                             <string>node_category_list</string>
-                            <string>_getiter_</string>
                             <string>node_category</string>
                             <string>node_category_url</string>
                             <string>getInventoryList</string>

Modified: erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.xml?rev=31059&r1=31058&r2=31059&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.xml [utf8] Fri Dec  4 09:13:11 2009
@@ -69,12 +69,19 @@
 while section.getPortalType() == period.getPortalType():\n
   section = section.getParentValue()\n
 \n
+section_category = section.getGroup(base=True)\n
+if not section_category:\n
+  raise ValidationFailed, translateString("This Organisation must be member of a Group")\n
+\n
+section_uid = portal.Base_getSectionUidListForSectionCategory(section_category)\n
+\n
 movement_list = portal.portal_simulation.getMovementHistoryList(\n
-      section_uid=section.getUid(),\n
+      section_uid=section_uid,\n
       from_date=period.getStartDate().earliestTime(),\n
       at_date=period.getStopDate().latestTime(),\n
       simulation_state=invalid_simulation_state_list,\n
-      portal_type=portal.getPortalAccountingMovementTypeList(),)\n
+      portal_type=portal.getPortalAccountingMovementTypeList(),\n
+      limit=1)\n
 \n
 if movement_list:\n
   raise ValidationFailed, translateString(\n
@@ -133,6 +140,9 @@
                             <string>state</string>
                             <string>invalid_simulation_state_list</string>
                             <string>section</string>
+                            <string>True</string>
+                            <string>section_category</string>
+                            <string>section_uid</string>
                             <string>movement_list</string>
                           </tuple>
                         </value>

Modified: erp5/trunk/bt5/erp5_accounting/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/bt/revision?rev=31059&r1=31058&r2=31059&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/bt/revision [utf8] Fri Dec  4 09:13:11 2009
@@ -1,1 +1,1 @@
-1071
+1073




More information about the Erp5-report mailing list