Commit aab014a9 authored by Jérome Perrin's avatar Jérome Perrin

Use inventory API for bank account's transaction tab

http://erp5.nexedi.com/bug_module/1591
parent fe87ebc8
...@@ -50,110 +50,19 @@ ...@@ -50,110 +50,19 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>src__ = 0\n <value> <string>"""Returns Accounting Transactions where this bank account is payment.\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n """\n
precision = context.Base_getPreferredPrecision()\n kw[\'payment_uid\'] = context.getUid()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n kw[\'node_category\'] = \'account_type/asset/cash/bank\'\n
\n transaction_list = context.Node_getAccountingTransactionList(**kw)\n
# read settings from user preference\n \n
preference = context.getPortalObject().portal_preferences\n # As we are showing quantities and not asset prices, we use the precision\n
simulation_state = preference.getPreferredAccountingTransactionSimulationStateList()\n # from this bank account currency\n
section_category = preference.getPreferredAccountingTransactionSectionCategory()\n if context.getPriceCurrency():\n
from_date = preference.getPreferredAccountingTransactionFromDate()\n container.REQUEST.set(\'precision\',\n
at_date = preference.getPreferredAccountingTransactionAtDate()\n context.getQuantityPrecisionFromResource(context.getPriceCurrency()))\n
\n \n
# Build the common inventory dict\n return transaction_list\n
params = {}\n
\n
if kw.get(\'no_from_date\', False): from_date = None\n
\n
if simulation_state: params[\'simulation_state\'] = simulation_state\n
params[\'section_uid\'] = context.Base_getSectionUidListForSectionCategory(section_category)\n
\n
\n
if kw.has_key(\'node_uid\') : params[\'node_uid\'] = kw[\'node_uid\']\n
if kw.has_key(\'portal_type\'): params[\'portal_type\'] = kw[\'portal_type\']\n
\n
# Create the related accouting line list\n
new_result = []\n
net_balance = 0.0\n
\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\' : True\n
, \'payment_uid\' : context.getUid()\n
, \'to_date\' : from_date\n
# , \'where_expression\': " section.portal_type = \'Organisation\' "\n
, \'stat\' : True\n
})\n
\n
getInventory = context.getPortalObject().portal_simulation.getInventory\n
# Get previous debit and credit\n
previous_total_debit = r_(getInventory(omit_output=True, **get_inventory_kw))\n
previous_total_credit = r_(getInventory(omit_input =True, **get_inventory_kw))\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
from Products.ERP5Type.Document import newTempAccountingTransaction\n
\n
net_balance = r_(previous_total_debit - previous_total_credit)\n
previous_balance = newTempAccountingTransaction( context.getPortalObject()\n
, "temp_%s" % context.getUid()\n
)\n
previous_balance.setUid(\'new_000\')\n
\n
previous_balance.edit( \\\n
title = context.Base_translateString("Previous Balance")\n
, date = from_date - 1\n
, portal_type = ""\n
, simulation_state_title = ""\n
, debit = previous_total_debit\n
, credit = previous_total_credit\n
, balance = net_balance\n
, net_balance = net_balance\n
, is_previous_balance = True\n
)\n
new_result.append(previous_balance)\n
\n
\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
, at_date = at_date\n
, src__ = src__\n
, **params\n
)\n
if src__:\n
return result\n
\n
# Add related accounting lines one by one in order to calculate intermediate balance\n
for l in result:\n
o = l.getObject()\n
net_balance += l.balance or 0.0\n
if o is not None:\n
c = o.asContext( net_balance = net_balance\n
, balance = l.balance\n
, credit = l.credit\n
, debit = l.debit\n
, date = l.date.toZone(l.getObject().getStartDate().timezone())\n
, section_title = l.section_title\n
, specific_reference = l.specific_reference\n
)\n
new_result.append(c)\n
\n
return new_result\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -50,12 +50,13 @@ ...@@ -50,12 +50,13 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>kw[\'omit_output\'] = 1\n <value> <string>"""Total balance (in local currency) of all accounting transactions having this\n
credit = context.BankAccount_statSourceBalance(**kw)\n bank account as payment node\n
if credit :\n """\n
return float(\'%.02f\' % - credit)\n kw[\'payment_uid\'] = context.getUid()\n
return 0.0\n kw[\'asset_price\'] = False\n
# vim: syntax=python\n kw[\'node_category\'] = \'account_type/asset/cash/bank\'\n
return context.Node_statAccountingBalance(**kw)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -64,7 +65,7 @@ return 0.0\n ...@@ -64,7 +65,7 @@ return 0.0\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>BankAccount_statSourceCredit</string> </value> <value> <string>BankAccount_statBalance</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,75 +50,17 @@ ...@@ -50,75 +50,17 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>params = {}\n <value> <string>"""Total credit (in local currency) of all accounting transactions having this\n
pref = context.getPortalObject().portal_preferences\n bank account as payment\n
precision = context.Base_getPreferredPrecision()\n """\n
kw[\'payment_uid\'] = context.getUid()\n
kw[\'omit_asset_increase\'] = 1\n
kw[\'asset_price\'] = False\n
kw[\'node_category\'] = \'account_type/asset/cash/bank\'\n
kw.update(kw[\'selection\'].getParams())\n
\n \n
###\n # here, or 0 is to prevent displaying "- 0"\n
# Get the \'from_date\' parameter\n return - context.Node_statAccountingBalance(**kw) or 0\n
from_date = kw.get( \'from_date\'\n
, pref.getPreferredAccountingTransactionFromDate()\n
)\n
if from_date:\n
params[\'from_date\'] = from_date\n
\n
###\n
# Get the \'at_date\' parameter\n
at_date = kw.get( \'at_date\'\n
, pref.getPreferredAccountingTransactionAtDate()\n
)\n
if at_date:\n
params[\'at_date\'] = at_date\n
\n
###\n
# Get the \'simulation_state\' parameter\n
# Sometimes \'simulation_state\' is now as \'transaction_simulation_state\'\n
simulation_state = kw.get( \'transaction_simulation_state\'\n
, None\n
)\n
if not simulation_state:\n
simulation_state = kw.get( \'simulation_state\'\n
, pref.getPreferredAccountingTransactionSimulationStateList()\n
)\n
if simulation_state:\n
params[\'simulation_state\'] = simulation_state\n
\n
###\n
# Get the \'section_category\' parameter\n
# Sometimes \'section_category\' is now as \'transaction_section_category\'\n
section_category = kw.get( \'transaction_section_category\'\n
, None\n
)\n
if not section_category:\n
section_category = kw.get( \'section_category\'\n
, pref.getPreferredAccountingTransactionSectionCategory()\n
)\n
if section_category:\n
params[\'section_category\'] = section_category\n
\n
###\n
# Parameters only used in reports\n
if kw.has_key(\'node_uid\'): params[\'node_uid\'] = kw[\'node_uid\']\n
\n
###\n
# Get omit parameters\n
if kw.get(\'omit_input\') : params[\'omit_input\'] = 1\n
if kw.get(\'omit_output\'): params[\'omit_output\'] = 1\n
\n
params[\'stat\'] = 1\n
\n
if kw.has_key(\'getUid\') : params[\'getUid\'] = kw[\'getUid\']\n
if kw.has_key(\'getParentUid\'): params[\'getParentUid\'] = kw[\'getParentUid\']\n
\n
###\n
# Call the query with selected parameters\n
result = context.BankAccount_zGetAccountingTransactionList(**params)\n
row = result[0]\n
\n
###\n
# Round the result to avoid float bad precision\n
# TODO: use currency precision\n
return context.Base_getRoundValue(row.quantity or 0.0, precision)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -127,7 +69,7 @@ return context.Base_getRoundValue(row.quantity or 0.0, precision)\n ...@@ -127,7 +69,7 @@ return context.Base_getRoundValue(row.quantity or 0.0, precision)\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>BankAccount_statSourceBalance</string> </value> <value> <string>BankAccount_statCredit</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,10 +50,16 @@ ...@@ -50,10 +50,16 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>kw[\'omit_input\'] = 1\n <value> <string>"""Total debit (in local currency) of all accounting transactions having this\n
debit = context.BankAccount_statSourceBalance(**kw)\n bank account as payment\n
return float(\'%.02f\' % debit)\n """\n
# vim: syntax=python\n kw[\'payment_uid\'] = context.getUid()\n
kw[\'omit_asset_decrease\'] = 1\n
kw[\'asset_price\'] = False\n
kw[\'node_category\'] = \'account_type/asset/cash/bank\'\n
kw.update(kw[\'selection\'].getParams())\n
\n
return context.Node_statAccountingBalance(**kw)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -62,7 +68,7 @@ return float(\'%.02f\' % debit)\n ...@@ -62,7 +68,7 @@ return float(\'%.02f\' % debit)\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>BankAccount_statSourceDebit</string> </value> <value> <string>BankAccount_statDebit</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<string>right</string> <string>right</string>
<string>center</string> <string>center</string>
<string>bottom</string> <string>bottom</string>
<string>hidden</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -76,6 +77,18 @@ ...@@ -76,6 +77,18 @@
</list> </list>
</value> </value>
</item> </item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_credit</string>
<string>listbox_date</string>
<string>listbox_debit</string>
<string>listbox_running_total_quantity</string>
<string>listbox_total_quantity</string>
</list>
</value>
</item>
<item> <item>
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
......
...@@ -11,10 +11,12 @@ ...@@ -11,10 +11,12 @@
<value> <value>
<list> <list>
<string>columns</string> <string>columns</string>
<string>domain_root_list</string> <string>editable_columns</string>
<string>list_method</string> <string>list_method</string>
<string>portal_types</string> <string>portal_types</string>
<string>selection_name</string> <string>selection_name</string>
<string>sort</string>
<string>sort_columns</string>
<string>stat_columns</string> <string>stat_columns</string>
<string>stat_method</string> <string>stat_method</string>
<string>title</string> <string>title</string>
...@@ -96,27 +98,31 @@ ...@@ -96,27 +98,31 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>title</string> <string>Movement_getSpecificReference</string>
<string>Title</string> <string>Reference</string>
</tuple> </tuple>
<tuple> <tuple>
<string>section_title</string> <string>Movement_getExplanationTitle</string>
<string>Section</string> <string>Title</string>
</tuple> </tuple>
<tuple> <tuple>
<string>date</string> <string>date</string>
<string>Date</string> <string>Date</string>
</tuple> </tuple>
<tuple> <tuple>
<string>translated_portal_type</string> <string>Movement_getExplanationTranslatedPortalType</string>
<string>Type</string> <string>Type</string>
</tuple> </tuple>
<tuple> <tuple>
<string>specific_reference</string> <string>Movement_getExplanationReference</string>
<string>Transaction Reference</string> <string>Invoice Number</string>
</tuple>
<tuple>
<string>Movement_getMirrorSectionTitle</string>
<string>Third Party</string>
</tuple> </tuple>
<tuple> <tuple>
<string>translated_simulation_state_title</string> <string>getTranslatedSimulationStateTitle</string>
<string>State</string> <string>State</string>
</tuple> </tuple>
<tuple> <tuple>
...@@ -128,27 +134,47 @@ ...@@ -128,27 +134,47 @@
<string>Credit</string> <string>Credit</string>
</tuple> </tuple>
<tuple> <tuple>
<string>balance</string> <string>total_quantity</string>
<string>Balance</string> <string>Balance</string>
</tuple> </tuple>
<tuple> <tuple>
<string>net_balance</string> <string>running_total_quantity</string>
<string>Net</string> <string>Running Balance</string>
</tuple> </tuple>
</list> </list>
</value> </value>
</item> </item>
<item> <item>
<key> <string>domain_root_list</string> </key> <key> <string>editable_columns</string> </key>
<value> <value>
<list> <list>
<tuple> <tuple>
<string>group</string> <string>function</string>
<string>Group</string> <string>function</string>
</tuple>
<tuple>
<string>project</string>
<string>project</string>
</tuple>
<tuple>
<string>date</string>
<string>date</string>
</tuple>
<tuple>
<string>debit</string>
<string>debit</string>
</tuple>
<tuple>
<string>credit</string>
<string>credit</string>
</tuple> </tuple>
<tuple> <tuple>
<string>region</string> <string>total_quantity</string>
<string>Region</string> <string>total_quantity</string>
</tuple>
<tuple>
<string>running_total_quantity</string>
<string>running_total_quantity</string>
</tuple> </tuple>
</list> </list>
</value> </value>
...@@ -194,21 +220,47 @@ ...@@ -194,21 +220,47 @@
<key> <string>selection_name</string> </key> <key> <string>selection_name</string> </key>
<value> <string>bank_account_transaction_selection</string> </value> <value> <string>bank_account_transaction_selection</string> </value>
</item> </item>
<item>
<key> <string>sort</string> </key>
<value>
<list>
<tuple>
<string>stock.date</string>
<string>ASC</string>
</tuple>
<tuple>
<string>stock.uid</string>
<string>ASC</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>sort_columns</string> </key>
<value>
<list>
<tuple>
<string>None</string>
<string>sorting disabled</string>
</tuple>
</list>
</value>
</item>
<item> <item>
<key> <string>stat_columns</string> </key> <key> <string>stat_columns</string> </key>
<value> <value>
<list> <list>
<tuple> <tuple>
<string>debit</string> <string>debit</string>
<string>BankAccount_statSourceDebit</string> <string>BankAccount_statDebit</string>
</tuple> </tuple>
<tuple> <tuple>
<string>credit</string> <string>credit</string>
<string>BankAccount_statSourceCredit</string> <string>BankAccount_statCredit</string>
</tuple> </tuple>
<tuple> <tuple>
<string>balance</string> <string>total_quantity</string>
<string>BankAccount_statSourceBalance</string> <string>BankAccount_statBalance</string>
</tuple> </tuple>
</list> </list>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_credit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_money_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_debit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_money_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_running_total_quantity</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_money_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_total_quantity</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_money_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Use_Database_Methods_Permission</string> </key>
<value>
<list>
<string>Member</string>
</list>
</value>
</item>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>getUid\r\n
getParentUid\r\n
query\r\n
omit_input\r\n
omit_output\r\n
resource_uid:list\r\n
from_date\r\n
at_date\r\n
to_date\r\n
simulation_state:list\r\n
node_uid:list\r\n
stat</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string>ZSQLCatalog.zsqlbrain</string> </value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string>ZSQLBrain</string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BankAccount_zGetAccountingTransactionList</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-if getParentUid>\n
SELECT\n
<dtml-if stat>\n
SUM(stock.quantity) AS quantity\n
<dtml-else>\n
catalog.uid\n
, catalog.path\n
, stock.date as date\n
, section.title as section_title\n
, IF(delivery.source_section_uid = stock.section_uid,\n
catalog.source_reference,\n
catalog.destination_reference) AS specific_reference\n
, IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) AS debit\n
, IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0) AS credit\n
, - IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0)\n
+ IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) AS balance \n
</dtml-if>\n
FROM\n
movement\n
, catalog AS child\n
, catalog\n
, catalog AS node\n
, category AS node_category\n
, delivery\n
, stock\n
LEFT JOIN catalog AS section\n
ON stock.mirror_section_uid = section.uid\n
<dtml-if query>\n
, category\n
</dtml-if>\n
WHERE stock.section_uid = <dtml-var getParentUid>\n
AND stock.payment_uid = <dtml-var getUid>\n
AND delivery.uid = catalog.uid\n
AND child.uid = stock.uid\n
AND child.parent_uid = catalog.uid\n
AND movement.uid = stock.uid\n
AND movement.is_accountable = 1\n
AND node.uid = stock.node_uid\n
AND node.uid = node_category.uid\n
AND node_category.category_uid = <dtml-sqlvar\n
"portal_categories.account_type.asset.cash.bank.getUid()" type="int">\n
<dtml-if node_uid>\n
AND (\n
<dtml-in node_uid>\n
stock.node_uid = <dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n
)\n
</dtml-if>\n
<dtml-if resource_uid>\n
AND (\n
<dtml-in resource_uid>\n
movement.resource_uid = <dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n
)\n
</dtml-if>\n
<dtml-if from_date>\n
AND stock.date >= <dtml-sqlvar from_date type="datetime">\n
</dtml-if>\n
<dtml-if at_date>\n
AND stock.date <= <dtml-sqlvar at_date type="datetime">\n
</dtml-if>\n
<dtml-if to_date>\n
AND stock.date < <dtml-sqlvar to_date type="datetime">\n
</dtml-if>\n
<dtml-if omit_input>\n
AND stock.quantity > 0\n
</dtml-if>\n
<dtml-if omit_output>\n
AND stock.quantity < 0\n
</dtml-if>\n
<dtml-if simulation_state>\n
AND (\n
<dtml-in simulation_state>\n
catalog.simulation_state = <dtml-sqlvar sequence-item type="string">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n
)\n
</dtml-if>\n
<dtml-if query>\n
AND category.uid = stock.section_uid\n
AND <dtml-var query>\n
</dtml-if>\n
<dtml-unless stat>\n
GROUP BY catalog.uid\n
</dtml-unless>\n
ORDER BY stock.date, movement.uid\n
</dtml-if>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -54,9 +54,13 @@ ...@@ -54,9 +54,13 @@
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
\n \n
params = portal.ERP5Accounting_getParams(selection_name=selection_name)\n params = portal.ERP5Accounting_getParams(selection_name=selection_name)\n
getInventoryAssetPrice = portal.portal_simulation.getInventoryAssetPrice\n
getSelectionDomainDictFor = context.portal_selections.getSelectionDomainDictFor\n getSelectionDomainDictFor = context.portal_selections.getSelectionDomainDictFor\n
\n \n
if asset_price:\n
getInventory = portal.portal_simulation.getInventoryAssetPrice\n
else:\n
getInventory = portal.portal_simulation.getInventory\n
\n
if kw.get(\'node_uid\'):\n if kw.get(\'node_uid\'):\n
params[\'node_uid\'] = kw[\'node_uid\']\n params[\'node_uid\'] = kw[\'node_uid\']\n
\n \n
...@@ -138,26 +142,26 @@ if period_start_date and params.get(\'node_uid\'):\n ...@@ -138,26 +142,26 @@ if period_start_date and params.get(\'node_uid\'):\n
# balance at the beginning of the period, plus debit or credit from this\n # balance at the beginning of the period, plus debit or credit from this\n
# beginning of period to the from_date\n # beginning of period to the from_date\n
at_date = params.pop(\'at_date\', None)\n at_date = params.pop(\'at_date\', None)\n
period_openning_balance = getInventoryAssetPrice(\n period_openning_balance = getInventory(\n
selection_domain=getSelectionDomainDictFor(selection_name),\n selection_domain=getSelectionDomainDictFor(selection_name),\n
to_date=period_start_date,\n to_date=period_start_date,\n
**params)\n **params)\n
if omit_asset_decrease:\n if omit_asset_decrease:\n
return getInventoryAssetPrice(omit_asset_decrease=1,\n return getInventory(omit_asset_decrease=1,\n
from_date=period_start_date,\n from_date=period_start_date,\n
at_date=at_date,\n at_date=at_date,\n
**params) + max(period_openning_balance, 0)\n **params) + max(period_openning_balance, 0)\n
elif omit_asset_increase:\n elif omit_asset_increase:\n
return getInventoryAssetPrice(omit_asset_increase=1,\n return getInventory(omit_asset_increase=1,\n
from_date=period_start_date,\n from_date=period_start_date,\n
at_date=at_date,\n at_date=at_date,\n
**params) - max(-period_openning_balance, 0)\n **params) - max(-period_openning_balance, 0)\n
return getInventoryAssetPrice(\n return getInventory(\n
from_date=period_start_date,\n from_date=period_start_date,\n
at_date=at_date,\n at_date=at_date,\n
**params) + period_openning_balance\n **params) + period_openning_balance\n
\n \n
return getInventoryAssetPrice(\n return getInventory(\n
omit_asset_increase=omit_asset_increase,\n omit_asset_increase=omit_asset_increase,\n
omit_asset_decrease=omit_asset_decrease,\n omit_asset_decrease=omit_asset_decrease,\n
selection_domain=getSelectionDomainDictFor(selection_name),\n selection_domain=getSelectionDomainDictFor(selection_name),\n
...@@ -166,7 +170,7 @@ return getInventoryAssetPrice(\n ...@@ -166,7 +170,7 @@ return getInventoryAssetPrice(\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>selection=None, omit_asset_increase=0, omit_asset_decrease=0, selection_name=None, **kw</string> </value> <value> <string>selection=None, omit_asset_increase=0, omit_asset_decrease=0, asset_price=True, selection_name=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
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