Class: AdvancedBilling::ProformaInvoiceTax

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

Overview

ProformaInvoiceTax Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(uid: SKIP, title: SKIP, source_type: SKIP, percentage: SKIP, taxable_amount: SKIP, tax_amount: SKIP, line_item_breakouts: SKIP, additional_properties: {}) ⇒ ProformaInvoiceTax

Returns a new instance of ProformaInvoiceTax.



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

def initialize(uid: SKIP, title: SKIP, source_type: SKIP, percentage: SKIP,
               taxable_amount: SKIP, tax_amount: SKIP,
               line_item_breakouts: SKIP, additional_properties: {})
  @uid = uid unless uid == SKIP
  @title = title unless title == SKIP
  @source_type = source_type unless source_type == SKIP
  @percentage = percentage unless percentage == SKIP
  @taxable_amount = taxable_amount unless taxable_amount == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @line_item_breakouts = line_item_breakouts unless line_item_breakouts == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#line_item_breakoutsArray[InvoiceTaxBreakout]

TODO: Write general description for this method

Returns:



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

def line_item_breakouts
  @line_item_breakouts
end

#percentageString

TODO: Write general description for this method

Returns:

  • (String)


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

def percentage
  @percentage
end

#source_typeProformaInvoiceTaxSourceType

TODO: Write general description for this method



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

def source_type
  @source_type
end

#tax_amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def tax_amount
  @tax_amount
end

#taxable_amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def taxable_amount
  @taxable_amount
end

#titleString

TODO: Write general description for this method

Returns:

  • (String)


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

def title
  @title
end

#uidString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/proforma_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.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/advanced_billing/models/proforma_invoice_tax.rb', line 89

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
  source_type = hash.key?('source_type') ? hash['source_type'] : 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
  # 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')

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  ProformaInvoiceTax.new(uid: uid,
                         title: title,
                         source_type: source_type,
                         percentage: percentage,
                         taxable_amount: taxable_amount,
                         tax_amount: tax_amount,
                         line_item_breakouts: line_item_breakouts,
                         additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/advanced_billing/models/proforma_invoice_tax.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['uid'] = 'uid'
  @_hash['title'] = 'title'
  @_hash['source_type'] = 'source_type'
  @_hash['percentage'] = 'percentage'
  @_hash['taxable_amount'] = 'taxable_amount'
  @_hash['tax_amount'] = 'tax_amount'
  @_hash['line_item_breakouts'] = 'line_item_breakouts'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/advanced_billing/models/proforma_invoice_tax.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/advanced_billing/models/proforma_invoice_tax.rb', line 54

def self.optionals
  %w[
    uid
    title
    source_type
    percentage
    taxable_amount
    tax_amount
    line_item_breakouts
  ]
end