Module: Invoicing::LedgerItem::ActMethods
- Defined in:
- lib/invoicing/ledger_item.rb
Instance Method Summary collapse
-
#acts_as_credit_note(options = {}) ⇒ Object
Synonym for
acts_as_ledger_item :subtype => :credit_note
. -
#acts_as_invoice(options = {}) ⇒ Object
Synonym for
acts_as_ledger_item :subtype => :invoice
. -
#acts_as_ledger_item(*args) ⇒ Object
Declares that the current class is a model for ledger items (i.e. invoices, credit notes and payment notes).
-
#acts_as_payment(options = {}) ⇒ Object
Synonym for
acts_as_ledger_item :subtype => :payment
.
Instance Method Details
#acts_as_credit_note(options = {}) ⇒ Object
Synonym for acts_as_ledger_item :subtype => :credit_note
. All options other than :subtype
are passed on to acts_as_ledger_item
. You should apply acts_as_credit_note
only to a model which is a subclass of an acts_as_ledger_item
type.
333 334 335 |
# File 'lib/invoicing/ledger_item.rb', line 333 def acts_as_credit_note(={}) acts_as_ledger_item(.clone.update({:subtype => :credit_note})) end |
#acts_as_invoice(options = {}) ⇒ Object
Synonym for acts_as_ledger_item :subtype => :invoice
. All options other than :subtype
are passed on to acts_as_ledger_item
. You should apply acts_as_invoice
only to a model which is a subclass of an acts_as_ledger_item
type.
326 327 328 |
# File 'lib/invoicing/ledger_item.rb', line 326 def acts_as_invoice(={}) acts_as_ledger_item(.clone.update({:subtype => :invoice})) end |
#acts_as_ledger_item(*args) ⇒ Object
Declares that the current class is a model for ledger items (i.e. invoices, credit notes and payment notes).
This method accepts a hash of options, all of which are optional:
:subtype
-
One of
:invoice
,:credit_note
or:payment
.
Also, the name of any attribute or method required by LedgerItem
(as documented on the LedgerItem
module) may be used as an option, with the value being the name under which that particular method or attribute can be found. This allows you to use names other than the defaults. For example, if your database column storing the invoice value is called gross_amount
instead of total_amount
:
acts_as_ledger_item :total_amount => :gross_amount
308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/invoicing/ledger_item.rb', line 308 def acts_as_ledger_item(*args) Invoicing::ClassInfo.acts_as(Invoicing::LedgerItem, self, args) info = ledger_item_class_info return unless info.previous_info.nil? # Called for the first time? # Set the 'amount' columns to act as currency values acts_as_currency_value(info.method(:total_amount), info.method(:tax_amount), :currency => info.method(:currency), :value_for_formatting => :value_for_formatting) extend Invoicing::FindSubclasses include Invoicing::LedgerItem::RenderHTML include Invoicing::LedgerItem::RenderUBL end |
#acts_as_payment(options = {}) ⇒ Object
Synonym for acts_as_ledger_item :subtype => :payment
. All options other than :subtype
are passed on to acts_as_ledger_item
. You should apply acts_as_payment
only to a model which is a subclass of an acts_as_ledger_item
type.
340 341 342 |
# File 'lib/invoicing/ledger_item.rb', line 340 def acts_as_payment(={}) acts_as_ledger_item(.clone.update({:subtype => :payment})) end |