Commit c0a7136f authored by Fabien Morin's avatar Fabien Morin

add a test to check it's possible to use fixed quantity (= not take it from base_amount)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27861 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent be909a49
...@@ -1799,6 +1799,40 @@ class TestBPMTestCases(TestBPMMixin): ...@@ -1799,6 +1799,40 @@ class TestBPMTestCases(TestBPMMixin):
self.assertEquals([q.getReference() for q in trade_model_line_list], self.assertEquals([q.getReference() for q in trade_model_line_list],
[q.getReference() for q in [A, B, C, D]]) [q.getReference() for q in [A, B, C, D]])
def test_tradeModelLineWithFixedPrice(self):
"""
Check it's possible to have fixed quantity on lines. Sometimes we want
to say "discount 10 euros" or "pay more 10 euros" instead of saying "10%
discount from total"
"""
trade_condition = self.createTradeCondition()
# create a model line with 100 euros
A = self.createTradeModelLine(trade_condition, reference='A',
base_contribution_list=['base_amount/total'])
A.edit(quantity=100, price=1)
# add a discount of 10 euros
B = self.createTradeModelLine(trade_condition, reference='B',
base_contribution_list=['base_amount/total'])
B.edit(quantity=10, price=-1)
order = self.createOrder()
order.setSpecialiseValue(trade_condition)
amount_list = trade_condition.getAggregatedAmountList(order)
self.assertEquals(2, len(amount_list))
total_amount_list = [q for q in amount_list
if q.getBaseContribution() == 'base_amount/total']
self.assertEquals(2, len(total_amount_list))
# the total amount for base_amount/total should be of 100 - 10 = 90 euros
total_amount = 0
for amount in total_amount_list:
total_amount += amount.getTotalPrice()
self.assertEqual(total_amount, 100 - 10)
def test_getAggregatedAmountList(self): def test_getAggregatedAmountList(self):
""" """
Test for case, when discount contributes to tax, and order has mix of contributing lines Test for case, when discount contributes to tax, and order has mix of contributing lines
......
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