UNPKG

@accounter/server

Version:

55 lines 1.82 kB
import { DocumentType } from '../../../__generated__/types.js'; export function normalizeDocumentType(rawType) { if (!rawType) { return DocumentType.Unprocessed; } if (typeof rawType === 'string' && rawType.startsWith('_')) { const int = parseInt(rawType.replace('_', '')); if (Number.isInteger(int)) { rawType = int; } } switch (rawType) { case 20: // חשבון / אישור תשלום return DocumentType.Invoice; case 300: // חשבונית עסקה return DocumentType.Proforma; case 305: // חשבונית מס return DocumentType.Invoice; case 320: // חשבונית מס\קבלה return DocumentType.InvoiceReceipt; case 330: // חשבונית זיכוי return DocumentType.CreditInvoice; case 400: // קבלה return DocumentType.Receipt; case 405: // קבלה על תרומה return DocumentType.Unprocessed; default: console.log(`Got a new document type from Green Invoice: ${rawType}`); return DocumentType.Unprocessed; } } export function getGreenInvoiceDocumentType(documentType) { switch (documentType) { case DocumentType.Invoice: return '_305'; case DocumentType.Proforma: return '_300'; case DocumentType.InvoiceReceipt: return '_320'; case DocumentType.CreditInvoice: return '_330'; case DocumentType.Receipt: return '_400'; default: throw new Error(`Unsupported document type: ${documentType}`); } } //# sourceMappingURL=green-invoice.helper.js.map