Add/csv import options (#420)
* feat(import): add customer and supplier parsing functionality - Implemented customer file parsing in `lib/import/customers/parser.ts` with support for Excel and CSV formats. - Created types for detected customer columns and parsed customer rows in `lib/import/customers/types.ts`. - Added tests for customer classification logic in `lib/import/shared/__tests__/classify.test.ts`. - Developed classification functions for customers and suppliers in `lib/import/shared/classify.ts`. - Introduced shared column utility functions in `lib/import/shared/column-utils.ts`. - Implemented supplier file parsing in `lib/import/suppliers/parser.ts` with validation for various fields. - Created types for detected supplier columns and parsed supplier rows in `lib/import/suppliers/types.ts`. - Added tests for supplier column detection and parsing in `lib/import/suppliers/__tests__/column-detector.test.ts` and `lib/import/suppliers/__tests__/parser.test.ts`. * fix(labels): update 'Svenskt företag' to 'Svenskt företag eller organisation' for clarity * feat(import): refactor encoding handling for Swedish files and add tests for character preservation * feat(recapt): implement clearRecaptIdentity function and integrate into logout flow * feat(bookkeeping): implement copy functionality and next voucher sequence retrieval * feat(import): enhance customer and supplier import functionality with normalization and event handling
This commit is contained in:
@@ -24,6 +24,7 @@ const PERSISTED_EVENT_TYPES: CoreEventType[] = [
|
||||
'period.locked',
|
||||
'period.year_closed',
|
||||
'customer.created',
|
||||
'supplier.created',
|
||||
'receipt.matched',
|
||||
'receipt.confirmed',
|
||||
'supplier_invoice.registered',
|
||||
@@ -52,7 +53,7 @@ const PERSISTED_EVENT_TYPES: CoreEventType[] = [
|
||||
function extractEntityId(payload: Record<string, unknown>): string | null {
|
||||
// Try common entity shapes in priority order
|
||||
const entityKeys = [
|
||||
'entry', 'invoice', 'transaction', 'customer', 'receipt',
|
||||
'entry', 'invoice', 'transaction', 'customer', 'supplier', 'receipt',
|
||||
'supplierInvoice', 'creditNote', 'period', 'document', 'inboxItem',
|
||||
] as const
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
Invoice,
|
||||
Transaction,
|
||||
Customer,
|
||||
Supplier,
|
||||
FiscalPeriod,
|
||||
DocumentAttachment,
|
||||
Receipt,
|
||||
@@ -40,6 +41,8 @@ export type CoreEvent =
|
||||
| { type: 'period.year_closed'; payload: { period: FiscalPeriod; userId: string; companyId: string } }
|
||||
// Customers
|
||||
| { type: 'customer.created'; payload: { customer: Customer; userId: string; companyId: string } }
|
||||
// Suppliers
|
||||
| { type: 'supplier.created'; payload: { supplier: Supplier; userId: string; companyId: string } }
|
||||
// Receipts
|
||||
| { type: 'receipt.extracted'; payload: {
|
||||
receipt: Receipt;
|
||||
|
||||
Reference in New Issue
Block a user