Commit 1c12aff8 authored by Julien Muchembled's avatar Julien Muchembled

Fix testAccountingReports

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@38463 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4c2d2fae
......@@ -21,6 +21,14 @@
<item>Purchase Invoice Transaction</item>
<item>Sale Invoice Transaction</item>
</portal_type>
<portal_type id="Accounting Transaction Root Simulation Rule">
<item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item>
<item>Net Converted Quantity Divergence Tester</item>
<item>String Divergence Tester</item>
<item>Variation Divergence Tester</item>
</portal_type>
<portal_type id="Balance Transaction">
<item>Balance Transaction Line</item>
</portal_type>
......
......@@ -47,11 +47,15 @@
</item>
<item>
<key> <string>init_script</string> </key>
<value> <string></string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value> <string></string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -7,6 +7,12 @@ Accounting Transaction Module | Balance Transaction
Accounting Transaction Module | Payment Transaction
Accounting Transaction Module | Purchase Invoice Transaction
Accounting Transaction Module | Sale Invoice Transaction
Accounting Transaction Root Simulation Rule | Category Membership Divergence Tester
Accounting Transaction Root Simulation Rule | DateTime Divergence Tester
Accounting Transaction Root Simulation Rule | Float Divergence Tester
Accounting Transaction Root Simulation Rule | Net Converted Quantity Divergence Tester
Accounting Transaction Root Simulation Rule | String Divergence Tester
Accounting Transaction Root Simulation Rule | Variation Divergence Tester
Accounting Transaction | Accounting Transaction Line
Accounting Transaction | File
Accounting Transaction | Image
......
......@@ -107,7 +107,7 @@
</item>
<item>
<key> <string>last_id</string> </key>
<value> <string>12</string> </value>
<value> <string>13</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="TradeModelPath" module="Products.ERP5Type.Document.TradeModelPath"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>modification_date</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>date</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>creation_date</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>date</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>trade_phase/default/accounting</string>
<string>trade_date/trade_phase/default/accounting</string>
</tuple>
</value>
</item>
<item>
<key> <string>creation_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1280786400.0</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TMP-ACCOUNTING</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>13</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>membership_criterion_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1280786400.0</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>payment_end_of_month</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Trade Model Path</string> </value>
</item>
<item>
<key> <string>string_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>test_method_id</string> </key>
<value>
<tuple>
<string>isAccountingMovementType</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Accounting</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="AccountingTransactionRootSimulationRule" module="Products.ERP5Type.Document.AccountingTransactionRootSimulationRule"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>trade_phase/default/accounting</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>default_accounting_transaction_rule</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>new_accounting_transaction_root_simulation_rule</string> </value>
</item>
<item>
<key> <string>last_id</string> </key>
<value> <string>1</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Accounting Transaction Root Simulation Rule</string> </value>
</item>
<item>
<key> <string>test_method_id</string> </key>
<value>
<tuple>
<string>Rule_testFalse</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>New Default Accounting Transaction Root Simulation Rule</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>3</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees._OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees._OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="CategoryMembershipEquivalenceTester" module="Products.ERP5Type.Document.CategoryMembershipEquivalenceTester"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>divergence_provider</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>delivery_tester</string> </value>
</item>
<item>
<key> <string>matching_provider</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Membership Divergence Tester</string> </value>
</item>
<item>
<key> <string>tested_property</string> </key>
<value>
<tuple>
<string>delivery</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>delivery divergence tester</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -3,6 +3,8 @@ business_process_module/erp5_default_business_process/**
portal_categories/trade_phase/default
portal_categories/trade_phase/default/**
portal_categories/trade_state/**
portal_rules/new_accounting_transaction_root_simulation_rule
portal_rules/new_accounting_transaction_root_simulation_rule/**
portal_rules/new_delivery_root_simulation_rule
portal_rules/new_delivery_root_simulation_rule/**
portal_rules/new_delivery_simulation_rule
......
......@@ -116,6 +116,7 @@ class AccountingTestCase(ERP5TypeTestCase):
"""
username = 'username'
business_process = 'business_process_module/erp5_default_business_process'
@reindex
def _makeOne(self, portal_type='Accounting Transaction', lines=None,
......@@ -139,6 +140,8 @@ class AccountingTestCase(ERP5TypeTestCase):
kw.setdefault('source_section_value', self.section)
tr = self.accounting_module.newContent(portal_type=portal_type,
created_by_builder=created_by_builder, **kw)
if self.business_process and not tr.getSpecialise():
tr._setSpecialise(self.business_process)
if lines:
for line in lines:
line.setdefault('portal_type', transaction_to_line_mapping[portal_type])
......
......@@ -85,10 +85,15 @@ class TestBPMMixin(ERP5TypeTestCase):
reference='default_path',
trade_phase_value_list=('default/discount', 'default/tax'),
trade_date='trade_phase/default/invoicing')
# A trade model path already exist for root simulation movements
# (Accounting Transaction Root Simulation Rule).
# The ones we are creating are for Invoice Transaction Simulation Rule
# so we add a test on the portal type of the input movement.
kw = dict(business_process=business_process,
trade_phase='default/accounting',
trade_date='trade_phase/default/invoicing',
membership_criterion_base_category='resource_use')
membership_criterion_base_category='resource_use',
criterion_property_dict={'portal_type': 'Simulation Movement'})
self.createTradeModelPath(reference='acounting_tax1',
efficiency=-1,
source_value=self.receivable_account,
......@@ -139,11 +144,17 @@ class TestBPMMixin(ERP5TypeTestCase):
portal_type=self.business_link_portal_type, **kw)
return business_link
def createTradeModelPath(self, business_process=None, **kw):
def createTradeModelPath(self, business_process=None,
criterion_property_dict={}, **kw):
if business_process is None:
business_process = self.createBusinessProcess()
return business_process.newContent(
trade_model_path = business_process.newContent(
portal_type=self.trade_model_path_portal_type, **kw)
if criterion_property_dict:
trade_model_path._setCriterionPropertyList(tuple(criterion_property_dict))
for property, identity in criterion_property_dict.iteritems():
trade_model_path.setCriterion(property, identity)
return trade_model_path
def createMovement(self):
# returns a movement for testing
......
......@@ -197,12 +197,17 @@ class TestConversionInSimulation(AccountingTestCase):
'product_line/apparel'))
for line_id, line_source_id, line_destination_id, line_ratio in \
self.transaction_line_definition_list:
business_process.newContent(
trade_model_path = business_process.newContent(
reference='acounting_' + line_id,
efficiency=line_ratio,
source='account_module/' + line_source_id,
destination='account_module/' + line_destination_id,
**kw)
# A trade model path already exist for root simulation movements
# (Accounting Transaction Root Simulation Rule).
# The ones we are creating are for Invoice Transaction Simulation Rule.
trade_model_path._setCriterionPropertyList(('portal_type',))
trade_model_path.setCriterion('portal_type', 'Simulation Movement')
transaction.commit()
self.tic()
......
......@@ -174,12 +174,17 @@ class TestInvoiceMixin(TestPackingListMixin):
portal.portal_workflow.doActionFor(account, 'validate_action')
for line_id, line_source_id, line_destination_id, line_ratio in \
self.transaction_line_definition_list:
business_process.newContent(
trade_model_path = business_process.newContent(
reference='accounting_' + line_id,
efficiency=line_ratio,
source_value=account_module[line_source_id],
destination_value=account_module[line_destination_id],
**kw)
# A trade model path already exist for root simulation movements
# (Accounting Transaction Root Simulation Rule).
# The ones we are creating are for Invoice Transaction Simulation Rule.
trade_model_path._setCriterionPropertyList(('portal_type',))
trade_model_path.setCriterion('portal_type', 'Simulation Movement')
self.business_process = business_process.getRelativeUrl()
def stepCreateEntities(self, sequence, **kw) :
......
......@@ -398,12 +398,12 @@ class TestTradeModelLine(TestTradeModelLineMixin):
rounded_total_price = round(line_dict['normal'], currency_precision)
rounded_tax_price = round(line_dict['tax'], currency_precision)
rounded_discount_price = round(line_dict['discount'], currency_precision)
self.assertEqual(abs(line_dict['payable_receivable']),
rounded_total_price + rounded_tax_price + rounded_discount_price)
self.assertEqual(abs(line_dict['vat']),
rounded_tax_price)
self.assertEquals(abs(line_dict['income_expense']),
rounded_total_price + rounded_discount_price)
self.assertEqual(str(abs(line_dict['payable_receivable'])),
str(rounded_total_price + rounded_tax_price + rounded_discount_price))
self.assertEqual(str(abs(line_dict['vat'])),
str(rounded_tax_price))
self.assertEquals(str(abs(line_dict['income_expense'])),
str(rounded_total_price + rounded_discount_price))
###
## Test cases
......@@ -468,7 +468,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
for movement in (order, order['taxed'], order['discounted'],
order['taxed_discounted']):
self.checkComposition(movement, [trade_condition], {
self.trade_model_path_portal_type: 10,
self.trade_model_path_portal_type: 11,
self.business_link_portal_type: 5,
"Trade Model Line": 2})
......@@ -719,7 +719,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
for movement in order, order['taxed'], order['discounted']:
self.checkComposition(movement, [trade_condition], {
self.trade_model_path_portal_type: 10,
self.trade_model_path_portal_type: 11,
self.business_link_portal_type: 5,
"Trade Model Line": 5})
......
......@@ -33,5 +33,6 @@
from Products.ERP5Legacy.tests import Legacy_getBusinessTemplateList
from Products.ERP5.tests.testAccounting import *
AccountingTestCase.business_process = None
Legacy_getBusinessTemplateList(AccountingTestCase)
Legacy_getBusinessTemplateList(TestAccountingWithSequences)
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