Commit 007d51db authored by Jérome Perrin's avatar Jérome Perrin

make it possible to extend account_type/expense and account_type/income

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34121 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1eae444c
...@@ -166,7 +166,7 @@ for node in getInventoryList(\n ...@@ -166,7 +166,7 @@ for node in getInventoryList(\n
\n \n
### profit & loss accounts {{{\n ### profit & loss accounts {{{\n
for node in getInventoryList(\n for node in getInventoryList(\n
node_category_strict_membership=profit_and_loss_account_type,\n node_category=profit_and_loss_account_type,\n
from_date=max(period_start_date, from_date),\n from_date=max(period_start_date, from_date),\n
group_by_node=1,\n group_by_node=1,\n
omit_output=1,\n omit_output=1,\n
...@@ -182,7 +182,7 @@ for node in getInventoryList(\n ...@@ -182,7 +182,7 @@ for node in getInventoryList(\n
total_debit += round(total_price, precision)\n total_debit += round(total_price, precision)\n
\n \n
for node in getInventoryList(\n for node in getInventoryList(\n
node_category_strict_membership=profit_and_loss_account_type,\n node_category=profit_and_loss_account_type,\n
from_date=max(period_start_date, from_date),\n from_date=max(period_start_date, from_date),\n
group_by_node=1,\n group_by_node=1,\n
omit_input=1,\n omit_input=1,\n
...@@ -387,7 +387,7 @@ for node in getInventoryList(\n ...@@ -387,7 +387,7 @@ for node in getInventoryList(\n
\n \n
### profit & loss accounts {{{\n ### profit & loss accounts {{{\n
for node in getInventoryList(\n for node in getInventoryList(\n
node_category_strict_membership=profit_and_loss_account_type,\n node_category=profit_and_loss_account_type,\n
omit_output=1,\n omit_output=1,\n
from_date=min(period_start_date,\n from_date=min(period_start_date,\n
initial_balance_date),\n initial_balance_date),\n
...@@ -403,7 +403,7 @@ for node in getInventoryList(\n ...@@ -403,7 +403,7 @@ for node in getInventoryList(\n
\'initial_debit_balance\', 0) + total_price\n \'initial_debit_balance\', 0) + total_price\n
\n \n
for node in getInventoryList(\n for node in getInventoryList(\n
node_category_strict_membership=profit_and_loss_account_type,\n node_category=profit_and_loss_account_type,\n
omit_input=1,\n omit_input=1,\n
from_date=min(period_start_date,\n from_date=min(period_start_date,\n
initial_balance_date),\n initial_balance_date),\n
......
...@@ -258,7 +258,7 @@ for inventory in portal.portal_simulation.getInventoryList(\n ...@@ -258,7 +258,7 @@ for inventory in portal.portal_simulation.getInventoryList(\n
\n \n
# profit & loss -> same, but from date limited to the current period\n # profit & loss -> same, but from date limited to the current period\n
for inventory in portal.portal_simulation.getInventoryList(\n for inventory in portal.portal_simulation.getInventoryList(\n
node_category_strict_membership=profit_and_loss_account_type,\n node_category=profit_and_loss_account_type,\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n portal_type=portal.getPortalAccountingMovementTypeList(),\n
from_date=max(from_date, period_start_date),\n from_date=max(from_date, period_start_date),\n
at_date=at_date,\n at_date=at_date,\n
......
...@@ -113,7 +113,8 @@ for section_uid in \\\n ...@@ -113,7 +113,8 @@ for section_uid in \\\n
\'account_type/asset/receivable\',\n \'account_type/asset/receivable\',\n
\'account_type/liability/payable\'):\n \'account_type/liability/payable\'):\n
group_by_mirror_section_node_category_list.append(node_category_url)\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 elif node_category.isMemberOf(\'account_type/income\') or \\\n
node_category.isMemberOf(\'account_type/expense\'):\n
profit_and_loss_node_category_list.append(node_category_url)\n profit_and_loss_node_category_list.append(node_category_url)\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
......
...@@ -92,15 +92,18 @@ if not \'parent_portal_type\' in params:\n ...@@ -92,15 +92,18 @@ if not \'parent_portal_type\' in params:\n
new_result = []\n new_result = []\n
net_balance = 0.0\n net_balance = 0.0\n
\n \n
node_account_type = None\n # accounts from PL have a balance calculated differently\n
is_pl_account = False\n
if params.get(\'node_uid\'):\n if params.get(\'node_uid\'):\n
if context.getUid() == params[\'node_uid\']:\n if context.getUid() == params[\'node_uid\']:\n
node_account_type = context.getAccountTypeId()\n is_pl_account = context.isMemberOf(\'account_type/expense\')\\\n
or context.isMemberOf(\'account_type/income\')\n
else:\n else:\n
node = portal.portal_catalog.getObject(params[\'node_uid\'])\n node = portal.portal_catalog.getObject(params[\'node_uid\'])\n
node_account_type = node.getAccountTypeId()\n is_pl_account = node.isMemberOf(\'account_type/expense\')\\\n
or node.isMemberOf(\'account_type/income\')\n
\n \n
if from_date or node_account_type in (\'expense\', \'income\'):\n if from_date or is_pl_account:\n
period_start_date = None\n period_start_date = None\n
# Create a new parameter list to get the previous balance\n # Create a new parameter list to get the previous balance\n
get_inventory_kw = params.copy()\n get_inventory_kw = params.copy()\n
...@@ -109,7 +112,7 @@ if from_date or node_account_type in (\'expense\', \'income\'):\n ...@@ -109,7 +112,7 @@ if from_date or node_account_type in (\'expense\', \'income\'):\n
get_inventory_kw.pop(\'at_date\', None)\n get_inventory_kw.pop(\'at_date\', None)\n
\n \n
if params.has_key(\'period_start_date\'):\n if params.has_key(\'period_start_date\'):\n
if node_account_type in (\'expense\', \'income\'):\n if is_pl_account:\n
# if we have on an expense / income account, only take into account\n # if we have on an expense / income account, only take into account\n
# movements from the current period.\n # movements from the current period.\n
period_start_date = params[\'period_start_date\']\n period_start_date = params[\'period_start_date\']\n
...@@ -126,13 +129,12 @@ if from_date or node_account_type in (\'expense\', \'income\'):\n ...@@ -126,13 +129,12 @@ if from_date or node_account_type in (\'expense\', \'income\'):\n
from_date = period_start_date\n from_date = period_start_date\n
\n \n
# Get previous debit and credit\n # Get previous debit and credit\n
if from_date == period_start_date and \\\n if from_date == period_start_date and is_pl_account:\n
node_account_type in (\'expense\', \'income\'):\n
previous_total_debit = previous_total_credit = 0\n previous_total_debit = previous_total_credit = 0\n
else:\n else:\n
getInventoryAssetPrice = portal.portal_simulation.getInventoryAssetPrice\n getInventoryAssetPrice = portal.portal_simulation.getInventoryAssetPrice\n
# first to the balance at the period start date\n # first to the balance at the period start date\n
if node_account_type in (\'expense\', \'income\'):\n if is_pl_account:\n
period_openning_balance = 0\n period_openning_balance = 0\n
else:\n else:\n
period_openning_balance = getInventoryAssetPrice(\n period_openning_balance = getInventoryAssetPrice(\n
...@@ -268,7 +270,8 @@ return portal.portal_simulation.getMovementHistoryList(\n ...@@ -268,7 +270,8 @@ return portal.portal_simulation.getMovementHistoryList(\n
<string>_write_</string> <string>_write_</string>
<string>new_result</string> <string>new_result</string>
<string>net_balance</string> <string>net_balance</string>
<string>node_account_type</string> <string>False</string>
<string>is_pl_account</string>
<string>node</string> <string>node</string>
<string>period_start_date</string> <string>period_start_date</string>
<string>get_inventory_kw</string> <string>get_inventory_kw</string>
......
...@@ -93,7 +93,8 @@ if params.get(\'period_start_date\', 0) and params.get(\'node_uid\'):\n ...@@ -93,7 +93,8 @@ if params.get(\'period_start_date\', 0) and params.get(\'node_uid\'):\n
node = context\n node = context\n
else:\n else:\n
node = portal.portal_catalog.getObject(params[\'node_uid\'])\n node = portal.portal_catalog.getObject(params[\'node_uid\'])\n
if node.getAccountTypeId() in (\'expense\', \'income\'):\n if node.isMemberOf(\'account_type/expense\') or\\\n
node.isMemberOf(\'account_type/income\'):\n
# For expense or income accounts, we only take into account transactions\n # For expense or income accounts, we only take into account transactions\n
# from the beginning of the period.\n # from the beginning of the period.\n
params[\'from_date\'] = params[\'period_start_date\']\n params[\'from_date\'] = params[\'period_start_date\']\n
......
1148 1150
\ 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