Commit 89f1e640 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Updated pseudo code to follow interface.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30392 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4c7733bd
......@@ -27,6 +27,8 @@
#
##############################################################################
import zope.interface
from Products.ERP5Type import interfaces
from DeliverySolver import DeliverySolver
class FIFO(DeliverySolver):
......@@ -34,7 +36,26 @@ class FIFO(DeliverySolver):
The FIFO solver reduces deliveted quantity by reducing the quantity of simulation movements from the last order.
"""
def solve(self, simulation_movement_list, new_quantity):
# Declarative interfaces
zope.interface.implements(interfaces.IDeliverySolver)
# IDeliverySolver Implementation
def __init__(self, simulation_movement_list):
"""
Move this to mixin
"""
self.simulation_movement_list = simulation_movement_list
def getTotalQuantity():
"""
Move this to mixin
"""
total_quantity = 0
for movement in self.simulation_movement_list:
total_quantity += movement.getQuantity()
return total_quantity
def setTotalQuantity(self, new_quantity):
"""
"""
result = []
......@@ -42,11 +63,8 @@ class FIFO(DeliverySolver):
return cmp(a.getExplainationValue().getStartDate() b.getExplainationValue().getStartDate())
simulation_movement_list.sort(sortByOrderStartDate)
simulation_movement_list.reverse()
total_quantity = 0
for movement in simulation_movement_list:
total_quantity += movement.getQuantity()
remaining_quantity = total_quantity - new_quantity
for movement in simulation_movement_list:
remaining_quantity = self.getTotalQuantity() - new_quantity
for movement in self.simulation_movement_list:
if remaining_quantity:
if movement.getQuantity() < remaining_quantity:
result.append((movement, movement.getQuantity()))
......
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