class Skr::Customer

Customers are Companies (or individuals) that purchase {Sku}s. They have both a billing and shipping address, a gl account that payments should be applied against, and a payment term.

Public Instance Methods

update_balance!(*) click to toggle source

Updates the amount the customer owes, which is the sum of the amount unpaid on open invoices

# File lib/skr/models/customer.rb, line 22
def update_balance!(*)
    update_attributes open_balance: invoices.open_for_customer(self)
                                            .with_details.sum('details.invoice_total')
end

Private Instance Methods

set_defaults() click to toggle source
Calls superclass method Skr::BusinessEntity#set_defaults
# File lib/skr/models/customer.rb, line 29
def set_defaults
    super
    self.gl_receivables_account ||= GlAccount.default_for( :ar )
end