zatca 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -2
  3. data/bin/console +0 -0
  4. data/bin/setup +0 -0
  5. data/einvoicing-sdk/Apps/fatoora +12 -0
  6. data/einvoicing-sdk/Apps/fatoora.bat +16 -0
  7. data/einvoicing-sdk/Apps/global.json +1 -0
  8. data/einvoicing-sdk/Apps/jq.exe +0 -0
  9. data/einvoicing-sdk/Apps/zatca-einvoicing-sdk-238-R3.2.7.jar +0 -0
  10. data/einvoicing-sdk/Configuration/config.json +11 -0
  11. data/einvoicing-sdk/Configuration/defaults.json +11 -0
  12. data/einvoicing-sdk/Configuration/jq.exe +0 -0
  13. data/einvoicing-sdk/Configuration/usage.txt +16 -0
  14. data/einvoicing-sdk/Data/Certificates/cert.pem +1 -0
  15. data/einvoicing-sdk/Data/Certificates/ec-secp256k1-priv-key.pem +1 -0
  16. data/einvoicing-sdk/Data/Input/csr-config-example-AR-VAT-Group.properties +9 -0
  17. data/einvoicing-sdk/Data/Input/csr-config-example-AR.properties +9 -0
  18. data/einvoicing-sdk/Data/Input/csr-config-example-EN-VAT-group.properties +9 -0
  19. data/einvoicing-sdk/Data/Input/csr-config-example-EN.properties +9 -0
  20. data/einvoicing-sdk/Data/Input/csr-config-template.properties +9 -0
  21. data/einvoicing-sdk/Data/PIH/pih.txt +1 -0
  22. data/einvoicing-sdk/Data/Rules/schematrons/20210819_ZATCA_E-invoice_Validation_Rules.xsl +2844 -0
  23. data/einvoicing-sdk/Data/Rules/schematrons/CEN-EN16931-UBL.xsl +1973 -0
  24. data/einvoicing-sdk/Data/Samples/PDF-A3/Simplified Debit Note.pdf +0 -0
  25. data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Credit Note.pdf +0 -0
  26. data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Debit Note.pdf +0 -0
  27. data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Invoice.pdf +0 -0
  28. data/einvoicing-sdk/Data/Samples/PDF-A3/Tax_Invoice_USD.pdf +0 -0
  29. data/einvoicing-sdk/Data/Samples/Simplified/Credit/Simplified_Credit_Note.xml +300 -0
  30. data/einvoicing-sdk/Data/Samples/Simplified/Credit/Simplified_Credit_Note_Error.xml +225 -0
  31. data/einvoicing-sdk/Data/Samples/Simplified/Debit/Simplified_Debit_Note.xml +211 -0
  32. data/einvoicing-sdk/Data/Samples/Simplified/Debit/Simplified_Debit_Note_Error.xml +226 -0
  33. data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Additional_Simplified_Invoices/Out_Of_Scope_Simplified_Invoice.xml +207 -0
  34. data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Additional_Simplified_Invoices/Simplified_Invoice_USD.xml +246 -0
  35. data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Simplified_Invoice.xml +246 -0
  36. data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Simplified_Invoice_Error.xml +228 -0
  37. data/einvoicing-sdk/Data/Samples/Standard/Credit/Standard_Credit_Note.xml +227 -0
  38. data/einvoicing-sdk/Data/Samples/Standard/Credit/Standard_Credit_Note_Error.xml +224 -0
  39. data/einvoicing-sdk/Data/Samples/Standard/Debit/Standard_Debit_Note.xml +227 -0
  40. data/einvoicing-sdk/Data/Samples/Standard/Debit/Standard_Debit_Note_Error.xml +226 -0
  41. data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Exempt_Standard_Invoice.xml +227 -0
  42. data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Standard_Invoice_USD.xml +227 -0
  43. data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Zero_Rate_Standard_Invoice.xml +227 -0
  44. data/einvoicing-sdk/Data/Samples/Standard/Invoice/Sample Invoice[Advance Payements] - 1.xml +294 -0
  45. data/einvoicing-sdk/Data/Samples/Standard/Invoice/Sample Invoice[Advance Payements] - 2.xml +432 -0
  46. data/einvoicing-sdk/Data/Samples/Standard/Invoice/Standard_Invoice.xml +222 -0
  47. data/einvoicing-sdk/Data/Samples/Standard/Invoice/Standard_Invoice_Error.xml +228 -0
  48. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/CCTS_CCT_SchemaModule-2.1.xsd +731 -0
  49. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonAggregateComponents-2.1.xsd +44365 -0
  50. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonBasicComponents-2.1.xsd +5389 -0
  51. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonExtensionComponents-2.1.xsd +223 -0
  52. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonSignatureComponents-2.1.xsd +101 -0
  53. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CoreComponentParameters-2.1.xsd +63 -0
  54. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-ExtensionContentDataType-2.1.xsd +89 -0
  55. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-QualifiedDataTypes-2.1.xsd +69 -0
  56. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-SignatureAggregateComponents-2.1.xsd +138 -0
  57. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-SignatureBasicComponents-2.1.xsd +78 -0
  58. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-UnqualifiedDataTypes-2.1.xsd +553 -0
  59. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-XAdESv132-2.1.xsd +476 -0
  60. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-XAdESv141-2.1.xsd +25 -0
  61. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-xmldsig-core-schema-2.1.xsd +330 -0
  62. data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/maindoc/UBL-Invoice-2.1.xsd +1002 -0
  63. data/einvoicing-sdk/Dockerfile +26 -0
  64. data/einvoicing-sdk/LICENSE.txt +56 -0
  65. data/einvoicing-sdk/Lib/.Net/DLL/BouncyCastle.Crypto.dll +0 -0
  66. data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Core.dll +0 -0
  67. data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Text.dll +0 -0
  68. data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Util.dll +0 -0
  69. data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.XML.API.dll +0 -0
  70. data/einvoicing-sdk/Lib/.Net/DLL/IKVM.Runtime.dll +0 -0
  71. data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.dll +0 -0
  72. data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.dll.config +43 -0
  73. data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.pdb +0 -0
  74. data/einvoicing-sdk/Lib/.Net/DLL/System.Net.Http.dll +0 -0
  75. data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-10.8.dll +0 -0
  76. data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-api-10.8.dll +0 -0
  77. data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-api-10.8.xml +11759 -0
  78. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/3f204b7a-faba-42d8-8288-8b6fe516555c.vsidx +0 -0
  79. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/f95b6f91-c110-4b7a-bb49-3fc6bde85b13.vsidx +0 -0
  80. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/read.lock +0 -0
  81. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/v17/.suo +0 -0
  82. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/App.config +14 -0
  83. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/BouncyCastle.Crypto.dll +0 -0
  84. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/CSRGeneratorOpenSSL.cs +58 -0
  85. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Core.dll +0 -0
  86. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Text.dll +0 -0
  87. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Util.dll +0 -0
  88. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.XML.API.dll +0 -0
  89. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.Runtime.dll +0 -0
  90. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Program.cs +194 -0
  91. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Properties/AssemblyInfo.cs +36 -0
  92. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Readme.txt +8 -0
  93. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.dll +0 -0
  94. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.dll.config +43 -0
  95. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.pdb +0 -0
  96. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.csproj +120 -0
  97. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.exe +0 -0
  98. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.exe.config +20 -0
  99. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.pdb +0 -0
  100. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.sln +25 -0
  101. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/BouncyCastle.Crypto.dll +0 -0
  102. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/certificate.txt +1 -0
  103. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/pih.txt +1 -0
  104. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/privateKey.txt +1 -0
  105. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Core.dll +0 -0
  106. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Text.dll +0 -0
  107. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Util.dll +0 -0
  108. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.XML.API.dll +0 -0
  109. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.Runtime.dll +0 -0
  110. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.dll +0 -0
  111. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.dll.config +43 -0
  112. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.pdb +0 -0
  113. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.exe +0 -0
  114. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.exe.config +20 -0
  115. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.pdb +0 -0
  116. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/System.Net.Http.dll +0 -0
  117. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-10.8.dll +0 -0
  118. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-api-10.8.dll +0 -0
  119. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-api-10.8.xml +11759 -0
  120. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs +4 -0
  121. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/DesignTimeResolveAssemblyReferences.cache +0 -0
  122. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
  123. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.AssemblyReference.cache +0 -0
  124. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.CopyComplete +0 -0
  125. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.CoreCompileInputs.cache +1 -0
  126. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.FileListAbsolute.txt +22 -0
  127. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.SuggestedBindingRedirects.cache +0 -0
  128. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.exe +0 -0
  129. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.pdb +0 -0
  130. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-10.8.dll +0 -0
  131. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-api-10.8.dll +0 -0
  132. data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-api-10.8.xml +11759 -0
  133. data/einvoicing-sdk/Lib/.Net/Test/BouncyCastle.Crypto.dll +0 -0
  134. data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Core.dll +0 -0
  135. data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Text.dll +0 -0
  136. data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Util.dll +0 -0
  137. data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.XML.API.dll +0 -0
  138. data/einvoicing-sdk/Lib/.Net/Test/IKVM.Runtime.dll +0 -0
  139. data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.dll +0 -0
  140. data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.dll.config +43 -0
  141. data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.pdb +0 -0
  142. data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.exe +0 -0
  143. data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.exe.config +20 -0
  144. data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.pdb +0 -0
  145. data/einvoicing-sdk/Lib/.Net/Test/saxon-he-10.8.dll +0 -0
  146. data/einvoicing-sdk/Lib/.Net/Test/saxon-he-api-10.8.dll +0 -0
  147. data/einvoicing-sdk/Lib/.Net/Test/saxon-he-api-10.8.xml +11759 -0
  148. data/einvoicing-sdk/README.md +15 -0
  149. data/einvoicing-sdk/Readme/readme.docx +0 -0
  150. data/einvoicing-sdk/Readme/readme.md +674 -0
  151. data/einvoicing-sdk/Readme/readme.pdf +0 -0
  152. data/einvoicing-sdk/Readme/~$readme.docx +0 -0
  153. data/einvoicing-sdk/docker-compose.yml +12 -0
  154. data/einvoicing-sdk/install.bat +74 -0
  155. data/einvoicing-sdk/install.sh +74 -0
  156. data/lib/zatca/client.rb +173 -0
  157. data/lib/zatca/hacks.rb +45 -0
  158. data/lib/zatca/hashing.rb +18 -0
  159. data/lib/zatca/qr_code_extractor.rb +31 -0
  160. data/lib/zatca/qr_code_generator.rb +9 -2
  161. data/lib/zatca/signing/certificate.rb +78 -0
  162. data/lib/zatca/signing/csr.rb +220 -0
  163. data/lib/zatca/signing/ecdsa.rb +59 -0
  164. data/lib/zatca/tag.rb +18 -8
  165. data/lib/zatca/tags.rb +5 -1
  166. data/lib/zatca/tags_schema.rb +5 -5
  167. data/lib/zatca/types.rb +7 -0
  168. data/lib/zatca/ubl/base_component.rb +142 -0
  169. data/lib/zatca/ubl/builder.rb +166 -0
  170. data/lib/zatca/ubl/common_aggregate_components/allowance_charge.rb +64 -0
  171. data/lib/zatca/ubl/common_aggregate_components/classified_tax_category.rb +25 -0
  172. data/lib/zatca/ubl/common_aggregate_components/delivery.rb +27 -0
  173. data/lib/zatca/ubl/common_aggregate_components/invoice_line.rb +63 -0
  174. data/lib/zatca/ubl/common_aggregate_components/item.rb +21 -0
  175. data/lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb +59 -0
  176. data/lib/zatca/ubl/common_aggregate_components/party.rb +28 -0
  177. data/lib/zatca/ubl/common_aggregate_components/party_identification.rb +25 -0
  178. data/lib/zatca/ubl/common_aggregate_components/party_legal_entity.rb +19 -0
  179. data/lib/zatca/ubl/common_aggregate_components/party_tax_scheme.rb +30 -0
  180. data/lib/zatca/ubl/common_aggregate_components/postal_address.rb +59 -0
  181. data/lib/zatca/ubl/common_aggregate_components/price.rb +20 -0
  182. data/lib/zatca/ubl/common_aggregate_components/tax_category.rb +56 -0
  183. data/lib/zatca/ubl/common_aggregate_components/tax_total.rb +58 -0
  184. data/lib/zatca/ubl/common_aggregate_components.rb +2 -0
  185. data/lib/zatca/ubl/invoice.rb +481 -0
  186. data/lib/zatca/ubl/invoice_subtype_builder.rb +50 -0
  187. data/lib/zatca/ubl/signing/cert.rb +48 -0
  188. data/lib/zatca/ubl/signing/invoice_signed_data_reference.rb +44 -0
  189. data/lib/zatca/ubl/signing/key_info.rb +25 -0
  190. data/lib/zatca/ubl/signing/object.rb +20 -0
  191. data/lib/zatca/ubl/signing/qualifying_properties.rb +27 -0
  192. data/lib/zatca/ubl/signing/signature.rb +50 -0
  193. data/lib/zatca/ubl/signing/signature_information.rb +19 -0
  194. data/lib/zatca/ubl/signing/signature_properties_reference.rb +26 -0
  195. data/lib/zatca/ubl/signing/signed_info.rb +21 -0
  196. data/lib/zatca/ubl/signing/signed_properties.rb +81 -0
  197. data/lib/zatca/ubl/signing/signed_signature_properties.rb +23 -0
  198. data/lib/zatca/ubl/signing/ubl_document_signatures.rb +25 -0
  199. data/lib/zatca/ubl/signing/ubl_extension.rb +22 -0
  200. data/lib/zatca/ubl/signing/ubl_extensions.rb +17 -0
  201. data/lib/zatca/ubl/signing.rb +2 -0
  202. data/lib/zatca/ubl.rb +2 -0
  203. data/lib/zatca/version.rb +1 -1
  204. data/lib/zatca.rb +27 -3
  205. data/zatca.gemspec +52 -0
  206. metadata +318 -10
  207. data/Gemfile.lock +0 -100
@@ -0,0 +1,15 @@
1
+ # E-Invoicing SDK
2
+ I could never get the SDK to run on my machine, so I dockerized it instead.
3
+
4
+ If you have Docker installed, you should be able to run the following command
5
+ to get a shell that's pre-installed with the SDK.
6
+
7
+ ```bash
8
+ docker compose run zatca
9
+ ```
10
+
11
+ The envoicing-sdk is mounted into the container, so any changes you do on the host
12
+ within that folder will appear inside the container.
13
+
14
+ NOTE: This command has one downside in that it runs `install.sh` every time so
15
+ `Configuration/config.json` will be overridden each time you run the container.
Binary file
@@ -0,0 +1,674 @@
1
+ ## **Welcome to ZATCA E-Invoice Java SDK (CLI)** {#welcome-to-zatca-e-invoice-java-sdk-cli .unnumbered}
2
+
3
+ This cli is a Java based tool that utilizes ZATCA's SDK jar to perform
4
+ several tasks. Basically, you can use it to validate different e-invoice
5
+ documents including Standard Invoice, Standard Debit Note, Standard
6
+ Credit Note, Simplified Invoice, Simplified Debit Note, and Simplified
7
+ Credit Note. Once validation has run, the tool will display the
8
+ validation results. This can be a PASS if all validations have passed,
9
+ otherwise a NOT PASS messf.net
10
+
11
+ age is displayed along with a list of errors indicating what has
12
+ happened. Moreover, this tool allows signing invoices, generating
13
+ invoice hash, generating api requests, generating certificate signing
14
+ requests (CSR), and generating QR code .
15
+
16
+ ## **SDK Prerequisite** {#sdk-prerequisite .unnumbered}
17
+
18
+ The SDK requires JAVA to run, please make sure you have a valid Java JRE
19
+ or SDK, the version must be between 11 and 15.
20
+
21
+ ## **SDK Installation Steps** {#sdk-installation-steps .unnumbered}
22
+
23
+ ### **Install/Update for Windows** {#installupdate-for-windows .unnumbered}
24
+
25
+ 1. Download the sdk.zip file
26
+
27
+ 2. Unzip the sdk.zip file
28
+
29
+ 3. Now, open a command line and point to the root folder of the sdk.
30
+
31
+ 4. Run the ***install.bat***
32
+
33
+ 5. Now, you can start using the fatoora cli. Please run ***fatoora
34
+ > -help*** to get all supported commands
35
+
36
+ ### **Install/Update for Linux** {#installupdate-for-linux .unnumbered}
37
+
38
+ 1. Install \[jq\] from
39
+ > [[https://stedolan.github.io/jq/]{.underline}](https://stedolan.github.io/jq/)
40
+
41
+ 2. Download the sdk.zip file
42
+
43
+ 3. Run command ***sh \~/.bash_profile***
44
+
45
+ 4. Unzip the sdk.zip file
46
+
47
+ 5. Now, open a command line/terminal and point to the root folder of
48
+ > the sdk.
49
+
50
+ 6. Run command ***install.sh***
51
+
52
+ 7. *Run **sh \~/.bash_profile***
53
+
54
+ 8. *Run command **cd \$FATOORA_HOME***
55
+
56
+ 9. *Run command **chmod +x fatoora***
57
+
58
+ 10. Now, you can start using the fatoora cli. Please run ***fatoora
59
+ > -help*** to get all supported commands
60
+
61
+ ## **Configuration**
62
+
63
+ ### ***fatoora \[ command \] \[ options \]*** {#fatoora-command-options .unnumbered}
64
+
65
+ --------- ---------------------- --------------------------------------------
66
+ **No.** **Command** **Description**
67
+
68
+ 1 \[-csr\] A flag used to generate csr and private key.
69
+
70
+ 2 \[-pem\] A flag used to generate csr and private key
71
+ in pem format.
72
+
73
+ 3 \[-privateKey The name of the private key output file.
74
+ fileName\]
75
+
76
+ 4 \[-generatedCsr The name of the csr output file.
77
+ fileName\]
78
+
79
+ 5 \[-csrConfig The name of the csr configuration file.
80
+ fileName\]
81
+
82
+ 6 \[-invoice fileName\] The name of the invoice file.
83
+
84
+ 7 \[-qr\] A flag used to generate qr.
85
+
86
+ 8 \[-sign\] A flag used to sign an invoice.
87
+
88
+ 9 \[-signedInvoice The name of the signed invoice output file.
89
+ fileName\]
90
+
91
+ 10 \[-invoiceRequest\] A flag used to generate an invoice API
92
+ request.
93
+
94
+ 11 \[-apiRequest The name of the invoice json request output
95
+ fileName\] file
96
+
97
+ 12 \[-validate\] A flag used to validate invoice.
98
+
99
+ 13 \[-generateHash\] A flag used to generate new hash for the
100
+ provided invoice.
101
+
102
+ 14 \[-nonprod\] A flag pointing to use the csr and private
103
+ key on a non production server.
104
+
105
+ 15 \[-sim\] A flag pointing to use the csr and private
106
+ key on a simulation server.
107
+
108
+ 16 \[-help\] A flag used to display this help menu and
109
+ exit.
110
+ --------- ---------------------- --------------------------------------------
111
+
112
+ ## **Generating a Certificate Signing Request (CSR):**
113
+
114
+ #### **Prerequisite:** {#prerequisite .unnumbered}
115
+
116
+ - **Input:**
117
+
118
+ > There is a CSR configuration properties file which contains all the
119
+ > input needed to generate a CSR. Those include the below:
120
+
121
+ - common name
122
+
123
+ - serial number
124
+
125
+ - organization identifier
126
+
127
+ - organization unit name
128
+
129
+ - organization name
130
+
131
+ - country name
132
+
133
+ - invoice type
134
+
135
+ - location address
136
+
137
+ - industry business category
138
+
139
+ > Also, please note that:
140
+
141
+ 1. You can follow the structure of the properties file by checking the
142
+ > template provided in:
143
+
144
+ > ***/Data/Input/csr-config-template.properties*.**
145
+
146
+ 2. Also an example is provided in:
147
+
148
+ > ***/Data/Input/csr-config-template.properties/csr-config-example.properties***
149
+ >
150
+ > Once done you can generate a csr using the config properties file by
151
+ > providing it as an option to the -csrConfig argument. Please see
152
+ > Arguments and Options below.
153
+
154
+ #### **Arguments and Options:** {#arguments-and-options .unnumbered}
155
+
156
+ ***fatoora -csr -csrConfig fileName -privateKey fileName -generatedCsr
157
+ fileName -pem***
158
+
159
+ --------- --------------------------- --------------------------------------------
160
+ **No.** **Argument(s)/Option(s)** **Description**
161
+
162
+ 1 \[-csr\] A flag used to generate csr and private key.
163
+
164
+ 2 \[-csrConfig \<filename\>\] This is a mandatory argument to provide
165
+ location and name of the csr configuration
166
+ file.
167
+
168
+ 3 \[-privateKey\] This is an optional argument to provide
169
+ \<filename\> location and name of generated private key
170
+ output file
171
+
172
+ 4 \[-generatedCsr\] This is an optional argument to provide
173
+ \<filename\> location and name of generated csr output
174
+ file
175
+
176
+ 5 \[-pem\] This is an optional argument used to
177
+ generate csr and private key in pem format
178
+ --------- --------------------------- --------------------------------------------
179
+
180
+ **[Notes:]{.underline}**
181
+
182
+ 1. If the user does not provide \[-privateKey\] argument then the
183
+ > private key file will be generated in the path of a running
184
+ > command prompt with file convention name pattern
185
+ > generated-private-key-yyyyMMddhhmmss.key
186
+
187
+ 2. If the user does not provide \[-generatedCsr\] argument then the csr
188
+ > file will be generated in the path of a running command prompt
189
+ > with file convention name pattern generated-csr-yyyyMMddhhmmss.csr
190
+
191
+ 3. If the user does not provide \[-pem\] argument then the csr file
192
+ > will be generated encoded base64 and private key file will be
193
+ > generated without header \"\-\-\-\--BEGIN EC PRIVATE
194
+ > KEY\-\-\-\--\" and footer \"\-\-\-\--END EC PRIVATE KEY\-\-\-\--\"
195
+
196
+ ## **Signing and Generating Invoice Hash:**
197
+
198
+ #### **Prerequisite:** {#prerequisite-1 .unnumbered}
199
+
200
+ > Please refer back to the prerequisites section of generating a CSR
201
+ > above.
202
+
203
+ - Input: The E-Invoice XML file full path.
204
+
205
+ - Output: an object of type \"Result\" that contains
206
+
207
+ ```{=html}
208
+ <!-- -->
209
+ ```
210
+ - IsValid : The final Status of the process.
211
+
212
+ - ResultValue: XML Hashed Generated if \"IsValid = True\". It should
213
+ be the same as the one already exists in the E-Invoice XML file.
214
+
215
+ - ErrorMessage: The error message if \"IsValid = false\".
216
+
217
+ ```{=html}
218
+ <!-- -->
219
+ ```
220
+ - Integration with other systems
221
+
222
+ ```{=html}
223
+ <!-- -->
224
+ ```
225
+ - Declare object from Class \"HashGenerationService\"
226
+
227
+ - Declare object from class "SigningService"
228
+
229
+ - Call function \"generateInvoiceHash\"
230
+
231
+ - Parameter 1 (xmlFilePath) : E-Invoice XML file full path
232
+
233
+ #### **Arguments and Options:** {#arguments-and-options-1 .unnumbered}
234
+
235
+ ***fatoora -sign -invoice \<filename\> -signedInvoice \<filename\>***
236
+
237
+ --------- --------------------------- ----------------------------------------
238
+ **No.** **Argument(s)/Option(s)** **Description**
239
+
240
+ 1 \[-sign\] A flag used to sign an invoice.
241
+
242
+ 2 -invoice \<filename\> This is an optional argument to provide
243
+ the name of the invoice file.
244
+
245
+ 3 \[-signedInvoice This is an optional argument to provide
246
+ \<fileName\>\] the name of the signed invoice output
247
+ file.
248
+ --------- --------------------------- ----------------------------------------
249
+
250
+ **[Notes:]{.underline}**
251
+
252
+ 1. If the user does not provide \[-signedInvoice\] argument then the
253
+ > signed invoice file will be generated in the path of a running
254
+ > command prompt with file convention name pattern \<same input file
255
+ > name\>\_signed.xml
256
+
257
+ ## **Generating JSON API Request:**
258
+
259
+ #### **Prerequisite:** {#prerequisite-2 .unnumbered}
260
+
261
+ None.
262
+
263
+ #### **Arguments and Options:** {#arguments-and-options-2 .unnumbered}
264
+
265
+ ***fatoora -invoice \<filename\> -invoiceRequest -apiRequest
266
+ \<fileName\>***
267
+
268
+ --------- --------------------------- ----------------------------------------
269
+ **No.** **Argument(s)/Option(s)** **Description**
270
+
271
+ 1 -invoice \<filename\> This is a mandatory argument used to
272
+ provide the name of the invoice file.
273
+
274
+ 2 \[-invoiceRequest\] A flag used to generate an invoice API
275
+ request.
276
+
277
+ 3 \[-apiRequest This is an optional argument used to
278
+ \<fileName\>\] provide the name of the invoice json
279
+ request output file
280
+ --------- --------------------------- ----------------------------------------
281
+
282
+ **[Notes:]{.underline}**
283
+
284
+ 1. If the user does not provide \[-apiRequest\] argument then the
285
+ > invoice request file will be generated in the path of a running
286
+ > command prompt with file convention name pattern
287
+ > generated-json-request-yyyyMMddhhmmss.json
288
+
289
+ ## **Generating QR Code:**
290
+
291
+ #### **Prerequisite:** {#prerequisite-3 .unnumbered}
292
+
293
+ > Replace SDK default private key and certificate with the custom
294
+ > values, as mentioned below in [section "Adding the private key and
295
+ > certificate"](#adding-the-private-key-and-certificate).
296
+
297
+ #### **Arguments and Options:** {#arguments-and-options-3 .unnumbered}
298
+
299
+ ***fatoora -qr -invoice \<filename\>***
300
+
301
+ --------- --------------------------- ----------------------------------------
302
+ **No.** **Argument(s)/Option(s)** **Description**
303
+
304
+ 1 \[-qr\] A flag used to generate qr code.
305
+
306
+ 2 -invoice \<filename\> This is a mandatory argument used to
307
+ provide the name of the invoice file.
308
+ --------- --------------------------- ----------------------------------------
309
+
310
+ ## **Validating an invoice:**
311
+
312
+ #### **Prerequisite:** {#prerequisite-4 .unnumbered}
313
+
314
+ > Replace SDK default private key and certificate with the custom
315
+ > values, as mentioned below in [section "Adding the private key and
316
+ > certificate"](#adding-the-private-key-and-certificate).
317
+
318
+ #### **Arguments and Options:** {#arguments-and-options-4 .unnumbered}
319
+
320
+ ***fatoora -validate -invoice \<filename\>***
321
+
322
+ --------- --------------------------- ----------------------------------------
323
+ **No.** **Argument(s)/Option(s)** **Description**
324
+
325
+ 1 \[-validate\] A flag used to validate the invoice.
326
+
327
+ 2 -invoice \<filename\> This is a mandatory argument used to
328
+ provide the name of the invoice file.
329
+ --------- --------------------------- ----------------------------------------
330
+
331
+ ## **Generating Invoice Hash:**
332
+
333
+ #### **Prerequisite:** {#prerequisite-5 .unnumbered}
334
+
335
+ > None.
336
+
337
+ #### **Arguments and Options:** {#arguments-and-options-5 .unnumbered}
338
+
339
+ ***fatoora -generateHash -invoice \<filename\>***
340
+
341
+ --------- --------------------------- ----------------------------------------
342
+ **No.** **Argument(s)/Option(s)** **Description**
343
+
344
+ 1 \[-generateHash\] A flag used to generate new hash for the
345
+ provided invoice.
346
+
347
+ 2 -invoice \<filename\> This is a mandatory argument used to
348
+ provide the name of the invoice file.
349
+ --------- --------------------------- ----------------------------------------
350
+
351
+ ## **Adding the Private Key and Certificate:**
352
+
353
+ 1. Replace Data/Certificates/ec-secp256k1-priv-key.pem with your
354
+ > private key using EC secp256k1 algorithm without header
355
+ > \"\-\-\-\--BEGIN EC PRIVATE KEY\-\-\-\--\" and footer
356
+ > \"\-\-\-\--END EC PRIVATE KEY\-\-\-\--\"
357
+
358
+ 2. Place yourCertificate generated by ZATCA into
359
+ > Data/Certificates/cert.pem *[without]{.underline}* header, footer
360
+ > and without any new lines \"\\n\".
361
+
362
+ 3. Once done, now you can sign your xml invoice using your private key
363
+ > and matching it on validation with the zatca certificate.
364
+
365
+ **Please note that the provided certificate**
366
+
367
+ **and private key in the SDK are dummy and for testing purposes only.**
368
+
369
+ ## **Technical FAQs:**
370
+
371
+ - **[What JAVA version should I install before using the
372
+ > SDK?]{.underline}**
373
+
374
+ > The prerequisite is using the Java SDK (JAR) versions \>=11 and \<15.
375
+
376
+ - **[What should the user do when faced with a JAVA
377
+ > error?]{.underline}**
378
+
379
+ > When faced with a JAVA error, the user needs to install JAVA (versions
380
+ > \>=11 and \<15) before running and using the SDK.
381
+
382
+ **[Running the SDK inside your application]{.underline}**
383
+
384
+ - **Prerequisites:**
385
+
386
+ Make sure to Install the latest SDK version (see section **SDK
387
+ Installation Steps).**
388
+
389
+ - **Running SDK inside a java application:**
390
+
391
+ To run any function inside your java application, use the following code
392
+ snippet:
393
+
394
+ Runtime rt = Runtime.getRuntime();
395
+
396
+ Process pr = rt.exec(\"***fatoora \<command\> \<args\>*** \");
397
+
398
+ where \<command\> is any sdk command. For example, **-generateCsr** or
399
+ **-generateHash** as well as any arguments associated as mentioned
400
+ previously in the documentation.
401
+
402
+ **Please note that the provided certificate**
403
+
404
+ **and private key in the SDK are dummy and for testing purposes only.**
405
+
406
+ > **[SDK .NET Framework]{.underline}**
407
+
408
+ **Target Framework : .NET Framework 4.7.2**
409
+
410
+ 1. **Generating Hashing**
411
+
412
+ - Input: The E-Invoice XML file full path.
413
+
414
+ - Output: an object of type \"Result\" that contains
415
+
416
+ ```{=html}
417
+ <!-- -->
418
+ ```
419
+ - IsValid : The final Status of the process.
420
+
421
+ - ResultValue: XML Hashed Generated if \"IsValid = True\". It should
422
+ be the same as the one already exists in the E-Invoice XML file.
423
+
424
+ - ErrorMessage: The error message if \"IsValid = false\".
425
+
426
+ ```{=html}
427
+ <!-- -->
428
+ ```
429
+ - Integration with other systems
430
+
431
+ ```{=html}
432
+ <!-- -->
433
+ ```
434
+ - Declare object from Class \" HashingValidator\"
435
+
436
+ - Call function \" GenerateEInvoiceHashing\"
437
+
438
+ - Parameter 1 (xmlFilePath) : E-Invoice XML file full path
439
+
440
+ 2. **Validating Hashing (Containing Generating Hash and validate it)**
441
+
442
+ - Input: The E-Invoice XML file full path.
443
+
444
+ - Output: an object of type \"Result\" that contains
445
+
446
+ ```{=html}
447
+ <!-- -->
448
+ ```
449
+ - IsValid : The final Status of the process it should be true if the
450
+ generated Hash is the same as the one already exists in E-Invoice
451
+ XML.
452
+
453
+ - ResultValue: Empty
454
+
455
+ - ErrorMessage: The error message if \"IsValid = false\".
456
+
457
+ ```{=html}
458
+ <!-- -->
459
+ ```
460
+ - Integration with other systems
461
+
462
+ ```{=html}
463
+ <!-- -->
464
+ ```
465
+ - Declare object from Class \" HashingValidator \"
466
+
467
+ - Call function \"ValidateEInvoiceHashing\"
468
+
469
+ - Parameter1 (xmlFilePath): E-Invoice XML file full path
470
+
471
+ 3. **Generating QR**
472
+
473
+ - Input: The E-Invoice XML file full path.
474
+
475
+ - Output: an object of type \"Result\" that contains
476
+
477
+ ```{=html}
478
+ <!-- -->
479
+ ```
480
+ - IsValid : The final Status of the process.
481
+
482
+ - ResultValue: QR code Generated if \"IsValid = True\". It should be
483
+ the same as the one already exists in the E-Invoice XML file.
484
+
485
+ - ErrorMessage: The error message if \"IsValid = false\".
486
+
487
+ ```{=html}
488
+ <!-- -->
489
+ ```
490
+ - Integration with other systems
491
+
492
+ ```{=html}
493
+ <!-- -->
494
+ ```
495
+ - Declare object from Class \"QRValidator\"
496
+
497
+ - Call function \"GenerateEInvoiceQRCode\"
498
+
499
+ - Parameter1 (xmlFilePath): E-Invoice XML file full path
500
+
501
+ 4. **Validating QR (Containing Generating QR and validate it)**
502
+
503
+ - Input: The E-Invoice XML file full path.
504
+
505
+ - Output: an object of type \"Result\" that contains
506
+
507
+ ```{=html}
508
+ <!-- -->
509
+ ```
510
+ - IsValid : The final Status of the process it should be true if the
511
+ generated QR Code is the same as the one already exists in E-Invoice
512
+ XML.
513
+
514
+ - ResultValue: Empty
515
+
516
+ - ErrorMessage: The error message if \"IsValid = false\".
517
+
518
+ ```{=html}
519
+ <!-- -->
520
+ ```
521
+ - Integration with other systems
522
+
523
+ ```{=html}
524
+ <!-- -->
525
+ ```
526
+ - Declare object from Class \"QRValidator\"
527
+
528
+ - Call function \"ValidateEInvoiceQRCode\"
529
+
530
+ - Parameter1 (xmlFilePath): E-Invoice XML file full path
531
+
532
+ 5. **Validating E-Invoice**
533
+
534
+ - There are two types of E-Invoices \"Simplified\" & \"Standard\"
535
+
536
+ - Validation of \"Simplified\" E-Invoice contains the next steps
537
+
538
+ ```{=html}
539
+ <!-- -->
540
+ ```
541
+ - Validate XSD
542
+
543
+ - Validate EN Schema Tron
544
+
545
+ - Validate KSA Schema Tron
546
+
547
+ - Validate Signature
548
+
549
+ - Validate QR
550
+
551
+ - Validate PIH
552
+
553
+ ```{=html}
554
+ <!-- -->
555
+ ```
556
+ - Validation of \"Standard\" E-Invoice contains the next steps
557
+
558
+ ```{=html}
559
+ <!-- -->
560
+ ```
561
+ - Validate XSD
562
+
563
+ - Validate EN Schema Tron
564
+
565
+ - Validate KSA Schema Tron
566
+
567
+ - Validate PIH
568
+
569
+ ```{=html}
570
+ <!-- -->
571
+ ```
572
+ - Input:
573
+
574
+ - The E-Invoice XML file full path
575
+
576
+ - The content of certificate file.
577
+
578
+ - The Current PIH as string .
579
+
580
+ - Output: an object of type \"Result\" that contains
581
+
582
+ ```{=html}
583
+ <!-- -->
584
+ ```
585
+ - IsValid : The final Status of the process it should be true if all
586
+ steps of E-Invoice validation \"IsValid\"
587
+
588
+ - ResultValue: Empty
589
+
590
+ - ErrorMessage: Empty.
591
+
592
+ - List of Steps each step is an object of type \"Result\" that
593
+ contains if this step IsValid or not and the error message if it is
594
+ not valid.
595
+
596
+ ```{=html}
597
+ <!-- -->
598
+ ```
599
+ - Integration with other systems
600
+
601
+ ```{=html}
602
+ <!-- -->
603
+ ```
604
+ - Declare object from Class \" EInvoiceValidator\"
605
+
606
+ - Call function \" ValidateEInvoice\"
607
+
608
+ - Parameter 1 (xmlFilePath): E-Invoice XML file full path
609
+
610
+ - Parameter 2 (certificateContent): Certificate content as string
611
+
612
+ - Parameter 3 (pihContent): PIH content as string
613
+
614
+ 6. **Signing E-Invoice**
615
+
616
+ - Signing E-Invoice contains the next steps
617
+
618
+ ```{=html}
619
+ <!-- -->
620
+ ```
621
+ - Generating Hashing
622
+
623
+ - Generating Signature
624
+
625
+ - Populating Data
626
+
627
+ - Generating and populating QR
628
+
629
+ ```{=html}
630
+ <!-- -->
631
+ ```
632
+ - Input:
633
+
634
+ - The E-Invoice XML file full path.
635
+
636
+ - The content of certificate file as string
637
+
638
+ - The content of private key as string (generated by OpenSSL)
639
+
640
+ - Output: an object of type \"Result\" that contains
641
+
642
+ ```{=html}
643
+ <!-- -->
644
+ ```
645
+ - IsValid : The final Status of the process it should be true if all
646
+ steps of E-Invoice Signing \"IsValid\"
647
+
648
+ - ResultValue: XML content after signing if it is valid
649
+
650
+ - ErrorMessage: Empty.
651
+
652
+ - List of Steps each step is an object of type \"Result\" that
653
+ contains if this step IsValid or not and the error message if it is
654
+ not valid.
655
+
656
+ ```{=html}
657
+ <!-- -->
658
+ ```
659
+ - Integration with other systems
660
+
661
+ ```{=html}
662
+ <!-- -->
663
+ ```
664
+ - Declare object from Class \" EInvoiceSigningLogic\"
665
+
666
+ - Call function \" SignDocument\"
667
+
668
+ - Parameter 1 (xmlFilePath): E-Invoice XML file full path
669
+
670
+ - Parameter 2 (certificateContent): Certificate file content as
671
+ string
672
+
673
+ - Parameter 3 (privateKeyContent): Private key file content as
674
+ string
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ version: "3.9"
2
+
3
+ services:
4
+ zatca:
5
+ build:
6
+ context: .
7
+ image: zatca:1.0.0
8
+ command: sh -c "(sh ./install.sh && /bin/bash)"
9
+ volumes:
10
+ - .:/zatca
11
+ tty: true
12
+ stdin_open: true