Skip to content
Henrique Vieira
All projects

Software for Angola's tax authority (AGT), multi-tenant

Electronic invoicing

Electronic invoicing software that other systems integrate through an API to issue invoices under the AGT's Executive Decree 683/25, with real-time submission and the SAF-T file generated by each company.

Role
Sole author: design, API, console and AGT integration
Period
Nov 2026 - present
Status
In the final stage, on the way to submission for AGT certification
Technologies
TypeScriptNestJSPrismaPostgreSQLBullMQNext.jsJWS RS256SAF-T (AO)

The problem

Under Executive Decree 683/25, in force since September 2025, invoices are signed and submitted to the AGT in real time, as JSON, instead of a file sent from time to time. Schools, clinics and companies that already have their own system need to comply without rebuilding it.

The goal is a service those systems call through an API to issue the invoice, and that handles signing, submission, the deadline and the SAF-T file. AutoPropina is the first to integrate.

The approach

  1. 01

    Two sources, compared field by field

    The AGT's technical documentation (schemaVersion 2.0) differs from the decree on structural points: the submission identifier, the series now assigned by the AGT, the establishment, the tax nature of each line. I compared the two sources field by field and recorded the documentation's own contradictions, to confirm during homologation.

  2. 02

    RS256 signature over the whole document

    Each document is signed as a compact JWS, RS256, over the complete canonical JSON object. Concatenating fields and signing the result, the easiest mistake to make, is exactly what the documentation warns against.

  3. 03

    Queued submission that never loses the answer

    The system that requests the invoice gets it back signed straight away; submission runs through queues: register, poll the status at growing intervals, notify by webhook. The notification is stored in the same transaction that applies the AGT's answer, and an error that is not transient is not retried, because it would only burn the deadline.

  4. 04

    Warning before the 24-hour deadline

    The AGT allows 24 hours to submit a signed document and, after that, accepts it with a penalty. A job runs every 15 minutes and warns 4 hours ahead, once per document, in the console and by webhook.

  5. 05

    SAF-T (AO) that passes the validator

    Each company generates its own SAF-T (AO) 1.01, and the file is validated against the official schema. The validator caught constraints that reading the schema did not reveal, such as the 172-character limit on the Hash, which requires a second key. Either a valid file comes out, or an error does: never a file with documents missing.

The results

18
document types from Annex I: invoices, invoice-receipts, credit notes, receipts, payment notices
56
AGT error codes handled, each marked as retry, fix or contact support
33
operations in the public API, with the OpenAPI contract checked on every change
10
concurrent issues in the concurrency test of the document key chain
4 h
of warning ahead of the 24-hour submission deadline

What I learned

The decree and the technical documentation do not always agree, and the documentation contradicts itself on some fields. I record each divergence with the decision taken and the reason, so homologation can confirm or correct it without anyone having to guess.

Next case

MediaSync

Synchronised digital signage for Smart TVs

Read the case