You are on page 1of 12

IT Department - United Group 12/03/2023

INFORMATION TECHNOLOGY

E-INVOICE TECHNICAL DOCUMENT

1
IT Department - United Group 12/03/2023

1. Introduction
Electronic Invoicing is a procedure that aims to convert the issuing of paper invoices as well as
credit and debit notes into an electronic process that allows the exchange and processing of
invoices, credit and debit notes in a structured electronic format between the buyer and seller. The
E-Invoicing Regulation shall be read together with the Unified VAT Agreement (the Agreement),
the VAT Law published on 4/11/1438H and its amendments (the VAT Law), the VAT
Implementing Regulation (VAT Implementing Regulation) and the resolutions issued pursuant to
the Electronic Invoicing Regulation, including the resolution on the Controls, Requirements,
Technical Specifications and Procedural Rules (herein after referred to as “E-Invoicing
Resolution”) required for implementing Electronic Invoicing in the Kingdom of Saudi Arabia

2. The Taxpayer E-invoicing Journey


The key steps that UG will take in order to fulfill ZATCA obligations for the Integration Phase of
E-invoicing.

Listed below, are the three key steps of the UG Journey for obtaining an EGS system and
successfully onboarding it with ZATCA, for the purposes of submitting e-documents to ZATCA:
• The UG will sure the e-invoicing solution is compliant with the e-invoicing
requirements(Compliance of EGS)
• The UG will onboard their EGS devices for integration with ZATCA; (Onboarding)
• The UG will successfully submit electronic invoices, credit notes and debit notes for
Clearance or Reporting to ZATCA.( Sharing invoices and notes (Clearance and Reporting))

2.1 Generating a Certificate Signing Request (CSR):


Prerequisite:
There is a CSR configuration properties file which contains all the input needed to
generate a CSR. Those include the below:
- common name
- serial number
- organization identifier
- organization unit name
- organization name
- country name
- invoice type
- location address
- industry business category
2.2 Sending a Certificate Signing Request (CSR) in order to receive a Compliance CSID
Description:
As a part of the first-time onboarding and renewal process, the EGS Unit(s) must submit a
Certificate signing request (CSR) to the E-invoicing Platform once an OTP is entered into the EGS

UG-IT Rev. 01 Page 1 of 12


IT Department - United Group 12/03/2023

unit. The CSR is an encoded text that the EGS Unit(s) submits to the E-invoicing Platform and the
ZATCA CA in order to receive a Compliance CSID. This is a self-signed certificate issued by the E-
invoicing Platform allowing clients to continue the Onboarding process.

UG-IT Rev. 01 Page 2 of 12


IT Department - United Group 12/03/2023

UG-IT Rev. 01 Page 3 of 12


IT Department - United Group 12/03/2023

Note: All CSR fields are mandatory and the input must follow the specification; otherwise, a CSR
could be rejected. Please refer to the EGS vendor's manual or support for information on how to
resolve issues

Process flow:
• The process for sending a CSR is as follows
• Once the OTP(s) has been entered into the UG EGS Unit(s),

UG-IT Rev. 01 Page 4 of 12


IT Department - United Group 12/03/2023

• The CSR process is initiated as per the below steps:


