class Skr::Voucher
A voucher is a record of a {Vendor}'s demand for payment, or a record of It transistions through the following states
* Saved; A {PurchaseOrder} has been recieved but an Invoice has not been received fromt the Vendor * It credit's each line's {Sku#gl_asset_account} and debit's the System default inventory_receipts_clearing * Confirmed; An Invoice has been received and verified as accurate. * Debit: {Vendor#gl_payables_account}, Credit: inventory_receipts_clearing * Paid; A payment has been made against the Voucher * Debit {Vendor#gl_payables_account}, Credit: Deposit clearing account
Public Instance Methods
po_receipt=(por)
click to toggle source
# File lib/skr/models/voucher.rb, line 63 def po_receipt=(por) self.vendor = por.vendor self.purchase_order = por.purchase_order self.terms = self.purchase_order.terms self.refno = por.refno end
Private Instance Methods
ensure_payment_line()
click to toggle source
def does_create_own_gl_records?
true
end
# File lib/skr/models/voucher.rb, line 85 def ensure_payment_line payment_line.present? end
record_confirmation_in_gl()
click to toggle source
# File lib/skr/models/voucher.rb, line 100 def record_confirmation_in_gl self.confirmation_date ||= Date.today GlTransaction.push_or_save( :owner => self, amount: total, :debit => vendor.gl_payables_account, :credit => GlAccount.default_for( :inventory_receipts_clearing ), :options => { description: "Voucher #{self.visible_id}" } ) true end
record_payment_in_gl()
click to toggle source
# File lib/skr/models/voucher.rb, line 111 def record_payment_in_gl gl = self.gl_transactions.build({ :source =>self, :location => self.purchase_order.location, :amount =>self.total, :description =>'Voucher Payment' }) gl.credit.account = self.vendor.gl_payables_account gl.debit.account = self.payment_line.payment.bank_account.gl_account gl.save! end
set_defaults()
click to toggle source
# File lib/skr/models/voucher.rb, line 89 def set_defaults # self.freight ||= 0.0 if self.purchase_order self.vendor = self.purchase_order.vendor #self.location = self.purchase_order.location self.terms ||= self.purchase_order.terms end end