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/customer.rb, line 22
def update_balance!(*)
    update_attributes open_balance: invoices.open_for_customer(self)
                                            .with_details.sum('details.total')
end

Private Instance Methods

set_defaults() click to toggle source
# File lib/skr/customer.rb, line 29
def set_defaults
    self.terms                  ||= PaymentTerm.find_by_code(Core.config.customer_terms_code)
    self.gl_receivables_account ||= GlAccount.default_for( :ar )
end