Class: XeroKiwi::Accounting::PaymentTerms
- Inherits:
-
Object
- Object
- XeroKiwi::Accounting::PaymentTerms
- Includes:
- Resource
- Defined in:
- lib/xero_kiwi/accounting/payment_terms.rb
Overview
Xero payment terms for an Organisation or Contact, containing separate terms for bills (payable) and sales (receivable).
See: developer.xero.com/documentation/api/accounting/types#paymentterms
Constant Summary collapse
- TERM_HYDRATOR =
A nil or empty sub-hash should collapse to nil rather than constructing a PaymentTerm with every attribute nil.
->(raw) { raw.nil? || raw.empty? ? nil : PaymentTerm.new(raw) }
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #inspect ⇒ Object
-
#to_h ⇒ Object
Override the mixin default: PaymentTerms’s to_h unwraps the nested PaymentTerm objects to hashes, matching the pre-DSL behaviour.
Methods included from Resource
included, #initialize, #reference?
Class Method Details
.from_hash(hash) ⇒ Object
19 20 21 22 23 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 19 def self.from_hash(hash) return nil if hash.nil? new(hash) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
31 32 33 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 31 def ==(other) other.is_a?(PaymentTerms) && bills == other.bills && sales == other.sales end |
#hash ⇒ Object
36 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 36 def hash = [self.class, bills, sales].hash |
#inspect ⇒ Object
38 39 40 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 38 def inspect "#<#{self.class} bills=#{bills.inspect} sales=#{sales.inspect}>" end |
#to_h ⇒ Object
Override the mixin default: PaymentTerms’s to_h unwraps the nested PaymentTerm objects to hashes, matching the pre-DSL behaviour.
27 28 29 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 27 def to_h { bills: bills&.to_h, sales: sales&.to_h } end |