Commit 839c47c7 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_base: minimum bound of quantity_step_list should be 0

we don't support negative quantity (it is better represented by an
inversion of source and destination), and this allows better support of
the smallest slice in ERP5, more especially in SupplyLine_asCellRange,
where the title of the cell is computed with the min and max being None
or not.
parent 8eb4b614
...@@ -201,7 +201,7 @@ class SupplyLine(Path, Amount, XMLMatrix): ...@@ -201,7 +201,7 @@ class SupplyLine(Path, Amount, XMLMatrix):
unused_predicate_id_set = self.getQuantityPredicateIdList(price_parameter) unused_predicate_id_set = self.getQuantityPredicateIdList(price_parameter)
if quantity_step_list: if quantity_step_list:
quantity_step_list.sort() quantity_step_list.sort()
quantity_step_list = [None] + quantity_step_list + [None] quantity_step_list = [0] + quantity_step_list + [None]
getTitle = getattr( getTitle = getattr(
self, self,
'SupplyLine_getTitle', 'SupplyLine_getTitle',
......
...@@ -29,7 +29,7 @@ if result["slice_base_price"]: ...@@ -29,7 +29,7 @@ if result["slice_base_price"]:
slice_min, slice_max = slice_range slice_min, slice_max = slice_range
if slice_max is None: if slice_max is None:
slice_max = quantity + 1 slice_max = quantity + 1
if slice_min is None: if slice_min == 0:
slice_min = 1 slice_min = 1
priced_quantity = min(slice_max - 1, quantity) - (slice_min - 1) priced_quantity = min(slice_max - 1, quantity) - (slice_min - 1)
total_price += priced_quantity * slice_price total_price += priced_quantity * slice_price
......
...@@ -7,7 +7,7 @@ if not quantity_criterion_list: ...@@ -7,7 +7,7 @@ if not quantity_criterion_list:
quantity_criterion, = quantity_criterion_list quantity_criterion, = quantity_criterion_list
supply_line_value = context.getParentValue() supply_line_value = context.getParentValue()
if supply_line_value.isBasePricePerSlice(): if supply_line_value.isBasePricePerSlice():
quantity_step_list = [None] + supply_line_value.getQuantityStepList(base_id='path') + [None] quantity_step_list = [0] + supply_line_value.getQuantityStepList(base_id='path') + [None]
try: try:
index = quantity_step_list.index(quantity_criterion.min) index = quantity_step_list.index(quantity_criterion.min)
except ValueError: except ValueError:
......
...@@ -39,7 +39,7 @@ Test toggling price per slice updates internal supply cells correctly ...@@ -39,7 +39,7 @@ Test toggling price per slice updates internal supply cells correctly
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 11.0</td> <td>0 &lt;= Quantity &lt; 11.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -36,7 +36,7 @@ Test quantity steps for price on internal supply line ...@@ -36,7 +36,7 @@ Test quantity steps for price on internal supply line
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 10.0</td> <td>0 &lt;= Quantity &lt; 10.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -39,7 +39,7 @@ Test toggling price per slice updates purchase supply cells correctly ...@@ -39,7 +39,7 @@ Test toggling price per slice updates purchase supply cells correctly
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 11.0</td> <td>0 &lt;= Quantity &lt; 11.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -36,7 +36,7 @@ Test quantity steps for price on purchase supply line ...@@ -36,7 +36,7 @@ Test quantity steps for price on purchase supply line
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 10.0</td> <td>0 &lt;= Quantity &lt; 10.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -39,7 +39,7 @@ Test toggling price per slice updates sale supply cells correctly ...@@ -39,7 +39,7 @@ Test toggling price per slice updates sale supply cells correctly
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 11.0</td> <td>0 &lt;= Quantity &lt; 11.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -36,7 +36,7 @@ Test quantity steps for price on sale supply line ...@@ -36,7 +36,7 @@ Test quantity steps for price on sale supply line
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 10.0</td> <td>0 &lt;= Quantity &lt; 10.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -1266,10 +1266,10 @@ class TestResource(ERP5TypeTestCase): ...@@ -1266,10 +1266,10 @@ class TestResource(ERP5TypeTestCase):
portal_type=self.sale_supply_cell_portal_type, portal_type=self.sale_supply_cell_portal_type,
id='path_0', id='path_0',
slice_base_price=10., slice_base_price=10.,
slice_quantity_range=(1, 11), slice_quantity_range=(0, 11),
) )
cell0.setCriterionPropertyList(('quantity', )) cell0.setCriterionPropertyList(('quantity', ))
cell0.setCriterion('quantity', min=1, max=None) cell0.setCriterion('quantity', min=0, max=None)
cell0.setMappedValuePropertyList( cell0.setMappedValuePropertyList(
["slice_base_price", "slice_quantity_range", "base_price", "base_unit_price"] ["slice_base_price", "slice_quantity_range", "base_price", "base_unit_price"]
) )
......
...@@ -101,7 +101,7 @@ Test quantity steps for price on internal supply line ...@@ -101,7 +101,7 @@ Test quantity steps for price on internal supply line
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 11.0</td> <td>0 &lt;= Quantity &lt; 11.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -101,7 +101,7 @@ Test quantity steps for price on purchase supply line ...@@ -101,7 +101,7 @@ Test quantity steps for price on purchase supply line
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 11.0</td> <td>0 &lt;= Quantity &lt; 11.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
...@@ -100,7 +100,7 @@ Test quantity steps for price on sale supply line ...@@ -100,7 +100,7 @@ Test quantity steps for price on sale supply line
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td> <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
<td>Quantity &lt; 11.0</td> <td>0 &lt;= Quantity &lt; 11.0</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
......
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