Build the DMR Monthly Remuneration Declaration (AT)
Skill: Convert monthly payroll into the Declaração Mensal de Remunerações (DMR) XML
Region: Portugal
Category: Payroll tax — DMR (Declaração Mensal de Remunerações), Autoridade Tributária e Aduaneira (AT)
Does: Takes a month's payroll figures and produces the AT DMR XML — the employer's monthly declaration of employment/pension income paid and IRS withholding (retenção na fonte) retained, with one record per employee carrying the income type code (A, H, …), the gross remuneration, the IRS withheld, and the geographic zone (Continente / Açores / Madeira), for upload on the Portal das Finanças.
Schema version: AT DMR (Declaração Mensal de Remunerações, Modelo aprovado pela Portaria n.º 6/2013 e alterações) — IRS/AT side only
The DMR submitted to the AT covers only the IRS dimension (income paid + IRS withholding + IRS surcharges). The parallel Segurança Social monthly declaration (DRI / "Declaração de Remunerações" via Segurança Social Direta) is a separate file with its own schema — this skill does not produce it. The DMR-AT is due by the 10th day of the month following the one in which the income was paid or made available. The AI builds the XML; validate it against the current AT DMR schema and the Portal das Finanças validator before submission.
When this applies
- Any entity that pays employment income (Categoria A) or pension income (Categoria H) subject to Portuguese IRS, and is therefore an IRS withholding agent, must file a DMR for every month in which income was paid or made available — even a "nil" month if obliged.
- The declaration reports, per beneficiary (NIF), the income code, the amount, the IRS retained, any IRS sobretaxa (where applicable historically), trade-union/other deductions, and the zone that determines the withholding tables.
- Excluded from this AT skill: the Segurança Social contribution base (handled by the DRI file), and income categories outside A/H unless the AT DMR record types cover them.
Conversion procedure
- Read the source. Accept a payroll export (CSV/JSON one row per employee), a payroll-software report, or pasted figures. For each beneficiary capture: NIF, income code, gross income for the period, IRS withheld, any surcharge, other withholdings, and the zone.
- Extract the entity header. The employer NIF (
NIFEmpregador), the reference year and month (Periodo), and a declaration type (1first /2substitution). - Validate identifiers. Every NIF is 9 digits. If a beneficiary NIF, an income code, or the withheld amount is missing or ambiguous, stop and ask — do not default a NIF or assume the income code.
- Normalise. Period as
YYYY-MM; amounts to dot-decimal 2 dp; income codes to the AT letter codes (A,H,A1, …); zone toC(Continente),RA-A(Açores),RA-M(Madeira) — match your schema's zone enumeration. - Build one record per beneficiary. Each
RemuneracaocarriesNIF,CodRendimento,Valor(income),RetencaoIRS,Sobretaxa(if any),ContribObrigatorias,RetencaoSobretaxa,QuotizacaoSindical, andLocalObtencaoRendimentos(the zone). - Compute totals and reconcile. Sum income, IRS retained, and surcharge across all records into the declaration totals; the per-beneficiary IRS must reconcile with the payroll register. Flag any mismatch.
- Validate. Work through the checklist; validate against the AT DMR schema.
Source → DMR field map
| From the source | → Target element / field |
|---|---|
| Employer NIF | DMRAT/Cabecalho/NIFEmpregador |
| Reference year | Cabecalho/AnoDeclaracao |
Reference month (01–12) |
Cabecalho/MesDeclaracao |
| Declaration type (1 first / 2 subst.) | Cabecalho/TipoDeclaracao |
| Reference / receipt of prior declaration | Cabecalho/ReferenciaDeclaracao |
| Total income declared | Cabecalho/TotalRendimentos |
| Total IRS withheld | Cabecalho/TotalRetencoesIRS |
| Total surcharge withheld | Cabecalho/TotalRetencoesSobretaxa |
| Beneficiary NIF | Quadro/Remuneracao/NIF |
| Income type code (A, H, …) | Remuneracao/CodRendimento |
| Gross income for the period | Remuneracao/Valor |
| IRS withheld (retenção na fonte) | Remuneracao/RetencaoIRS |
| IRS surcharge (sobretaxa) | Remuneracao/Sobretaxa |
| Surcharge withheld | Remuneracao/RetencaoSobretaxa |
| Mandatory social contributions | Remuneracao/ContribObrigatorias |
| Trade-union dues | Remuneracao/QuotizacaoSindical |
| Zone (Continente / Açores / Madeira) | Remuneracao/LocalObtencaoRendimentos |
Every required output element appears above. Repeat Remuneracao once per beneficiary-and-income-code combination.
Document structure
DMRAT (DMR — AT / IRS declaration)
├── Cabecalho (header — once)
│ ├── NIFEmpregador (9-digit employer NIF)
│ ├── AnoDeclaracao (yyyy)
│ ├── MesDeclaracao (01–12)
│ ├── TipoDeclaracao (1 primeira | 2 substituicao)
│ ├── ReferenciaDeclaracao (receipt of declaration being replaced; blank if first)
│ ├── TotalRendimentos (Σ income)
│ ├── TotalRetencoesIRS (Σ IRS withheld)
│ └── TotalRetencoesSobretaxa (Σ surcharge withheld)
└── Quadro (body — the remuneration table)
└── Remuneracao * (one per beneficiary + income code)
├── NIF (beneficiary NIF)
├── CodRendimento (A, A1, H, H1, B, …)
├── LocalObtencaoRendimentos (C | RA-A | RA-M)
├── Valor (gross income)
├── RetencaoIRS (IRS withheld)
├── Sobretaxa (surcharge base, where applicable)
├── RetencaoSobretaxa (surcharge withheld)
├── ContribObrigatorias (mandatory SS/CGA contributions)
└── QuotizacaoSindical (union dues)
Notes: every Remuneracao is keyed by NIF + CodRendimento + LocalObtencaoRendimentos; the same employee can have multiple records if paid under several income codes or zones. Sobretaxa/RetencaoSobretaxa are zero in years where the IRS surcharge no longer applies but the elements remain in the schema.
Code tables
CodRendimento (income type — selected)
| Code | Meaning |
|---|---|
A |
Rendimentos do trabalho dependente (employment income, Categoria A) |
A1 |
Trabalho dependente — gratificações não atribuídas pela entidade patronal |
H |
Pensões (Categoria H) |
H1 |
Pensões — rendas temporárias e vitalícias |
B |
Rendimentos empresariais e profissionais com retenção (Categoria B) |
SR |
Rendimentos sujeitos a taxas liberatórias / sem retenção (where applicable) |
LocalObtencaoRendimentos (zone — determines the withholding tables)
| Code | Meaning |
|---|---|
C |
Continente (mainland) |
RA-A |
Região Autónoma dos Açores |
RA-M |
Região Autónoma da Madeira |
TipoDeclaracao
| Code | Meaning |
|---|---|
1 |
Primeira declaração (first declaration for the period) |
2 |
Declaração de substituição (replaces a prior one — ReferenciaDeclaracao required) |
Calculation rules
- Per-beneficiary IRS (
RetencaoIRS): copy the amount actually withheld per the applicable IRS withholding table for the zone and personal situation; recompute against the payroll register and flag mismatches. Do not derive a rate yourself unless the source provides the table. - TotalRendimentos = Σ
Valoracross allRemuneracaorecords, 2 dp. - TotalRetencoesIRS = Σ
RetencaoIRSacross all records, 2 dp. - TotalRetencoesSobretaxa = Σ
RetencaoSobretaxaacross all records, 2 dp. - A beneficiary paid under two income codes or in two zones produces two
Remuneracaorecords; the header totals still sum every record. - Amounts in EUR, dot decimal, 2 dp, no thousands separators. Recompute every header total from the records; flag any mismatch with the source.
Worked example (end-to-end)
Exemplo Empregador, Lda. (NIF 501234567) files the DMR for June 2026, first declaration. One employee, NIF 198765432, was paid employment income (A) in the mainland (C) of 2000.00 gross, with 300.00 IRS withheld and 220.00 mandatory social-security contributions; no surcharge applies. Header totals: income 2000.00, IRS 300.00, surcharge 0.00.
Input — payroll export (pasted)
Empregador: Exemplo Empregador, Lda. | NIF 501 234 567 | Periodo 2026-06 | Tipo: primeira
Funcionario: NIF 198 765 432 | Cod A | Zona Continente
Rendimento bruto 2.000,00 | Retencao IRS 300,00 | Contrib. obrigatorias 220,00 | Sindical 0,00
After extraction + normalisation (intermediate)
NIFEmpregador 501234567 ; Ano 2026 ; Mes 06 ; TipoDeclaracao 1
Remuneracao: NIF 198765432 ; CodRendimento A ; Local C ; Valor 2000.00 ; RetencaoIRS 300.00 ;
Sobretaxa 0.00 ; RetencaoSobretaxa 0.00 ; ContribObrigatorias 220.00 ; QuotizacaoSindical 0.00
Totais: TotalRendimentos 2000.00 ; TotalRetencoesIRS 300.00 ; TotalRetencoesSobretaxa 0.00
Output — DMR (AT) XML
<?xml version="1.0" encoding="UTF-8"?>
<DMRAT xmlns="http://www.at.gov.pt/schemas/dmr">
<Cabecalho>
<NIFEmpregador>501234567</NIFEmpregador>
<AnoDeclaracao>2026</AnoDeclaracao>
<MesDeclaracao>06</MesDeclaracao>
<TipoDeclaracao>1</TipoDeclaracao>
<ReferenciaDeclaracao></ReferenciaDeclaracao>
<TotalRendimentos>2000.00</TotalRendimentos>
<TotalRetencoesIRS>300.00</TotalRetencoesIRS>
<TotalRetencoesSobretaxa>0.00</TotalRetencoesSobretaxa>
</Cabecalho>
<Quadro>
<Remuneracao>
<NIF>198765432</NIF>
<CodRendimento>A</CodRendimento>
<LocalObtencaoRendimentos>C</LocalObtencaoRendimentos>
<Valor>2000.00</Valor>
<RetencaoIRS>300.00</RetencaoIRS>
<Sobretaxa>0.00</Sobretaxa>
<RetencaoSobretaxa>0.00</RetencaoSobretaxa>
<ContribObrigatorias>220.00</ContribObrigatorias>
<QuotizacaoSindical>0.00</QuotizacaoSindical>
</Remuneracao>
</Quadro>
</DMRAT>
Normalisations shown: employer NIF 501 234 567 → 501234567; beneficiary NIF 198 765 432 → 198765432 (9 digits, no spaces); period → AnoDeclaracao 2026 / MesDeclaracao 06; type "primeira" → TipoDeclaracao 1 (so ReferenciaDeclaracao empty); zone "Continente" → C; amounts 2.000,00 → 2000.00 (dot decimal, 2 dp); header totals recomputed from the single record (TotalRendimentos 2000.00, TotalRetencoesIRS 300.00, TotalRetencoesSobretaxa 0.00). The Segurança Social side (DRI) is filed separately and is not part of this XML.
Validation checklist
- All required fields extracted; AI asked about anything missing or ambiguous (no invented NIFs, income codes, or withheld amounts)
- Employer and every beneficiary
NIFare 9 digits, numeric -
AnoDeclaracao(yyyy) andMesDeclaracao(01–12) match the reference period;TipoDeclaracaois1or2(2carriesReferenciaDeclaracao) - Each
Remuneracaohas a validCodRendimento(A,H, …) andLocalObtencaoRendimentos(C/RA-A/RA-M) -
RetencaoIRSper beneficiary reconciles with the payroll register; surcharge fields present (zero where not applicable) -
TotalRendimentos,TotalRetencoesIRS,TotalRetencoesSobretaxaequal the sums of the records; mismatches flagged - Amounts EUR, dot decimal, 2 dp, no thousands separators
- This is the AT/IRS DMR only — the Segurança Social DRI is filed separately
- File validated against the current AT DMR schema and the Portal das Finanças validator before submission by the 10th of the following month
Last updated: 2026-06-13 — verify the active AT DMR schema, the CodRendimento/zone code lists, the applicability of the IRS sobretaxa, and the monthly submission deadline against the current AT specification before use.