foodsoft/app/models/invoice.rb
wvengen 7841245795 migrate to Rails 4.0 (closes foodcoops#214)
Conflicts:
	Gemfile.lock
2014-02-24 12:46:28 +01:00

21 lines
450 B
Ruby

class Invoice < ActiveRecord::Base
belongs_to :supplier
belongs_to :delivery
belongs_to :order
validates_presence_of :supplier_id
validates_numericality_of :amount, :deposit, :deposit_credit
scope :unpaid, -> { where(paid_on: nil) }
# Replace numeric seperator with database format
localize_input_of :amount, :deposit, :deposit_credit
# Amount without deposit
def net_amount
amount - deposit + deposit_credit
end
end