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().
Cluj-Napoca companies that bill, ship and book from a custom PHP system run into a reporting format the system was not built for: the Romanian SAF-T file, filed with ANAF as the informative declaration D406. The format is XML, the schema is published, and the content comes from accounting records. This page follows the ANAF documents. I am Mariusz Szatkowski, a PHP developer based in Gdynia, and the export is what I build. Which obligations your company has is for your accountant to confirm.

Piața Unirii in the centre of Cluj-Napoca. Photo: Nuță Lucian from Cluj-Napoca, Romania, CC BY-SA 2.0, Wikimedia Commons.
ANAF Order 1783/2021, published in the Official Gazette no. 1073 of 9 November 2021, sets the nature of the information, the model, the procedure, the deadlines and the dates from which each taxpayer category must file the standard audit file (SAF-T). The file travels inside the informative declaration D406. The order applies from 1 January 2022, and its five annexes are on the ANAF SAF-T page.
The ANAF page itself lists an amending order, 373/2022, but the link labelled with that number opens a different file, so I could not read a consolidated text from anaf.ro. What follows from the annexes is stated as published in 2021, and every later fact has its own ANAF document behind it.
Annex 5 as published in 2021 gives these start dates:
| Taxpayer category | D406 obligation begins |
|---|---|
| Large taxpayers, in the category on 1 January 2022 and also in 2021 | 1 January 2022 |
| Newly classified large taxpayers | 1 July 2022 |
| Medium taxpayers, in the category on 31 December 2021 | 1 January 2023 |
| Small taxpayers, in the category on 31 December 2021 | 1 January 2025 |
| Taxpayers newly registered after the category date | From the date of registration |
An ANAF communique of 18 November 2024 confirms the last date: from 1 January 2025 small taxpayers must file the D406 as well, and it names the order and Annex 5 as the legal basis.
The annex lists the forms of business that are in scope: among them SRL, SA, SCA, SCS, SNC, cooperatives, foreign legal entities with a permanent establishment in Romania and non-resident companies with a VAT registration. It lists the forms that are out of scope: among them PFA, individual and family enterprises, lawyers’ and notaries’ offices, individual medical practices and public institutions. A notice from an ANAF regional directorate of 23 June 2025 repeats the grace-period rules and names non-residents registered for VAT only among the filers, so the list was extended in some way after 2021. Treat the 2021 list as a starting point and ask your accountant for the current text.
Annex 4 of the order sets the deadlines:
New filers get a grace period, confirmed by the 2024 communique. Monthly filers have 6 months for the first report, 5 for the second, 4 for the third, 3 for the fourth and 2 for the fifth. Quarterly filers have 3 months for the first report. A valid D406 within that window is not sanctioned as a contravention under the Fiscal Procedure Code.
A function that turns a period into its deadline belongs in the ERP rather than in a spreadsheet. A sketch is in the code section below.
Annex 3 describes the sequence. The system of the taxpayer generates the SAF-T file in XML. ANAF supplies a validator, an independent Java program, which checks the structure and some relations between data before upload. The validator also produces the D406 as a PDF with the XML attached. That PDF is signed with a qualified digital certificate and filed online through the ANAF online services or the e-guvernare portal. Filing is done by the taxpayer or by a representative enrolled in the ANAF system.
The annex names three ways to prepare the XML: automatic export from an accounting or ERP system, manual editing against the schema for taxpayers without such a system, and external generation by a specialised data operator. A custom PHP system belongs to the first group.
If a PHP application produces the PDF itself instead of using the validator, Annex 3 requires metadata fields in the PDF: the tax identifier without the RO prefix, the reporting year, the reporting month, a marker for initial or rectifying, a control sum and a code identifying the declaration type and version. The form must follow the model in Annex 2 of the order.
A test declaration type, D406T, exists for testing before real filing.
The ANAF page lists the current schema as the XSD version 2.4.9 (2025), alongside a spreadsheet of schema definitions and codes republished on 16 February 2026. The XSD states that it is based on the OECD Standard Audit File for Taxation 2.00. The root element is AuditFile with four sections in this order: Header, MasterFiles, GeneralLedgerEntries and SourceDocuments. SourceDocuments holds sales invoices, purchase invoices, payments and movement of goods, among others.
The target namespace in the XSD file is mfp:anaf:dgti:d406t:declaratie:v1, and elements are namespace-qualified, so an export has to emit that namespace. The Header starts with the audit file version, country, creation date and software identification. A PHP system should hold these as configuration and take the version from the XSD annotation each time ANAF publishes a new one.
The validator page notes that the year and month passed to the validator must match the period in the XML, and that the taxpayer is responsible for assigning them correctly.
Annex 3 describes modal reporting for large volumes: one period can be filed as several D406 forms, each carrying part of the data. The split is made by the taxpayer at the level of sub-sections. The rules the annex states:
ANAF sends a receipt for each form, and only the last receipt in a series confirms that the whole declaration is conform.
For corrections, the first valid D406 for a month or quarter is the initial one, and later ones for the same period are automatically rectifying. A rectifying declaration must contain all information of the initial one plus the corrections. The order says in Annex 4 that for a declaration with errors flagged in a receipt the taxpayer resends the entire D406 with the corrected file, and that selective partial corrections are not admitted.
In software terms: the system needs to keep every generated file per period, and a rerun has to regenerate a full file and not a diff.
The sketch below uses XMLWriter to stream the file, DOMDocument::schemaValidate to check it against the ANAF XSD, and DateTimeImmutable for the deadline. It is a skeleton of the structure, not a complete export: the content of each section comes from the schema definition spreadsheet.
<?php
declare(strict_types=1);
const SAFT_NS = 'mfp:anaf:dgti:d406t:declaratie:v1';
function openSaftFile(string $path): XMLWriter
{
$w = new XMLWriter();
$w->openUri($path);
$w->setIndent(true);
$w->startDocument('1.0', 'UTF-8');
$w->startElementNs(null, 'AuditFile', SAFT_NS);
return $w;
}
function validateSaft(string $xmlPath, string $xsdPath): array
{
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->load($xmlPath);
$dom->schemaValidate($xsdPath);
$messages = array_map(
static fn (LibXMLError $e): string => $e->line . ': ' . trim($e->message),
libxml_get_errors()
);
libxml_clear_errors();
return $messages;
}
function d406Deadline(int $year, int $month, bool $quarterly): DateTimeImmutable
{
$endMonth = $quarterly ? (int) ceil($month / 3) * 3 : $month;
$next = (new DateTimeImmutable(sprintf('%04d-%02d-01', $year, $endMonth)))
->add(new DateInterval('P1M'));
return $next->setDate((int) $next->format('Y'), (int) $next->format('n'), (int) $next->format('t'));
}The XMLWriter writes to disk as it goes, which keeps memory flat for large ledgers. DOMDocument loads the whole file, so for very large files the ANAF validator and the split into several forms matter in practice. The validate function is a pre-check. The ANAF validator remains the reference, since it also runs semantic checks, and its newest archive is the one the ANAF page lists.
The last item is the one that saves time. ANAF lists communiques on consistency tests on the same page, and reading them shows which relations between sections the authority checks. A mismatch is easier to trace when the export keeps the link from each field back to its source row.
Send the ERP or order system as it is: the database structure, the invoice and payment flows, the VAT periods and the person who files. The reply comes by email, within 24 hours on working days. The first written estimate is free and splits the work into the export, the validation step and the receipt handling. I develop against a copy of your data with sample periods, and you or your accountant compare the output with the ANAF validator before anything is filed. The filing and the signature stay with you. The PHP developer page covers the rest of what I build in PHP.
I am not a lawyer or an accountant, and ANAF updates its technical files several times a year. If your company in Cluj-Napoca runs a custom ERP or order system and the D406 export is still a manual job, send the system outline through the contact form. A written estimate for the export costs nothing and states where I would start.
Examples of my work.
Digital World Capital LLP is an alternative investment manager specializing in the telecommunications and media sectors on a global scale. The company focuse...
In the eastern part of Mielno, an exclusive apartment complex by the Baltic Sea, DUNE Resort, is being developed. This exceptional investment evokes the lu...
Instytut-csr.net is one of the valuable projects in my WordPress developer portfolio, realised as an educational and informational platform dedicated to Corp...
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.