Class: ZATCA::UBL::CommonAggregateComponents::TaxCategory

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/zatca/ubl/common_aggregate_components/tax_category.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(tax_percent: "15.00", id: "S", scheme_agency_id: "6", scheme_id: "UN/ECE 5305", tax_scheme_id: "VAT", tax_scheme_scheme_id: "UN/ECE 5153", tax_exemption_reason_code: nil) ⇒ TaxCategory

<cac:TaxCategory>

    <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
    <cbc:Percent>15.00</cbc:Percent>
    <cac:TaxScheme>
        <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
    </cac:TaxScheme>
</cac:TaxCategory>

<cac:TaxCategory>

<cbc:ID>O</cbc:ID>
<cbc:TaxExemptionReasonCode>VATEX-EU-O</cbc:TaxExemptionReasonCode>
<cac:TaxScheme>
  <cbc:ID>VAT</cbc:ID>
  </cac:TaxScheme>

</cac:TaxCategory>



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

def initialize(
  tax_percent: "15.00", id: "S", scheme_agency_id: "6",
  scheme_id: "UN/ECE 5305", tax_scheme_id: "VAT",
  tax_scheme_scheme_id: "UN/ECE 5153", tax_exemption_reason_code: nil
)
  super()

  @tax_percent = tax_percent
  @id = id
  @scheme_agency_id = scheme_agency_id
  @scheme_id = scheme_id
  @tax_scheme_id = tax_scheme_id
  @tax_scheme_scheme_id = tax_scheme_scheme_id
  @tax_exemption_reason_code = tax_exemption_reason_code
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#percentObject (readonly)

Returns the value of attribute percent.



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

def percent
  @percent
end

Instance Method Details

#elementsObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/zatca/ubl/common_aggregate_components/tax_category.rb', line 38

def elements
  [
    ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @id, attributes: {"schemeAgencyID" => @scheme_agency_id, "schemeID" => @scheme_id}.compact),
    tax_exemption_reason_code_element,
    ZATCA::UBL::BaseComponent.new(name: "cbc:Percent", value: @tax_percent),
    ZATCA::UBL::BaseComponent.new(name: "cac:TaxScheme", elements: [
      ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @tax_scheme_id, attributes: {"schemeAgencyID" => @scheme_agency_id, "schemeID" => @tax_scheme_scheme_id}.compact)
    ])
  ]
end

#nameObject



34
35
36
# File 'lib/zatca/ubl/common_aggregate_components/tax_category.rb', line 34

def name
  "cac:TaxCategory"
end