How to display the current and parent category in WordPress
Need to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().
A PHP application that issues invoices in Portugal is not only an application. Portuguese rules treat it as a system that must make tampering visible, number documents in series, print codes and export a standard file. I am Mariusz Szatkowski, a PHP developer in Gdynia, and I work with Lisbon clients by email and shared documents. Whether your company needs certified software is a decision for you and your accountant. I build the module so its data model meets the technical texts, and this page shows which texts those are.

Parque das Nações with the Vasco da Gama Tower, photographed by Haydn Blackey (Cardiff) and shared under CC BY-SA 2.0 on Wikimedia Commons.
Decree-Law 28/2019 of 15 February consolidates the invoicing rules for VAT taxpayers. Article 3 says invoices and other tax-relevant documents are processed by one of three means: invoicing programs (including the application the Autoridade Tributária e Aduaneira, AT, makes available), other electronic means such as cash registers and terminals, or pre-printed documents from an authorised printer.
Article 4 then obliges taxpayers with a seat, permanent establishment or domicile in Portugal to use only programs previously certified by the AT, when the conditions listed in that article apply. They include a turnover test for the previous calendar year and the use of invoicing software. I leave the exact test to your adviser, because the article can be amended. The AT portal shows the decree-law as in force, amended by Decree-Law 48/2020 and Decree-Law 49/2025.
The AT keeps a list of certified programs and versions on its website, with the producers named (article 4(3)). The certificate belongs to a program version. Article 5(5) of Portaria 363/2010 adds that a certified version must keep meeting the requirements even when a taxpayer who is not obliged to use certified software runs it.
The Portaria of 23 June 2010 regulates the prior certification of invoicing programs. Its preamble gives the reason: electronic processing speeds up work but allows later alteration of recorded data, so only programs that guarantee the inviolability of the first record may be used. The AT portal lists it as in force and names these amendments: Portaria 22-A/2012, Portaria 160/2013, Portaria 340/2013 (which republished it) and Decree-Law 28/2019, which revoked articles 1, 2, 8 and 9.
Article 3 sets five cumulative requirements for certification:
The last item points to technical documents I did not read for this page. Anyone building to certification works from them as well.
Article 6 names the algorithm: RSA. The message to sign is built from five values of the sales document, joined in this order with a semicolon:
The resulting signature and the version of the private key must be kept in the program’s database. Article 7 applies the same mechanism to transport documents and to working documents handed to a customer to check delivery, with their own field lists.
In PHP the signing step is one call. The openssl_sign manual documents it as openssl_sign(string $data, string &$signature, $private_key, string|int $algorithm = OPENSSL_ALGO_SHA1), returning a boolean. The Portaria names RSA and not a digest, so the digest below is a parameter that comes from the AT’s technical documentation.
<?php
declare(strict_types=1);
function signInvoice(
string $invoiceDate, // 2026-12-04
string $systemEntryDate, // 2026-12-04T10:15:00
string $invoiceNo, // FT 2026A/12
string $grossTotal, // format per the AT technical notes
string $previousHash, // empty rule for a first document: AT notes
\OpenSSLAsymmetricKey $privateKey,
string|int $digest,
): string {
$message = implode(';', [$invoiceDate, $systemEntryDate, $invoiceNo, $grossTotal, $previousHash]);
if (!openssl_sign($message, $signature, $privateKey, $digest)) {
throw new \RuntimeException('Signing failed');
}
return base64_encode($signature);
}Two storage decisions follow from the text. The stored signature is never recomputed on read, and the key version sits in the same row as the signature, so a later key rotation does not orphan old documents.
Article 6(3) of the Portaria lists what a signed document carries:
With zero-based string offsets, as substr counts them according to the php.net manual, those positions are 0, 10, 20 and 30. An off-by-one error here is easy to ship, so I keep it in a single tested function. The same four characters feed field Q of the QR code, and the certificate number feeds field R, according to the AT’s QR specification.
Article 7(4) of Decree-Law 28/2019 requires invoices and tax-relevant documents to be issued in one or more series, dated and numbered progressively and continuously within each series, for a period of not less than one fiscal year. Article 35 adds that taxpayers communicate each series electronically to the AT before using it, and that the AT assigns a code which becomes part of the unique document code.
Portaria 195/2020 of 13 August sets the details. For each series, the taxpayer communicates:
| Element | Source in the Portaria |
|---|---|
| Series identifier | article 2(a) |
| Document type, per the SAF-T types | article 2(b) |
| Start of the sequential numbering | article 2(c) |
| Expected first date of use | article 2(d) |
The AT returns a validation code of at least eight characters. The ATCUD is that code, a hyphen and the sequence number, which in invoicing programs is the digit string right after the slash in the document’s unique identification. The mandatory print format is ATCUD:CodigodeValidação-NumeroSequencial, on every invoice and tax-relevant document from any processing means. On a multi-page document it appears on every page.
For the data model this means a series table with the validation code, the document type, the next number and a flag that the code has been obtained. A document cannot be finalised while its series lacks a code. The text of the Portaria gives the entry into force as 1 January 2021, with a transitional communication window in December 2020. I did not confirm from a primary source the date from which the AT enforces the ATCUD in practice, so check the current AT notices.
Article 6 of the Portaria requires the QR code on documents issued by programs certified by the AT. The technical content comes from the AT’s specification, version 1.1 of October 2020, which sets:
Each field is marked mandatory or optional in the table, and optional fields without data are left out. A PHP module should build the string from the same records that feed the SAF-T export, so the QR and the file cannot disagree. Rendering the image is a library choice. What matters is the checks: a unit test that parses the string back into fields, and a test per document type from the examples in the specification.
The first requirement of article 3 is the export of the SAF-T (PT) file. The structure was set by Portaria 321-A/2007 and changed by Portaria 302/2016 of 2 December, which the AT portal lists as in force. Decree-Law 28/2019 also amends article 3 of Decree-Law 198/2012. As worded on the AT portal, taxpayers communicate invoice data either by real-time transmission or by sending a standard file based on the SAF-T (PT), no later than the 10th day of the month after issue.
A custom module therefore keeps its tax records in a shape that exports without transformation guesses: one row per document line with the tax code and rate, document status, and the dates in the form the SAF-T expects. I do not repeat the full schema here. The AT publishes it and the file should be validated against it in the test pipeline.
I need access to the repository or the current system, and the technical notes you already hold from the AT. The wider scope of custom PHP work is described on the PHP developer page.
Describe the documents you issue and the system you issue them from through the contact form. The first written estimate is free, and it comes with the questions I would put to your accountant before any code is written. I am not a lawyer, and the legal reading stays with you and your adviser.
Examples of my work.
surfuje.pl is a website for surfers and watersports enthusiasts, with clear content, simple publishing, and stable technical operation.
zamki-szkocji.com is a comprehensive information portal dedicated to the castles of Scotland, combining rich historical content, interactive maps, photo gall...
scalac.io is an international platform founded in 2014 to meet the challenges associated with big data management and business operations scaling, specializing in Scala, distributed systems, and cryptography solutions.
Describe your project by e-mail. I reply within 24 hours.
Describe your projectNeed to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().
Need to get the URL of the first image or link in an article? Prefer DOMDocument over regex. Ready-made WordPress PHP for developers.
On 1 December 2026 Taylor Otwell shipped the Laravel Rust beta, and Laravel Go followed a day later. What the framework contains, what the 18x benchmark really measures, what happens to Laravel PHP and WordPress, and when a rewrite makes sense.
Custom WordPress engineering and architecture.
Scalable headless, ERP, and AI architecture for enterprise.
Stores, checkout flow, and sales logic.
Stability, updates, and post-launch support.
What the monthly care fee covers and what changes it.
Business process automation around WordPress and company systems.
Headless WordPress, Sanity, Strapi, and Contentful with Astro or Next.js.
Astro, MDX, edge delivery, and Core Web Vitals measured on real traffic.

How to start as a WordPress developer in 2026. Local environment, theme and plugin development, REST API and headless paths, security and Core Web Vitals. A practitioner playbook that does not waste your first month.

WordPress 7.0 with AI Client against Astro 7 with the Rust compiler and Vite 8. Speed, cost, SEO and security compared, plus the real bill for my own Astro 6 to 7 migration.

A detailed comparison table of EmDash CMS and WordPress across architecture, security, plugins, AI features, content model, hosting, and ecosystem maturity.