Class: ZATCA::UBL::CommonAggregateComponents::PartyTaxScheme

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

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ArrayOfBaseComponentOrNil

Instance Attribute Summary

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(company_id: nil, tax_scheme_id: "VAT") ⇒ PartyTaxScheme

Returns a new instance of PartyTaxScheme.



2
3
4
5
6
7
8
9
10
# File 'lib/zatca/ubl/common_aggregate_components/party_tax_scheme.rb', line 2

def initialize(
  company_id: nil,
  tax_scheme_id: "VAT"
)
  super()

  @company_id = company_id
  @tax_scheme_id = tax_scheme_id
end

Instance Method Details

#company_id_elementObject



16
17
18
19
20
# File 'lib/zatca/ubl/common_aggregate_components/party_tax_scheme.rb', line 16

def company_id_element
  return nil if @company_id.blank?

  ZATCA::UBL::BaseComponent.new(name: "cbc:CompanyID", value: @company_id)
end

#elementsObject



22
23
24
25
26
27
28
29
# File 'lib/zatca/ubl/common_aggregate_components/party_tax_scheme.rb', line 22

def elements
  [
    company_id_element,
    ZATCA::UBL::BaseComponent.new(name: "cac:TaxScheme", elements: [
      ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @tax_scheme_id)
    ])
  ]
end

#nameObject



12
13
14
# File 'lib/zatca/ubl/common_aggregate_components/party_tax_scheme.rb', line 12

def name
  "cac:PartyTaxScheme"
end