Order refactoring part two: Balancing workflow was adapted to the new order schema. Article modification is still missing.

This commit is contained in:
Benjamin Meichsner 2009-01-29 21:28:22 +01:00
parent 9eb2125f15
commit 190a777278
53 changed files with 568 additions and 603 deletions

View file

@ -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