[Erp5-report] r30019 - in /erp5/trunk/products/ERP5: Document/ PropertySheet/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Oct 27 08:26:20 CET 2009
Author: tatuya
Date: Tue Oct 27 08:26:19 2009
New Revision: 30019
URL: http://svn.erp5.org?rev=30019&view=rev
Log:
Change the usage of price, quantity and efficiency in Trade Model Line.
Until now, when using, for example, VAT, you put like this:
price=0.196, efficiency=1.0
so the result by getAggregatedAmountList is, if the base is 100:
price=0.196, efficiency=1.0, quantity=100
Thus, the total price is 19.6.
This works but not compatible with rounding, as, for instance, if we want to
round it up to 20, the result is not saved at anywhere.
So, from now on, we do like this instead:
price=1.0, efficiency=0.196
so the result is:
price=1.0, efficiency=0.196, quantity=100, total price=19.6
The total price does not change. When we apply a rounding method, it would
result in:
price=1.0, efficiency=0.196, quantity=100, total price=20
--
This modification is approved by YO and Yusei.
TODO: write some test-cases
Modified:
erp5/trunk/products/ERP5/Document/TradeModelLine.py
erp5/trunk/products/ERP5/PropertySheet/TradeModelLine.py
Modified: erp5/trunk/products/ERP5/Document/TradeModelLine.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TradeModelLine.py?rev=30019&r1=30018&r2=30019&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeModelLine.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeModelLine.py [utf8] Tue Oct 27 08:26:19 2009
@@ -201,6 +201,7 @@
'stop_date': context.getStopDate(),
'create_line': self.isCreateLine(),
'trade_phase_list': self.getTradePhaseList(),
+ 'efficiency': self.getEfficiency(),
}
common_params.update(property_dict)
@@ -223,6 +224,7 @@
variation_base_category_list = cell.getVariationBaseCategoryList(),
variation_category_list = cell.getVariationCategoryList(),
price = cell.getPrice(),
+ base_quantity = cell.getQuantity(0.0),
quantity = cell.getQuantity(0.0),
**common_params
)
@@ -231,6 +233,7 @@
tmp_movement = newTempSimulationMovement(self.getPortalObject(),
self_id,
quantity = self.getQuantity(0.0),
+ base_quantity = self.getQuantity(0.0),
price = self.getPrice(),
**common_params
)
@@ -255,10 +258,17 @@
# at least one base application is in base contributions and
# if the movement have no variation category, it's the same as
# if he have all variation categories
- quantity = tmp_movement.getQuantity(0.0)
+ original_quantity = tmp_movement.getQuantity(0.0)
+ total_price = movement.getTotalPrice()
+ base_quantity = original_quantity + total_price
+ quantity = original_quantity + total_price * self.getEfficiency()
modified = 1
- tmp_movement.setQuantity(quantity + movement.getTotalPrice())
-
+ rounding_method = self.getRoundingMethod()
+ if rounding_method:
+ roundQuantity = getattr(self, 'TradeModelLine_roundQuantity', None)
+ if roundQuantity is not None:
+ quantity = roundQuantity(context, quantity, rounding_method)
+ tmp_movement.edit(base_quantity=base_quantity, quantity=quantity)
else:
# if the quantity is defined, use it
modified = 1
Modified: erp5/trunk/products/ERP5/PropertySheet/TradeModelLine.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/TradeModelLine.py?rev=30019&r1=30018&r2=30019&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/TradeModelLine.py [utf8] (original)
+++ erp5/trunk/products/ERP5/PropertySheet/TradeModelLine.py [utf8] Tue Oct 27 08:26:19 2009
@@ -48,5 +48,5 @@
)
_categories = (
- 'base_application', 'base_contribution', 'trade_phase',
+ 'base_application', 'base_contribution', 'trade_phase', 'rounding_method',
)
More information about the Erp5-report
mailing list