Class: ZATCA::UBL::CommonAggregateComponents::LegalMonetaryTotal

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ArrayOfBaseComponentOrNil

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#attributes, #index, #value

Instance Method Summary collapse

Methods inherited from BaseComponent

#[], build, #build_xml, #dig, #find_nested_element_by_path, #generate_xml, #schema, #to_h, #to_xml

Constructor Details

#initialize(line_extension_amount:, tax_exclusive_amount:, tax_inclusive_amount:, allowance_total_amount:, prepaid_amount: nil, payable_amount: nil, currency_id: "SAR") ⇒ LegalMonetaryTotal

<cac:LegalMonetaryTotal>

<cbc:LineExtensionAmount currencyID="SAR">966.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="SAR">964.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="SAR">1108.90</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="SAR">2.00</cbc:AllowanceTotalAmount>
<cbc:PrepaidAmount currencyID="SAR">0.00</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="SAR">1108.90</cbc:PayableAmount>

</cac:LegalMonetaryTotal>



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 15

def initialize(
  line_extension_amount:,
  tax_exclusive_amount:,
  tax_inclusive_amount:,
  allowance_total_amount:,
  prepaid_amount: nil,
  payable_amount: nil,
  currency_id: "SAR"
)
  @line_extension_amount = line_extension_amount
  @tax_exclusive_amount = tax_exclusive_amount
  @tax_inclusive_amount = tax_inclusive_amount
  @allowance_total_amount = allowance_total_amount
  @prepaid_amount = prepaid_amount
  @payable_amount = payable_amount
  @currency_id = currency_id
end

Instance Attribute Details

#allowance_total_amountObject (readonly)

Returns the value of attribute allowance_total_amount.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 2

def allowance_total_amount
  @allowance_total_amount
end

#currency_idObject (readonly)

Returns the value of attribute currency_id.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 2

def currency_id
  @currency_id
end

#line_extension_amountObject (readonly)

Returns the value of attribute line_extension_amount.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 2

def line_extension_amount
  @line_extension_amount
end

#payable_amountObject (readonly)

Returns the value of attribute payable_amount.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 2

def payable_amount
  @payable_amount
end

#prepaid_amountObject (readonly)

Returns the value of attribute prepaid_amount.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 2

def prepaid_amount
  @prepaid_amount
end

#tax_exclusive_amountObject (readonly)

Returns the value of attribute tax_exclusive_amount.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 2

def tax_exclusive_amount
  @tax_exclusive_amount
end

#tax_inclusive_amountObject (readonly)

Returns the value of attribute tax_inclusive_amount.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 2

def tax_inclusive_amount
  @tax_inclusive_amount
end

Instance Method Details

#elementsObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 49

def elements
  [
    ZATCA::UBL::BaseComponent.new(name: "cbc:LineExtensionAmount", value: @line_extension_amount, attributes: {"currencyID" => @currency_id}),
    ZATCA::UBL::BaseComponent.new(name: "cbc:TaxExclusiveAmount", value: @tax_exclusive_amount, attributes: {"currencyID" => @currency_id}),
    ZATCA::UBL::BaseComponent.new(name: "cbc:TaxInclusiveAmount", value: @tax_inclusive_amount, attributes: {"currencyID" => @currency_id}),
    ZATCA::UBL::BaseComponent.new(name: "cbc:AllowanceTotalAmount", value: @allowance_total_amount, attributes: {"currencyID" => @currency_id}),
    prepaid_amount_element,
    payable_amount_element
  ]
end

#nameObject



33
34
35
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 33

def name
  "cac:LegalMonetaryTotal"
end

#payable_amount_elementObject



43
44
45
46
47
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 43

def payable_amount_element
  return nil if @payable_amount.blank?

  ZATCA::UBL::BaseComponent.new(name: "cbc:PayableAmount", value: @payable_amount, attributes: {"currencyID" => @currency_id})
end

#prepaid_amount_elementObject



37
38
39
40
41
# File 'lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb', line 37

def prepaid_amount_element
  return nil if @prepaid_amount.blank?

  ZATCA::UBL::BaseComponent.new(name: "cbc:PrepaidAmount", value: @prepaid_amount, attributes: {"currencyID" => @currency_id})
end