Commit 0153f990 authored by Jérome Perrin's avatar Jérome Perrin

use total_price instead of quantity

be side independant


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5617 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d384dc78
...@@ -72,16 +72,23 @@ LOG=lambda message: context.log("AccountModule_statBalance", message)\n ...@@ -72,16 +72,23 @@ LOG=lambda message: context.log("AccountModule_statBalance", message)\n
\n \n
# read settings from user preference\n # read settings from user preference\n
preference = context.getPortalObject().portal_preferences\n preference = context.getPortalObject().portal_preferences\n
from_date = preference.getPreferredAccountingTransactionFromDate()\n from_date = preference.getPreferredAccountingTransactionFromDate()\\\n
or kw.get(\'from_date\', None)\n
if from_date :\n if from_date :\n
params[\'from_date\'] = from_date\n params[\'from_date\'] = from_date\n
at_date = preference.getPreferredAccountingTransactionAtDate()\n \n
at_date = preference.getPreferredAccountingTransactionAtDate()\\\n
or kw.get(\'at_date\', None)\n
if at_date :\n if at_date :\n
params[\'at_date\'] = at_date\n params[\'at_date\'] = at_date\n
simulation_state = preference.getPreferredAccountingTransactionSimulationStateList()\n \n
simulation_state = preference.getPreferredAccountingTransactionSimulationStateList()\\\n
or kw.get(\'simulation_state\', kw.get(\'transaction_simulation_state\', None))\n
if simulation_state :\n if simulation_state :\n
params[\'simulation_state\'] = simulation_state\n params[\'simulation_state\'] = simulation_state\n
section_category = preference.getPreferredAccountingTransactionSectionCategory()\n \n
section_category = preference.getPreferredAccountingTransactionSectionCategory()\\\n
or kw.get(\'section_category\', kw.get(\'transaction_section_category\', None))\n
if section_category :\n if section_category :\n
params[\'section_category\'] = section_category\n params[\'section_category\'] = section_category\n
\n \n
...@@ -116,12 +123,14 @@ if kw.get(\'omit_input\'):\n ...@@ -116,12 +123,14 @@ if kw.get(\'omit_input\'):\n
if kw.get(\'omit_output\'):\n if kw.get(\'omit_output\'):\n
params[\'omit_output\'] = 1\n params[\'omit_output\'] = 1\n
\n \n
context.log(\'params\', params)\n
context.log(\'at_date\', at_date)\n
results = context.Resource_zStatInventory(omit_simulation=1,\n results = context.Resource_zStatInventory(omit_simulation=1,\n
**params)\n **params)\n
row = results[0]\n row = results[0]\n
total = 0\n total = 0\n
if row.quantity :\n if row.total_price :\n
total = row.quantity or 0.00\n total = row.total_price or 0.00\n
return total\n return total\n
\n \n
# FIXME:\n # FIXME:\n
...@@ -145,7 +154,7 @@ return context.portal_simulation.getInventory( omit_simulation=1, **params )\n ...@@ -145,7 +154,7 @@ return context.portal_simulation.getInventory( omit_simulation=1, **params )\n
</item> </item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_accounting/AccountModule_statBalance</string> </value> <value> <string>Script (Python):/erp5/portal_skins/erp5_accounting/AccountModule_statBalance</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
...@@ -183,6 +192,7 @@ return context.portal_simulation.getInventory( omit_simulation=1, **params )\n ...@@ -183,6 +192,7 @@ return context.portal_simulation.getInventory( omit_simulation=1, **params )\n
<string>LOG</string> <string>LOG</string>
<string>context</string> <string>context</string>
<string>preference</string> <string>preference</string>
<string>None</string>
<string>from_date</string> <string>from_date</string>
<string>_write_</string> <string>_write_</string>
<string>at_date</string> <string>at_date</string>
......
...@@ -104,12 +104,16 @@ net_balance = 0.0\n ...@@ -104,12 +104,16 @@ net_balance = 0.0\n
# \n # \n
for l in result:\n for l in result:\n
o = l.getObject()\n o = l.getObject()\n
net_balance += l.source_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
source_balance=l.source_balance,\n balance=l.balance,\n
source_credit=l.source_credit,\n credit=l.credit,\n
source_debit=l.source_debit )\n debit=l.debit,\n
section_title=l.section_title,\n
specific_reference=l.specific_reference,\n
date=l.date,\n
)\n
new_result.append(c)\n new_result.append(c)\n
\n \n
return new_result\n return new_result\n
...@@ -130,7 +134,7 @@ return new_result\n ...@@ -130,7 +134,7 @@ return new_result\n
</item> </item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_accounting/BankAccount_getAccountingTransactionList</string> </value> <value> <string>Script (Python):/erp5/portal_skins/erp5_accounting/BankAccount_getAccountingTransactionList</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
......
...@@ -134,18 +134,18 @@ ...@@ -134,18 +134,18 @@
<key> <string>_keys</string> </key> <key> <string>_keys</string> </key>
<value> <value>
<list> <list>
<string>getUid</string> <string>getUid</string>
<string>getParentUid</string> <string>getParentUid</string>
<string>query</string> <string>query</string>
<string>omit_input</string> <string>omit_input</string>
<string>omit_output</string> <string>omit_output</string>
<string>resource_uid</string> <string>resource_uid</string>
<string>from_date</string> <string>from_date</string>
<string>at_date</string> <string>at_date</string>
<string>to_date</string> <string>to_date</string>
<string>transaction_simulation_state</string> <string>transaction_simulation_state</string>
<string>node_uid</string> <string>node_uid</string>
<string>stat</string> <string>stat</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -195,7 +195,9 @@ stat</string> </value> ...@@ -195,7 +195,9 @@ stat</string> </value>
</item> </item>
<item> <item>
<key> <string>connection_hook</string> </key> <key> <string>connection_hook</string> </key>
<value> <string></string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>connection_id</string> </key> <key> <string>connection_id</string> </key>
...@@ -220,14 +222,18 @@ stat</string> </value> ...@@ -220,14 +222,18 @@ stat</string> </value>
<dtml-if getParentUid>\n <dtml-if getParentUid>\n
SELECT\n SELECT\n
<dtml-if stat>\n <dtml-if stat>\n
SUM(stock.quantity) AS quantity\n SUM(stock.total_price) AS quantity\n
<dtml-else>\n <dtml-else>\n
catalog.uid\n catalog.uid\n
, catalog.path\n , catalog.path\n
-- , @runningTotal:=IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0) - IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) + @runningTotal AS net_balance\n , stock.date as date\n
, IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) AS source_debit\n , section.title as section_title\n
, IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0) AS source_credit\n , IF(delivery.source_section_uid = stock.section_uid,\n
, - IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0) + IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) AS source_balance\n catalog.source_reference, catalog.destination_reference) AS specific_reference\n
, IFNULL(SUM(IF(stock.total_price > 0, stock.total_price, 0)), 0) AS debit\n
, IFNULL(SUM(IF(stock.total_price < 0, - stock.total_price, 0)), 0) AS credit\n
, - IFNULL(SUM(IF(stock.total_price < 0, - stock.total_price, 0)), 0)\n
+ IFNULL(SUM(IF(stock.total_price > 0, stock.total_price, 0)), 0) AS balance\n
</dtml-if>\n </dtml-if>\n
FROM\n FROM\n
movement\n movement\n
...@@ -236,29 +242,36 @@ FROM\n ...@@ -236,29 +242,36 @@ FROM\n
, catalog\n , catalog\n
, catalog AS node\n , catalog AS node\n
, category AS node_category\n , category AS node_category\n
, catalog AS section\n
, delivery\n
<dtml-if query>\n <dtml-if query>\n
, category\n , category\n
</dtml-if>\n </dtml-if>\n
WHERE stock.section_uid = <dtml-var getParentUid>\n WHERE stock.section_uid = <dtml-var getParentUid>\n
AND stock.payment_uid = <dtml-var getUid>\n AND stock.payment_uid = <dtml-var getUid>\n
AND child.uid = stock.uid \n AND stock.mirror_section_uid = section.uid\n
AND delivery.uid = catalog.uid\n
AND child.uid = stock.uid\n
AND child.parent_uid = catalog.uid\n AND child.parent_uid = catalog.uid\n
AND movement.uid = stock.uid\n AND movement.uid = stock.uid\n
AND movement.is_accountable = 1\n AND movement.is_accountable = 1\n
AND node.uid = stock.node_uid\n AND node.uid = stock.node_uid\n
AND node.uid = node_category.uid\n AND node.uid = node_category.uid\n
AND node_category.category_uid = <dtml-sqlvar "portal_categories.account_type.asset.cash.getUid()" type="int">\n AND node_category.category_uid = <dtml-sqlvar\n
"portal_categories.account_type.asset.cash.getUid()" type="int">\n
<dtml-if node_uid>\n <dtml-if node_uid>\n
AND (\n AND (\n
<dtml-in node_uid>\n <dtml-in node_uid>\n
stock.node_uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n stock.node_uid = <dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n </dtml-in>\n
)\n )\n
</dtml-if>\n </dtml-if>\n
<dtml-if resource_uid>\n <dtml-if resource_uid>\n
AND (\n AND (\n
<dtml-in resource_uid>\n <dtml-in resource_uid>\n
movement.resource_uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n movement.resource_uid = <dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n </dtml-in>\n
)\n )\n
</dtml-if>\n </dtml-if>\n
...@@ -272,15 +285,16 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n ...@@ -272,15 +285,16 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n
AND stock.date < <dtml-sqlvar to_date type="datetime">\n AND stock.date < <dtml-sqlvar to_date type="datetime">\n
</dtml-if>\n </dtml-if>\n
<dtml-if omit_input>\n <dtml-if omit_input>\n
AND stock.quantity > 0\n AND stock.total_price > 0\n
</dtml-if>\n </dtml-if>\n
<dtml-if omit_output>\n <dtml-if omit_output>\n
AND stock.quantity < 0\n AND stock.total_price < 0\n
</dtml-if>\n </dtml-if>\n
<dtml-if transaction_simulation_state>\n <dtml-if transaction_simulation_state>\n
AND (\n AND (\n
<dtml-in transaction_simulation_state>\n <dtml-in transaction_simulation_state>\n
catalog.simulation_state = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n catalog.simulation_state = <dtml-sqlvar sequence-item type="string">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n </dtml-in>\n
)\n )\n
</dtml-if>\n </dtml-if>\n
...@@ -289,9 +303,9 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n ...@@ -289,9 +303,9 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n
AND <dtml-var query>\n AND <dtml-var query>\n
</dtml-if>\n </dtml-if>\n
<dtml-unless stat>\n <dtml-unless stat>\n
GROUP BY catalog.uid\n GROUP BY catalog.uid\n
</dtml-unless>\n </dtml-unless>\n
ORDER BY stock.date, movement.uid\n ORDER BY stock.date, movement.uid\n
</dtml-if>\n </dtml-if>\n
...@@ -334,14 +348,18 @@ ORDER BY stock.date, movement.uid\n ...@@ -334,14 +348,18 @@ ORDER BY stock.date, movement.uid\n
<dtml-if getParentUid>\n <dtml-if getParentUid>\n
SELECT\n SELECT\n
<dtml-if stat>\n <dtml-if stat>\n
SUM(stock.quantity) AS quantity\n SUM(stock.total_price) AS quantity\n
<dtml-else>\n <dtml-else>\n
catalog.uid\n catalog.uid\n
, catalog.path\n , catalog.path\n
-- , @runningTotal:=IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0) - IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) + @runningTotal AS net_balance\n , stock.date as date\n
, IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) AS source_debit\n , section.title as section_title\n
, IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0) AS source_credit\n , IF(delivery.source_section_uid = stock.section_uid,\n
, - IFNULL(SUM(IF(stock.quantity < 0, - stock.quantity, 0)), 0) + IFNULL(SUM(IF(stock.quantity > 0, stock.quantity, 0)), 0) AS source_balance\n catalog.source_reference, catalog.destination_reference) AS specific_reference\n
, IFNULL(SUM(IF(stock.total_price > 0, stock.total_price, 0)), 0) AS debit\n
, IFNULL(SUM(IF(stock.total_price < 0, - stock.total_price, 0)), 0) AS credit\n
, - IFNULL(SUM(IF(stock.total_price < 0, - stock.total_price, 0)), 0)\n
+ IFNULL(SUM(IF(stock.total_price > 0, stock.total_price, 0)), 0) AS balance\n
</dtml-if>\n </dtml-if>\n
FROM\n FROM\n
movement\n movement\n
...@@ -350,29 +368,36 @@ FROM\n ...@@ -350,29 +368,36 @@ FROM\n
, catalog\n , catalog\n
, catalog AS node\n , catalog AS node\n
, category AS node_category\n , category AS node_category\n
, catalog AS section\n
, delivery\n
<dtml-if query>\n <dtml-if query>\n
, category\n , category\n
</dtml-if>\n </dtml-if>\n
WHERE stock.section_uid = <dtml-var getParentUid>\n WHERE stock.section_uid = <dtml-var getParentUid>\n
AND stock.payment_uid = <dtml-var getUid>\n AND stock.payment_uid = <dtml-var getUid>\n
AND child.uid = stock.uid \n AND stock.mirror_section_uid = section.uid\n
AND delivery.uid = catalog.uid\n
AND child.uid = stock.uid\n
AND child.parent_uid = catalog.uid\n AND child.parent_uid = catalog.uid\n
AND movement.uid = stock.uid\n AND movement.uid = stock.uid\n
AND movement.is_accountable = 1\n AND movement.is_accountable = 1\n
AND node.uid = stock.node_uid\n AND node.uid = stock.node_uid\n
AND node.uid = node_category.uid\n AND node.uid = node_category.uid\n
AND node_category.category_uid = <dtml-sqlvar "portal_categories.account_type.asset.cash.getUid()" type="int">\n AND node_category.category_uid = <dtml-sqlvar\n
"portal_categories.account_type.asset.cash.getUid()" type="int">\n
<dtml-if node_uid>\n <dtml-if node_uid>\n
AND (\n AND (\n
<dtml-in node_uid>\n <dtml-in node_uid>\n
stock.node_uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n stock.node_uid = <dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n </dtml-in>\n
)\n )\n
</dtml-if>\n </dtml-if>\n
<dtml-if resource_uid>\n <dtml-if resource_uid>\n
AND (\n AND (\n
<dtml-in resource_uid>\n <dtml-in resource_uid>\n
movement.resource_uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n movement.resource_uid = <dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n </dtml-in>\n
)\n )\n
</dtml-if>\n </dtml-if>\n
...@@ -386,15 +411,16 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n ...@@ -386,15 +411,16 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n
AND stock.date < <dtml-sqlvar to_date type="datetime">\n AND stock.date < <dtml-sqlvar to_date type="datetime">\n
</dtml-if>\n </dtml-if>\n
<dtml-if omit_input>\n <dtml-if omit_input>\n
AND stock.quantity > 0\n AND stock.total_price > 0\n
</dtml-if>\n </dtml-if>\n
<dtml-if omit_output>\n <dtml-if omit_output>\n
AND stock.quantity < 0\n AND stock.total_price < 0\n
</dtml-if>\n </dtml-if>\n
<dtml-if transaction_simulation_state>\n <dtml-if transaction_simulation_state>\n
AND (\n AND (\n
<dtml-in transaction_simulation_state>\n <dtml-in transaction_simulation_state>\n
catalog.simulation_state = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n catalog.simulation_state = <dtml-sqlvar sequence-item type="string">\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n </dtml-in>\n
)\n )\n
</dtml-if>\n </dtml-if>\n
...@@ -403,9 +429,9 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n ...@@ -403,9 +429,9 @@ WHERE stock.section_uid = <dtml-var getParentUid>\n
AND <dtml-var query>\n AND <dtml-var query>\n
</dtml-if>\n </dtml-if>\n
<dtml-unless stat>\n <dtml-unless stat>\n
GROUP BY catalog.uid\n GROUP BY catalog.uid\n
</dtml-unless>\n </dtml-unless>\n
ORDER BY stock.date, movement.uid\n ORDER BY stock.date, movement.uid\n
</dtml-if>\n </dtml-if>\n
......
...@@ -77,13 +77,18 @@ preference = context.getPortalObject().portal_preferences\n ...@@ -77,13 +77,18 @@ preference = context.getPortalObject().portal_preferences\n
from_date = preference.getPreferredAccountingTransactionFromDate()\n from_date = preference.getPreferredAccountingTransactionFromDate()\n
if from_date :\n if from_date :\n
kwd[\'from_date\'] = from_date\n kwd[\'from_date\'] = from_date\n
\n
at_date = preference.getPreferredAccountingTransactionAtDate()\n at_date = preference.getPreferredAccountingTransactionAtDate()\n
if at_date :\n if at_date :\n
kwd[\'at_date\'] = at_date\n kwd[\'at_date\'] = at_date\n
simulation_state = preference.getPreferredAccountingTransactionSimulationStateList()\n \n
simulation_state = preference\\\n
.getPreferredAccountingTransactionSimulationStateList()\n
if simulation_state :\n if simulation_state :\n
kwd[\'transaction_simulation_state\'] = simulation_state\n kwd[\'transaction_simulation_state\'] = simulation_state\n
section_category = preference.getPreferredAccountingTransactionSectionCategory()\n \n
section_category = preference\\\n
.getPreferredAccountingTransactionSectionCategory()\n
if section_category :\n if section_category :\n
kwd[\'transaction_section_category\'] = section_category\n kwd[\'transaction_section_category\'] = section_category\n
\n \n
...@@ -93,9 +98,9 @@ if kw.has_key(\'transaction_portal_type\'):\n ...@@ -93,9 +98,9 @@ if kw.has_key(\'transaction_portal_type\'):\n
kwd[\'transaction_portal_type\'] = kw[\'transaction_portal_type\']\n kwd[\'transaction_portal_type\'] = kw[\'transaction_portal_type\']\n
\n \n
\n \n
# FIXME: same problem as in BankAccount_getAccountingTransactionList\n
\n \n
#LOG("SQL used: %s" % context.Entity_zGetAccountingTransactionList(src__=1, **kwd))\n # FIXME: same problem as in BankAccount_getAccountingTransactionList\n
# LOG("SQL used: %s" % context.Entity_zGetAccountingTransactionList(src__=1, **kwd))\n
\n \n
new_result = []\n new_result = []\n
result = context.Entity_zGetAccountingTransactionList(**kwd)\n result = context.Entity_zGetAccountingTransactionList(**kwd)\n
...@@ -104,17 +109,20 @@ if src__:\n ...@@ -104,17 +109,20 @@ if src__:\n
net_balance = 0.0\n net_balance = 0.0\n
for l in result:\n for l in result:\n
o = l.getObject()\n o = l.getObject()\n
net_balance += l.source_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
source_balance=l.source_balance,\n balance=l.balance,\n
source_credit=l.source_credit,\n credit=l.credit,\n
source_debit=l.source_debit,\n debit=l.debit,\n
date=l.date,\n date=l.date,\n
section_title=l.section_title,\n
parent_reference=l.parent_reference,\n parent_reference=l.parent_reference,\n
parent_source_reference=l.parent_source_reference,\n parent_specific_reference=l.parent_specific_reference,\n
translated_simulation_state_title = o.getTranslatedSimulationStateTitle(),\n translated_simulation_state_title =\n
portal_type=l.portal_type )\n o.getTranslatedSimulationStateTitle(),\n
portal_type=l.portal_type,\n
account_uid=l.account_uid, )\n
new_result.append(c)\n new_result.append(c)\n
\n \n
return new_result\n return new_result\n
...@@ -135,7 +143,7 @@ return new_result\n ...@@ -135,7 +143,7 @@ return new_result\n
</item> </item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_accounting/Entity_getAccountingTransactionList</string> </value> <value> <string>Script (Python):/erp5/portal_skins/erp5_accounting/Entity_getAccountingTransactionList</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</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