Class: ZATCA::UBL::CommonAggregateComponents::AllowanceCharge
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- ZATCA::UBL::CommonAggregateComponents::AllowanceCharge
- Defined in:
- lib/zatca/ubl/common_aggregate_components/allowance_charge.rb
Constant Summary
Constants inherited from BaseComponent
BaseComponent::ArrayOfBaseComponentOrNil
Instance Attribute Summary collapse
-
#allowance_charge_reason ⇒ Object
Returns the value of attribute allowance_charge_reason.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#charge_indicator ⇒ Object
Returns the value of attribute charge_indicator.
-
#id ⇒ Object
Returns the value of attribute id.
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #elements ⇒ Object
- #id_element ⇒ Object
-
#initialize(charge_indicator:, allowance_charge_reason:, amount:, currency_id: "SAR", tax_category: nil, add_tax_category: true, add_id: true, tax_categories: []) ⇒ AllowanceCharge
constructor
<cac:AllowanceCharge> <cbc:ID>1</cbc:ID> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID=“SAR”>2</cbc:Amount> <cac:TaxCategory> <cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5305”>S</cbc:ID> <cbc:Percent>15</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5153”>VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:AllowanceCharge>.
- #name ⇒ Object
Methods inherited from BaseComponent
#[], build, #build_xml, #dig, #find_nested_element_by_path, #generate_xml, #schema, #to_h, #to_xml
Constructor Details
#initialize(charge_indicator:, allowance_charge_reason:, amount:, currency_id: "SAR", tax_category: nil, add_tax_category: true, add_id: true, tax_categories: []) ⇒ AllowanceCharge
<cac:AllowanceCharge>
<cbc:ID>1</cbc:ID>
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="SAR">2</cbc:Amount>
<cac:TaxCategory>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
<cbc:Percent>15</cbc:Percent>
<cac:TaxScheme>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:AllowanceCharge>
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 18 def initialize( charge_indicator:, allowance_charge_reason:, amount:, currency_id: "SAR", tax_category: nil, add_tax_category: true, add_id: true, tax_categories: [] ) super() @charge_indicator = charge_indicator.to_s @allowance_charge_reason = allowance_charge_reason @amount = amount @currency_id = currency_id @add_tax_category = add_tax_category @tax_category = tax_category @add_id = add_id if add_tax_category && @tax_category.blank? @tax_category = ZATCA::UBL::CommonAggregateComponents::TaxCategory.new end @tax_categories = if @tax_category.present? && tax_categories.blank? [@tax_category] else tax_categories end end |
Instance Attribute Details
#allowance_charge_reason ⇒ Object
Returns the value of attribute allowance_charge_reason.
2 3 4 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 2 def allowance_charge_reason @allowance_charge_reason end |
#amount ⇒ Object
Returns the value of attribute amount.
2 3 4 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 2 def amount @amount end |
#charge_indicator ⇒ Object
Returns the value of attribute charge_indicator.
2 3 4 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 2 def charge_indicator @charge_indicator end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 2 def id @id end |
Instance Method Details
#elements ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 55 def elements [ id_element, ZATCA::UBL::BaseComponent.new(name: "cbc:ChargeIndicator", value: @charge_indicator), ZATCA::UBL::BaseComponent.new(name: "cbc:AllowanceChargeReason", value: @allowance_charge_reason), ZATCA::UBL::BaseComponent.new(name: "cbc:Amount", value: @amount, attributes: {"currencyID" => @currency_id}), *@tax_categories ] end |
#id_element ⇒ Object
49 50 51 52 53 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 49 def id_element if @add_id && index.present? ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: index) end end |
#name ⇒ Object
45 46 47 |
# File 'lib/zatca/ubl/common_aggregate_components/allowance_charge.rb', line 45 def name "cac:AllowanceCharge" end |