PHP developer in Cluj-Napoca

WordPress for businesses in Cluj-Napoca, delivered remotely by one developer.

PHP developer

My place in the WordPress community

  • I have had a wordpress.org account since 2006.
  • I contributed to WordPress core for versions 7.0 and 7.1.
  • I maintain 30 plugins on wordpress.org.
  • I organise and speak at WordCamps.
  • I have attended every WordCamp Europe from 2017 to 2026.

My WordPress.org profile

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

Piața Unirii in the centre of Cluj-Napoca. Photo: Nuță Lucian from Cluj-Napoca, Romania, CC BY-SA 2.0, Wikimedia Commons.

#What is the D406 and what does ANAF require?

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.

#Who files, and from when?

Annex 5 as published in 2021 gives these start dates:

Taxpayer categoryD406 obligation begins
Large taxpayers, in the category on 1 January 2022 and also in 20211 January 2022
Newly classified large taxpayers1 July 2022
Medium taxpayers, in the category on 31 December 20211 January 2023
Small taxpayers, in the category on 31 December 20211 January 2025
Taxpayers newly registered after the category dateFrom 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.

#When is it due?

Annex 4 of the order sets the deadlines:

  • Periodic data: the last calendar day of the month after the reporting month or quarter.
  • Which period: monthly or quarterly, following the VAT period. Taxpayers with a half-yearly or yearly VAT period file quarterly, and so do taxpayers not registered for VAT.
  • Assets: one filing per financial year, by the deadline for the annual financial statements.
  • Stocks: only on a request from the central tax body, with a deadline of at least 30 calendar days from the request.

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.

#How is the declaration built and filed?

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.

#What does the schema look like?

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.

#What about large files and corrections?

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:

  • The Header section must be present in every XML file.
  • MasterFiles, GeneralLedgerEntries and SourceDocuments may be reported as many times as needed to stay within the maximum file size.
  • A sub-section that would exceed the limit as a whole is cut into files holding only parts of it.
  • A section or sub-section with nothing new since the previous period may be left empty, with only its opening and closing tags.
  • The declaration is complete when all mandatory sections and fields are present across the files of the period.

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.

#Which PHP functions help?

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.

#What should the ERP or order system record?

  • the reporting period and whether the taxpayer files monthly or quarterly
  • the XSD version and validator version used for each file
  • every generated file with its hash, so a rectifying declaration can be compared
  • the receipt or processing result received from ANAF, with its date
  • the SPV messages, if the taxpayer is enrolled there
  • the data lineage from SAF-T fields to source tables

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.

#How does a project run?

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.

#Bringing a Cluj-Napoca ERP into line

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.

Need this service: PHP developer in Cluj-Napoca?

Describe your project by e-mail. I reply within 24 hours.

Describe your project

Latest PHP developer articles

Dec 2, 2026

Laravel Rust: what does it mean for PHP apps?

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.

Explore other WordPress services and knowledge base