Commit 3e874abb authored by Jérome Perrin's avatar Jérome Perrin

Support multiple sections properly in accounting periods.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31059 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5f6dd24d
...@@ -76,11 +76,18 @@ at_date = context.getStopDate()\n ...@@ -76,11 +76,18 @@ at_date = context.getStopDate()\n
assert at_date\n assert at_date\n
\n \n
section = context.getParentValue()\n section = context.getParentValue()\n
section_uid = context.getParentUid()\n
section_currency = section.getPriceCurrency()\n section_currency = section.getPriceCurrency()\n
section_currency_precision = section.getPriceCurrencyValue().getQuantityPrecision()\n section_currency_precision = section.getPriceCurrencyValue().getQuantityPrecision()\n
section_category = section.getGroup(base=True)\n
\n \n
balance_transaction = portal.accounting_module.newContent(\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
section = portal.portal_catalog.getObject(uid=section_uid)\n
\n
balance_transaction = portal.accounting_module.newContent(\n
activate_kw=dict(tag=activity_tag),\n activate_kw=dict(tag=activity_tag),\n
portal_type=\'Balance Transaction\',\n portal_type=\'Balance Transaction\',\n
start_date=(at_date + 1).earliestTime(),\n start_date=(at_date + 1).earliestTime(),\n
...@@ -89,14 +96,14 @@ balance_transaction = portal.accounting_module.newContent(\n ...@@ -89,14 +96,14 @@ balance_transaction = portal.accounting_module.newContent(\n
resource=section_currency,\n resource=section_currency,\n
causality_value=context)\n causality_value=context)\n
\n \n
group_by_node_node_category_list = []\n group_by_node_node_category_list = []\n
group_by_mirror_section_node_category_list = []\n group_by_mirror_section_node_category_list = []\n
group_by_payment_node_category_list = []\n group_by_payment_node_category_list = []\n
profit_and_loss_node_category_list = []\n profit_and_loss_node_category_list = []\n
\n \n
node_category_list = portal.portal_categories\\\n node_category_list = portal.portal_categories\\\n
.account_type.getCategoryChildValueList()\n .account_type.getCategoryChildValueList()\n
for node_category in node_category_list:\n for node_category in node_category_list:\n
node_category_url = node_category.getRelativeUrl()\n node_category_url = node_category.getRelativeUrl()\n
if node_category_url in (\n if node_category_url in (\n
\'account_type/asset/cash/bank\',):\n \'account_type/asset/cash/bank\',):\n
...@@ -110,20 +117,20 @@ for node_category in node_category_list:\n ...@@ -110,20 +117,20 @@ for node_category in node_category_list:\n
else:\n else:\n
group_by_node_node_category_list.append(node_category_url)\n group_by_node_node_category_list.append(node_category_url)\n
\n \n
getInventoryList = portal.portal_simulation.getInventoryList\n getInventoryList = portal.portal_simulation.getInventoryList\n
\n \n
inventory_param_dict = dict(section_uid=section_uid,\n inventory_param_dict = dict(section_uid=section_uid,\n
simulation_state=(\'delivered\',),\n simulation_state=(\'delivered\',),\n
precision=section_currency_precision,\n precision=section_currency_precision,\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n portal_type=portal.getPortalAccountingMovementTypeList(),\n
at_date=at_date.latestTime(),)\n at_date=at_date.latestTime(),)\n
\n \n
section_currency_uid = context.getParentValue().getPriceCurrencyUid()\n section_currency_uid = context.getParentValue().getPriceCurrencyUid()\n
\n \n
profit_and_loss_quantity = 0\n profit_and_loss_quantity = 0\n
line_count = 0\n line_count = 0\n
\n \n
for inventory in getInventoryList(\n for inventory in getInventoryList(\n
node_category_strict_membership=group_by_node_node_category_list,\n node_category_strict_membership=group_by_node_node_category_list,\n
group_by_node=1,\n group_by_node=1,\n
group_by_resource=1,\n group_by_resource=1,\n
...@@ -165,7 +172,7 @@ for inventory in getInventoryList(\n ...@@ -165,7 +172,7 @@ for inventory in getInventoryList(\n
quantity=total_price)\n quantity=total_price)\n
\n \n
\n \n
for inventory in getInventoryList(\n for inventory in getInventoryList(\n
node_category_strict_membership=group_by_mirror_section_node_category_list,\n node_category_strict_membership=group_by_mirror_section_node_category_list,\n
group_by_node=1,\n group_by_node=1,\n
group_by_mirror_section=1,\n group_by_mirror_section=1,\n
...@@ -202,7 +209,7 @@ for inventory in getInventoryList(\n ...@@ -202,7 +209,7 @@ for inventory in getInventoryList(\n
quantity=total_price)\n quantity=total_price)\n
\n \n
\n \n
for inventory in getInventoryList(\n for inventory in getInventoryList(\n
node_category_strict_membership=group_by_payment_node_category_list,\n node_category_strict_membership=group_by_payment_node_category_list,\n
group_by_node=1,\n group_by_node=1,\n
group_by_payment=1,\n group_by_payment=1,\n
...@@ -239,16 +246,16 @@ for inventory in getInventoryList(\n ...@@ -239,16 +246,16 @@ for inventory in getInventoryList(\n
destination_payment_uid=inventory.payment_uid,\n destination_payment_uid=inventory.payment_uid,\n
quantity=total_price)\n quantity=total_price)\n
\n \n
# add a final line for p&l\n # add a final line for p&l\n
balance_transaction.newContent(\n balance_transaction.newContent(\n
id=\'%03d\' % (line_count + 1),\n id=\'%03d\' % (line_count + 1),\n
portal_type=\'Balance Transaction Line\',\n portal_type=\'Balance Transaction Line\',\n
destination=profit_and_loss_account,\n destination=profit_and_loss_account,\n
quantity=-profit_and_loss_quantity)\n quantity=-profit_and_loss_quantity)\n
\n \n
# and go to delivered state directly (the user is not supposed to edit this document)\n # and go to delivered state directly (the user is not supposed to edit this document)\n
balance_transaction.stop()\n balance_transaction.stop()\n
balance_transaction.deliver()\n balance_transaction.deliver()\n
\n \n
# make sure this Accounting Period has an activity pending during the indexing\n # make sure this Accounting Period has an activity pending during the indexing\n
# of the balance transaction.\n # of the balance transaction.\n
...@@ -303,16 +310,18 @@ context.activate(after_tag=activity_tag).getTitle()\n ...@@ -303,16 +310,18 @@ context.activate(after_tag=activity_tag).getTitle()\n
<string>at_date</string> <string>at_date</string>
<string>AssertionError</string> <string>AssertionError</string>
<string>section</string> <string>section</string>
<string>section_uid</string>
<string>section_currency</string> <string>section_currency</string>
<string>section_currency_precision</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>balance_transaction</string>
<string>group_by_node_node_category_list</string> <string>group_by_node_node_category_list</string>
<string>group_by_mirror_section_node_category_list</string> <string>group_by_mirror_section_node_category_list</string>
<string>group_by_payment_node_category_list</string> <string>group_by_payment_node_category_list</string>
<string>profit_and_loss_node_category_list</string> <string>profit_and_loss_node_category_list</string>
<string>node_category_list</string> <string>node_category_list</string>
<string>_getiter_</string>
<string>node_category</string> <string>node_category</string>
<string>node_category_url</string> <string>node_category_url</string>
<string>getInventoryList</string> <string>getInventoryList</string>
......
...@@ -69,12 +69,19 @@ section = period.getParentValue()\n ...@@ -69,12 +69,19 @@ section = period.getParentValue()\n
while section.getPortalType() == period.getPortalType():\n while section.getPortalType() == period.getPortalType():\n
section = section.getParentValue()\n section = section.getParentValue()\n
\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 movement_list = portal.portal_simulation.getMovementHistoryList(\n
section_uid=section.getUid(),\n section_uid=section_uid,\n
from_date=period.getStartDate().earliestTime(),\n from_date=period.getStartDate().earliestTime(),\n
at_date=period.getStopDate().latestTime(),\n at_date=period.getStopDate().latestTime(),\n
simulation_state=invalid_simulation_state_list,\n simulation_state=invalid_simulation_state_list,\n
portal_type=portal.getPortalAccountingMovementTypeList(),)\n portal_type=portal.getPortalAccountingMovementTypeList(),\n
limit=1)\n
\n \n
if movement_list:\n if movement_list:\n
raise ValidationFailed, translateString(\n raise ValidationFailed, translateString(\n
...@@ -133,6 +140,9 @@ if movement_list:\n ...@@ -133,6 +140,9 @@ if movement_list:\n
<string>state</string> <string>state</string>
<string>invalid_simulation_state_list</string> <string>invalid_simulation_state_list</string>
<string>section</string> <string>section</string>
<string>True</string>
<string>section_category</string>
<string>section_uid</string>
<string>movement_list</string> <string>movement_list</string>
</tuple> </tuple>
</value> </value>
......
1071 1073
\ No newline at end of file \ 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