[Erp5-report] r27861 - /erp5/trunk/products/ERP5/tests/testBPMCore.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jul 2 10:51:25 CEST 2009
Author: fabien
Date: Thu Jul 2 10:51:19 2009
New Revision: 27861
URL: http://svn.erp5.org?rev=27861&view=rev
Log:
add a test to check it's possible to use fixed quantity (= not take it from base_amount)
Modified:
erp5/trunk/products/ERP5/tests/testBPMCore.py
Modified: erp5/trunk/products/ERP5/tests/testBPMCore.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBPMCore.py?rev=27861&r1=27860&r2=27861&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBPMCore.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testBPMCore.py [utf8] Thu Jul 2 10:51:19 2009
@@ -1799,6 +1799,40 @@
self.assertEquals([q.getReference() for q in trade_model_line_list],
[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):
"""
Test for case, when discount contributes to tax, and order has mix of contributing lines
More information about the Erp5-report
mailing list