Class: XeroKiwi::Accounting::PaymentTerm

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_kiwi/accounting/payment_terms.rb

Overview

A single payment term (either bills or sales side).

Constant Summary collapse

ATTRIBUTES =
{
  day:  "Day",
  type: "Type"
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ PaymentTerm

Returns a new instance of PaymentTerm.



55
56
57
58
59
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 55

def initialize(attrs)
  attrs = attrs.transform_keys(&:to_s)
  @day  = attrs["Day"]
  @type = attrs["Type"]
end

Class Method Details

.from_hash(hash) ⇒ Object



49
50
51
52
53
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 49

def self.from_hash(hash)
  return nil if hash.nil? || hash.empty?

  new(hash)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



65
66
67
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 65

def ==(other)
  other.is_a?(PaymentTerm) && day == other.day && type == other.type
end

#hashObject



70
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 70

def hash = [self.class, day, type].hash

#inspectObject



72
73
74
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 72

def inspect
  "#<#{self.class} day=#{day.inspect} type=#{type.inspect}>"
end

#to_hObject



61
62
63
# File 'lib/xero_kiwi/accounting/payment_terms.rb', line 61

def to_h
  ATTRIBUTES.keys.to_h { |key| [key, public_send(key)] }
end