Skip to content

Commit 9755451

Browse files
committed
ci: Add GitHub Action for invoice validation using Fatoora SDK
1 parent cf52902 commit 9755451

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Validate Invoice with Fatoora
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
validate_invoice:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: 🛠️ Checkout Repository
11+
uses: actions/checkout@v3
12+
13+
- name: Set up PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.2'
17+
extensions: mbstring, xml, ctype, json, curl, openssl
18+
19+
- name: Install Composer dependencies
20+
run: composer install --prefer-dist --no-progress --no-suggest
21+
22+
- name: Generator Invoice
23+
run: |
24+
cd examples
25+
php GeneratorInvoice.php
26+
php SigningInvoices.php
27+
28+
- name: ☕ Install OpenJDK 11.0.26
29+
run: |
30+
sudo apt update
31+
sudo apt install -y openjdk-11-jdk
32+
java -version
33+
34+
- name: 📥 Download SDK
35+
run: |
36+
curl -o sdk.zip "https://latency.sa/zatca-einvoicing-sdk-Java-238-R3.3.9.zip"
37+
ls -lah sdk.zip
38+
39+
- name: 📦 Extract SDK
40+
run: |
41+
unzip sdk.zip -d sdk
42+
43+
- name: ✅ Validate Invoice using Fatoora
44+
run: |
45+
cd sdk/zatca-einvoicing-sdk-Java-238-R3.3.9/
46+
SDK_CONFIG="${PWD}/Configuration/config.json"
47+
export FATOORA_HOME="${PWD}"
48+
export PATH=$PATH:$FATOORA_HOME/Apps/
49+
export FATOORA_HOME=${PWD}/Apps
50+
export SDK_CONFIG=$SDK_CONFIG
51+
cd Configuration
52+
53+
parentDir="$(dirname "$PWD")"
54+
55+
xsdPath=$(jq -r '.xsdPath' defaults.json)
56+
xsdPathFileName="$(basename $xsdPath)"
57+
58+
enSchematron=$(jq -r '.enSchematron' defaults.json)
59+
enSchematronFileName="$(basename $enSchematron)"
60+
61+
zatcaSchematron=$(jq -r '.zatcaSchematron' defaults.json)
62+
zatcaSchematronFileName="$(basename $zatcaSchematron)"
63+
64+
certPath=$(jq -r '.certPath' defaults.json)
65+
certPathFileName="$(basename $certPath)"
66+
67+
pkPath=$(jq -r '.privateKeyPath' defaults.json)
68+
pkPathFileName="$(basename $pkPath)"
69+
70+
pihPath=$(jq -r '.pihPath' defaults.json)
71+
pihPathFileName="$(basename $pihPath)"
72+
73+
usagePath=$(jq -r '.usagePathFile' defaults.json)
74+
usagePathFileName="$(basename $usagePath)"
75+
76+
jq -n '{"xsdPath":$one, "enSchematron":$two, "zatcaSchematron":$thr,"certPath":$fou, "privateKeyPath":$fiv ,"pihPath":$six ,"inputPath":$sev,"usagePathFile":$eight}' \
77+
--arg one "${parentDir}/Data/Schemas/xsds/UBL2.1/xsd/maindoc/$xsdPathFileName" \
78+
--arg two "${parentDir}/Data/Rules/schematrons/$enSchematronFileName" \
79+
--arg thr "${parentDir}/Data/Rules/schematrons/$zatcaSchematronFileName" \
80+
--arg fou "${parentDir}/Data/Certificates/$certPathFileName" \
81+
--arg fiv "${parentDir}/Data/Certificates/$pkPathFileName" \
82+
--arg six "${parentDir}/Data/PIH/$pihPathFileName" \
83+
--arg sev "${parentDir}/Data/Input" \
84+
--arg eight "${parentDir}/Configuration/$usagePathFileName" >config.json
85+
86+
cd ../Apps
87+
chmod +x fatoora
88+
# ✅ Validate Invoice using Fatoora
89+
fatoora -validate -invoice ../../../examples/output/unsigned_invoice.xml
90+
fatoora -validate -invoice ../../../examples/output/signed_invoice.xml
91+

0 commit comments

Comments
 (0)