From 9f7c842a334de383ca32a3086b3a8d859138a10e Mon Sep 17 00:00:00 2001 From: Jakob Wennberg <149234542+jakobwennberg@users.noreply.github.com> Date: Fri, 3 Jul 2026 16:12:51 +0200 Subject: [PATCH] feat(skatt): setup gates + auto-loading momsdeklaration across Skatt & bokslut tabs (#885) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(skatt): setup gates + auto-loading momsdeklaration across Skatt & bokslut tabs Every tab in the Skatt & bokslut nav group now tells an unconfigured user what is missing and where to fix it, instead of dead-ending or rendering zeros: - Momsdeklaration: gates on vat_registered with a settings CTA; auto-fetches the configured period on load and on every period change (no more "Hämta" button); one period control (räkenskapsår picked inline for helårsmoms, shell selector + back link dropped via new ReportDescriptor.standalone); raw setPeriodType(e.target.value as VatPeriodType)} - className="w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm" + onValueChange={(value) => handlePeriodTypeChange(value as VatPeriodType)} > - - - - + + + + + Månadsvis + Kvartalsvis + Årsvis + + {isYearly ? ( - // Annual VAT covers the selected räkenskapsår — driven by the - // fiscal-year picker on the report page, not a calendar year. -
- -
- {fiscalPeriodBounds - ? `${formatDate(fiscalPeriodBounds.start)} – ${formatDate(fiscalPeriodBounds.end)}` - : '—'} -
-
+ // Annual VAT covers a räkenskapsår — picked here, not a + // calendar year. + setFiscalPeriodId(id || '')} + includeAllOption={false} + hideFuturePeriods + /> ) : ( <>
- +
- setPeriod(parseInt(value))} > - {getPeriodOptions().map((opt) => ( - - ))} - + + + + + {getPeriodOptions().map((opt) => ( + + {opt.label} + + ))} + +
)} - {error && ( - - - {error} + + +

{error}

+
)} - {data && ( - <> + {!error && (awaitingFiscalPeriod || (loading && !data)) && ( + + + + + + + )} + + {data && !awaitingFiscalPeriod && ( +
{/* Summary */} - +
Momsdeklaration - {data.period.start} till {data.period.end} @@ -1403,24 +1508,20 @@ export function VatDeclarationView({
- +
)} - {/* Skatteverket integration panel */} - - - {!data && !loading && !error && ( - - - Välj period och klicka "Hämta" för att se momsdeklaration. - - + {/* Skatteverket integration panel — hidden while the räkenskapsår for + helårsmoms is unresolved, so its actions can never target an + unconfirmed period. */} + {!awaitingFiscalPeriod && ( + )} diff --git a/lib/reports/catalog.ts b/lib/reports/catalog.ts index b24dba80..b6d56523 100644 --- a/lib/reports/catalog.ts +++ b/lib/reports/catalog.ts @@ -69,6 +69,12 @@ export interface ReportDescriptor { dimensions?: boolean /** Only shown when company_settings.dimensions_enabled is true. */ needsDimensions?: boolean + /** + * Nav-promoted page that happens to render in the focused-report shell. + * Hides the report-library back link and the shell's fiscal-year selector — + * the view owns all of its period controls. + */ + standalone?: boolean } /** Categories shown in the legacy desktop rail, in order. */ @@ -206,6 +212,9 @@ export const REPORT_CATALOG: ReportDescriptor[] = [ category: 'tax_vat', params: 'calendar', exports: ['xlsx'], + // Promoted to the Skatt & bokslut nav group — reached directly, not via + // the report library, and it manages its own period selection. + standalone: true, }, { slug: 'periodisk-sammanstallning', diff --git a/messages/en.json b/messages/en.json index bb9776a0..057bd766 100644 --- a/messages/en.json +++ b/messages/en.json @@ -303,7 +303,9 @@ "deleted_title": "Deadline deleted", "delete_failed_title": "Could not delete deadline", "retry": "Please try again.", - "overdue_invoices": "{count} overdue invoices" + "overdue_invoices": "{count} overdue invoices", + "no_system_deadlines_title": "Automatic tax deadlines missing.", + "no_system_deadlines_description": "Deadlines for VAT, employer declarations and F-tax are generated from your company's tax settings — make sure they are filled in." }, "bureau": { "title": "Bureau", diff --git a/messages/sv.json b/messages/sv.json index c1effa3a..d2da8108 100644 --- a/messages/sv.json +++ b/messages/sv.json @@ -303,7 +303,9 @@ "deleted_title": "Deadline borttagen", "delete_failed_title": "Kunde inte ta bort deadline", "retry": "Försök igen.", - "overdue_invoices": "{count} förfallna fakturor" + "overdue_invoices": "{count} förfallna fakturor", + "no_system_deadlines_title": "Automatiska skattedeadlines saknas.", + "no_system_deadlines_description": "Deadlines för moms, arbetsgivardeklaration och F-skatt skapas från företagets skatteinställningar — kontrollera att de är ifyllda." }, "bureau": { "title": "Byrå",