2009-10-01 02:17:50 -04:00
|
|
|
class Invoice < ActiveRecord::Base
|
2016-08-06 13:37:57 -04:00
|
|
|
has_many :line_items, autosave: true
|
2016-08-16 03:30:11 -04:00
|
|
|
before_save { |record| record.balance = record.line_items.map(&:amount).sum }
|
2009-10-01 02:17:50 -04:00
|
|
|
end
|