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

- implement invoice building from split packing list

 - remove not needed checks
 - support checking simulation movements in case of split parent movements
 - use total price from invoicing movement instead of order line, to support split packing list


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26682 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b778f81a
...@@ -58,6 +58,8 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -58,6 +58,8 @@ class TestBPMMixin(ERP5TypeTestCase):
modified_order_line_price_ratio = 2.0 modified_order_line_price_ratio = 2.0
modified_order_line_quantity_ratio = 2.5 modified_order_line_quantity_ratio = 2.5
modified_packing_list_line_quantity_ratio = 0.4
normal_resource_use_category_list = ['normal'] normal_resource_use_category_list = ['normal']
invoicing_resource_use_category_list = ['discount', 'tax'] invoicing_resource_use_category_list = ['discount', 'tax']
...@@ -248,6 +250,34 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -248,6 +250,34 @@ class TestBPMMixin(ERP5TypeTestCase):
workflow_tool = getToolByName(self.portal, 'portal_workflow') workflow_tool = getToolByName(self.portal, 'portal_workflow')
workflow_tool.doActionFor(packing_list, 'deliver_action') workflow_tool.doActionFor(packing_list, 'deliver_action')
def stepCheckPackingListDiverged(self, sequence=None, **kw):
packing_list = sequence.get('packing_list')
self.assertEqual(
'diverged',
packing_list.getCausalityState()
)
def stepSplitAndDeferPackingList(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
kw = {'listbox':[
{'listbox_key':line.getRelativeUrl(),
'choice':'SplitAndDefer'} for line in packing_list.getMovementList() \
if line.isDivergent()]}
self.portal.portal_workflow.doActionFor(
packing_list,
'split_and_defer_action',
start_date=packing_list.getStartDate() + 15,
stop_date=packing_list.getStopDate() + 25,
**kw)
def stepDecreasePackingListLineListQuantity(self, sequence=None, **kw):
packing_list = sequence.get('packing_list')
for movement in packing_list.getMovementList():
movement.edit(
quantity = movement.getQuantity() * \
self.modified_packing_list_line_quantity_ratio
)
def stepPackPackingList(self, sequence=None, **kw): def stepPackPackingList(self, sequence=None, **kw):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
if getattr(packing_list,'getContainerState', None) is None: if getattr(packing_list,'getContainerState', None) is None:
...@@ -329,6 +359,23 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -329,6 +359,23 @@ class TestBPMMixin(ERP5TypeTestCase):
self.assertEqual(1, len(invoice_list)) # XXX 1 HC self.assertEqual(1, len(invoice_list)) # XXX 1 HC
sequence.edit(invoice = invoice_list[0]) sequence.edit(invoice = invoice_list[0])
def stepSetNewPackingListAsPackingList(self, sequence=None, **kw):
packing_list = sequence.get('packing_list')
new_packing_list = sequence.get('new_packing_list')
sequence.edit(
packing_list = new_packing_list,
new_packing_list = None
)
def stepGetNewPackingList(self, sequence=None, **kw):
order = sequence.get('order')
packing_list = sequence.get('packing_list')
packing_list_list = order.getCausalityRelatedValueList(
portal_type=self.packing_list_portal_type)
self.assertEqual(2, len(packing_list_list)) # XXX 2 HC
new_packing_list = [q for q in packing_list_list if q != packing_list][0]
sequence.edit(new_packing_list = new_packing_list)
def stepGetPackingList(self, sequence=None, **kw): def stepGetPackingList(self, sequence=None, **kw):
order = sequence.get('order') order = sequence.get('order')
packing_list_list = order.getCausalityRelatedValueList( packing_list_list = order.getCausalityRelatedValueList(
...@@ -342,20 +389,22 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -342,20 +389,22 @@ class TestBPMMixin(ERP5TypeTestCase):
workflow_tool.doActionFor(order, 'confirm_action') workflow_tool.doActionFor(order, 'confirm_action')
def getTradeModelSimulationMovementList(self, order_line): def getTradeModelSimulationMovementList(self, order_line):
line_simulation_movement = order_line \ result_list = []
.getOrderRelatedValue(portal_type='Simulation Movement') for line_simulation_movement in order_line.getOrderRelatedValueList(
portal_type='Simulation Movement'):
invoicing_applied_rule = [x for x in invoicing_applied_rule = [x for x in
line_simulation_movement.objectValues() line_simulation_movement.objectValues()
if x.getSpecialiseValue().getPortalType() == 'Invoicing Rule'][0] if x.getSpecialiseValue().getPortalType() == 'Invoicing Rule'][0]
invoicing_movement = invoicing_applied_rule.objectValues()[0] invoicing_movement = invoicing_applied_rule.objectValues()[0]
trade_model_rule = [x for x in invoicing_movement.objectValues() trade_model_rule = [x for x in invoicing_movement.objectValues()
if x.getSpecialiseValue().getPortalType() == 'Trade Model Rule'][0] if x.getSpecialiseValue().getPortalType() == 'Trade Model Rule'][0]
return trade_model_rule.objectValues() result_list.append(trade_model_rule.objectValues())
return result_list
def stepCheckOrderTaxNoSimulation(self, sequence=None, **kw): def stepCheckOrderTaxNoSimulation(self, sequence=None, **kw):
order_line_taxed = sequence.get('order_line_taxed') order_line_taxed = sequence.get('order_line_taxed')
trade_model_simulation_movement_list = \ for trade_model_simulation_movement_list in \
self.getTradeModelSimulationMovementList(order_line_taxed) self.getTradeModelSimulationMovementList(order_line_taxed):
self.assertEquals(0, len(trade_model_simulation_movement_list)) self.assertEquals(0, len(trade_model_simulation_movement_list))
# XXX: Merge: stepCheckOrderLineDiscountedSimulation stepCheckOrderLineTaxedSimulation stepCheckOrderLineDiscountedTaxedSimulation # XXX: Merge: stepCheckOrderLineDiscountedSimulation stepCheckOrderLineTaxedSimulation stepCheckOrderLineDiscountedTaxedSimulation
...@@ -365,11 +414,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -365,11 +414,6 @@ class TestBPMMixin(ERP5TypeTestCase):
business_path_discounting = sequence.get('business_path_discounting') business_path_discounting = sequence.get('business_path_discounting')
business_path_taxing = sequence.get('business_path_taxing') business_path_taxing = sequence.get('business_path_taxing')
price_currency = sequence.get('price_currency') price_currency = sequence.get('price_currency')
taxed_complex_resource_model_old_simulation_movement_relative_url = sequence.get(
'taxed_complex_resource_model_old_simulation_movement_relative_url')
discounted_complex_resource_model_old_simulation_movement_relative_url = sequence.get(
'discounted_complex_resource_model_old_simulation_movement_relative_url')
service_tax = sequence.get('service_tax') service_tax = sequence.get('service_tax')
service_discount = sequence.get('service_discount') service_discount = sequence.get('service_discount')
...@@ -378,8 +422,8 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -378,8 +422,8 @@ class TestBPMMixin(ERP5TypeTestCase):
self.assertNotEqual(None, business_path_taxing) self.assertNotEqual(None, business_path_taxing)
self.assertNotEqual(None, price_currency) self.assertNotEqual(None, price_currency)
trade_model_simulation_movement_list = \ for trade_model_simulation_movement_list in \
self.getTradeModelSimulationMovementList(order_line) self.getTradeModelSimulationMovementList(order_line):
self.assertEquals(2, len(trade_model_simulation_movement_list)) self.assertEquals(2, len(trade_model_simulation_movement_list))
trade_model_simulation_movement_discount_complex = [q for q in \ trade_model_simulation_movement_discount_complex = [q for q in \
...@@ -391,18 +435,9 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -391,18 +435,9 @@ class TestBPMMixin(ERP5TypeTestCase):
if q.getResourceValue() == service_tax][0] if q.getResourceValue() == service_tax][0]
# discount complex # discount complex
if discounted_complex_resource_model_old_simulation_movement_relative_url is not None:
# check that there is not change...
self.assertEqual(
discounted_complex_resource_model_old_simulation_movement_relative_url,
trade_model_simulation_movement_discount_complex.getRelativeUrl()
)
sequence.edit(discounted_complex_resource_model_old_simulation_movement_relative_url = \
trade_model_simulation_movement_discount_complex.getRelativeUrl())
self.assertEqual( self.assertEqual(
order_line.getTotalPrice() * self.default_discount_ratio, trade_model_simulation_movement_discount_complex.getParentValue() \
.getParentValue().getTotalPrice() * self.default_discount_ratio,
trade_model_simulation_movement_discount_complex.getTotalPrice() trade_model_simulation_movement_discount_complex.getTotalPrice()
) )
...@@ -432,18 +467,12 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -432,18 +467,12 @@ class TestBPMMixin(ERP5TypeTestCase):
# * dates # * dates
# tax complex # tax complex
if taxed_complex_resource_model_old_simulation_movement_relative_url is not None:
# check that there is not change...
self.assertEqual(
taxed_complex_resource_model_old_simulation_movement_relative_url,
trade_model_simulation_movement_tax_complex.getRelativeUrl()
)
sequence.edit(taxed_complex_resource_model_old_simulation_movement_relative_url = \
trade_model_simulation_movement_tax_complex.getRelativeUrl())
self.assertEqual( self.assertEqual(
(order_line.getTotalPrice() + order_line.getTotalPrice() * self.default_discount_ratio) * self.default_tax_ratio, (trade_model_simulation_movement_tax_complex.getParentValue()\
.getParentValue().getTotalPrice() + \
trade_model_simulation_movement_tax_complex.getParentValue()\
.getParentValue().getTotalPrice() * self.default_discount_ratio) \
* self.default_tax_ratio,
trade_model_simulation_movement_tax_complex.getTotalPrice() trade_model_simulation_movement_tax_complex.getTotalPrice()
) )
...@@ -477,11 +506,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -477,11 +506,6 @@ class TestBPMMixin(ERP5TypeTestCase):
business_path_discounting = sequence.get('business_path_discounting') business_path_discounting = sequence.get('business_path_discounting')
business_path_taxing = sequence.get('business_path_taxing') business_path_taxing = sequence.get('business_path_taxing')
price_currency = sequence.get('price_currency') price_currency = sequence.get('price_currency')
taxed_only_resource_model_old_simulation_movement_relative_url = sequence.get(
'taxed_only_resource_model_old_simulation_movement_relative_url')
discounted_only_resource_model_old_simulation_movement_relative_url = sequence.get(
'discounted_only_resource_model_old_simulation_movement_relative_url')
service_tax = sequence.get('service_tax') service_tax = sequence.get('service_tax')
service_discount = sequence.get('service_discount') service_discount = sequence.get('service_discount')
...@@ -490,8 +514,8 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -490,8 +514,8 @@ class TestBPMMixin(ERP5TypeTestCase):
self.assertNotEqual(None, business_path_taxing) self.assertNotEqual(None, business_path_taxing)
self.assertNotEqual(None, price_currency) self.assertNotEqual(None, price_currency)
trade_model_simulation_movement_list = \ for trade_model_simulation_movement_list in \
self.getTradeModelSimulationMovementList(order_line) self.getTradeModelSimulationMovementList(order_line):
self.assertEquals(2, len(trade_model_simulation_movement_list)) self.assertEquals(2, len(trade_model_simulation_movement_list))
trade_model_simulation_movement_discount_only = [q for q in \ trade_model_simulation_movement_discount_only = [q for q in \
...@@ -503,18 +527,9 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -503,18 +527,9 @@ class TestBPMMixin(ERP5TypeTestCase):
if q.getResourceValue() == service_tax][0] if q.getResourceValue() == service_tax][0]
# discount only # discount only
if discounted_only_resource_model_old_simulation_movement_relative_url is not None:
# check that there is not change...
self.assertEqual(
discounted_only_resource_model_old_simulation_movement_relative_url,
trade_model_simulation_movement_discount_only.getRelativeUrl()
)
sequence.edit(discounted_only_resource_model_old_simulation_movement_relative_url = \
trade_model_simulation_movement_discount_only.getRelativeUrl())
self.assertEqual( self.assertEqual(
order_line.getTotalPrice() * self.default_discount_ratio, trade_model_simulation_movement_discount_only.getParentValue()\
.getParentValue().getTotalPrice() * self.default_discount_ratio,
trade_model_simulation_movement_discount_only.getTotalPrice() trade_model_simulation_movement_discount_only.getTotalPrice()
) )
...@@ -544,16 +559,6 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -544,16 +559,6 @@ class TestBPMMixin(ERP5TypeTestCase):
# * dates # * dates
# tax only # tax only
if taxed_only_resource_model_old_simulation_movement_relative_url is not None:
# check that there is not change...
self.assertEqual(
taxed_only_resource_model_old_simulation_movement_relative_url,
trade_model_simulation_movement_tax_only.getRelativeUrl()
)
sequence.edit(taxed_only_resource_model_old_simulation_movement_relative_url = \
trade_model_simulation_movement_tax_only.getRelativeUrl())
# below tax is applied only to discount part # below tax is applied only to discount part
self.assertEqual(trade_model_simulation_movement_discount_only. \ self.assertEqual(trade_model_simulation_movement_discount_only. \
getTotalPrice() * self.default_tax_ratio, getTotalPrice() * self.default_tax_ratio,
...@@ -588,27 +593,16 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -588,27 +593,16 @@ class TestBPMMixin(ERP5TypeTestCase):
order_line = sequence.get('order_line_taxed') order_line = sequence.get('order_line_taxed')
business_path = sequence.get('business_path_taxing') business_path = sequence.get('business_path_taxing')
price_currency = sequence.get('price_currency') price_currency = sequence.get('price_currency')
taxed_resource_model_old_simulation_movement_relative_url = sequence.get(
'taxed_resource_model_old_simulation_movement_relative_url')
self.assertNotEqual(None, business_path) self.assertNotEqual(None, business_path)
self.assertNotEqual(None, price_currency) self.assertNotEqual(None, price_currency)
trade_model_simulation_movement_list = \ for trade_model_simulation_movement_list in \
self.getTradeModelSimulationMovementList(order_line) self.getTradeModelSimulationMovementList(order_line):
self.assertEquals(1, len(trade_model_simulation_movement_list)) self.assertEquals(1, len(trade_model_simulation_movement_list))
trade_model_simulation_movement = trade_model_simulation_movement_list[0] trade_model_simulation_movement = trade_model_simulation_movement_list[0]
if taxed_resource_model_old_simulation_movement_relative_url is not None:
# check that there is not change...
self.assertEqual(
taxed_resource_model_old_simulation_movement_relative_url,
trade_model_simulation_movement.getRelativeUrl()
)
sequence.edit(taxed_resource_model_old_simulation_movement_relative_url = \
trade_model_simulation_movement.getRelativeUrl())
self.assertEqual( self.assertEqual(
order_line.getTotalPrice() * self.default_tax_ratio, trade_model_simulation_movement.getParentValue().getParentValue() \
.getTotalPrice() * self.default_tax_ratio,
trade_model_simulation_movement.getTotalPrice() trade_model_simulation_movement.getTotalPrice()
) )
...@@ -1131,7 +1125,50 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1131,7 +1125,50 @@ class TestBPMTestCases(TestBPMMixin):
def test_TradeModelRuleSimulationPackingListSplitBuildInvoiceBuild(self): def test_TradeModelRuleSimulationPackingListSplitBuildInvoiceBuild(self):
"""Check building invoice after splitting packing list""" """Check building invoice after splitting packing list"""
raise NotImplementedError('TODO') sequence_list = SequenceList()
sequence_string = self.trade_model_rule_simulation_common_string
sequence_string += """
ConfirmOrder
Tic
""" + self.aggregated_amount_simulation_check + """
GetPackingList
DecreasePackingListLineListQuantity
Tic
""" + self.aggregated_amount_simulation_check + """
CheckPackingListDiverged
SplitAndDeferPackingList
Tic
""" + self.aggregated_amount_simulation_check + """
GetNewPackingList
PackPackingList
Tic
""" + self.aggregated_amount_simulation_check + """
StartPackingList
StopPackingList
DeliverPackingList
Tic
""" + self.aggregated_amount_simulation_check + """
GetInvoice
CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
SetNewPackingListAsPackingList
PackPackingList
Tic
StartPackingList
""" + self.aggregated_amount_simulation_check + """
StopPackingList
DeliverPackingList
Tic
""" + self.aggregated_amount_simulation_check + """
GetInvoice
CheckInvoiceCausalityStateSolved
CheckInvoiceNormalMovements
CheckInvoiceTradeModelRelatedMovements
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
class TestBPMSale(TestBPMTestCases): class TestBPMSale(TestBPMTestCases):
invoice_portal_type = 'Sale Invoice Transaction' invoice_portal_type = '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