o Create CSR and include the required data
o Generate public/private key pair
o Send CSR to generate self-signed certificate.
• Possible errors that can occur when submitting a CSR include:
o Invalid OTP/OTC (not exactly six digits, not numeric)
o OTP/OTC not matching for this VAT Registration Number (OTP/OTC provided
does not match an active valid OTP/OTC that was generated for this Taxpayer on
the portal)
o OTP/OTC expired
o Invalid VAT Registration Number (Syntax, not corresponding to a valid VAT
Registration Number on Fatoora Portal (ERAD)
o Invalid request type
o Missing fields (with details of the fields missing)
o One or more of the compliance steps has failed.
2.3 Completion of the Compliance checks by the EGS Unit
Description:
Once a CSR is sent successfully and the Compliance CSID is obtained, the Taxpayer's
EGS Unit(s) must undergo compliance checks in order to ensure that the EGS Unit is able
to generate compliant invoices. Upon successful completion and passing of the
compliance checks, the EGS Unit receives a Production CSID. The Production CSID is a
certificate issued by the ZATCA CA to enable clients to authenticate and use the core e-
invoicing APIs

Process Flow
It must be noted that the EGS performs the steps for the completion of the compliance
checks automatically. The Taxpayer should refer to the EGS Guideline for the onboarding
procedure appropriate to their device. The process for the completion of the compliance
checks is as follows:
• Formulate a compliant CSR and receive the CSID for onboarding / renewal (checking the
capability of the EGS Units to perform renewal). Note that reaching compliance checks
implicitly means that the EGS Unit has successfully acquired a compliance CSID

• Based on the invoice type that has been added to the CSR, validation checks are required.

o If the Invoice Type is "1000", then the user should send 3 requests for

▪ Standard Tax Invoice (B2B)

▪ Standard Debit Note (B2B)

▪ Standard Credit Note (B2B)

UG-IT Rev. 01 Page 5 of 12


IT Department - United Group 12/03/2023

o If the Invoice Type is "0100", then the user should send 3 requests for

▪ Simplified Tax Invoice (B2C)

▪ Simplified Debit Note (B2C)

▪ Simplified Credit Note (B2C)

• The compliance verification of an EGS is concluded when the EGS Unit has undergone the
compliance checks
o The submitted documents are checked against all the validations as well as the
relevant referential/ additional checks and all tests are successfully passed.
o Once found to be compliant, the compliance flag is checked
2.4 Generating a new CSID for the EGS Unit or Renewing the existing CSID
Description:
The CSID generation process occurs at the back-end of the E-invoicing Generation Solution
and is initiated upon the successful completion of the compliance checks and can be
regarded as the final step in the journey of receiving a new CSID. The process flow is
common for both receiving a CSID for the first time and also for renewing the existing CSID.
However, for renewal, the existing CSID of the EGS Unit is revoked and a new one is issued.
Process Flow
The process for the generation and renewal of a CSID is as follows:
• The EGS Unit(s) submit(s) a request to receive its production CSID(s).
• ZATCA CA issues the CSID(s) for the Taxpayer's EGS Unit(s). In cases of renewal,
the ZATCA CA first revokes the existing CSID and then issues the new one.
• The Fatoora Platform relays the new CSID(s) to the Taxpayer's EGS Unit that
originally submitted the CSR to the Fatoora Platform.
3. Onboarding :
The Onboarding section acts as a guide for Taxpayers to help users operate the Onboarding
ZATCA Portal in order to obtain the necessary Cryptographic Stamp Identifiers (CSID) and perform
any other relevant activities such as the revocation of CSID(s). Please note that Taxpayers should
refer to the Guidelineof the E-Invoicing Generation Solution (EGS) Unit for any steps taking place
on the Taxpayer's EGS Unit.

The Onboarding functionality aims to address the following:


• Onboarding of a new EGS Unit(s) (i.e. receiving a CSID for the first-time)
• Renewal of existing CSID(s) for EGS Unit(s)
• Revocation of CSID(s) for one or more EGS Unit(s) (by the Taxpayer or automatically by
ZATCA)
4. Clearance and Reporting
1- Generating Hashing
• Input: The E-Invoice XML.

UG-IT Rev. 01 Page 6 of 12


IT Department - United Group 12/03/2023

• Output: an object of type "Result" that contains


- IsValid : The final Status of the process.
- ResultValue: XML Hashed Generated if "IsValid = True". It should be the same
as the one already exists in the E-Invoice XML file.
- ErrorMessage: The error message if "IsValid = false".
• Integration with other systems
- Declare object from Class " HashingValidator"
- Call function " GenerateEInvoiceHashing"
o Parameter 1 (xmlFilePath) : E-Invoice XML file full path

2- Validating Hashing (Containing Generating Hash and validate it)


• Input: The E-Invoice XML.
• Output: an object of type "Result" that contains
- IsValid : The final Status of the process it should be true if the generated Hash
is the same as the one already exists in E-Invoice XML.
- ResultValue: Empty
- ErrorMessage: The error message if "IsValid = false".
• Integration with other systems
- Declare object from Class " HashingValidator "
- Call function "ValidateEInvoiceHashing"
o Parameter1 (xmlFilePath): E-Invoice XML

3- Generating QR
• Input: The E-Invoice XML.
• Output: an object of type "Result" that contains
- IsValid : The final Status of the process.
- ResultValue: QR code Generated if "IsValid = True". It should be the same as
the one already exists in the E-Invoice XML file.
- ErrorMessage: The error message if "IsValid = false".
• Integration with other systems
- Declare object from Class "QRValidator"
- Call function "GenerateEInvoiceQRCode"
o Parameter1 (xmlFilePath): E-Invoice

4- Validating QR (Containing Generating QR and validate it)


• Input: The E-Invoice XML.
• Output: an object of type "Result" that contains
- IsValid : The final Status of the process it should be true if the generated QR
Code is the same as the one already exists in E-Invoice XML.

UG-IT Rev. 01 Page 7 of 12


IT Department - United Group 12/03/2023

- ResultValue: Empty
- ErrorMessage: The error message if "IsValid = false".
• Integration with other systems
- Declare object from Class "QRValidator"
- Call function "ValidateEInvoiceQRCode"
o Parameter1 (xmlFilePath): E-Invoice XML

5- Validating E-Invoice
• There are two types of E-Invoices "Simplified" & "Standard"
• Validation of "Simplified" E-Invoice contains the next steps
- Validate XSD
- Validate EN Schema Tron
- Validate KSA Schema Tron
- Validate Signature
- Validate QR
- Validate PIH
• Validation of "Standard" E-Invoice contains the next steps
- Validate XSD
- Validate EN Schema Tron
- Validate KSA Schema Tron
- Validate PIH
• Input:
The E-Invoice XML
The content of certificate file.
The Current PIH as string.
• Output: an object of type "Result" that contains
- IsValid : The final Status of the process it should be true if all steps of E-
Invoice validation "IsValid"
- ResultValue: Empty
- ErrorMessage: Empty.
- List of Steps each step is an object of type "Result" that contains if this step
IsValid or not and the error message if it is not valid.
• Integration with other systems
- Declare object from Class " EInvoiceValidator"
- Call function " ValidateEInvoice"
o Parameter 1 (xmlFilePath): E-Invoice XML
o Parameter 2 (certificateContent): Certificate content as string
o Parameter 3 (pihContent): PIH content as string

UG-IT Rev. 01 Page 8 of 12


IT Department - United Group 12/03/2023

6- Signing E-Invoice
• Signing E-Invoice contains the next steps
- Generating Hashing
- Generating Signature
- Populating Data
- Generating and populating QR
• Input:
- The E-Invoice XML
- The content of certificate file as string
- The content of private key as string (generated by OpenSSL)
• Output: an object of type "Result" that contains
- IsValid : The final Status of the process it should be true if all steps of E-
Invoice Signing "IsValid"
- ResultValue: XML content after signing if it is valid
- ErrorMessage: Empty.
- List of Steps each step is an object of type "Result" that contains if this step
IsValid or not and the error message if it is not valid.
• Integration with other systems
- Declare object from Class " EInvoiceSigningLogic"
- Call function " SignDocument"
o Parameter 1 (xmlFilePath): E-Invoice XML file full path
o Parameter 2 (certificateContent): Certificate file content as string
o Parameter 3 (privateKeyContent): Private key file content as string

5. System design
5.1 Overview:

Refers to the systems development life cycle a set of processes or stages and all stages of the system
where a number of steps and the main stage falls below .all the steps and methodologies are:

- Plan
- Analysis
- Design
- Implementation

5.2 E-Invoice:

Electronic Invoicing is a procedure that aims to convert the issuing of paper invoices as well as
credit and debit notes into an electronic process that allows the exchange and processing of
invoices, credit and debit notes in a structured electronic format between the buyer and seller.

UG-IT Rev. 01 Page 9 of 12


IT Department - United Group 12/03/2023

5.3 Programming languages:

• IDE: Visual Studio 2022 is the professional IDE (Integrated Development Environment) of
choice for many .NET developers. It's created by Microsoft, who also makes the .NET
framework as well as the C# programming language, so this makes perfect sense. Historically,
VS (short for Visual Studio) has been expensive to use, but fortunately for you and me,
Microsoft has offered a free version for individual developers for many years.

• Language ASP.NET is a free web framework for building websites and web applications on
.NET Framework using HTML, CSS, and JavaScript. ASP.NET MVC 5 is a web framework
based on Model-View-Controller (MVC) architecture. Developers can build dynamic web
applications using ASP.NET MVC framework that enables a clean separation of concerns, fast
development, and TDD friendly.

UG-IT Rev. 01 Page 10 of 12


IT Department - United Group 12/03/2023

• HTML is the basic language in web programming and is the cornerstone of web programming.

• ORACLE (ORION): Standard and Modeled Data Language in Database Organization.

• JavaScript: JavaScript is a programming language used for interactive web periods - it works
on your computer and does not bear the download from your web site.

• CSS language: to design the style of the website.

UG-IT Rev. 01 Page 11 of 12

You might also like