Class: AdvancedBilling::InvoiceTax

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/invoice_tax.rb

Overview

InvoiceTax Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(uid: SKIP, title: SKIP, description: SKIP, source_type: SKIP, source_id: SKIP, percentage: SKIP, taxable_amount: SKIP, tax_amount: SKIP, transaction_id: SKIP, line_item_breakouts: SKIP, tax_component_breakouts: SKIP, eu_vat: SKIP, type: SKIP, tax_exempt_amount: SKIP, additional_properties: {}) ⇒ InvoiceTax

Returns a new instance of InvoiceTax.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/advanced_billing/models/invoice_tax.rb', line 115

def initialize(uid: SKIP, title: SKIP, description: SKIP, source_type: SKIP,
               source_id: SKIP, percentage: SKIP, taxable_amount: SKIP,
               tax_amount: SKIP, transaction_id: SKIP,
               line_item_breakouts: SKIP, tax_component_breakouts: SKIP,
               eu_vat: SKIP, type: SKIP, tax_exempt_amount: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @uid = uid unless uid == SKIP
  @title = title unless title == SKIP
  @description = description unless description == SKIP
  @source_type = source_type unless source_type == SKIP
  @source_id = source_id unless source_id == SKIP
  @percentage = percentage unless percentage == SKIP
  @taxable_amount = taxable_amount unless taxable_amount == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @transaction_id = transaction_id unless transaction_id == SKIP
  @line_item_breakouts = line_item_breakouts unless line_item_breakouts == SKIP
  @tax_component_breakouts = tax_component_breakouts unless tax_component_breakouts == SKIP
  @eu_vat = eu_vat unless eu_vat == SKIP
  @type = type unless type == SKIP
  @tax_exempt_amount = tax_exempt_amount unless tax_exempt_amount == SKIP
end

Instance Attribute Details

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/invoice_tax.rb', line 22

def description
  @description
end

#eu_vatTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


58
59
60
# File 'lib/advanced_billing/models/invoice_tax.rb', line 58

def eu_vat
  @eu_vat
end

#line_item_breakoutsArray[InvoiceTaxBreakout]

TODO: Write general description for this method

Returns:



50
51
52
# File 'lib/advanced_billing/models/invoice_tax.rb', line 50

def line_item_breakouts
  @line_item_breakouts
end

#percentageString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/advanced_billing/models/invoice_tax.rb', line 34

def percentage
  @percentage
end

#source_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


30
31
32
# File 'lib/advanced_billing/models/invoice_tax.rb', line 30

def source_id
  @source_id
end

#source_typeProformaInvoiceTaxSourceType

TODO: Write general description for this method



26
27
28
# File 'lib/advanced_billing/models/invoice_tax.rb', line 26

def source_type
  @source_type
end

#tax_amountString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/invoice_tax.rb', line 42

def tax_amount
  @tax_amount
end

#tax_component_breakoutsArray[InvoiceTaxComponentBreakout]

TODO: Write general description for this method

Returns:



54
55
56
# File 'lib/advanced_billing/models/invoice_tax.rb', line 54

def tax_component_breakouts
  @tax_component_breakouts
end

#tax_exempt_amountString

TODO: Write general description for this method

Returns:

  • (String)


66
67
68
# File 'lib/advanced_billing/models/invoice_tax.rb', line 66

def tax_exempt_amount
  @tax_exempt_amount
end

#taxable_amountString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/invoice_tax.rb', line 38

def taxable_amount
  @taxable_amount
end

#titleString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/invoice_tax.rb', line 18

def title
  @title
end

#transaction_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


46
47
48
# File 'lib/advanced_billing/models/invoice_tax.rb', line 46

def transaction_id
  @transaction_id
end

#typeString

TODO: Write general description for this method

Returns:

  • (String)


62
63
64
# File 'lib/advanced_billing/models/invoice_tax.rb', line 62

def type
  @type
end

#uidString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/invoice_tax.rb', line 14

def uid
  @uid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/advanced_billing/models/invoice_tax.rb', line 143

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  uid = hash.key?('uid') ? hash['uid'] : SKIP
  title = hash.key?('title') ? hash['title'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  source_type = hash.key?('source_type') ? hash['source_type'] : SKIP
  source_id = hash.key?('source_id') ? hash['source_id'] : SKIP
  percentage = hash.key?('percentage') ? hash['percentage'] : SKIP
  taxable_amount =
    hash.key?('taxable_amount') ? hash['taxable_amount'] : SKIP
  tax_amount = hash.key?('tax_amount') ? hash['tax_amount'] : SKIP
  transaction_id =
    hash.key?('transaction_id') ? hash['transaction_id'] : SKIP
  # Parameter is an array, so we need to iterate through it
  line_item_breakouts = nil
  unless hash['line_item_breakouts'].nil?
    line_item_breakouts = []
    hash['line_item_breakouts'].each do |structure|
      line_item_breakouts << (InvoiceTaxBreakout.from_hash(structure) if structure)
    end
  end

  line_item_breakouts = SKIP unless hash.key?('line_item_breakouts')
  # Parameter is an array, so we need to iterate through it
  tax_component_breakouts = nil
  unless hash['tax_component_breakouts'].nil?
    tax_component_breakouts = []
    hash['tax_component_breakouts'].each do |structure|
      tax_component_breakouts << (InvoiceTaxComponentBreakout.from_hash(structure) if structure)
    end
  end

  tax_component_breakouts = SKIP unless hash.key?('tax_component_breakouts')
  eu_vat = hash.key?('eu_vat') ? hash['eu_vat'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  tax_exempt_amount =
    hash.key?('tax_exempt_amount') ? hash['tax_exempt_amount'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  InvoiceTax.new(uid: uid,
                 title: title,
                 description: description,
                 source_type: source_type,
                 source_id: source_id,
                 percentage: percentage,
                 taxable_amount: taxable_amount,
                 tax_amount: tax_amount,
                 transaction_id: transaction_id,
                 line_item_breakouts: line_item_breakouts,
                 tax_component_breakouts: tax_component_breakouts,
                 eu_vat: eu_vat,
                 type: type,
                 tax_exempt_amount: tax_exempt_amount,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/advanced_billing/models/invoice_tax.rb', line 69

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['uid'] = 'uid'
  @_hash['title'] = 'title'
  @_hash['description'] = 'description'
  @_hash['source_type'] = 'source_type'
  @_hash['source_id'] = 'source_id'
  @_hash['percentage'] = 'percentage'
  @_hash['taxable_amount'] = 'taxable_amount'
  @_hash['tax_amount'] = 'tax_amount'
  @_hash['transaction_id'] = 'transaction_id'
  @_hash['line_item_breakouts'] = 'line_item_breakouts'
  @_hash['tax_component_breakouts'] = 'tax_component_breakouts'
  @_hash['eu_vat'] = 'eu_vat'
  @_hash['type'] = 'type'
  @_hash['tax_exempt_amount'] = 'tax_exempt_amount'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
112
113
# File 'lib/advanced_billing/models/invoice_tax.rb', line 109

def self.nullables
  %w[
    description
  ]
end

.optionalsObject

An array for optional fields



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/advanced_billing/models/invoice_tax.rb', line 89

def self.optionals
  %w[
    uid
    title
    description
    source_type
    source_id
    percentage
    taxable_amount
    tax_amount
    transaction_id
    line_item_breakouts
    tax_component_breakouts
    eu_vat
    type
    tax_exempt_amount
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoiceTax | Hash)

    value against the validation is performed.



206
207
208
209
210
211
212
# File 'lib/advanced_billing/models/invoice_tax.rb', line 206

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end