Commit 65510198 authored by Kevin Deldycke's avatar Kevin Deldycke

2006-02-28 Kevin

* Update SaleInvoiceTransaction_zSelectMovement to not include a 'AS movement' statement in SQL query.

2006-02-27 Kevin
* Update Section_getCurrencyPrecision (more generic now).
* Update Account_getAccountingTransactionList to get the default rounding value. As I understand, Account_getAccountingTransactionList is not only used to generated the General Ledger report but is also involved in all Transaction tabs. This mean that Section_getCurrencyPrecision is not generic enough, because the organisation that hold the currency in which the amount must be displayed is not easy to guess. Perhaps using the one defined on preferences is the way to do... (but this has heavy consequences).
* Update AccountingTransaction_roundDebitCredit, to round more efficiently.

2006-02-23 Kevin
* Add AccountingTransaction_roundDebitCredit.
* Add Section_getCurrencyPrecision (not finished yet, will be used in AccountingTransaction_roundDebitCredit and Account_getAccountingTransactionList to get the precision).

2006-02-22 kevin
* Add a patch in Account_getAccountingTransactionList to get round values (based on a hack done by vincent for french accounting).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5863 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4284b4cf
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
</portal_type> </portal_type>
<portal_type id="Accounting Transaction Module"> <portal_type id="Accounting Transaction Module">
<item>Purchase Invoice Transaction</item> <item>Purchase Invoice Transaction</item>
<item>Pay Sheet Transaction</item>
<item>Accounting Transaction</item> <item>Accounting Transaction</item>
<item>Sale Invoice Transaction</item> <item>Sale Invoice Transaction</item>
<item>Payment Transaction</item> <item>Payment Transaction</item>
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Payment Transaction</string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -129,9 +129,8 @@ def formatValues(dict) :\n ...@@ -129,9 +129,8 @@ def formatValues(dict) :\n
while i != len(integer):\n while i != len(integer):\n
value += \' \' + integer[i:i+3]\n value += \' \' + integer[i:i+3]\n
i += 3\n i += 3\n
dict[k] = \'%s.%s\'%(value, str(value_list[1])[:2])\n value = \'%s.%s\'%(value, str(value_list[1])[:2])\n
# XXX ohada l10n local hack, we only use integer part !\n dict[k] = value\n
#dict[k] = \'%s\'%(value)\n
if k in (\'opening_balance\', \'closing_balance\') :\n if k in (\'opening_balance\', \'closing_balance\') :\n
if negative:\n if negative:\n
dict[k] = \'%s CR\'%(value)\n dict[k] = \'%s CR\'%(value)\n
......
...@@ -458,15 +458,15 @@ ...@@ -458,15 +458,15 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>portal_categories/gap</string> <string>gap</string>
<string>GAP</string> <string>GAP</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_categories/account_type</string> <string>account_type</string>
<string>Account Type</string> <string>Account Type</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_categories/financial_section</string> <string>financial_section</string>
<string>Financial Section</string> <string>Financial Section</string>
</tuple> </tuple>
</list> </list>
...@@ -540,15 +540,15 @@ ...@@ -540,15 +540,15 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>portal_categories/gap</string> <string>gap</string>
<string>GAP</string> <string>GAP</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_categories/account_type</string> <string>account_type</string>
<string>Account Type</string> <string>Account Type</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_categories/financial_section</string> <string>financial_section</string>
<string>Financial Section</string> <string>Financial Section</string>
</tuple> </tuple>
</list> </list>
......
...@@ -66,10 +66,20 @@ ...@@ -66,10 +66,20 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>LOG=lambda message: context.log("Account_getAccountingTransactionList", message)\n <value> <string encoding="cdata"><![CDATA[
LOG=lambda message: context.log("Account_getAccountingTransactionList", message)\n
\n \n
from Products.ERP5Type.Document import newTempAccountingTransaction\n from Products.ERP5Type.Document import newTempAccountingTransaction\n
\n \n
# WARNINGS by Vincent (2006/01/31)\n
# This hack do a rounding on intermediate amount values.\n
# This prevent floating point bugs such as :\n
# >>> 54.99\n
# 54.990000000000002\n
# kev: isn\'t it better to set precision as an integer ?\n
precision = float(10 ** context.Section_getCurrencyPrecision())\n
\n
kwd={"omit_simulation" : 1}\n kwd={"omit_simulation" : 1}\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
...@@ -151,7 +161,7 @@ if from_date not in (None, MARKER) and kw.get(\'from_date_summary\', 0) :\n ...@@ -151,7 +161,7 @@ if from_date not in (None, MARKER) and kw.get(\'from_date_summary\', 0) :\n
from_date_summary = newTempAccountingTransaction(\n from_date_summary = newTempAccountingTransaction(\n
context.getPortalObject(), "temp_%s" % context.getUid())\n context.getPortalObject(), "temp_%s" % context.getUid())\n
from_date_summary.setUid(\'new_000\')\n from_date_summary.setUid(\'new_000\')\n
net_balance = last_total_debit - last_total_credit\n net_balance = (last_total_debit - last_total_credit) * precision # WARNING : See Above\n
from_date_summary.edit(\n from_date_summary.edit(\n
title = context.Base_TranslateString("Previous Balance"),\n title = context.Base_TranslateString("Previous Balance"),\n
translated_portal_type = "",\n translated_portal_type = "",\n
...@@ -171,9 +181,9 @@ if src__:\n ...@@ -171,9 +181,9 @@ if src__:\n
\n \n
for l in result:\n 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) * precision # WARNING : See above\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 / precision, # WARNING : See above\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
...@@ -187,7 +197,9 @@ for l in result:\n ...@@ -187,7 +197,9 @@ 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>
...@@ -238,9 +250,11 @@ return new_result\n ...@@ -238,9 +250,11 @@ return new_result\n
<string>LOG</string> <string>LOG</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
<string>newTempAccountingTransaction</string> <string>newTempAccountingTransaction</string>
<string>kwd</string> <string>float</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>precision</string>
<string>kwd</string>
<string>preference</string> <string>preference</string>
<string>None</string> <string>None</string>
<string>from_date</string> <string>from_date</string>
......
...@@ -413,11 +413,11 @@ ...@@ -413,11 +413,11 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>portal_categories/group</string> <string>group</string>
<string>Group</string> <string>Group</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_categories/region</string> <string>region</string>
<string>Region</string> <string>Region</string>
</tuple> </tuple>
</list> </list>
......
...@@ -71,16 +71,13 @@ ...@@ -71,16 +71,13 @@
transaction = context\n transaction = context\n
preference_tool = getToolByName(context, \'portal_preferences\')\n preference_tool = getToolByName(context, \'portal_preferences\')\n
\n \n
try : \n transaction.edit (\n
transaction.edit (\n
source_section = preference_tool.getPreferredAccountingTransactionSourceSection(),\n source_section = preference_tool.getPreferredAccountingTransactionSourceSection(),\n
resource = preference_tool.getPreferredAccountingTransactionCurrency())\n resource = preference_tool.getPreferredAccountingTransactionCurrency())\n
except AttributeError, e :\n
context.log(\'AccountingTransaction_InitFromPreferences\', \'error : %s\' % e)\n
\n \n
if hasattr(context, \'startBuilding\') :\n if hasattr(transaction, \'startBuilding\') :\n
context.startBuilding()\n transaction.startBuilding()\n
context.updateCausalityState()\n transaction.updateCausalityState()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -129,8 +126,6 @@ if hasattr(context, \'startBuilding\') :\n ...@@ -129,8 +126,6 @@ if hasattr(context, \'startBuilding\') :\n
<string>transaction</string> <string>transaction</string>
<string>preference_tool</string> <string>preference_tool</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>AttributeError</string>
<string>e</string>
<string>hasattr</string> <string>hasattr</string>
</tuple> </tuple>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value> <string encoding="base64">O/INCg==</string> </value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
""" Round debit & credit in a generated accounting transaction """\n
\n
precision = int(context.Section_getCurrencyPrecision(mapping_id=\'source_section\'))\n
\n
debit_list = []\n
credit_list = []\n
line = None\n
total_quantity = 0\n
\n
for line in context.getMovementList(portal_type =\n
context.getPortalAccountingMovementTypeList()) :\n
if line.getSourceDebit() > 0 :\n
# line.setSourceDebit((line.getSourceDebit() * precision) / int(precision))\n
line.setSourceDebit( float((\'%.\'+str(precision)+\'f\') % (line.getSourceDebit())) )\n
total_quantity += line.getQuantity()\n
else :\n
# line.setSourceCredit((line.getSourceCredit() * precision) / int(precision))\n
line.setSourceCredit( float((\'%.\'+str(precision)+\'f\') % (line.getSourceCredit())) )\n
total_quantity += line.getQuantity()\n
\n
if abs(total_quantity) > 2:\n
# if the difference is important, then it\'s probably a misconfiguration in the rule\n
# so we have to raise an errror.\n
raise ValueError, \'debit != credit for %s => %s\' % (\n
context.getPath(), total_quantity)\n
\n
if line is not None :\n
line.setQuantity(line.getQuantity() - total_quantity)\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_accounting/AccountingTransaction_roundDebitCredit</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>int</string>
<string>_getattr_</string>
<string>context</string>
<string>precision</string>
<string>debit_list</string>
<string>credit_list</string>
<string>None</string>
<string>line</string>
<string>total_quantity</string>
<string>_getiter_</string>
<string>float</string>
<string>str</string>
<string>abs</string>
<string>ValueError</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransaction_roundDebitCredit</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -409,11 +409,11 @@ ...@@ -409,11 +409,11 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>portal_categories/group</string> <string>group</string>
<string>Group</string> <string>Group</string>
</tuple> </tuple>
<tuple> <tuple>
<string>portal_categories/region</string> <string>region</string>
<string>Region</string> <string>Region</string>
</tuple> </tuple>
</list> </list>
......
...@@ -70,9 +70,9 @@ ...@@ -70,9 +70,9 @@
<key> <string>_keys</string> </key> <key> <string>_keys</string> </key>
<value> <value>
<list> <list>
<string>from_table_list</string> <string>from_table_list</string>
<string>where_expression</string> <string>where_expression</string>
<string>order_by_expression</string> <string>order_by_expression</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -146,7 +146,7 @@ SELECT\n ...@@ -146,7 +146,7 @@ SELECT\n
FROM\n FROM\n
movement\n movement\n
<dtml-in prefix="table" expr="from_table_list"> \n <dtml-in prefix="table" expr="from_table_list"> \n
<dtml-if expr="table_key != \'catalog\'">\n <dtml-if expr="table_key not in (\'catalog\', \'movement\')">\n
, <dtml-var table_item> AS <dtml-var table_key>\n , <dtml-var table_item> AS <dtml-var table_key>\n
</dtml-if>\n </dtml-if>\n
</dtml-in>\n </dtml-in>\n
...@@ -216,7 +216,7 @@ SELECT\n ...@@ -216,7 +216,7 @@ SELECT\n
FROM\n FROM\n
movement\n movement\n
<dtml-in prefix="table" expr="from_table_list"> \n <dtml-in prefix="table" expr="from_table_list"> \n
<dtml-if expr="table_key != \'catalog\'">\n <dtml-if expr="table_key not in (\'catalog\', \'movement\')">\n
, <dtml-var table_item> AS <dtml-var table_key>\n , <dtml-var table_item> AS <dtml-var table_key>\n
</dtml-if>\n </dtml-if>\n
</dtml-in>\n </dtml-in>\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value> <string encoding="base64">O/INCg==</string> </value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># Return default precision\n
if mapping_id in (None, \'\'):\n
return 2\n
\n
# Get the category that hold the organisation\n
from Products.ERP5Type.Utils import convertToUpperCase\n
method_id = "get" + convertToUpperCase(mapping_id) + "Value"\n
if not hasattr(context, method_id):\n
raise "Error in roundDebitCredit", "\'%s\' is not defined on %s" % (method_id, context.getRelativeUrl())\n
method = getattr(context, method_id, None)\n
mapping_category = method()\n
\n
# Get the organisation that hold the currency\n
organisation = None\n
mapping_portal_type = mapping_category.getPortalType()\n
if mapping_portal_type == \'Category\':\n
organisation = mapping_category.getMappingRelatedValue(portal_type=\'Organisation\')\n
elif mapping_portal_type == \'Organisation\':\n
organisation = mapping_category\n
if organisation == None:\n
raise "Error in roundDebitCredit", "Organisation not found via \'%s\' category on %s" % (mapping_id, context.getRelativeUrl())\n
\n
# Get the currency\n
currency = organisation.getPriceCurrencyValue()\n
if currency in (\'\', None):\n
raise "Error in roundDebitCredit", "Currency on %s is required" % (organisation.getRelativeUrl())\n
\n
# Return the precision of the currency\n
return currency.getQuantityPrecision()\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_accounting/Section_getCurrencyPrecision</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>mapping_id=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>mapping_id</string>
<string>None</string>
<string>Products.ERP5Type.Utils</string>
<string>convertToUpperCase</string>
<string>method_id</string>
<string>hasattr</string>
<string>context</string>
<string>_getattr_</string>
<string>getattr</string>
<string>method</string>
<string>mapping_category</string>
<string>organisation</string>
<string>mapping_portal_type</string>
<string>currency</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Section_getCurrencyPrecision</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2006-02-28 Kevin
* Update SaleInvoiceTransaction_zSelectMovement to not include a 'AS movement' statement in SQL query.
2006-02-27 Kevin
* Update Section_getCurrencyPrecision (more generic now).
* Update Account_getAccountingTransactionList to get the default rounding value. As I understand, Account_getAccountingTransactionList is not only used to generated the General Ledger report but is also involved in all Transaction tabs. This mean that Section_getCurrencyPrecision is not generic enough, because the organisation that hold the currency in which the amount must be displayed is not easy to guess. Perhaps using the one defined on preferences is the way to do... (but this has heavy consequences).
* Update AccountingTransaction_roundDebitCredit, to round more efficiently.
2006-02-23 Kevin
* Add AccountingTransaction_roundDebitCredit.
* Add Section_getCurrencyPrecision (not finished yet, will be used in AccountingTransaction_roundDebitCredit and Account_getAccountingTransactionList to get the precision).
2006-02-22 kevin
* Add a patch in Account_getAccountingTransactionList to get round values (based on a hack done by vincent for french accounting).
2006-02-17 kevin 2006-02-17 kevin
* Add Balance at the start-date and stop-date on General Ledger Report. * Add Balance at the start-date and stop-date on General Ledger Report.
......
...@@ -2,7 +2,6 @@ Account Module | Account ...@@ -2,7 +2,6 @@ Account Module | Account
Accounting Rule Cell | Accounting Transaction Line Accounting Rule Cell | Accounting Transaction Line
Accounting Transaction Module | Accounting Transaction Accounting Transaction Module | Accounting Transaction
Accounting Transaction Module | Balance Transaction Accounting Transaction Module | Balance Transaction
Accounting Transaction Module | Pay Sheet Transaction
Accounting Transaction Module | Payment Transaction Accounting Transaction Module | Payment Transaction
Accounting Transaction Module | Purchase Invoice Transaction Accounting Transaction Module | Purchase Invoice Transaction
Accounting Transaction Module | Sale Invoice Transaction Accounting Transaction Module | Sale Invoice Transaction
......
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