Commit 6b0fb0d2 authored by Tatuya Kamada's avatar Tatuya Kamada

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



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30019 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8cd1d2ee
......@@ -201,6 +201,7 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
'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 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
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 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
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 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
# 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
......
......@@ -48,5 +48,5 @@ class TradeModelLine:
)
_categories = (
'base_application', 'base_contribution', 'trade_phase',
'base_application', 'base_contribution', 'trade_phase', 'rounding_method',
)
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