Commit 40475e3a authored by Jérome Perrin's avatar Jérome Perrin

Don't display a previous balance line if from_date is not set

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6474 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b07a4ec2
......@@ -66,9 +66,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
src__ = 0\n
<value> <string>src__ = 0\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n
precision = context.Base_getPreferredPrecision()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n
......@@ -123,15 +121,13 @@ get_inventory_kw.update({ \'omit_simulation\' : 1\n
get_inventory_kw[\'node_uid\'] = kw.get(\'node_uid\', context.getUid())\n
\n
# Get previous debit and credit\n
# Get previous debit and credit\n
getInventoryAssetPrice = context.getPortalObject().portal_simulation.getInventoryAssetPrice\n
previous_total_debit = getInventoryAssetPrice(omit_output=1, **get_inventory_kw)\n
previous_total_credit = getInventoryAssetPrice(omit_input =1, **get_inventory_kw)\n
previous_total_debit = getInventoryAssetPrice(omit_output=True, **get_inventory_kw)\n
previous_total_credit = getInventoryAssetPrice(omit_input =True, **get_inventory_kw)\n
\n
# previous_total_debit = r_(previous_total_debit[0].quantity)\n
# previous_total_credit = r_(previous_total_credit[0].quantity)\n
# Get Absolute value of debit and credit\n
if previous_total_debit < 0: previous_total_debit = - previous_total_debit\n
if previous_total_credit < 0: previous_total_credit = - previous_total_credit\n
if previous_total_credit != 0:\n
previous_total_credit = - previous_total_credit\n
\n
# Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n
......@@ -190,9 +186,7 @@ for l in result:\n
new_result.append(c)\n
\n
return new_result\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -264,12 +258,12 @@ return new_result\n
<string>get_inventory_kw</string>
<string>getInventoryAssetPrice</string>
<string>_apply_</string>
<string>True</string>
<string>previous_total_debit</string>
<string>previous_total_credit</string>
<string>Products.ERP5Type.Document</string>
<string>newTempAccountingTransaction</string>
<string>previous_balance</string>
<string>True</string>
<string>result</string>
<string>_getiter_</string>
<string>l</string>
......
......@@ -66,9 +66,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
src__ = 0\n
<value> <string>src__ = 0\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n
precision = context.Base_getPreferredPrecision()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n
......@@ -95,25 +93,26 @@ if kw.has_key(\'portal_type\'): params[\'portal_type\'] = kw[\'portal_type\']\n
new_result = []\n
net_balance = 0.0\n
\n
# Create a new parameter list to get the previous balance\n
get_inventory_kw = params.copy()\n
get_inventory_kw.update({ \'omit_simulation\' : 1\n
if from_date is not None :\n
# Create a new parameter list to get the previous balance\n
get_inventory_kw = params.copy()\n
get_inventory_kw.update({ \'omit_simulation\' : 1\n
, \'to_date\' : from_date\n
, \'mirror_section_uid\' : context.getUid()\n
, \'section_portal_type_list\': [\'Organisation\']\n
, \'stat\' : 1\n
})\n
getInventory = context.getPortalObject()\\\n
.portal_simulation.getInventoryAssetPrice\n
# Get previous debit and credit\n
previous_total_debit = r_(getInventoryAssetPrice(omit_output=1,\n
**get_inventory_kw))\n
previous_total_credit = r_(getInventoryAssetPrice(omit_input =1,\n
**get_inventory_kw))\n
if previous_total_credit != 0 :\n
previous_total_credit = - previous_total_credit\n
\n
# Get previous debit and credit\n
previous_total_debit = context.BankAccount_zGetAccountingTransactionList(omit_output=1, **get_inventory_kw)\n
previous_total_credit = context.BankAccount_zGetAccountingTransactionList(omit_input =1, **get_inventory_kw)\n
previous_total_debit = r_(previous_total_debit[0].quantity)\n
previous_total_credit = r_(previous_total_credit[0].quantity)\n
# Get Absolute value of debit and credit\n
if previous_total_debit < 0: previous_total_debit = - previous_total_debit\n
if previous_total_credit < 0: previous_total_credit = - previous_total_credit\n
\n
# Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n
# Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n
from Products.ERP5Type.Document import newTempAccountingTransaction\n
\n
net_balance = r_(previous_total_debit - previous_total_credit)\n
......@@ -123,12 +122,17 @@ if previous_total_credit != 0 or previous_total_debit != 0:\n
previous_balance.setUid(\'new_000\')\n
\n
previous_balance.edit( \\\n
title = context.Base_translateString("Previous Balance")\n
parent_title = context.Base_translateString("Previous Balance")\n
, section_title = ""\n
, date = from_date - 1\n
, portal_type = ""\n
, simulation_state_title = ""\n
, account_uid = None\n
, parent_reference = None\n
, parent_specific_reference = None\n
, translated_simulation_state_title = None\n
, debit = previous_total_debit\n
, credit = previous_total_credit\n
, grouping_reference = None\n
, balance = net_balance\n
, net_balance = net_balance\n
, is_previous_balance = True\n
......@@ -139,15 +143,8 @@ if previous_total_credit != 0 or previous_total_debit != 0:\n
# Show / Hide grouping if needed\n
if kw.has_key(\'hide_grouping\'): params[\'hide_grouping\'] = kw[\'hide_grouping\']\n
\n
# FIXME:\n
# using listbox current page number * number of line per listbox page, you can call a\n
# ZSQL Method to initialize net_balance and calculate this only for this page.\n
#\n
# But this is just temporary because some day, erp5_accounting will be rewritten using\n
# only portal_catalog and getInventory. The Iventory API should provide a way to implement\n
# such a net_balance column (in one instruction, so that we do not need to write a wrapping\n
# list method like this one)\n
result = context.BankAccount_zGetAccountingTransactionList( from_date = from_date\n
# FIXME: same problem as in BankAccount_getAccountingTransactionList\n
result = context.Entity_zGetAccountingTransactionList( from_date = from_date\n
, at_date = at_date\n
, src__ = src__\n
, **params\n
......@@ -166,14 +163,18 @@ for l in result:\n
, debit = l.debit\n
, date = l.date\n
, section_title = l.section_title\n
, specific_reference = l.specific_reference\n
, parent_reference = l.parent_reference\n
, parent_specific_reference = l.parent_specific_reference\n
, translated_simulation_state_title = o.getTranslatedSimulationStateTitle()\n
# FIXME: overriding \'portal_type\' in asContext is clearly a bad idea, as many methods are storred on the portal type\n
# (hence the translated_simulation_state_title hack) -j\xc3\xa9rome\n
, portal_type = l.portal_type\n
, account_uid = l.account_uid\n
)\n
new_result.append(c)\n
\n
return new_result\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -237,7 +238,9 @@ return new_result\n
<string>new_result</string>
<string>net_balance</string>
<string>get_inventory_kw</string>
<string>getInventory</string>
<string>_apply_</string>
<string>getInventoryAssetPrice</string>
<string>previous_total_debit</string>
<string>previous_total_credit</string>
<string>Products.ERP5Type.Document</string>
......
......@@ -66,9 +66,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
src__ = 0\n
<value> <string>src__ = 0\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n
precision = context.Base_getPreferredPrecision()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n
......@@ -95,25 +93,26 @@ if kw.has_key(\'portal_type\'): params[\'portal_type\'] = kw[\'portal_type\']\n
new_result = []\n
net_balance = 0.0\n
\n
# Create a new parameter list to get the previous balance\n
get_inventory_kw = params.copy()\n
get_inventory_kw.update({ \'omit_simulation\' : 1\n
if from_date is not None :\n
# Create a new parameter list to get the previous balance\n
get_inventory_kw = params.copy()\n
get_inventory_kw.update({ \'omit_simulation\' : 1\n
, \'to_date\' : from_date\n
, \'mirror_section_uid\' : context.getUid()\n
, \'section_portal_type_list\': [\'Organisation\']\n
, \'stat\' : 1\n
})\n
getInventory = context.getPortalObject()\\\n
.portal_simulation.getInventoryAssetPrice\n
# Get previous debit and credit\n
previous_total_debit = r_(getInventoryAssetPrice(omit_output=1,\n
**get_inventory_kw))\n
previous_total_credit = r_(getInventoryAssetPrice(omit_input =1,\n
**get_inventory_kw))\n
if previous_total_credit != 0 :\n
previous_total_credit = - previous_total_credit\n
\n
# Get previous debit and credit\n
previous_total_debit = context.Entity_zGetAccountingTransactionList(omit_output=1, **get_inventory_kw)\n
previous_total_credit = context.Entity_zGetAccountingTransactionList(omit_input =1, **get_inventory_kw)\n
previous_total_debit = r_(previous_total_debit[0].total_price)\n
previous_total_credit = r_(previous_total_credit[0].total_price)\n
# Get Absolute value of debit and credit\n
if previous_total_debit < 0: previous_total_debit = - previous_total_debit\n
if previous_total_credit < 0: previous_total_credit = - previous_total_credit\n
\n
# Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n
# Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n
from Products.ERP5Type.Document import newTempAccountingTransaction\n
\n
net_balance = r_(previous_total_debit - previous_total_credit)\n
......@@ -167,7 +166,7 @@ for l in result:\n
, parent_reference = l.parent_reference\n
, parent_specific_reference = l.parent_specific_reference\n
, translated_simulation_state_title = o.getTranslatedSimulationStateTitle()\n
# FIXME: overriding \'portal_type\' in asContext is clearly a bad idea, as many methods are storred on the portal type \n
# FIXME: overriding \'portal_type\' in asContext is clearly a bad idea, as many methods are storred on the portal type\n
# (hence the translated_simulation_state_title hack) -j\xc3\xa9rome\n
, portal_type = l.portal_type\n
, account_uid = l.account_uid\n
......@@ -175,9 +174,7 @@ for l in result:\n
new_result.append(c)\n
\n
return new_result\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -241,7 +238,9 @@ return new_result\n
<string>new_result</string>
<string>net_balance</string>
<string>get_inventory_kw</string>
<string>getInventory</string>
<string>_apply_</string>
<string>getInventoryAssetPrice</string>
<string>previous_total_debit</string>
<string>previous_total_credit</string>
<string>Products.ERP5Type.Document</string>
......
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