* fix: prevent credit notes from entering payment flow * fix: persist and display customer personal numbers * feat: configure automatic invoice reminder days * fix: issue credit notes through send flow * chore: add repository agent guidance * feat(mcp): route tools across user companies * fix(articles): delete unused register entries * feat(invoices): improve issued invoice actions * feat(supplier-invoices): retain uploaded source documents * docs: record implementation decisions * feat: enhance customer personal number handling and validation - Updated CustomerForm to allow personal numbers in the format of "********-1234" for individual customers. - Added validation to ensure personal numbers are only accepted for individual customers in CreateCustomerSchema. - Implemented masking and encryption for personal numbers to enhance data protection. - Introduced new utility functions for masking and encrypting personal numbers. - Added database migration to enforce unique constraints on credit note relationships and prevent duplicate entries. - Enhanced error handling and logging for credit note issuance and invoice processing. - Updated tests to cover new credit note creation guards and personal number handling. * test: enhance list companies test with supabase query mocks
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { isEditableInvoiceDraft } from '@/lib/invoices/is-editable-draft'
|
|
|
|
describe('isEditableInvoiceDraft', () => {
|
|
it('allows a plain draft with no committed verifikat', () => {
|
|
expect(
|
|
isEditableInvoiceDraft({ status: 'draft', journal_entry_id: null, is_self_billed: false }),
|
|
).toBe(true)
|
|
})
|
|
|
|
it('allows a draft when the optional fields are absent', () => {
|
|
expect(isEditableInvoiceDraft({ status: 'draft' })).toBe(true)
|
|
})
|
|
|
|
it('blocks any non-draft status', () => {
|
|
for (const status of ['sent', 'paid', 'cancelled', 'credited', 'overdue']) {
|
|
expect(isEditableInvoiceDraft({ status })).toBe(false)
|
|
}
|
|
})
|
|
|
|
it('blocks a draft that somehow already carries a committed verifikat', () => {
|
|
expect(
|
|
isEditableInvoiceDraft({ status: 'draft', journal_entry_id: 'je-1', is_self_billed: false }),
|
|
).toBe(false)
|
|
})
|
|
|
|
it('blocks a received self-billed document', () => {
|
|
expect(
|
|
isEditableInvoiceDraft({ status: 'draft', journal_entry_id: null, is_self_billed: true }),
|
|
).toBe(false)
|
|
})
|
|
|
|
it('blocks a credit-note draft because it must continue mirroring the original', () => {
|
|
expect(
|
|
isEditableInvoiceDraft({
|
|
status: 'draft',
|
|
journal_entry_id: null,
|
|
credited_invoice_id: 'invoice-1',
|
|
}),
|
|
).toBe(false)
|
|
})
|
|
})
|