Class: ZATCA::UBL::CommonAggregateComponents::InvoiceLine

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/zatca/ubl/common_aggregate_components/invoice_line.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(invoiced_quantity:, invoiced_quantity_unit_code:, line_extension_amount:, tax_total:, item:, price:, allowance_charge: nil, currency_id: "SAR") ⇒ InvoiceLine

</cac:TaxTotal> cac:Item cbc:Namedsd</cbc:Name> cac:ClassifiedTaxCategory cbc:IDS</cbc:ID> cbc:Percent15.00</cbc:Percent> cac:TaxScheme cbc:IDVAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> cac:Price <cbc:PriceAmount currencyID="SAR">22.00</cbc:PriceAmount> cac:AllowanceCharge cbc:ChargeIndicatorfalse</cbc:ChargeIndicator> cbc:AllowanceChargeReasondiscount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">2.00</cbc:Amount> </cac:AllowanceCharge> </cac:Price> </cac:InvoiceLine>



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/zatca/ubl/common_aggregate_components/invoice_line.rb', line 31

def initialize(
  invoiced_quantity:, invoiced_quantity_unit_code:,
  line_extension_amount:, tax_total:, item:,
  price:, allowance_charge: nil, currency_id: "SAR"
)
  super()

  @invoiced_quantity = invoiced_quantity
  @invoiced_quantity_unit_code = invoiced_quantity_unit_code
  @line_extension_amount = line_extension_amount
  @tax_total = tax_total
  @item = item
  @price = price
  @allowance_charge = allowance_charge
  @currency_id = currency_id
end

Instance Method Details

#elementsObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/zatca/ubl/common_aggregate_components/invoice_line.rb', line 52

def elements
  [
    ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: index),
    ZATCA::UBL::BaseComponent.new(name: "cbc:InvoicedQuantity", value: @invoiced_quantity, attributes: {unitCode: @invoiced_quantity_unit_code}),
    ZATCA::UBL::BaseComponent.new(name: "cbc:LineExtensionAmount", value: @line_extension_amount, attributes: {currencyID: @currency_id}),
    @tax_total,
    @item,
    @price,
    @allowance_charge
  ]
end

#nameObject



48
49
50
# File 'lib/zatca/ubl/common_aggregate_components/invoice_line.rb', line 48

def name
  "cac:InvoiceLine"
end