Commit b2692f05 authored by Łukasz Nowak's avatar Łukasz Nowak

- update test to current implementation - without delivering of trade model...

 - update test to current implementation - without delivering of trade model rule related simulation movements
 - there is no need to affect default invoice builders from test
 - as there are no invoice lines for trade model rule related movements use getAggregatedAmountList to obtain values for testing
 - as there are no invoice lines for trade model rule related movements do not check them
 - update test name to its implementation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26839 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a9be574a
No related merge requests found
...@@ -326,20 +326,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -326,20 +326,6 @@ class TestBPMMixin(ERP5TypeTestCase):
self.setSystemPreference() self.setSystemPreference()
self.createInvoiceTransationRule() self.createInvoiceTransationRule()
# XXX for testing purpose only...
# This builder is not supporting yet deeper simulation tree
# New one shall be done (decision making with
# DeliveryCausalityAssignmentMovementGroup), but right now it is enough
# to support invoice building that way
sale_invoice_builder, purchase_invoice_builder = self.portal. \
portal_deliveries.sale_invoice_builder, \
self.portal.portal_deliveries.purchase_invoice_builder
delete_id = 'causality_movement_group_on_delivery'
if getattr(sale_invoice_builder, delete_id, None) is not None:
sale_invoice_builder.manage_delObjects(ids=[delete_id])
if getattr(purchase_invoice_builder, delete_id, None) is not None:
purchase_invoice_builder.manage_delObjects(ids=[delete_id])
@reindex @reindex
def beforeTearDown(self): def beforeTearDown(self):
self.portal.portal_rules.manage_delObjects( self.portal.portal_rules.manage_delObjects(
...@@ -475,8 +461,11 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -475,8 +461,11 @@ class TestBPMMixin(ERP5TypeTestCase):
invoice = sequence.get('invoice') invoice = sequence.get('invoice')
currency = sequence.get('price_currency') currency = sequence.get('price_currency')
currency_precision = currency.getQuantityPrecision() currency_precision = currency.getQuantityPrecision()
invoice_line_tax = sequence.get('invoice_line_tax') aggregated_amount_list_list = [
invoice_line_discount = sequence.get('invoice_line_discount') (q.getResourceValue().getUse(), q)
for q in invoice.getSpecialiseValue().getAggregatedAmountList(invoice)]
invoice_line_tax = [q[1] for q in aggregated_amount_list_list if q[0] == 'tax'][0]
invoice_line_discount = [q[1] for q in aggregated_amount_list_list if q[0] == 'discount'][0]
movement_list = invoice.getMovementList( movement_list = invoice.getMovementList(
portal_type=invoice.getPortalAccountingMovementTypeList()) portal_type=invoice.getPortalAccountingMovementTypeList())
...@@ -493,15 +482,17 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -493,15 +482,17 @@ class TestBPMMixin(ERP5TypeTestCase):
rounded_total_price = round(invoice.getTotalPrice(), currency_precision) rounded_total_price = round(invoice.getTotalPrice(), currency_precision)
rounded_tax_price = round(invoice_line_tax.getTotalPrice(), rounded_tax_price = round(invoice_line_tax.getTotalPrice(),
currency_precision) currency_precision)
rounded_discount_price = round(invoice_line_discount.getTotalPrice(),
currency_precision)
self.assertEqual(abs(payable_receivable_line.getTotalPrice()), self.assertEqual(abs(payable_receivable_line.getTotalPrice()),
rounded_total_price) rounded_total_price + rounded_tax_price + rounded_discount_price)
self.assertEqual(abs(vat_line.getTotalPrice()), self.assertEqual(abs(vat_line.getTotalPrice()),
rounded_tax_price) rounded_tax_price)
self.assertEquals(abs(income_expense_line.getTotalPrice()), self.assertEquals(abs(income_expense_line.getTotalPrice()),
rounded_total_price - rounded_tax_price) rounded_total_price + rounded_discount_price)
def stepSetTradeConditionOld(self, sequence=None, **kw): def stepSetTradeConditionOld(self, sequence=None, **kw):
trade_condition = sequence.get('trade_condition') trade_condition = sequence.get('trade_condition')
...@@ -541,54 +532,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -541,54 +532,6 @@ class TestBPMMixin(ERP5TypeTestCase):
trade_condition = trade_condition, trade_condition = trade_condition,
) )
def stepCheckInvoiceTradeModelRelatedMovements(self, sequence=None, **kw):
# movement selection is done by hand, as no API is yet defined
invoice = sequence.get('invoice')
trade_condition = sequence.get('trade_condition')
trade_model_invoice_line_list = [q for q in invoice.getMovementList()
if q.getResourceValue().getUse() in ('discount','tax')]
self.assertEqual(2, len(trade_model_invoice_line_list))
invoice_line_tax = [q for q in trade_model_invoice_line_list if
q.getResourceValue().getUse() == 'tax' ][0]
invoice_line_discount = [q for q in trade_model_invoice_line_list if
q.getResourceValue().getUse() == 'discount' ][0]
sequence.edit(invoice_line_discount = invoice_line_discount)
sequence.edit(invoice_line_tax = invoice_line_tax)
amount_list = trade_condition.getAggregatedAmountList(invoice)
self.assertEquals(2, len(amount_list))
discount_amount_list = [q for q in amount_list
if q.getBaseApplication() == 'base_amount/discount']
tax_amount_list = [q for q in amount_list
if q.getBaseApplication() == 'base_amount/tax']
self.assertEquals(1, len(discount_amount_list))
self.assertEquals(1, len(tax_amount_list))
discount_amount = discount_amount_list[0]
tax_amount = tax_amount_list[0]
self.assertSameSet(discount_amount.getBaseApplicationList(),
invoice_line_discount.getBaseApplicationList())
self.assertSameSet(discount_amount.getBaseContributionList(),
invoice_line_discount.getBaseContributionList())
self.assertSameSet(tax_amount.getBaseApplicationList(),
invoice_line_tax.getBaseApplicationList())
self.assertSameSet(tax_amount.getBaseContributionList(),
invoice_line_tax.getBaseContributionList())
self.assertEqual(
invoice_line_discount.getTotalPrice(),
discount_amount.getTotalPrice()
)
self.assertEqual(
invoice_line_tax.getTotalPrice(),
tax_amount.getTotalPrice()
)
def stepAcceptDecisionInvoice(self, sequence=None, **kw): def stepAcceptDecisionInvoice(self, sequence=None, **kw):
invoice = sequence.get('invoice') invoice = sequence.get('invoice')
invoice.portal_workflow.doActionFor(invoice,'accept_decision_action') invoice.portal_workflow.doActionFor(invoice,'accept_decision_action')
...@@ -1705,13 +1648,12 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1705,13 +1648,12 @@ class TestBPMTestCases(TestBPMMixin):
GetInvoice GetInvoice
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
""" """
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_TradeModelRuleSimulationBuildInvoiceNewTradeConditionDivergencyAndSolving(self): def test_TradeModelRuleSimulationBuildInvoiceNewTradeCondition(self):
"""Check that after changing trade condition invoice is properly diverged and it is possible to solve""" """Check that after changing trade condition invoice is not diverged"""
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = self.TRADE_MODEL_RULE_SIMULATION_SEQUENCE_STRING sequence_string = self.TRADE_MODEL_RULE_SIMULATION_SEQUENCE_STRING
sequence_string += """ sequence_string += """
...@@ -1730,7 +1672,6 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1730,7 +1672,6 @@ class TestBPMTestCases(TestBPMMixin):
GetInvoice GetInvoice
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
SetTradeConditionOld SetTradeConditionOld
...@@ -1744,19 +1685,7 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1744,19 +1685,7 @@ class TestBPMTestCases(TestBPMMixin):
SpecialiseInvoiceTradeCondition SpecialiseInvoiceTradeCondition
Tic Tic
SetTradeConditionNew
GetOldTradeCondition
CheckInvoiceCausalityStateDiverged
CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
AdoptPrevisionQuantityInvoice
Tic
GetNewTradeCondition
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
""" """
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
...@@ -1785,11 +1714,6 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1785,11 +1714,6 @@ class TestBPMTestCases(TestBPMMixin):
GetInvoice GetInvoice
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
GetInvoiceLineDiscounted
GetInvoiceLineDiscountedTaxed
GetInvoiceLineTaxed
ModifyQuantityInvoiceLineDiscounted ModifyQuantityInvoiceLineDiscounted
ModifyQuantityInvoiceLineDiscountedTaxed ModifyQuantityInvoiceLineDiscountedTaxed
...@@ -1798,12 +1722,8 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1798,12 +1722,8 @@ class TestBPMTestCases(TestBPMMixin):
CheckInvoiceCausalityStateDiverged CheckInvoiceCausalityStateDiverged
AcceptDecisionQuantityInvoice AcceptDecisionQuantityInvoice
Tic Tic
CheckInvoiceCausalityStateDiverged
AdoptPrevisionQuantityInvoice
Tic
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
""" """
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
...@@ -1828,13 +1748,14 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1828,13 +1748,14 @@ class TestBPMTestCases(TestBPMMixin):
GetInvoice GetInvoice
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
StartInvoice StartInvoice
Tic Tic
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements GetInvoiceLineDiscounted
GetInvoiceLineDiscountedTaxed
GetInvoiceLineTaxed
CheckInvoiceAccountingMovements CheckInvoiceAccountingMovements
StopInvoice StopInvoice
DeliverInvoice DeliverInvoice
...@@ -1868,7 +1789,6 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1868,7 +1789,6 @@ class TestBPMTestCases(TestBPMMixin):
GetInvoice GetInvoice
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
SetNewPackingListAsPackingList SetNewPackingListAsPackingList
PackPackingList PackPackingList
...@@ -1882,7 +1802,6 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1882,7 +1802,6 @@ class TestBPMTestCases(TestBPMMixin):
GetInvoice GetInvoice
CheckInvoiceCausalityStateSolved CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
""" """
def test_TradeModelRuleSimulationPackingListSplitBuildInvoiceBuildDifferentRatio(self): def test_TradeModelRuleSimulationPackingListSplitBuildInvoiceBuildDifferentRatio(self):
......
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