Class: ZATCA::UBL::CommonAggregateComponents::Price

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/zatca/ubl/common_aggregate_components/price.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(price_amount:, allowance_charge: nil, currency_id: "SAR") ⇒ Price

Returns a new instance of Price.



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

def initialize(price_amount:, allowance_charge: nil, currency_id: "SAR")
  super()

  @price_amount = price_amount
  @allowance_charge = allowance_charge
  @currency_id = currency_id
end

Instance Method Details

#elementsObject



14
15
16
17
18
19
# File 'lib/zatca/ubl/common_aggregate_components/price.rb', line 14

def elements
  [
    ZATCA::UBL::BaseComponent.new(name: "cbc:PriceAmount", value: @price_amount, attributes: {currencyID: @currency_id}),
    @allowance_charge
  ]
end

#nameObject



10
11
12
# File 'lib/zatca/ubl/common_aggregate_components/price.rb', line 10

def name
  "cac:Price"
end