Commit ce3e4426 authored by Jérome Perrin's avatar Jérome Perrin

Movements with 0 quantity where ignored by getCurrentInventory

Also, movement with 0 price where ignored by omit_asset_increase /
omit_asset_decrease
Signed-off-by: Aurel's avatarAurélien Calonne <aurel@nexedi.com>
parent 074462d9
...@@ -230,7 +230,7 @@ class SimulationTool(BaseTool): ...@@ -230,7 +230,7 @@ class SimulationTool(BaseTool):
elif input_simulation_state is not None: elif input_simulation_state is not None:
input_quantity_query = ComplexQuery( input_quantity_query = ComplexQuery(
ComplexQuery( ComplexQuery(
Query(**{'%s.quantity' % table: '>0'}), Query(**{'%s.quantity' % table: '>=0'}),
Query(**{'%s.is_cancellation' % table: 0}), Query(**{'%s.is_cancellation' % table: 0}),
operator='AND'), operator='AND'),
ComplexQuery( ComplexQuery(
...@@ -251,7 +251,7 @@ class SimulationTool(BaseTool): ...@@ -251,7 +251,7 @@ class SimulationTool(BaseTool):
Query(**{'%s.is_cancellation' % table: 0}), Query(**{'%s.is_cancellation' % table: 0}),
operator='AND'), operator='AND'),
ComplexQuery( ComplexQuery(
Query(**{'%s.quantity' % table: '>0'}), Query(**{'%s.quantity' % table: '>=0'}),
Query(**{'%s.is_cancellation' % table: 1}), Query(**{'%s.is_cancellation' % table: 1}),
operator='AND'), operator='AND'),
operator='OR') operator='OR')
...@@ -389,7 +389,7 @@ class SimulationTool(BaseTool): ...@@ -389,7 +389,7 @@ class SimulationTool(BaseTool):
Query(**{'%s.is_cancellation' % query_table: 0}), Query(**{'%s.is_cancellation' % query_table: 0}),
operator='AND'), operator='AND'),
ComplexQuery( ComplexQuery(
Query(**{'%s.quantity' % query_table: '>0'}), Query(**{'%s.quantity' % query_table: '>=0'}),
Query(**{'%s.is_cancellation' % query_table: 1}), Query(**{'%s.is_cancellation' % query_table: 1}),
operator='AND'), operator='AND'),
operator='OR') operator='OR')
...@@ -398,7 +398,7 @@ class SimulationTool(BaseTool): ...@@ -398,7 +398,7 @@ class SimulationTool(BaseTool):
if omit_output: if omit_output:
quantity_query = ComplexQuery( quantity_query = ComplexQuery(
ComplexQuery( ComplexQuery(
Query(**{'%s.quantity' % query_table: '>0'}), Query(**{'%s.quantity' % query_table: '>=0'}),
Query(**{'%s.is_cancellation' % query_table: 0}), Query(**{'%s.is_cancellation' % query_table: 0}),
operator='AND'), operator='AND'),
ComplexQuery( ComplexQuery(
...@@ -420,7 +420,7 @@ class SimulationTool(BaseTool): ...@@ -420,7 +420,7 @@ class SimulationTool(BaseTool):
Query(**{'%s.is_cancellation' % query_table: 0}), Query(**{'%s.is_cancellation' % query_table: 0}),
operator='AND'), operator='AND'),
ComplexQuery( ComplexQuery(
Query(**{'%s.total_price' % query_table: '>0'}), Query(**{'%s.total_price' % query_table: '>=0'}),
Query(**{'%s.is_cancellation' % query_table: 1}), Query(**{'%s.is_cancellation' % query_table: 1}),
operator='AND'), operator='AND'),
operator='OR') operator='OR')
...@@ -434,7 +434,7 @@ class SimulationTool(BaseTool): ...@@ -434,7 +434,7 @@ class SimulationTool(BaseTool):
if omit_asset_decrease: if omit_asset_decrease:
asset_price_query = ComplexQuery( asset_price_query = ComplexQuery(
ComplexQuery( ComplexQuery(
Query(**{'%s.total_price' % query_table: '>0'}), Query(**{'%s.total_price' % query_table: '>=0'}),
Query(**{'%s.is_cancellation' % query_table: 0}), Query(**{'%s.is_cancellation' % query_table: 0}),
operator='AND'), operator='AND'),
ComplexQuery( ComplexQuery(
......
...@@ -756,6 +756,19 @@ class TestInventory(InventoryAPITestCase): ...@@ -756,6 +756,19 @@ class TestInventory(InventoryAPITestCase):
payment_uid=self.other_payment_node.getUid(), payment_uid=self.other_payment_node.getUid(),
omit_input=1) omit_input=1)
def test_OmitInputOmitOutputWithZeroQuantity(self):
self._makeMovement(quantity=0, destination_total_asset_price=1)
getInventoryAssetPrice = self.portal.portal_simulation.getInventoryAssetPrice
self.assertEquals(0, getInventoryAssetPrice(node_uid=self.node.getUid(),
omit_input=1))
self.assertEquals(1, getInventoryAssetPrice(node_uid=self.node.getUid(),
omit_output=1))
def test_OmitAssetIncreaseDecreaseWithZeroPrice(self):
self._makeMovement(quantity=1, destination_total_asset_price=0)
self.assertInventoryEquals(0, node_uid=self.node.getUid(), omit_input=1)
self.assertInventoryEquals(1, node_uid=self.node.getUid(), omit_output=1)
def test_TimeZone(self): def test_TimeZone(self):
""" """
Check that getInventory support DateTime parameter with Check that getInventory support DateTime parameter with
......
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