From 8976cd812d10b6f529ffd126a30871eb004ad969 Mon Sep 17 00:00:00 2001 From: Mattsson <111893710+mattssonn@users.noreply.github.com> Date: Tue, 17 Mar 2026 14:28:58 +0100 Subject: [PATCH] Vat onboarding fixes (#39) * fix: enhance validation for moms_period and conditionally set vat_number and moms_period based on vat_registered * Enhance preprocessing for first year fields, fiscal year end month, and accounting method in schema validation * fix: simplify schema validation by removing unnecessary preprocessors * fix: prevent setting invalid values in select components across multiple forms * fix: improve layout responsiveness and conditional rendering in onboarding steps --- app/(dashboard)/import/page.tsx | 14 +-------- components/bookkeeping/AccountCombobox.tsx | 10 +++++-- components/bookkeeping/AddAccountDialog.tsx | 2 +- components/customers/CustomerForm.tsx | 2 +- components/deadlines/DeadlineForm.tsx | 6 ++-- .../import/BankFileColumnMappingStep.tsx | 4 +-- .../onboarding/Step3TaxRegistration.tsx | 29 ++++++++++++------- components/onboarding/Step4PreliminaryTax.tsx | 7 +++-- components/onboarding/Step6ConnectBank.tsx | 4 +-- components/suppliers/SupplierForm.tsx | 4 +-- .../transactions/VatTreatmentSelect.tsx | 2 +- 11 files changed, 42 insertions(+), 42 deletions(-) diff --git a/app/(dashboard)/import/page.tsx b/app/(dashboard)/import/page.tsx index 2a4d4231..6552895c 100644 --- a/app/(dashboard)/import/page.tsx +++ b/app/(dashboard)/import/page.tsx @@ -786,20 +786,8 @@ export default function ImportPage() {

- {mode === null && ( + {mode === null && hasBankingExtension !== null && (
- {hasBankingExtension === null && ( - - -
-
-
-
-
-
- - - )} {hasBankingExtension === true && ( { - function handleClickOutside(e: MouseEvent) { + function handleClickOutside(e: MouseEvent | TouchEvent) { if (containerRef.current && !containerRef.current.contains(e.target as Node)) { setIsOpen(false) } } document.addEventListener('mousedown', handleClickOutside) - return () => document.removeEventListener('mousedown', handleClickOutside) + document.addEventListener('touchstart', handleClickOutside) + return () => { + document.removeEventListener('mousedown', handleClickOutside) + document.removeEventListener('touchstart', handleClickOutside) + } }, []) const selectAccount = useCallback( diff --git a/components/bookkeeping/AddAccountDialog.tsx b/components/bookkeeping/AddAccountDialog.tsx index a98d0e0e..837db2a4 100644 --- a/components/bookkeeping/AddAccountDialog.tsx +++ b/components/bookkeeping/AddAccountDialog.tsx @@ -146,7 +146,7 @@ export function AddAccountDialog({ open, onOpenChange, onCreated }: AddAccountDi
- { if (v) setNormalBalance(v as 'debit' | 'credit') }}> diff --git a/components/customers/CustomerForm.tsx b/components/customers/CustomerForm.tsx index d1ec7099..97914007 100644 --- a/components/customers/CustomerForm.tsx +++ b/components/customers/CustomerForm.tsx @@ -136,7 +136,7 @@ export default function CustomerForm({ name="customer_type" control={control} render={({ field }) => ( - { if (v) field.onChange(v) }}> diff --git a/components/deadlines/DeadlineForm.tsx b/components/deadlines/DeadlineForm.tsx index a3b7dcb9..93b5624b 100644 --- a/components/deadlines/DeadlineForm.tsx +++ b/components/deadlines/DeadlineForm.tsx @@ -176,7 +176,7 @@ export function DeadlineForm({ updateField('priority', v as DeadlinePriority)} + onValueChange={(v) => { if (v) updateField('priority', v as DeadlinePriority) }} > @@ -216,7 +216,7 @@ export function DeadlineForm({ + setDecimalSep(v as ',' | '.')}> + handleMonthChange(parseInt(v))} + onValueChange={(v) => { if (v) handleMonthChange(parseInt(v)) }} > @@ -447,7 +454,7 @@ export default function Step3TaxRegistration({ setAbEndMonth(parseInt(v))} + onValueChange={(v) => { if (v) setAbEndMonth(parseInt(v)) }} > @@ -502,7 +509,7 @@ export default function Step3TaxRegistration({ render={({ field }) => ( field.onChange(parseInt(value))} + onValueChange={(v) => { if (v) field.onChange(parseInt(v)) }} > @@ -644,7 +651,7 @@ export default function Step3TaxRegistration({
{vatRegistered && ( -
+
( { if (v) field.onChange(v) }} > diff --git a/components/onboarding/Step4PreliminaryTax.tsx b/components/onboarding/Step4PreliminaryTax.tsx index dead5453..6c7c4211 100644 --- a/components/onboarding/Step4PreliminaryTax.tsx +++ b/components/onboarding/Step4PreliminaryTax.tsx @@ -95,7 +95,7 @@ export default function Step4PreliminaryTax({
-
+
-
+
- -
+