Muhandis Online

A point-of-sale system linked to e-invoicing, store by store

A client in Saudi Arabia runs one point-of-sale system for several stores. Invoices printed with a QR code, but when it came to sending them to the tax authority's platform, they were rejected. I built the signing, the certificates and a chain per store, and the invoices were accepted.

A client in Saudi Arabia with several stores (not named)

Branch tills

Duration
12 days for the core work, then two weeks for the tax details
Invoicing tests
64 tests, up from none
Result
Invoices are sent and accepted

From the project

The cashier screen with a basket of six items and the total with VAT (demo data)
The cashier screen with a basket of six items and the total with VAT (demo data)
  • The sale receipt with its phase-2 QR code and the invoice status "signed" (demo data)
    The sale receipt with its phase-2 QR code and the invoice status "signed" (demo data)
  • The e-invoice status board: cleared, reported, signed, pending and failed invoices (demo data)
    The e-invoice status board: cleared, reported, signed, pending and failed invoices (demo data)
  • The invoice-chain integrity check from the store screen: 14 documents intact (demo data)
    The invoice-chain integrity check from the store screen: 14 documents intact (demo data)

What I found

  • The signature was a "stamp" made with a fixed key written in the code, not with a certificate issued by the authority.
  • No device was registered, so there was no certificate.
  • The invoice hash was taken from a JSON text, not from the invoice file.
  • One invoice chain shared by every store, broken by every server restart.
  • A first-phase QR code, and every invoice reported, even business invoices that need clearing first.

What I built

  • Registration for each store: a one-time code, the certificate request, then the compliance certificate, then the production certificate.
  • A real ECDSA signature inside the invoice file, and each store’s private key stored encrypted.
  • A hash of the canonical UBL file, and a separate chain per store saved in the database together with the invoice.
  • A QR code with the second-phase fields: the hash, the signature and the public key.
  • Business invoices cleared before they reach the buyer, simplified invoices reported.
  • Three retries when the platform does not answer, a periodic sweep of pending invoices, a status board, and a check that recomputes the whole chain.

How I checked

64 invoicing tests where there were none, among them one that checks a store's chain never leaks into another: I wrote it before the fix, it failed on the old code, then passed. After registration and the production certificate, the invoices were sent and accepted.

After the core work, two weeks for the tax details: a category on each line (standard, zero-rated, exempt) instead of one fixed rate, and invoices kept for 6 years with proof they were not changed.

Built with

PythonUBL 2.1ECDSA (secp256k1)XAdESAES-256-GCM

Services in this work

Tell me what you want built.

I reply within one working day, with questions or a first idea of scope and price.