feat: add language preference for customers to support invoice locali… (#561)

* feat: add language preference for customers to support invoice localization

- Introduced language support for invoices, allowing customers to choose between Swedish and English.
- Updated invoice PDF generation to reflect the selected language for titles, labels, and messages.
- Enhanced email templates to generate content in the customer's preferred language.
- Added migration to include a language column in the customers table with a default value of Swedish.
- Updated tests to verify correct language usage in invoice emails and PDFs.

* fix: debounce API requests in InvoicePreviewCard and update F-skatt terminology in email templates
This commit is contained in:
Mattsson
2026-05-22 15:21:05 +02:00
committed by GitHub
parent 64bbeb4021
commit 78c91e00e4
21 changed files with 807 additions and 342 deletions
+1
View File
@@ -67,6 +67,7 @@ export const PATCH = withRouteContext(
if (body.country !== undefined) updateData.country = body.country
if (body.org_number !== undefined) updateData.org_number = body.org_number
if (body.vat_number !== undefined) updateData.vat_number = body.vat_number
if (body.language !== undefined) updateData.language = body.language
if (body.default_payment_terms !== undefined) updateData.default_payment_terms = body.default_payment_terms
if (body.notes !== undefined) updateData.notes = body.notes
+1
View File
@@ -58,6 +58,7 @@ export const POST = withRouteContext(
country: body.country || 'Sweden',
org_number: body.org_number,
vat_number: body.vat_number,
language: body.language || 'sv',
default_payment_terms: body.default_payment_terms || 30,
notes: body.notes,
})
+1 -1
View File
@@ -90,7 +90,7 @@ export async function POST(request: Request) {
id: 'preview',
user_id: user.id,
customer_id,
invoice_number: typeof invoice_number === 'string' && invoice_number.trim() ? invoice_number : 'FÖRHANDSGRANSKNING',
invoice_number: typeof invoice_number === 'string' && invoice_number.trim() ? invoice_number : null,
invoice_date: invoice_date || new Date().toISOString().split('T')[0],
due_date: due_date || new Date().toISOString().split('T')[0],
delivery_date: delivery_date || null,
@@ -303,6 +303,7 @@ export const PATCH = withApiV1<{ params: Promise<{ companyId: string; id: string
'country',
'org_number',
'vat_number',
'language',
'default_payment_terms',
'notes',
'archived_at',
@@ -396,6 +396,7 @@ export const POST = withApiV1<{ params: Promise<{ companyId: string }> }>(
vat_number: body.vat_number ?? null,
vat_number_validated: vatValidated,
vat_number_validated_at: vatValidatedAt,
language: body.language ?? 'sv',
default_payment_terms: body.default_payment_terms ?? 30,
notes: body.notes ?? null,
})