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

Test & fix behaviour with movements with NULL price & 0 quantity

parent 8dddf306
......@@ -97,7 +97,7 @@ SELECT\n
<dtml-if transformed_uid> * transformation.quantity</dtml-if>, <dtml-var precision>))\n
AS converted_quantity,\n
</dtml-if>\n
SUM(ROUND(<dtml-var stock_table_id>.total_price, <dtml-var precision>)) AS total_price\n
IFNULL(SUM(ROUND(<dtml-var stock_table_id>.total_price, <dtml-var precision>)), 0) AS total_price\n
<dtml-else>\n
SUM(<dtml-var stock_table_id>.quantity <dtml-if transformed_uid> * transformation.quantity</dtml-if>) AS inventory,\n
SUM(<dtml-var stock_table_id>.quantity <dtml-if transformed_uid> * transformation.quantity</dtml-if>) AS total_quantity,\n
......@@ -107,7 +107,7 @@ SELECT\n
<dtml-if transformed_uid> * transformation.quantity</dtml-if>), 12)\n
AS converted_quantity,\n
</dtml-if>\n
SUM(<dtml-var stock_table_id>.total_price) AS total_price\n
IFNULL(SUM(<dtml-var stock_table_id>.total_price), 0) AS total_price\n
</dtml-if>\n
<dtml-if inventory_list>\n
,node.title AS node_title,\n
......
41068
\ No newline at end of file
41069
\ No newline at end of file
......@@ -819,6 +819,15 @@ class TestInventoryList(InventoryAPITestCase):
# default is an empty list
self.assertEquals(0, len(inventory_list))
def testDefault0(self):
getInventoryList = self.getSimulationTool().getInventoryList
self._makeMovement()
inventory_list = getInventoryList(section_uid=self.section.getUid(),)
self.assertEquals(1, len(inventory_list))
self.assertEquals(0, inventory_list[0].total_quantity)
# The total price of grouped movements without price is 0
self.assertEquals(0, inventory_list[0].total_price)
def test_GroupByNode(self):
getInventoryList = self.getSimulationTool().getInventoryList
self._makeMovement(quantity=100)
......@@ -1394,7 +1403,17 @@ class TestMovementHistoryList(InventoryAPITestCase):
'Shared.DC.ZRDB.Results.Results')
# default is an empty list
self.assertEquals(0, len(mvt_history_list))
def testDefault0(self):
self._makeMovement()
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
mvt_history_list = getMovementHistoryList(
section_uid=self.section.getUid(),)
self.assertEquals(1, len(mvt_history_list))
self.assertEquals(0, mvt_history_list[0].total_quantity)
# If a movement have no price, None is returned
self.assertEquals(None, mvt_history_list[0].total_price)
def testMovementBothSides(self):
"""Movement History List returns movement from both sides"""
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
......
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