Å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.
35 lines
1.5 KiB
TypeScript
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()
|
|
}
|