foodsoft/app/models/invoice.rb

22 lines
458 B
Ruby
Raw Normal View History

class Invoice < ActiveRecord::Base
belongs_to :supplier
2009-01-18 17:42:51 +01:00
belongs_to :delivery
belongs_to :order
validates_presence_of :supplier_id
2012-04-20 18:33:47 +02:00
validates_numericality_of :amount, :deposit, :deposit_credit
scope :unpaid, :conditions => { :paid_on => nil }
2012-04-20 18:33:47 +02:00
# 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