Class: XeroKiwi::Accounting::PaymentTerms
- Inherits:
-
Object
- Object
- XeroKiwi::Accounting::PaymentTerms
- 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
Instance Attribute Summary collapse
-
#bills ⇒ Object
readonly
Returns the value of attribute bills.
-
#sales ⇒ Object
readonly
Returns the value of attribute sales.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(attrs) ⇒ PaymentTerms
constructor
A new instance of PaymentTerms.
- #inspect ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(attrs) ⇒ PaymentTerms
Returns a new instance of PaymentTerms.
18 19 20 21 22 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 18 def initialize(attrs) attrs = attrs.transform_keys(&:to_s) @bills = PaymentTerm.from_hash(attrs["Bills"]) @sales = PaymentTerm.from_hash(attrs["Sales"]) end |
Instance Attribute Details
#bills ⇒ Object (readonly)
Returns the value of attribute bills.
10 11 12 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 10 def bills @bills end |
#sales ⇒ Object (readonly)
Returns the value of attribute sales.
10 11 12 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 10 def sales @sales end |
Class Method Details
.from_hash(hash) ⇒ Object
12 13 14 15 16 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 12 def self.from_hash(hash) return nil if hash.nil? new(hash) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
28 29 30 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 28 def ==(other) other.is_a?(PaymentTerms) && bills == other.bills && sales == other.sales end |
#hash ⇒ Object
33 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 33 def hash = [self.class, bills, sales].hash |
#inspect ⇒ Object
35 36 37 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 35 def inspect "#<#{self.class} bills=#{bills.inspect} sales=#{sales.inspect}>" end |
#to_h ⇒ Object
24 25 26 |
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 24 def to_h { bills: bills&.to_h, sales: sales&.to_h } end |