Arbetsgivardeklarationen is filed for the calendar month the pay went out (kontantprincipen), so a run for August paid on 25 September belongs to redovisningsperiod 202609. The generator, the submit route, the run page and the run header all took run.period_year/period_month instead, and three PATCH paths refused any payment date outside that month, which made lön i efterskott impossible to set up at all. - lib/salary/agi/reporting-period.ts: one dependency-free helper (agiReportingPeriod) derives the period from payment_date, falling back to the run period only when the date is missing. - generate-declaration.ts: XML Redovisningsperiod, the agi_declarations lookup/insert and the sanity warnings key on the payout month. New AGI_PERIOD_CONFLICT (409) refuses to overwrite another live run's declaration for the same payout month; corrections still replace. - submit route, run page (AGI panel, submission hook, tax-payment fetch, XML filename) and RunHeader use the helper; the header says "AGI redovisas för 2026-09 (utbetalningsmånaden)" whenever the two differ. - The in-period payment-date guard is lifted in the dashboard PATCH, lib/salary/update-run.ts (MCP staged tool + pending-ops executor) and the v1 PATCH, plus the RunHeader min/max; its only stated reason was the period-keyed AGI. Generated API skill reference updated. Existing agi_declarations rows keep their stored period: a declaration already filed under the earned month is a correction with Skatteverket, not a re-key. Rule verified against Skatteverket's guidance on redovisningsperiod (kontantprincipen). Closes #2191 Claude-Session: https://claude.ai/code/session_01QPQLwHNEiQfiCNLSMzXMiQ Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Jakob Wennberg
Claude Fable 5.1
parent
601e521584
commit
cb39cded81
@@ -3158,8 +3158,11 @@ const SALARY: Record<string, StructuredErrorEntry> = {
|
||||
// month, the run itself belongs in that period.
|
||||
SALARY_RUN_PAYMENT_DATE_OUTSIDE_PERIOD: {
|
||||
httpStatus: 400,
|
||||
message_sv: 'Utbetalningsdagen måste ligga i lönekörningens period: AGI redovisas per utbetalningsmånad. Skapa en lönekörning för rätt period i stället.',
|
||||
message_en: 'The payment date must fall within the salary run\'s period month: the AGI is declared per payment month. Create a salary run for the correct period instead.',
|
||||
// No longer raised (#2191): the AGI period follows payment_date, so a
|
||||
// payout in another month is legal. Kept so clients mapping the code
|
||||
// keep compiling.
|
||||
message_sv: 'Utbetalningsdagen måste ligga i lönekörningens period.',
|
||||
message_en: 'The payment date must fall within the salary run\'s period month.',
|
||||
},
|
||||
SALARY_RUN_DELETE_NOT_DRAFT: {
|
||||
httpStatus: 400,
|
||||
@@ -3211,6 +3214,13 @@ const SALARY: Record<string, StructuredErrorEntry> = {
|
||||
message_sv: 'AGI kan endast genereras för lönekörningar i status review, approved, paid, booked eller corrected.',
|
||||
message_en: 'AGI can only be generated for salary runs in review, approved, paid, booked, or corrected status.',
|
||||
},
|
||||
AGI_PERIOD_CONFLICT: {
|
||||
httpStatus: 409,
|
||||
message_sv:
|
||||
'En annan lönekörning är redan deklarerad för samma redovisningsperiod (utbetalningsmånad). En arbetsgivardeklaration per månad ska omfatta alla utbetalningar den månaden: slå ihop körningarna eller rätta den befintliga deklarationen.',
|
||||
message_en:
|
||||
'Another salary run is already declared for the same reporting period (payout month). One employer declaration per month must cover every payment made that month: merge the runs or correct the existing declaration.',
|
||||
},
|
||||
AGI_INCOMPLETE_DATA: {
|
||||
httpStatus: 400,
|
||||
message_sv: 'AGI-data ofullständig: kontrollera att företaget har organisationsnummer, kontaktnamn, telefon och e-post.',
|
||||
|
||||
Reference in New Issue
Block a user