Order refactoring part two: Balancing workflow was adapted to the new order schema. Article modification is still missing.
This commit is contained in:
parent
9eb2125f15
commit
190a777278
53 changed files with 568 additions and 603 deletions
|
|
@ -82,9 +82,13 @@ class Order < ActiveRecord::Base
|
|||
memoize :get_articles
|
||||
|
||||
# Returns the defecit/benefit for the foodcoop
|
||||
def profit(with_markup = true)
|
||||
groups_sum = with_markup ? sum(:groups) : sum(:groups_without_markup)
|
||||
groups_sum - invoice_amount + deposit - deposit_credit
|
||||
# Requires a valid invoice, belonging to this order
|
||||
def profit(options = {})
|
||||
markup = options[:with_markup] || true
|
||||
if invoice
|
||||
groups_sum = markup ? sum(:groups) : sum(:groups_without_markup)
|
||||
groups_sum - invoice.net_amount
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the all round price of a finished order
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue