Skip to content

Commit

Permalink
Merge pull request #15 from mrsool/feature/api_wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
obahareth authored Dec 6, 2023
2 parents b0b57a8 + 9d564ba commit 8d43f2e
Show file tree
Hide file tree
Showing 227 changed files with 116,066 additions and 143 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/main.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ruby
name: Lint

on:
push:
Expand All @@ -21,6 +21,3 @@ jobs:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Lint
run: bundle exec standardrb

- name: Run tests
run: bundle exec rspec
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: ['3.1', '3.0', '2.7', '2.6', '2.5']

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 2 # changes cache key if you need to clear cache

- name: Run tests
run: bundle exec rspec
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
/pkg/
/spec/reports/
/tmp/

.byebug_history
/*.pem
.byebug_history
Gemfile.lock
100 changes: 0 additions & 100 deletions Gemfile.lock

This file was deleted.

9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

A Ruby library for generating QR Codes for the e-invoice standard by ZATCA in Saudi Arabia.

✅ Validated to have the same output as [ZATCA's SDK](https://zatca.gov.sa/en/E-Invoicing/SystemsDevelopers/ComplianceEnablementToolbox/Pages/DownloadSDK.aspx) as of 12 November 2021.
✅ Validated to have the same output as [ZATCA's SDK](https://zatca.gov.sa/en/E-Invoicing/SystemsDevelopers/ComplianceEnablementToolbox/Pages/DownloadSDK.aspx) as of 15 November 2023.

# Installation

Expand All @@ -19,6 +19,7 @@ bundle add zatca

# Usage

## Phase 1
```rb
require "zatca"

Expand Down Expand Up @@ -51,3 +52,9 @@ tags = ZATCA::Tags.new({
generator = ZATCA::QRCodeGenerator.new(tags)
generator.render(size: 512)
```

## Notice of Non-Affiliation and Disclaimer
This library is not affiliated, associated, authorized, endorsed by, or in any way officially connected with ZATCA (Zakat, Tax and Customs Authority), or any of its subsidiaries or its affiliates. The official ZATCA website can be found at https://zatca.gov.sa.

## Phase 2
Documentation is still in progress, and can be found in this repository's [wiki](https://github.com/mrsool/zatca/wiki)
Empty file modified bin/console
100755 → 100644
Empty file.
Empty file modified bin/setup
100755 → 100644
Empty file.
12 changes: 12 additions & 0 deletions einvoicing-sdk/Apps/fatoora
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

EXTVER=$(jq -r '.version' ${FATOORA_HOME}/global.json)

CERTPASSWORD=$(jq -r '.certPassword' ${FATOORA_HOME}/global.json)


java -Djdk.module.illegalAccess=deny -Djdk.sunec.disableNative=false -jar ${FATOORA_HOME}/zatca-einvoicing-sdk-${EXTVER}.jar --globalVersion $EXTVER -certpassword $CERTPASSWORD $1 $2 $3 $4 $5 $6




16 changes: 16 additions & 0 deletions einvoicing-sdk/Apps/fatoora.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

@echo off

SET VAR=
FOR /F %%I IN ('jq .version %FATOORA_HOME%/global.json') DO set "VAR=%%I"

SET CERT_PASS=
FOR /F %%N IN ('jq .certPassword %FATOORA_HOME%/global.json') DO set "CERT_PASS=%%N"


set "VAR=%VAR:~1,-1%"

set "CERT_PASS=%CERT_PASS:~1,-1%"


if exist "%FATOORA_HOME%/zatca-einvoicing-sdk-%VAR%.jar" call java -Djdk.module.illegalAccess=deny -Dfile.encoding=UTF-8 -jar %FATOORA_HOME%/zatca-einvoicing-sdk-%VAR%.jar --globalVersion %VAR% -certpassword %CERT_PASS% %*
1 change: 1 addition & 0 deletions einvoicing-sdk/Apps/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"238-R3.2.7" , "certPassword": "123456789" }
Binary file added einvoicing-sdk/Apps/jq.exe
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions einvoicing-sdk/Configuration/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"xsdPath": "/zatca/Data/Schemas/xsds/UBL2.1/xsd/maindoc/UBL-Invoice-2.1.xsd",
"enSchematron": "/zatca/Data/Rules/schematrons/CEN-EN16931-UBL.xsl",
"zatcaSchematron": "/zatca/Data/Rules/schematrons/20210819_ZATCA_E-invoice_Validation_Rules.xsl",
"certPath": "/zatca/Data/Certificates/cert.pem",
"privateKeyPath": "/zatca/Data/Certificates/ec-secp256k1-priv-key.pem",
"pihPath": "/zatca/Data/PIH/pih.txt",
"certPassword": "123456789",
"inputPath": "/zatca/Data/Input",
"usagePathFile": "/zatca/Configuration/usage.txt"
}
11 changes: 11 additions & 0 deletions einvoicing-sdk/Configuration/defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"xsdPath": "../Data/Schemas/xsds/UBL2.1/xsd/maindoc/UBL-Invoice-2.1.xsd",
"enSchematron": "../Data/Rules/schematrons/CEN-EN16931-UBL.xsl",
"zatcaSchematron": "../Data/Rules/schematrons/20210819_ZATCA_E-invoice_Validation_Rules.xsl",
"certPath": "../Data/Certificates/cert.pem",
"privateKeyPath": "../Data/Certificates/ec-secp256k1-priv-key.pem",
"pihPath": "../Data/PIH/pih.txt",
"certPassword": "123456789",
"inputPath": "../Data/Input",
"usagePathFile": "../Configuration/usage.txt"
}
Binary file added einvoicing-sdk/Configuration/jq.exe
Binary file not shown.
16 changes: 16 additions & 0 deletions einvoicing-sdk/Configuration/usage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[-csr]: flag used to generate csr and private key.
[-pem]: flag used to generate csr and private key in pem format.
[-privateKey <fileName>]: The name of the private key output file.
[-generatedCsr <fileName>]: The name of the csr output file.
[-csrConfig] <fileName> : The name of the csr configuration file.
[-invoice] <filename> : The name of the invoice file.
[-qr]: flag used to generate qr.
[-sign]: flag used to sign invoice.
[-signedInvoice <fileName>]: The name of the signed invoice output file.
[-invoiceRequest]: flag used to generate invoice request.
[-apiRequest <fileName>]: The name of the invoice json request output file
[-generateHash]: flag used to generate new hash for the provided invoice.
[-validate]: flag used to validate invoice.
[-nonprod]: flag pointing to use the csr and private key on non production server.
[-sim]: flag pointing to use the csr and private key on simulation server.
[-help]: flag used to display this help menu and exit.
1 change: 1 addition & 0 deletions einvoicing-sdk/Data/Certificates/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MIID6jCCA5CgAwIBAgITbwAAgbuRbo5tpQ+QjgABAACBuzAKBggqhkjOPQQDAjBjMRUwEwYKCZImiZPyLGQBGRYFbG9jYWwxEzARBgoJkiaJk/IsZAEZFgNnb3YxFzAVBgoJkiaJk/IsZAEZFgdleHRnYXp0MRwwGgYDVQQDExNUU1pFSU5WT0lDRS1TdWJDQS0xMB4XDTIyMTEwOTA4MDcyMloXDTI0MTEwODA4MDcyMlowTjELMAkGA1UEBhMCU0ExEzARBgNVBAoTCjM5OTk5OTk5OTkxDDAKBgNVBAsTA1RTVDEcMBoGA1UEAxMTVFNULTM5OTk5OTk5OTkwMDAwMzBWMBAGByqGSM49AgEGBSuBBAAKA0IABGGDDKDmhWAITDv7LXqLX2cmr6+qddUkpcLCvWs5rC2O29W/hS4ajAK4Qdnahym6MaijX75Cg3j4aao7ouYXJ9GjggI5MIICNTCBmgYDVR0RBIGSMIGPpIGMMIGJMTswOQYDVQQEDDIxLVRTVHwyLVRTVHwzLTlmMDkyMjM4LTFkOTctNDcxOC1iNDQxLWNiYzMwMTMyMWIwYTEfMB0GCgmSJomT8ixkAQEMDzM5OTk5OTk5OTkwMDAwMzENMAsGA1UEDAwEMTEwMDEMMAoGA1UEGgwDVFNUMQwwCgYDVQQPDANUU1QwHQYDVR0OBBYEFDuWYlOzWpFN3no1WtyNktQdrA8JMB8GA1UdIwQYMBaAFHZgjPsGoKxnVzWdz5qspyuZNbUvME4GA1UdHwRHMEUwQ6BBoD+GPWh0dHA6Ly90c3RjcmwuemF0Y2EuZ292LnNhL0NlcnRFbnJvbGwvVFNaRUlOVk9JQ0UtU3ViQ0EtMS5jcmwwga0GCCsGAQUFBwEBBIGgMIGdMG4GCCsGAQUFBzABhmJodHRwOi8vdHN0Y3JsLnphdGNhLmdvdi5zYS9DZXJ0RW5yb2xsL1RTWkVpbnZvaWNlU0NBMS5leHRnYXp0Lmdvdi5sb2NhbF9UU1pFSU5WT0lDRS1TdWJDQS0xKDEpLmNydDArBggrBgEFBQcwAYYfaHR0cDovL3RzdGNybC56YXRjYS5nb3Yuc2Evb2NzcDAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMDMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwIwCgYIKwYBBQUHAwMwCgYIKoZIzj0EAwIDSAAwRQIgeWUEjxXaW4s8XilH/abzbDJhHHjO3uLaD87YqioA89YCIQDNltfAU98b8FnTD7M8NYIk8cqi7OnPu7h85v5V1Bt3Hg==
1 change: 1 addition & 0 deletions einvoicing-sdk/Data/Certificates/ec-secp256k1-priv-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MHQCAQEEIDyLDaWIn/1/g3PGLrwupV4nTiiLKM59UEqUch1vDfhpoAcGBSuBBAAKoUQDQgAEYYMMoOaFYAhMO/steotfZyavr6p11SSlwsK9azmsLY7b1b+FLhqMArhB2dqHKboxqKNfvkKDePhpqjui5hcn0Q==
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
csr.common.name=TST-886431145-311111111101113
csr.serial.number=1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f
csr.organization.identifier=311111111111113
csr.organization.unit.name=3111111111
csr.organization.name=ABCD المحدودة
csr.country.name=SA
csr.invoice.type=1111
csr.location.address=RRRD2929
csr.industry.business.category=الأنشطة العقارية
9 changes: 9 additions & 0 deletions einvoicing-sdk/Data/Input/csr-config-example-AR.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
csr.common.name=TST-886431145-311111111101113
csr.serial.number=1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f
csr.organization.identifier=311111111101113
csr.organization.unit.name=فرع الرياض
csr.organization.name=ABCD المحدودة
csr.country.name=SA
csr.invoice.type=1111
csr.location.address=RRRD2929
csr.industry.business.category=الأنشطة العقارية
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
csr.common.name=TST-886431145-311111111101113
csr.serial.number=1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f
csr.organization.identifier=311111111111113
csr.organization.unit.name=3111111111
csr.organization.name=ABCD Limited
csr.country.name=SA
csr.invoice.type=1111
csr.location.address=RRRD2929
csr.industry.business.category=Real estate activities
9 changes: 9 additions & 0 deletions einvoicing-sdk/Data/Input/csr-config-example-EN.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
csr.common.name=TST-886431145-311111111101113
csr.serial.number=1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f
csr.organization.identifier=311111111101113
csr.organization.unit.name=Riyadh Branch
csr.organization.name=ABCD Limited
csr.country.name=SA
csr.invoice.type=1111
csr.location.address=RRRD2929
csr.industry.business.category=Real estate activities
9 changes: 9 additions & 0 deletions einvoicing-sdk/Data/Input/csr-config-template.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
csr.common.name=
csr.serial.number=
csr.organization.identifier=
csr.organization.unit.name=
csr.organization.name=
csr.country.name=
csr.invoice.type=
csr.location.address=
csr.industry.business.category=
1 change: 1 addition & 0 deletions einvoicing-sdk/Data/PIH/pih.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==
Loading

0 comments on commit 8d43f2e

Please sign in to comment.