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 @@ ...@@ -66,9 +66,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>src__ = 0\n
src__ = 0\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n
precision = context.Base_getPreferredPrecision()\n precision = context.Base_getPreferredPrecision()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n r_ = lambda x: context.Base_getRoundValue(x, precision)\n
...@@ -123,15 +121,13 @@ get_inventory_kw.update({ \'omit_simulation\' : 1\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 get_inventory_kw[\'node_uid\'] = kw.get(\'node_uid\', context.getUid())\n
\n \n
# Get previous debit and credit\n # Get previous debit and credit\n
# Get previous debit and credit\n
getInventoryAssetPrice = context.getPortalObject().portal_simulation.getInventoryAssetPrice\n getInventoryAssetPrice = context.getPortalObject().portal_simulation.getInventoryAssetPrice\n
previous_total_debit = getInventoryAssetPrice(omit_output=1, **get_inventory_kw)\n previous_total_debit = getInventoryAssetPrice(omit_output=True, **get_inventory_kw)\n
previous_total_credit = getInventoryAssetPrice(omit_input =1, **get_inventory_kw)\n previous_total_credit = getInventoryAssetPrice(omit_input =True, **get_inventory_kw)\n
\n \n
# previous_total_debit = r_(previous_total_debit[0].quantity)\n if previous_total_credit != 0:\n
# previous_total_credit = r_(previous_total_credit[0].quantity)\n previous_total_credit = - previous_total_credit\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 \n
# Show the previous balance if not empty\n # Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n if previous_total_credit != 0 or previous_total_debit != 0:\n
...@@ -190,9 +186,7 @@ for l in result:\n ...@@ -190,9 +186,7 @@ for l in result:\n
new_result.append(c)\n new_result.append(c)\n
\n \n
return new_result\n return new_result\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -264,12 +258,12 @@ return new_result\n ...@@ -264,12 +258,12 @@ return new_result\n
<string>get_inventory_kw</string> <string>get_inventory_kw</string>
<string>getInventoryAssetPrice</string> <string>getInventoryAssetPrice</string>
<string>_apply_</string> <string>_apply_</string>
<string>True</string>
<string>previous_total_debit</string> <string>previous_total_debit</string>
<string>previous_total_credit</string> <string>previous_total_credit</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
<string>newTempAccountingTransaction</string> <string>newTempAccountingTransaction</string>
<string>previous_balance</string> <string>previous_balance</string>
<string>True</string>
<string>result</string> <string>result</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>l</string> <string>l</string>
......
...@@ -66,9 +66,7 @@ ...@@ -66,9 +66,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>src__ = 0\n
src__ = 0\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n
precision = context.Base_getPreferredPrecision()\n precision = context.Base_getPreferredPrecision()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n r_ = lambda x: context.Base_getRoundValue(x, precision)\n
...@@ -95,63 +93,62 @@ if kw.has_key(\'portal_type\'): params[\'portal_type\'] = kw[\'portal_type\']\n ...@@ -95,63 +93,62 @@ if kw.has_key(\'portal_type\'): params[\'portal_type\'] = kw[\'portal_type\']\n
new_result = []\n new_result = []\n
net_balance = 0.0\n net_balance = 0.0\n
\n \n
# Create a new parameter list to get the previous balance\n if from_date is not None :\n
get_inventory_kw = params.copy()\n # Create a new parameter list to get the previous balance\n
get_inventory_kw.update({ \'omit_simulation\' : 1\n get_inventory_kw = params.copy()\n
, \'to_date\' : from_date\n get_inventory_kw.update({ \'omit_simulation\' : 1\n
, \'section_portal_type_list\': [\'Organisation\']\n , \'to_date\' : from_date\n
, \'stat\' : 1\n , \'mirror_section_uid\' : context.getUid()\n
})\n , \'section_portal_type_list\': [\'Organisation\']\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 \n
# Get previous debit and credit\n # Show the previous balance if not empty\n
previous_total_debit = context.BankAccount_zGetAccountingTransactionList(omit_output=1, **get_inventory_kw)\n if previous_total_credit != 0 or previous_total_debit != 0:\n
previous_total_credit = context.BankAccount_zGetAccountingTransactionList(omit_input =1, **get_inventory_kw)\n from Products.ERP5Type.Document import newTempAccountingTransaction\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 \n
# Show the previous balance if not empty\n net_balance = r_(previous_total_debit - previous_total_credit)\n
if previous_total_credit != 0 or previous_total_debit != 0:\n previous_balance = newTempAccountingTransaction( context.getPortalObject()\n
from Products.ERP5Type.Document import newTempAccountingTransaction\n , "temp_%s" % context.getUid()\n
)\n
previous_balance.setUid(\'new_000\')\n
\n \n
net_balance = r_(previous_total_debit - previous_total_credit)\n previous_balance.edit( \\\n
previous_balance = newTempAccountingTransaction( context.getPortalObject()\n parent_title = context.Base_translateString("Previous Balance")\n
, "temp_%s" % context.getUid()\n , section_title = ""\n
)\n , date = from_date - 1\n
previous_balance.setUid(\'new_000\')\n , portal_type = ""\n
\n , account_uid = None\n
previous_balance.edit( \\\n , parent_reference = None\n
title = context.Base_translateString("Previous Balance")\n , parent_specific_reference = None\n
, date = from_date - 1\n , translated_simulation_state_title = None\n
, portal_type = ""\n , debit = previous_total_debit\n
, simulation_state_title = ""\n , credit = previous_total_credit\n
, debit = previous_total_debit\n , grouping_reference = None\n
, credit = previous_total_credit\n , balance = net_balance\n
, balance = net_balance\n , net_balance = net_balance\n
, net_balance = net_balance\n , is_previous_balance = True\n
, is_previous_balance = True\n )\n
)\n new_result.append(previous_balance)\n
new_result.append(previous_balance)\n
\n \n
\n \n
# Show / Hide grouping if needed\n # Show / Hide grouping if needed\n
if kw.has_key(\'hide_grouping\'): params[\'hide_grouping\'] = kw[\'hide_grouping\']\n if kw.has_key(\'hide_grouping\'): params[\'hide_grouping\'] = kw[\'hide_grouping\']\n
\n \n
# FIXME:\n # FIXME: same problem as in BankAccount_getAccountingTransactionList\n
# using listbox current page number * number of line per listbox page, you can call a\n result = context.Entity_zGetAccountingTransactionList( from_date = from_date\n
# ZSQL Method to initialize net_balance and calculate this only for this page.\n , at_date = at_date\n
#\n , src__ = src__\n
# But this is just temporary because some day, erp5_accounting will be rewritten using\n , **params\n
# only portal_catalog and getInventory. The Iventory API should provide a way to implement\n )\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
, at_date = at_date\n
, src__ = src__\n
, **params\n
)\n
if src__:\n if src__:\n
return result\n return result\n
\n \n
...@@ -160,20 +157,24 @@ for l in result:\n ...@@ -160,20 +157,24 @@ for l in result:\n
o = l.getObject()\n o = l.getObject()\n
net_balance += l.balance or 0.0\n net_balance += l.balance or 0.0\n
if o is not None:\n if o is not None:\n
c = o.asContext( net_balance = net_balance\n c = o.asContext( net_balance = net_balance\n
, balance = l.balance\n , balance = l.balance\n
, credit = l.credit\n , credit = l.credit\n
, debit = l.debit\n , debit = l.debit\n
, date = l.date\n , date = l.date\n
, section_title = l.section_title\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 )\n
new_result.append(c)\n new_result.append(c)\n
\n \n
return new_result\n return new_result\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -237,7 +238,9 @@ return new_result\n ...@@ -237,7 +238,9 @@ return new_result\n
<string>new_result</string> <string>new_result</string>
<string>net_balance</string> <string>net_balance</string>
<string>get_inventory_kw</string> <string>get_inventory_kw</string>
<string>getInventory</string>
<string>_apply_</string> <string>_apply_</string>
<string>getInventoryAssetPrice</string>
<string>previous_total_debit</string> <string>previous_total_debit</string>
<string>previous_total_credit</string> <string>previous_total_credit</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
......
...@@ -66,9 +66,7 @@ ...@@ -66,9 +66,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>src__ = 0\n
src__ = 0\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n
precision = context.Base_getPreferredPrecision()\n precision = context.Base_getPreferredPrecision()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n r_ = lambda x: context.Base_getRoundValue(x, precision)\n
...@@ -95,50 +93,51 @@ if kw.has_key(\'portal_type\'): params[\'portal_type\'] = kw[\'portal_type\']\n ...@@ -95,50 +93,51 @@ if kw.has_key(\'portal_type\'): params[\'portal_type\'] = kw[\'portal_type\']\n
new_result = []\n new_result = []\n
net_balance = 0.0\n net_balance = 0.0\n
\n \n
# Create a new parameter list to get the previous balance\n if from_date is not None :\n
get_inventory_kw = params.copy()\n # Create a new parameter list to get the previous balance\n
get_inventory_kw.update({ \'omit_simulation\' : 1\n get_inventory_kw = params.copy()\n
, \'to_date\' : from_date\n get_inventory_kw.update({ \'omit_simulation\' : 1\n
, \'section_portal_type_list\': [\'Organisation\']\n , \'to_date\' : from_date\n
, \'stat\' : 1\n , \'mirror_section_uid\' : context.getUid()\n
})\n , \'section_portal_type_list\': [\'Organisation\']\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 \n
# Get previous debit and credit\n # Show the previous balance if not empty\n
previous_total_debit = context.Entity_zGetAccountingTransactionList(omit_output=1, **get_inventory_kw)\n if previous_total_credit != 0 or previous_total_debit != 0:\n
previous_total_credit = context.Entity_zGetAccountingTransactionList(omit_input =1, **get_inventory_kw)\n from Products.ERP5Type.Document import newTempAccountingTransaction\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 \n
# Show the previous balance if not empty\n net_balance = r_(previous_total_debit - previous_total_credit)\n
if previous_total_credit != 0 or previous_total_debit != 0:\n previous_balance = newTempAccountingTransaction( context.getPortalObject()\n
from Products.ERP5Type.Document import newTempAccountingTransaction\n , "temp_%s" % context.getUid()\n
)\n
previous_balance.setUid(\'new_000\')\n
\n \n
net_balance = r_(previous_total_debit - previous_total_credit)\n previous_balance.edit( \\\n
previous_balance = newTempAccountingTransaction( context.getPortalObject()\n parent_title = context.Base_translateString("Previous Balance")\n
, "temp_%s" % context.getUid()\n , section_title = ""\n
)\n , date = from_date - 1\n
previous_balance.setUid(\'new_000\')\n , portal_type = ""\n
\n , account_uid = None\n
previous_balance.edit( \\\n , parent_reference = None\n
parent_title = context.Base_translateString("Previous Balance")\n , parent_specific_reference = None\n
, section_title = ""\n , translated_simulation_state_title = None\n
, date = from_date - 1\n , debit = previous_total_debit\n
, portal_type = ""\n , credit = previous_total_credit\n
, account_uid = None\n , grouping_reference = None\n
, parent_reference = None\n , balance = net_balance\n
, parent_specific_reference = None\n , net_balance = net_balance\n
, translated_simulation_state_title = None\n , is_previous_balance = True\n
, debit = previous_total_debit\n )\n
, credit = previous_total_credit\n new_result.append(previous_balance)\n
, grouping_reference = None\n
, balance = net_balance\n
, net_balance = net_balance\n
, is_previous_balance = True\n
)\n
new_result.append(previous_balance)\n
\n \n
\n \n
# Show / Hide grouping if needed\n # Show / Hide grouping if needed\n
...@@ -167,7 +166,7 @@ for l in result:\n ...@@ -167,7 +166,7 @@ for l in result:\n
, parent_reference = l.parent_reference\n , parent_reference = l.parent_reference\n
, parent_specific_reference = l.parent_specific_reference\n , parent_specific_reference = l.parent_specific_reference\n
, translated_simulation_state_title = o.getTranslatedSimulationStateTitle()\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 # (hence the translated_simulation_state_title hack) -j\xc3\xa9rome\n
, portal_type = l.portal_type\n , portal_type = l.portal_type\n
, account_uid = l.account_uid\n , account_uid = l.account_uid\n
...@@ -175,9 +174,7 @@ for l in result:\n ...@@ -175,9 +174,7 @@ for l in result:\n
new_result.append(c)\n new_result.append(c)\n
\n \n
return new_result\n return new_result\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -241,7 +238,9 @@ return new_result\n ...@@ -241,7 +238,9 @@ return new_result\n
<string>new_result</string> <string>new_result</string>
<string>net_balance</string> <string>net_balance</string>
<string>get_inventory_kw</string> <string>get_inventory_kw</string>
<string>getInventory</string>
<string>_apply_</string> <string>_apply_</string>
<string>getInventoryAssetPrice</string>
<string>previous_total_debit</string> <string>previous_total_debit</string>
<string>previous_total_credit</string> <string>previous_total_credit</string>
<string>Products.ERP5Type.Document</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