* refactor: optimize page loading and data fetching * fix: resolve recurring production runtime errors * feat: add MCP company and customer updates * fix: handle year-end tax adjustments * feat: harden annual report compliance * fix: expand invoice logo and font support * fix: sanitize API route error responses * fix: sanitize user-facing error messages * feat: persist onboarding and tax assessment notices * fix: reduce cloud backup audit churn * feat: refine invoice editor layout * fix: show saved tax adjustments in INK2 * fix: complete annual report API mappings * docs: record operational safeguards and decisions * fix: harden annual report review findings * fix: adjust column span for description based on VAT registration * New css class name
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { z } from 'zod'
|
|
import { UpdateSettingsSchema } from '@/lib/api/schemas'
|
|
import {
|
|
validateBankgiroNumber,
|
|
validatePlusgiroNumber,
|
|
} from '@/lib/bankgiro/luhn'
|
|
|
|
const CompanySettingsChangesSchema = z
|
|
.object({
|
|
bank_name: UpdateSettingsSchema.shape.bank_name,
|
|
clearing_number: UpdateSettingsSchema.shape.clearing_number,
|
|
account_number: UpdateSettingsSchema.shape.account_number,
|
|
bankgiro: UpdateSettingsSchema.shape.bankgiro,
|
|
plusgiro: UpdateSettingsSchema.shape.plusgiro,
|
|
swish: UpdateSettingsSchema.shape.swish,
|
|
iban: UpdateSettingsSchema.shape.iban,
|
|
bic: UpdateSettingsSchema.shape.bic,
|
|
default_our_reference: UpdateSettingsSchema.shape.default_our_reference,
|
|
})
|
|
.strict()
|
|
.superRefine((changes, ctx) => {
|
|
if (Object.keys(changes).length === 0) {
|
|
ctx.addIssue({
|
|
code: 'custom',
|
|
message: 'At least one company setting must be supplied',
|
|
})
|
|
}
|
|
|
|
if (changes.bankgiro && !validateBankgiroNumber(changes.bankgiro)) {
|
|
ctx.addIssue({
|
|
code: 'custom',
|
|
path: ['bankgiro'],
|
|
message: 'Invalid Bankgiro number',
|
|
})
|
|
}
|
|
|
|
if (changes.plusgiro && !validatePlusgiroNumber(changes.plusgiro)) {
|
|
ctx.addIssue({
|
|
code: 'custom',
|
|
path: ['plusgiro'],
|
|
message: 'Invalid Plusgiro number',
|
|
})
|
|
}
|
|
})
|
|
|
|
export const UpdateCompanySettingsParamsSchema = z
|
|
.object({
|
|
changes: CompanySettingsChangesSchema,
|
|
})
|
|
.strict()
|
|
|
|
export type UpdateCompanySettingsParams = z.infer<
|
|
typeof UpdateCompanySettingsParamsSchema
|
|
>
|