fix(vat): enforce fraction unit for supplier invoice vat_rate writes (#1385)
Closes the remaining #310 write paths: credit-note item copies (web, v1, pending-operations) and arcim-migration supplier imports now normalize vat_rate to the decimal-fraction unit before storage, and a NOT VALID CHECK constraint guards every new supplier_invoice_items row. Customer invoice items deliberately stay percent; legacy supplier rows are left untouched so posted-entry reversals reuse the exact original values. Fixes #310 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
5b9605d8e9
commit
8443062b1f
@@ -24,7 +24,10 @@ import {
|
||||
} from '@/lib/currency/supplier-invoice-rate'
|
||||
import { roundOre } from '@/lib/money'
|
||||
import { validateVatNumber } from '@/lib/vat/vies-client'
|
||||
import { normalizeVatRateToDecimal } from '@/lib/vat/supplier-invoice-line-checks'
|
||||
import {
|
||||
normalizeVatRateToDecimal,
|
||||
normalizeVatRateToFraction,
|
||||
} from '@/lib/vat/supplier-invoice-line-checks'
|
||||
import {
|
||||
createInvoicePaymentJournalEntry,
|
||||
createInvoiceCashEntry,
|
||||
@@ -3729,7 +3732,7 @@ async function commitCreditSupplierInvoice(
|
||||
line_total: item.line_total,
|
||||
account_number: item.account_number,
|
||||
vat_code: item.vat_code,
|
||||
vat_rate: item.vat_rate,
|
||||
vat_rate: normalizeVatRateToFraction(item.vat_rate),
|
||||
vat_amount: item.vat_amount,
|
||||
dimensions: item.dimensions ?? {},
|
||||
}))
|
||||
@@ -3747,7 +3750,7 @@ async function commitCreditSupplierInvoice(
|
||||
companyId,
|
||||
userId,
|
||||
creditNote,
|
||||
creditItems as never,
|
||||
original.items as never,
|
||||
original.supplier?.supplier_type || 'swedish_business',
|
||||
original.supplier?.name
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user