Files
accounted/lib/invoices/seller-vat-number.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

35 lines
1.5 KiB
TypeScript

import type { CompanySettings, Invoice } from '@/types'
/**
* A momsregistrerad seller must state its momsregistreringsnummer on every
* faktura (ML (2023:200) 17 kap. 24 §). Issuing without it produces a formally
* defective invoice and a defective input-VAT underlag for the buyer, so
* issuance is gated the same way the payment account is.
*
* Proformas, quotes (offert) and delivery notes are not tax documents. Credit notes are
* exempted deliberately: an ändringsfaktura has its own mandatory-content
* list (ML 17 kap. 22-23 §§: unambiguous reference to the original, the
* change, own number and date, negative amounts, VAT per original rate)
* which does not include the seller's VAT number, and blocking a correction
* of an already-issued invoice would trap a company that only needs to fix
* its settings.
*/
export function invoiceRequiresSellerVatNumber(
invoice: Pick<Invoice, 'credited_invoice_id' | 'document_type'>,
): boolean {
return !invoice.credited_invoice_id
&& invoice.document_type !== 'delivery_note'
&& invoice.document_type !== 'proforma'
// A quote is not a faktura under ML 17 kap.: no mandatory-content list applies.
&& invoice.document_type !== 'quote'
}
export function hasRequiredSellerVatNumber(
company: Pick<CompanySettings, 'vat_registered' | 'vat_number'>,
invoice: Pick<Invoice, 'credited_invoice_id' | 'document_type'>,
): boolean {
if (!invoiceRequiresSellerVatNumber(invoice)) return true
if (!company.vat_registered) return true
return !!company.vat_number?.trim()
}