Commit 1f1c9461 authored by Jérome Perrin's avatar Jérome Perrin

Check delivery rules are not applied on builder created movements, which are already simulated

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7140 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1a274154
...@@ -603,16 +603,16 @@ class TestInvoice(TestAccountingRulesMixin, ...@@ -603,16 +603,16 @@ class TestInvoice(TestAccountingRulesMixin,
for key in found_dict.keys(): for key in found_dict.keys():
self.assertAlmostEquals(expected_dict[key], found_dict[key], places=2) self.assertAlmostEquals(expected_dict[key], found_dict[key], places=2)
def stepRebuildAndCheckNothingIsCreated(self, sequence=None, def stepRebuildAndCheckNothingIsCreated(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
"""Rebuilds with sale_invoice_builder and checks nothing more is """Rebuilds with sale_invoice_builder and checks nothing more is
created. """ created. """
return 'TODO' #XXX
accounting_module = self.getAccountingModule() accounting_module = self.getAccountingModule()
sale_invoice_transaction_list = accounting_module.objectValues() sale_invoice_transaction_count = len(accounting_module.objectValues())
self.assertEquals(len(sale_invoice_transaction_list), 1) for builder in self.getPortal().portal_deliveries.objectValues():
builder.build()
self.assertEquals(sale_invoice_transaction_count,
len(accounting_module.objectValues()))
def stepModifyInvoicesDate(self, sequence=None, def stepModifyInvoicesDate(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -626,7 +626,7 @@ class TestInvoice(TestAccountingRulesMixin, ...@@ -626,7 +626,7 @@ class TestInvoice(TestAccountingRulesMixin,
stop_date=self.datetime+1) stop_date=self.datetime+1)
def stepRemoveDateMovementGroupForTransactionBuilder(self, sequence=None, def stepRemoveDateMovementGroupForTransactionBuilder(self, sequence=None,
sequence_list=None,**kw): sequence_list=None, **kw):
""" """
Remove DateMovementGroup Remove DateMovementGroup
""" """
...@@ -637,6 +637,52 @@ class TestInvoice(TestAccountingRulesMixin, ...@@ -637,6 +637,52 @@ class TestInvoice(TestAccountingRulesMixin,
new_list.append('ParentExplanationMovementGroup') new_list.append('ParentExplanationMovementGroup')
builder.setDeliveryCollectOrderList(new_list) builder.setDeliveryCollectOrderList(new_list)
def stepEditInvoice(self, sequence=None, sequence_list=None, **kw):
"""Edit the current invoice, to trigger updateAppliedRule."""
invoice = sequence.get('invoice')
invoice.edit()
# call updateAppliedRule directly, don't rely on edit interactions
rule_id = 'default_invoice_rule'
self.failUnless(rule_id in
self.getPortal().portal_rules.objectIds())
invoice.updateAppliedRule(rule_id=rule_id)
def stepCheckInvoiceRuleNotAppliedOnInvoiceEdit(self,
sequence=None, sequence_list=None, **kw):
"""If we call edit on the invoice, invoice rule should not be
applied on lines created by delivery builder."""
invoice = sequence.get('invoice')
# FIXME: empty applied rule should not be created
#self.assertEquals(len(invoice.getCausalityRelatedValueList(
# portal_type=self.applied_rule_portal_type)), 0)
for invoice_mvt in invoice.getMovementList():
self.assertEquals(len(invoice_mvt.getOrderRelatedValueList(
portal_type=self.simulation_movement_portal_type)), 0)
def stepEditPackingList(self, sequence=None, sequence_list=None, **kw):
"""Edit the current packing list, to trigger updateAppliedRule."""
packing_list = sequence.get('packing_list')
packing_list.edit()
# call updateAppliedRule directly, don't rely on edit interactions
rule_id = 'default_delivery_rule'
self.failUnless(rule_id in
self.getPortal().portal_rules.objectIds())
packing_list.updateAppliedRule(rule_id=rule_id)
def stepCheckDeliveryRuleNotAppliedOnPackingListEdit(self,
sequence=None, sequence_list=None, **kw):
"""If we call edit on the packing list, delivery rule should not be
applied on lines created by delivery builder."""
packing_list = sequence.get('packing_list')
# FIXME: empty applied rule should not be created
#self.assertEquals(len(packing_list.getCausalityRelatedValueList(
# portal_type=self.applied_rule_portal_type)), 0)
for delivery_mvt in packing_list.getMovementList():
self.assertEquals(len(delivery_mvt.getOrderRelatedValueList(
portal_type=self.simulation_movement_portal_type)), 0)
# default sequence for one line of not varianted resource. # default sequence for one line of not varianted resource.
PACKING_LIST_DEFAULT_SEQUENCE = """ PACKING_LIST_DEFAULT_SEQUENCE = """
stepCreateSaleInvoiceTransactionRule stepCreateSaleInvoiceTransactionRule
...@@ -744,6 +790,43 @@ class TestInvoice(TestAccountingRulesMixin, ...@@ -744,6 +790,43 @@ class TestInvoice(TestAccountingRulesMixin,
stepCheckTwoInvoicesTransactionLines stepCheckTwoInvoicesTransactionLines
""") """)
def test_InvoiceEditAndInvoiceRule(self, quiet=0, run=1):
"""Invoice Rule should not be applied on invoice lines created from\
Packing List.
We went to prevent this from happening:
- Create a packing list
- An invoice is created from packing list
- Invoice is edited, updateAppliedRule is called
- A new Invoice Rule is created for this invoice, and accounting
movements for this invoice are present twice in the simulation.
"""
for base_sequence in (TestInvoice.PACKING_LIST_DEFAULT_SEQUENCE, ) :
self.playSequence(
base_sequence +
"""
stepSetReadyPackingList
stepTic
stepStartPackingList
stepCheckInvoicingRule
stepTic
stepCheckInvoiceBuilding
stepEditInvoice
stepCheckInvoiceRuleNotAppliedOnInvoiceEdit
""")
def test_PackingListEditAndInvoiceRule(self, quiet=0, run=1):
"""Delivery Rule should not be applied on packing list lines created\
from Order.
"""
for base_sequence in (TestInvoice.PACKING_LIST_DEFAULT_SEQUENCE, ) :
self.playSequence(
base_sequence +
"""
stepEditPackingList
stepCheckDeliveryRuleNotAppliedOnPackingListEdit
""")
def DISABLEDtest_InvoiceEditPackingListLine(self, quiet=0, run=RUN_ALL_TESTS): def DISABLEDtest_InvoiceEditPackingListLine(self, quiet=0, run=RUN_ALL_TESTS):
"""Checks that editing a Packing List Line still creates a correct """Checks that editing a Packing List Line still creates a correct
Invoice""" Invoice"""
......
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