Commit 187aa9e2 authored by Jérome Perrin's avatar Jérome Perrin

running_total_price should work even if no total_price is defined on the movement



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11767 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f87239a6
......@@ -662,7 +662,7 @@ SELECT \n
q1.*,\n
@running_total_quantity := q1.total_quantity + \n
@running_total_quantity AS running_total_quantity,\n
@running_total_price := q1.total_price + \n
@running_total_price := IFNULL(q1.total_price, 0) + \n
@running_total_price AS running_total_price\n
FROM (\n
SELECT\n
......@@ -819,7 +819,7 @@ SELECT \n
q1.*,\n
@running_total_quantity := q1.total_quantity + \n
@running_total_quantity AS running_total_quantity,\n
@running_total_price := q1.total_price + \n
@running_total_price := IFNULL(q1.total_price, 0) + \n
@running_total_price AS running_total_price\n
FROM (\n
SELECT\n
......
223
\ No newline at end of file
224
\ No newline at end of file
......@@ -931,6 +931,24 @@ class TestMovementHistoryList(InventoryAPITestCase):
running_total_price += quantity * quantity # we've set price=quantity
self.assertEquals(running_total_price, brain.running_total_price)
def testRunningQuantityWithQuantity0(self):
# a 0 quantity should not be a problem for running total price
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date = DateTime()
quantity = -1
for i in range(3):
self._makeMovement( quantity=quantity+i, price=1, start_date=date+i )
mvt_history_list = getMovementHistoryList(
node_uid=self.node.getUid(),
sort_on=[['stock.date', 'ASC']])
self.assertEquals(3, len(mvt_history_list))
self.assertEquals(-1, mvt_history_list[0].running_total_quantity)
self.assertEquals(-1, mvt_history_list[0].running_total_price)
self.assertEquals(-1, mvt_history_list[1].running_total_quantity)
self.assertEquals(-1, mvt_history_list[1].running_total_price)
self.assertEquals(0, mvt_history_list[2].running_total_quantity)
self.assertEquals(0, mvt_history_list[2].running_total_price)
# bug #352
def testSameNodeDifferentDates(self):
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