zatca 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/einvoicing-sdk/Apps/fatoora +12 -0
- data/einvoicing-sdk/Apps/fatoora.bat +16 -0
- data/einvoicing-sdk/Apps/global.json +1 -0
- data/einvoicing-sdk/Apps/jq.exe +0 -0
- data/einvoicing-sdk/Apps/zatca-einvoicing-sdk-238-R3.2.7.jar +0 -0
- data/einvoicing-sdk/Configuration/config.json +11 -0
- data/einvoicing-sdk/Configuration/defaults.json +11 -0
- data/einvoicing-sdk/Configuration/jq.exe +0 -0
- data/einvoicing-sdk/Configuration/usage.txt +16 -0
- data/einvoicing-sdk/Data/Certificates/cert.pem +1 -0
- data/einvoicing-sdk/Data/Certificates/ec-secp256k1-priv-key.pem +1 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-AR-VAT-Group.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-AR.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-EN-VAT-group.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-EN.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-template.properties +9 -0
- data/einvoicing-sdk/Data/PIH/pih.txt +1 -0
- data/einvoicing-sdk/Data/Rules/schematrons/20210819_ZATCA_E-invoice_Validation_Rules.xsl +2844 -0
- data/einvoicing-sdk/Data/Rules/schematrons/CEN-EN16931-UBL.xsl +1973 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Simplified Debit Note.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Credit Note.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Debit Note.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Invoice.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Tax_Invoice_USD.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Credit/Simplified_Credit_Note.xml +300 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Credit/Simplified_Credit_Note_Error.xml +225 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Debit/Simplified_Debit_Note.xml +211 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Debit/Simplified_Debit_Note_Error.xml +226 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Additional_Simplified_Invoices/Out_Of_Scope_Simplified_Invoice.xml +207 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Additional_Simplified_Invoices/Simplified_Invoice_USD.xml +246 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Simplified_Invoice.xml +246 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Simplified_Invoice_Error.xml +228 -0
- data/einvoicing-sdk/Data/Samples/Standard/Credit/Standard_Credit_Note.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Credit/Standard_Credit_Note_Error.xml +224 -0
- data/einvoicing-sdk/Data/Samples/Standard/Debit/Standard_Debit_Note.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Debit/Standard_Debit_Note_Error.xml +226 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Exempt_Standard_Invoice.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Standard_Invoice_USD.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Zero_Rate_Standard_Invoice.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Sample Invoice[Advance Payements] - 1.xml +294 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Sample Invoice[Advance Payements] - 2.xml +432 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Standard_Invoice.xml +222 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Standard_Invoice_Error.xml +228 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/CCTS_CCT_SchemaModule-2.1.xsd +731 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonAggregateComponents-2.1.xsd +44365 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonBasicComponents-2.1.xsd +5389 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonExtensionComponents-2.1.xsd +223 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonSignatureComponents-2.1.xsd +101 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CoreComponentParameters-2.1.xsd +63 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-ExtensionContentDataType-2.1.xsd +89 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-QualifiedDataTypes-2.1.xsd +69 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-SignatureAggregateComponents-2.1.xsd +138 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-SignatureBasicComponents-2.1.xsd +78 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-UnqualifiedDataTypes-2.1.xsd +553 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-XAdESv132-2.1.xsd +476 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-XAdESv141-2.1.xsd +25 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-xmldsig-core-schema-2.1.xsd +330 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/maindoc/UBL-Invoice-2.1.xsd +1002 -0
- data/einvoicing-sdk/Dockerfile +26 -0
- data/einvoicing-sdk/LICENSE.txt +56 -0
- data/einvoicing-sdk/Lib/.Net/DLL/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/System.Net.Http.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/3f204b7a-faba-42d8-8288-8b6fe516555c.vsidx +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/f95b6f91-c110-4b7a-bb49-3fc6bde85b13.vsidx +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/read.lock +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/v17/.suo +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/App.config +14 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/CSRGeneratorOpenSSL.cs +58 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Program.cs +194 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Properties/AssemblyInfo.cs +36 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Readme.txt +8 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.csproj +120 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.exe.config +20 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.sln +25 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/certificate.txt +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/pih.txt +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/privateKey.txt +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.exe.config +20 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/System.Net.Http.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs +4 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/DesignTimeResolveAssemblyReferences.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.AssemblyReference.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.CopyComplete +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.CoreCompileInputs.cache +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.FileListAbsolute.txt +22 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.SuggestedBindingRedirects.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/Lib/.Net/Test/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.exe.config +20 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/README.md +15 -0
- data/einvoicing-sdk/Readme/readme.docx +0 -0
- data/einvoicing-sdk/Readme/readme.md +674 -0
- data/einvoicing-sdk/Readme/readme.pdf +0 -0
- data/einvoicing-sdk/Readme/~$readme.docx +0 -0
- data/einvoicing-sdk/docker-compose.yml +12 -0
- data/einvoicing-sdk/install.bat +74 -0
- data/einvoicing-sdk/install.sh +74 -0
- data/lib/zatca/client.rb +173 -0
- data/lib/zatca/hacks.rb +45 -0
- data/lib/zatca/hashing.rb +18 -0
- data/lib/zatca/qr_code_extractor.rb +31 -0
- data/lib/zatca/qr_code_generator.rb +9 -2
- data/lib/zatca/signing/certificate.rb +78 -0
- data/lib/zatca/signing/csr.rb +220 -0
- data/lib/zatca/signing/ecdsa.rb +59 -0
- data/lib/zatca/tag.rb +18 -8
- data/lib/zatca/tags.rb +5 -1
- data/lib/zatca/tags_schema.rb +5 -5
- data/lib/zatca/types.rb +7 -0
- data/lib/zatca/ubl/base_component.rb +142 -0
- data/lib/zatca/ubl/builder.rb +166 -0
- data/lib/zatca/ubl/common_aggregate_components/allowance_charge.rb +64 -0
- data/lib/zatca/ubl/common_aggregate_components/classified_tax_category.rb +25 -0
- data/lib/zatca/ubl/common_aggregate_components/delivery.rb +27 -0
- data/lib/zatca/ubl/common_aggregate_components/invoice_line.rb +63 -0
- data/lib/zatca/ubl/common_aggregate_components/item.rb +21 -0
- data/lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb +59 -0
- data/lib/zatca/ubl/common_aggregate_components/party.rb +28 -0
- data/lib/zatca/ubl/common_aggregate_components/party_identification.rb +25 -0
- data/lib/zatca/ubl/common_aggregate_components/party_legal_entity.rb +19 -0
- data/lib/zatca/ubl/common_aggregate_components/party_tax_scheme.rb +30 -0
- data/lib/zatca/ubl/common_aggregate_components/postal_address.rb +59 -0
- data/lib/zatca/ubl/common_aggregate_components/price.rb +20 -0
- data/lib/zatca/ubl/common_aggregate_components/tax_category.rb +56 -0
- data/lib/zatca/ubl/common_aggregate_components/tax_total.rb +58 -0
- data/lib/zatca/ubl/common_aggregate_components.rb +2 -0
- data/lib/zatca/ubl/invoice.rb +481 -0
- data/lib/zatca/ubl/invoice_subtype_builder.rb +50 -0
- data/lib/zatca/ubl/signing/cert.rb +48 -0
- data/lib/zatca/ubl/signing/invoice_signed_data_reference.rb +44 -0
- data/lib/zatca/ubl/signing/key_info.rb +25 -0
- data/lib/zatca/ubl/signing/object.rb +20 -0
- data/lib/zatca/ubl/signing/qualifying_properties.rb +27 -0
- data/lib/zatca/ubl/signing/signature.rb +50 -0
- data/lib/zatca/ubl/signing/signature_information.rb +19 -0
- data/lib/zatca/ubl/signing/signature_properties_reference.rb +26 -0
- data/lib/zatca/ubl/signing/signed_info.rb +21 -0
- data/lib/zatca/ubl/signing/signed_properties.rb +81 -0
- data/lib/zatca/ubl/signing/signed_signature_properties.rb +23 -0
- data/lib/zatca/ubl/signing/ubl_document_signatures.rb +25 -0
- data/lib/zatca/ubl/signing/ubl_extension.rb +22 -0
- data/lib/zatca/ubl/signing/ubl_extensions.rb +17 -0
- data/lib/zatca/ubl/signing.rb +2 -0
- data/lib/zatca/ubl.rb +2 -0
- data/lib/zatca/version.rb +1 -1
- data/lib/zatca.rb +27 -3
- data/zatca.gemspec +52 -0
- metadata +318 -10
- data/Gemfile.lock +0 -100
@@ -0,0 +1,64 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::AllowanceCharge < ZATCA::UBL::BaseComponent
|
2
|
+
attr_accessor :id, :charge_indicator, :allowance_charge_reason, :amount
|
3
|
+
|
4
|
+
# <cac:AllowanceCharge>
|
5
|
+
# <cbc:ID>1</cbc:ID>
|
6
|
+
# <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
|
7
|
+
# <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
|
8
|
+
# <cbc:Amount currencyID="SAR">2</cbc:Amount>
|
9
|
+
# <cac:TaxCategory>
|
10
|
+
# <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
|
11
|
+
# <cbc:Percent>15</cbc:Percent>
|
12
|
+
# <cac:TaxScheme>
|
13
|
+
# <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
|
14
|
+
# </cac:TaxScheme>
|
15
|
+
# </cac:TaxCategory>
|
16
|
+
# </cac:AllowanceCharge>
|
17
|
+
|
18
|
+
def initialize(
|
19
|
+
charge_indicator:, allowance_charge_reason:, amount:, currency_id: "SAR",
|
20
|
+
tax_category: nil, add_tax_category: true, add_id: true, tax_categories: []
|
21
|
+
)
|
22
|
+
super()
|
23
|
+
|
24
|
+
@charge_indicator = charge_indicator.to_s
|
25
|
+
|
26
|
+
@allowance_charge_reason = allowance_charge_reason
|
27
|
+
@amount = amount
|
28
|
+
@currency_id = currency_id
|
29
|
+
|
30
|
+
@add_tax_category = add_tax_category
|
31
|
+
@tax_category = tax_category
|
32
|
+
@add_id = add_id
|
33
|
+
|
34
|
+
if add_tax_category && @tax_category.blank?
|
35
|
+
@tax_category = ZATCA::UBL::CommonAggregateComponents::TaxCategory.new
|
36
|
+
end
|
37
|
+
|
38
|
+
@tax_categories = if @tax_category.present? && tax_categories.blank?
|
39
|
+
[@tax_category]
|
40
|
+
else
|
41
|
+
tax_categories
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def name
|
46
|
+
"cac:AllowanceCharge"
|
47
|
+
end
|
48
|
+
|
49
|
+
def id_element
|
50
|
+
if @add_id && index.present?
|
51
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: index)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def elements
|
56
|
+
[
|
57
|
+
id_element,
|
58
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ChargeIndicator", value: @charge_indicator),
|
59
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:AllowanceChargeReason", value: @allowance_charge_reason),
|
60
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:Amount", value: @amount, attributes: {"currencyID" => @currency_id}),
|
61
|
+
*@tax_categories
|
62
|
+
]
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::ClassifiedTaxCategory < ZATCA::UBL::BaseComponent
|
2
|
+
attr_reader :scheme_id, :id
|
3
|
+
|
4
|
+
def initialize(id: "S", percent: "15.00", tax_scheme_id: "VAT")
|
5
|
+
super()
|
6
|
+
|
7
|
+
@id = id
|
8
|
+
@percent = percent
|
9
|
+
@tax_scheme_id = tax_scheme_id
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
"cac:ClassifiedTaxCategory"
|
14
|
+
end
|
15
|
+
|
16
|
+
def elements
|
17
|
+
[
|
18
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @id),
|
19
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:Percent", value: @percent),
|
20
|
+
ZATCA::UBL::BaseComponent.new(name: "cac:TaxScheme", elements: [
|
21
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @tax_scheme_id)
|
22
|
+
])
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::Delivery < ZATCA::UBL::BaseComponent
|
2
|
+
attr_reader :scheme_id, :id
|
3
|
+
|
4
|
+
def initialize(actual_delivery_date:, latest_delivery_date: nil)
|
5
|
+
super()
|
6
|
+
|
7
|
+
@latest_delivery_date = latest_delivery_date
|
8
|
+
@actual_delivery_date = actual_delivery_date
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
"cac:Delivery"
|
13
|
+
end
|
14
|
+
|
15
|
+
def latest_delivery_date_element
|
16
|
+
return nil if @latest_delivery_date.nil?
|
17
|
+
|
18
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:LatestDeliveryDate", value: @latest_delivery_date)
|
19
|
+
end
|
20
|
+
|
21
|
+
def elements
|
22
|
+
[
|
23
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ActualDeliveryDate", value: @actual_delivery_date),
|
24
|
+
latest_delivery_date_element
|
25
|
+
]
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::InvoiceLine < ZATCA::UBL::BaseComponent
|
2
|
+
# <cac:InvoiceLine>
|
3
|
+
# <cbc:ID>1</cbc:ID>
|
4
|
+
# <cbc:InvoicedQuantity unitCode="PCE">44.000000</cbc:InvoicedQuantity>
|
5
|
+
# <cbc:LineExtensionAmount currencyID="SAR">966.00</cbc:LineExtensionAmount>
|
6
|
+
# <cac:TaxTotal>
|
7
|
+
# <cbc:TaxAmount currencyID="SAR">144.90</cbc:TaxAmount>
|
8
|
+
# <cbc:RoundingAmount currencyID="SAR">1110.90</cbc:RoundingAmount>
|
9
|
+
|
10
|
+
# </cac:TaxTotal>
|
11
|
+
# <cac:Item>
|
12
|
+
# <cbc:Name>dsd</cbc:Name>
|
13
|
+
# <cac:ClassifiedTaxCategory>
|
14
|
+
# <cbc:ID>S</cbc:ID>
|
15
|
+
# <cbc:Percent>15.00</cbc:Percent>
|
16
|
+
# <cac:TaxScheme>
|
17
|
+
# <cbc:ID>VAT</cbc:ID>
|
18
|
+
# </cac:TaxScheme>
|
19
|
+
# </cac:ClassifiedTaxCategory>
|
20
|
+
# </cac:Item>
|
21
|
+
# <cac:Price>
|
22
|
+
# <cbc:PriceAmount currencyID="SAR">22.00</cbc:PriceAmount>
|
23
|
+
# <cac:AllowanceCharge>
|
24
|
+
# <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
|
25
|
+
# <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
|
26
|
+
# <cbc:Amount currencyID="SAR">2.00</cbc:Amount>
|
27
|
+
# </cac:AllowanceCharge>
|
28
|
+
# </cac:Price>
|
29
|
+
# </cac:InvoiceLine>
|
30
|
+
|
31
|
+
def initialize(
|
32
|
+
invoiced_quantity:, invoiced_quantity_unit_code:,
|
33
|
+
line_extension_amount:, tax_total:, item:,
|
34
|
+
price:, allowance_charge: nil, currency_id: "SAR"
|
35
|
+
)
|
36
|
+
super()
|
37
|
+
|
38
|
+
@invoiced_quantity = invoiced_quantity
|
39
|
+
@invoiced_quantity_unit_code = invoiced_quantity_unit_code
|
40
|
+
@line_extension_amount = line_extension_amount
|
41
|
+
@tax_total = tax_total
|
42
|
+
@item = item
|
43
|
+
@price = price
|
44
|
+
@allowance_charge = allowance_charge
|
45
|
+
@currency_id = currency_id
|
46
|
+
end
|
47
|
+
|
48
|
+
def name
|
49
|
+
"cac:InvoiceLine"
|
50
|
+
end
|
51
|
+
|
52
|
+
def elements
|
53
|
+
[
|
54
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: index),
|
55
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:InvoicedQuantity", value: @invoiced_quantity, attributes: {unitCode: @invoiced_quantity_unit_code}),
|
56
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:LineExtensionAmount", value: @line_extension_amount, attributes: {currencyID: @currency_id}),
|
57
|
+
@tax_total,
|
58
|
+
@item,
|
59
|
+
@price,
|
60
|
+
@allowance_charge
|
61
|
+
]
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::Item < ZATCA::UBL::BaseComponent
|
2
|
+
attr_reader :scheme_id, :id
|
3
|
+
|
4
|
+
def initialize(name:, classified_tax_category: nil)
|
5
|
+
super()
|
6
|
+
|
7
|
+
@name = name
|
8
|
+
@classified_tax_category = classified_tax_category || ZATCA::UBL::CommonAggregateComponents::ClassifiedTaxCategory.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
"cac:Item"
|
13
|
+
end
|
14
|
+
|
15
|
+
def elements
|
16
|
+
[
|
17
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:Name", value: @name),
|
18
|
+
@classified_tax_category
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::LegalMonetaryTotal < ZATCA::UBL::BaseComponent
|
2
|
+
attr_reader :line_extension_amount, :tax_exclusive_amount,
|
3
|
+
:tax_inclusive_amount, :allowance_total_amount, :prepaid_amount,
|
4
|
+
:payable_amount, :currency_id
|
5
|
+
|
6
|
+
# <cac:LegalMonetaryTotal>
|
7
|
+
# <cbc:LineExtensionAmount currencyID="SAR">966.00</cbc:LineExtensionAmount>
|
8
|
+
# <cbc:TaxExclusiveAmount currencyID="SAR">964.00</cbc:TaxExclusiveAmount>
|
9
|
+
# <cbc:TaxInclusiveAmount currencyID="SAR">1108.90</cbc:TaxInclusiveAmount>
|
10
|
+
# <cbc:AllowanceTotalAmount currencyID="SAR">2.00</cbc:AllowanceTotalAmount>
|
11
|
+
# <cbc:PrepaidAmount currencyID="SAR">0.00</cbc:PrepaidAmount>
|
12
|
+
# <cbc:PayableAmount currencyID="SAR">1108.90</cbc:PayableAmount>
|
13
|
+
# </cac:LegalMonetaryTotal>
|
14
|
+
|
15
|
+
def initialize(
|
16
|
+
line_extension_amount:,
|
17
|
+
tax_exclusive_amount:,
|
18
|
+
tax_inclusive_amount:,
|
19
|
+
allowance_total_amount:,
|
20
|
+
prepaid_amount: nil,
|
21
|
+
payable_amount: nil,
|
22
|
+
currency_id: "SAR"
|
23
|
+
)
|
24
|
+
@line_extension_amount = line_extension_amount
|
25
|
+
@tax_exclusive_amount = tax_exclusive_amount
|
26
|
+
@tax_inclusive_amount = tax_inclusive_amount
|
27
|
+
@allowance_total_amount = allowance_total_amount
|
28
|
+
@prepaid_amount = prepaid_amount
|
29
|
+
@payable_amount = payable_amount
|
30
|
+
@currency_id = currency_id
|
31
|
+
end
|
32
|
+
|
33
|
+
def name
|
34
|
+
"cac:LegalMonetaryTotal"
|
35
|
+
end
|
36
|
+
|
37
|
+
def prepaid_amount_element
|
38
|
+
return nil if @prepaid_amount.blank?
|
39
|
+
|
40
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:PrepaidAmount", value: @prepaid_amount, attributes: {"currencyID" => @currency_id})
|
41
|
+
end
|
42
|
+
|
43
|
+
def payable_amount_element
|
44
|
+
return nil if @payable_amount.blank?
|
45
|
+
|
46
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:PayableAmount", value: @payable_amount, attributes: {"currencyID" => @currency_id})
|
47
|
+
end
|
48
|
+
|
49
|
+
def elements
|
50
|
+
[
|
51
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:LineExtensionAmount", value: @line_extension_amount, attributes: {"currencyID" => @currency_id}),
|
52
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:TaxExclusiveAmount", value: @tax_exclusive_amount, attributes: {"currencyID" => @currency_id}),
|
53
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:TaxInclusiveAmount", value: @tax_inclusive_amount, attributes: {"currencyID" => @currency_id}),
|
54
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:AllowanceTotalAmount", value: @allowance_total_amount, attributes: {"currencyID" => @currency_id}),
|
55
|
+
prepaid_amount_element,
|
56
|
+
payable_amount_element
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::Party < ZATCA::UBL::BaseComponent
|
2
|
+
# Has:
|
3
|
+
# PartyIdentification
|
4
|
+
# PostalAddress
|
5
|
+
# PartyTaxScheme
|
6
|
+
# PartyLegalEntity
|
7
|
+
def initialize(party_identification:, postal_address:, party_tax_scheme:, party_legal_entity:)
|
8
|
+
super()
|
9
|
+
|
10
|
+
@party_identification = party_identification
|
11
|
+
@postal_address = postal_address
|
12
|
+
@party_tax_scheme = party_tax_scheme
|
13
|
+
@party_legal_entity = party_legal_entity
|
14
|
+
end
|
15
|
+
|
16
|
+
def name
|
17
|
+
"cac:Party"
|
18
|
+
end
|
19
|
+
|
20
|
+
def elements
|
21
|
+
[
|
22
|
+
@party_identification,
|
23
|
+
@postal_address,
|
24
|
+
@party_tax_scheme,
|
25
|
+
@party_legal_entity
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::PartyIdentification < ZATCA::UBL::BaseComponent
|
2
|
+
attr_reader :scheme_id, :id
|
3
|
+
|
4
|
+
SCHEMA = Dry::Schema.Params do
|
5
|
+
required(:id).filled(:string)
|
6
|
+
required(:scheme_id).filled(:string)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(id:, scheme_id: "CRN")
|
10
|
+
super()
|
11
|
+
|
12
|
+
@id = id
|
13
|
+
@scheme_id = scheme_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def name
|
17
|
+
"cac:PartyIdentification"
|
18
|
+
end
|
19
|
+
|
20
|
+
def elements
|
21
|
+
[
|
22
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @id, attributes: {"schemeID" => @scheme_id})
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::PartyLegalEntity < ZATCA::UBL::BaseComponent
|
2
|
+
attr_reader :scheme_id, :id
|
3
|
+
|
4
|
+
def initialize(registration_name:)
|
5
|
+
super()
|
6
|
+
|
7
|
+
@registration_name = registration_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
"cac:PartyLegalEntity"
|
12
|
+
end
|
13
|
+
|
14
|
+
def elements
|
15
|
+
[
|
16
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:RegistrationName", value: @registration_name)
|
17
|
+
]
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::PartyTaxScheme < ZATCA::UBL::BaseComponent
|
2
|
+
def initialize(
|
3
|
+
company_id: nil,
|
4
|
+
tax_scheme_id: "VAT"
|
5
|
+
)
|
6
|
+
super()
|
7
|
+
|
8
|
+
@company_id = company_id
|
9
|
+
@tax_scheme_id = tax_scheme_id
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
"cac:PartyTaxScheme"
|
14
|
+
end
|
15
|
+
|
16
|
+
def company_id_element
|
17
|
+
return nil if @company_id.blank?
|
18
|
+
|
19
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:CompanyID", value: @company_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def elements
|
23
|
+
[
|
24
|
+
company_id_element,
|
25
|
+
ZATCA::UBL::BaseComponent.new(name: "cac:TaxScheme", elements: [
|
26
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @tax_scheme_id)
|
27
|
+
])
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::PostalAddress < ZATCA::UBL::BaseComponent
|
2
|
+
attr_accessor :street_name,
|
3
|
+
:additional_street_name,
|
4
|
+
:building_number,
|
5
|
+
:plot_identification,
|
6
|
+
:city_subdivision_name,
|
7
|
+
:city_name,
|
8
|
+
:postal_zone,
|
9
|
+
:country_subentity,
|
10
|
+
:country
|
11
|
+
|
12
|
+
SCHEMA = Dry::Schema.Params do
|
13
|
+
required(:street_name).filled(:string)
|
14
|
+
required(:additional_street_name).filled(:string)
|
15
|
+
required(:building_number).filled(:string)
|
16
|
+
required(:plot_identification).filled(:string)
|
17
|
+
required(:city_subdivision_name).filled(:string)
|
18
|
+
required(:city_name).filled(:string)
|
19
|
+
required(:postal_zone).filled(:string)
|
20
|
+
required(:country_subentity).filled(:string)
|
21
|
+
required(:country_identification_code).filled(:string)
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(
|
25
|
+
street_name:, building_number:, plot_identification:,
|
26
|
+
city_subdivision_name:, city_name:, postal_zone:, country_subentity:,
|
27
|
+
additional_street_name: nil, country_identification_code: "SA"
|
28
|
+
)
|
29
|
+
@street_name = street_name
|
30
|
+
@additional_street_name = additional_street_name
|
31
|
+
@building_number = building_number
|
32
|
+
@plot_identification = plot_identification
|
33
|
+
@city_subdivision_name = city_subdivision_name
|
34
|
+
@city_name = city_name
|
35
|
+
@postal_zone = postal_zone
|
36
|
+
@country_subentity = country_subentity
|
37
|
+
@country_identification_code = country_identification_code
|
38
|
+
end
|
39
|
+
|
40
|
+
def name
|
41
|
+
"cac:PostalAddress"
|
42
|
+
end
|
43
|
+
|
44
|
+
def elements
|
45
|
+
[
|
46
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:StreetName", value: @street_name),
|
47
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:AdditionalStreetName", value: @additional_street_name),
|
48
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:BuildingNumber", value: @building_number),
|
49
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:PlotIdentification", value: @plot_identification),
|
50
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:CitySubdivisionName", value: @city_subdivision_name),
|
51
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:CityName", value: @city_name),
|
52
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:PostalZone", value: @postal_zone),
|
53
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:CountrySubentity", value: @country_subentity),
|
54
|
+
ZATCA::UBL::BaseComponent.build(name: "cac:Country", elements: [
|
55
|
+
ZATCA::UBL::BaseComponent.build(name: "cbc:IdentificationCode", value: @country_identification_code)
|
56
|
+
])
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::Price < ZATCA::UBL::BaseComponent
|
2
|
+
def initialize(price_amount:, allowance_charge: nil, currency_id: "SAR")
|
3
|
+
super()
|
4
|
+
|
5
|
+
@price_amount = price_amount
|
6
|
+
@allowance_charge = allowance_charge
|
7
|
+
@currency_id = currency_id
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
"cac:Price"
|
12
|
+
end
|
13
|
+
|
14
|
+
def elements
|
15
|
+
[
|
16
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:PriceAmount", value: @price_amount, attributes: {currencyID: @currency_id}),
|
17
|
+
@allowance_charge
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::TaxCategory < ZATCA::UBL::BaseComponent
|
2
|
+
attr_reader :id, :percent
|
3
|
+
|
4
|
+
# <cac:TaxCategory>
|
5
|
+
# <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
|
6
|
+
# <cbc:Percent>15.00</cbc:Percent>
|
7
|
+
# <cac:TaxScheme>
|
8
|
+
# <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
|
9
|
+
# </cac:TaxScheme>
|
10
|
+
# </cac:TaxCategory>
|
11
|
+
# <cac:TaxCategory>
|
12
|
+
# <cbc:ID>O</cbc:ID>
|
13
|
+
# <cbc:TaxExemptionReasonCode>VATEX-EU-O</cbc:TaxExemptionReasonCode>
|
14
|
+
# <cac:TaxScheme>
|
15
|
+
# <cbc:ID>VAT</cbc:ID>
|
16
|
+
# </cac:TaxScheme>
|
17
|
+
# </cac:TaxCategory>
|
18
|
+
def initialize(
|
19
|
+
tax_percent: "15.00", id: "S", scheme_agency_id: "6",
|
20
|
+
scheme_id: "UN/ECE 5305", tax_scheme_id: "VAT",
|
21
|
+
tax_scheme_scheme_id: "UN/ECE 5153", tax_exemption_reason_code: nil
|
22
|
+
)
|
23
|
+
super()
|
24
|
+
|
25
|
+
@tax_percent = tax_percent
|
26
|
+
@id = id
|
27
|
+
@scheme_agency_id = scheme_agency_id
|
28
|
+
@scheme_id = scheme_id
|
29
|
+
@tax_scheme_id = tax_scheme_id
|
30
|
+
@tax_scheme_scheme_id = tax_scheme_scheme_id
|
31
|
+
@tax_exemption_reason_code = tax_exemption_reason_code
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
"cac:TaxCategory"
|
36
|
+
end
|
37
|
+
|
38
|
+
def elements
|
39
|
+
[
|
40
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @id, attributes: {"schemeAgencyID" => @scheme_agency_id, "schemeID" => @scheme_id}.compact),
|
41
|
+
tax_exemption_reason_code_element,
|
42
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:Percent", value: @tax_percent),
|
43
|
+
ZATCA::UBL::BaseComponent.new(name: "cac:TaxScheme", elements: [
|
44
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: @tax_scheme_id, attributes: {"schemeAgencyID" => @scheme_agency_id, "schemeID" => @tax_scheme_scheme_id}.compact)
|
45
|
+
])
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def tax_exemption_reason_code_element
|
52
|
+
if @tax_exemption_reason_code.present?
|
53
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:TaxExemptionReasonCode", value: @tax_exemption_reason_code)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class ZATCA::UBL::CommonAggregateComponents::TaxTotal < ZATCA::UBL::BaseComponent
|
2
|
+
# <cac:TaxTotal>
|
3
|
+
# <cbc:TaxAmount currencyID="SAR">144.9</cbc:TaxAmount>
|
4
|
+
# <cac:TaxSubtotal>
|
5
|
+
# <cbc:TaxableAmount currencyID="SAR">966.00</cbc:TaxableAmount>
|
6
|
+
# <cbc:TaxAmount currencyID="SAR">144.90</cbc:TaxAmount>
|
7
|
+
# <cac:TaxCategory>
|
8
|
+
# <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
|
9
|
+
# <cbc:Percent>15.00</cbc:Percent>
|
10
|
+
# <cac:TaxScheme>
|
11
|
+
# <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
|
12
|
+
# </cac:TaxScheme>
|
13
|
+
# </cac:TaxCategory>
|
14
|
+
# </cac:TaxSubtotal>
|
15
|
+
# </cac:TaxTotal>
|
16
|
+
|
17
|
+
def initialize(
|
18
|
+
tax_amount:, tax_subtotal_amount: nil, taxable_amount: nil,
|
19
|
+
rounding_amount: nil, tax_category: nil, currency_id: "SAR"
|
20
|
+
)
|
21
|
+
super()
|
22
|
+
|
23
|
+
@tax_amount = tax_amount
|
24
|
+
@tax_subtotal_amount = tax_subtotal_amount
|
25
|
+
@taxable_amount = taxable_amount
|
26
|
+
@rounding_amount = rounding_amount
|
27
|
+
@tax_category = tax_category || ZATCA::UBL::CommonAggregateComponents::TaxCategory.new
|
28
|
+
@currency_id = currency_id
|
29
|
+
end
|
30
|
+
|
31
|
+
def name
|
32
|
+
"cac:TaxTotal"
|
33
|
+
end
|
34
|
+
|
35
|
+
def tax_subtotal_element
|
36
|
+
if @taxable_amount.present? && @tax_subtotal_amount.present? && @tax_category.present?
|
37
|
+
ZATCA::UBL::BaseComponent.new(name: "cac:TaxSubtotal", elements: [
|
38
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:TaxableAmount", value: @taxable_amount, attributes: {"currencyID" => @currency_id}),
|
39
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:TaxAmount", value: @tax_subtotal_amount, attributes: {"currencyID" => @currency_id}),
|
40
|
+
@tax_category
|
41
|
+
])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def rounding_amount_element
|
46
|
+
if @rounding_amount.present?
|
47
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:RoundingAmount", value: @rounding_amount, attributes: {"currencyID" => @currency_id})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def elements
|
52
|
+
[
|
53
|
+
ZATCA::UBL::BaseComponent.new(name: "cbc:TaxAmount", value: @tax_amount, attributes: {"currencyID" => @currency_id}),
|
54
|
+
rounding_amount_element,
|
55
|
+
tax_subtotal_element
|
56
|
+
]
|
57
|
+
end
|
58
|
+
end
|