Class: Skr::Invoice
- Defined in:
- lib/skr/invoice.rb
Overview
Invoices constitute a demand for payment for goods that have been delivered to a Customer. A invoice contains:
* Customer contact information
* An inventory location that goods will be taken from.
* The customer provided {PurchaseOrder} Number
* The Payment Terms that were extended. This will control how much time the Customer has to pay the invoice in full.
* One or more SKUs, the quantity desired for each and the selling price for them.
While an Invoice often originates with a SalesOrder, it does not have to. Sales that take place in a retail environment where the customer selects the goods and pays for them immediately do not require a sales order record.
Once an invoice is saved, it immediately removes the SKUs from the SkuLoc and generates corresponding General Ledger entries debiting the asset account and crediting the customers receivables account.
When payment is received against the Invoice, the receivables account is debited and the payments holding account is credited.
invoice = Invoice.new( customer: Customer.find_by_code("ACME")
invoice.lines.build({ sku: Sku.find_by_code('LABOR'), qty: 1, price: 8.27 })
invoice.save
Instance Method Summary collapse
-
#fully_paid? ⇒ Boolean
Is the invoice paid in full.
-
#initialize(attributes = {}) ⇒ Invoice
constructor
A new instance of Invoice.
-
#unpaid_amount ⇒ BigDecimal
Total - amount_paid.
Constructor Details
#initialize(attributes = {}) ⇒ Invoice
Returns a new instance of Invoice.
77 78 79 80 |
# File 'lib/skr/invoice.rb', line 77 def initialize(attributes = {}) super self.invoice_date = Date.today end |
Instance Method Details
#fully_paid? ⇒ Boolean
Returns is the invoice paid in full.
88 89 90 |
# File 'lib/skr/invoice.rb', line 88 def fully_paid? unpaid_amount <= 0 end |
#unpaid_amount ⇒ BigDecimal
Returns total - amount_paid.
83 84 85 |
# File 'lib/skr/invoice.rb', line 83 def unpaid_amount self.total - amount_paid end |