Is this type of calculation to be put in Model or Controller?
- by Hadi
i have Product and SalesOrder model (to simplify, 1 sales_order only for 1 product)
Product has_many SalesOrder
SalesOrder belongs_to Product
pa = Product A #2000
so1 = SalesOrder 1 order product A #1000, date:yesterday
so2 = SalesOrder 2 order product A #999, date:yesterday
so3 = SalesOrder 3 order product A #1000, date:now
Based on the date, pa.find_sales_orders_that_can_be_delivered will give:
SalesOrder 1 order product A #1000, date:yesterday
SalesOrder 2 order product A #999, date:yesterday
SalesOrder 3 order product A #1, date:now <-- the newest
The question is: is find_sales_orders_that_can_be_delivered should be in the Model?
i can do it in controller.
and the general question is: what goes in Model and what goes in Controller.
Thank you