b6b345f245
- Refactor email verification and password reset utilities to use new email service. - Introduce email delivery queue and notification delivery model for better tracking. - Enhance file validation and storage services for improved security and ownership management. - Add cron job for cleaning inactive notifications with retention policy. - Update document worker to handle document generation and storage more efficiently. - Implement logging improvements in activity and log workers. - Create comprehensive documentation for new API endpoints and services. - Add unit tests for file validation and notification policies to ensure robustness.
77 lines
2.3 KiB
JavaScript
77 lines
2.3 KiB
JavaScript
/**
|
|
* Copyright (c) 2026 Niolla
|
|
* All rights reserved.
|
|
*
|
|
* This source code is proprietary and confidential.
|
|
* Unauthorized copying, modification, distribution, or use
|
|
* of this file, via any medium, is strictly prohibited.
|
|
*/
|
|
|
|
// app/logic/documents/registry.js
|
|
|
|
let buildPreCostTemplate, buildInvoiceTemplate, buildDispatchNoteTemplate, buildDeliveryNoteTemplate, buildPOTemplate, buildCustomDocumentTemplate, buildCreditNoteTemplate;
|
|
let precostBuilder, invoiceBuilder;
|
|
|
|
try {
|
|
buildPreCostTemplate = require("../../templates/documents/precost/preCost.template");
|
|
buildInvoiceTemplate = require("../../templates/documents/invoice/invoice.template");
|
|
buildDispatchNoteTemplate = require("../../templates/documents/dispatchNote/dispatchNote.template");
|
|
buildDeliveryNoteTemplate = require("../../templates/documents/deliveryNote/deliveryNote.template");
|
|
buildPOTemplate = require("../../templates/documents/po/po.template");
|
|
buildCustomDocumentTemplate = require("../../templates/documents/customDocument/customDocument.template");
|
|
buildCreditNoteTemplate = require("../../templates/documents/creditNote/creditNote.template");
|
|
|
|
precostBuilder = require("./builders/precost.builder");
|
|
invoiceBuilder = require("./builders/invoice.builder");
|
|
|
|
console.log("✅ All document templates loaded successfully");
|
|
} catch (error) {
|
|
console.error("❌ Error loading document templates:", error.message);
|
|
console.error(error.stack);
|
|
}
|
|
|
|
const registry = {
|
|
precost: {
|
|
pdfTemplate: buildPreCostTemplate,
|
|
excelBuilder: precostBuilder,
|
|
},
|
|
|
|
invoice: {
|
|
pdfTemplate: buildInvoiceTemplate,
|
|
excelBuilder: invoiceBuilder,
|
|
},
|
|
|
|
dispatchnote: {
|
|
pdfTemplate: buildDispatchNoteTemplate,
|
|
excelBuilder: null,
|
|
},
|
|
|
|
deliverynote: {
|
|
pdfTemplate: buildDeliveryNoteTemplate,
|
|
excelBuilder: null,
|
|
},
|
|
|
|
po: {
|
|
pdfTemplate: buildPOTemplate,
|
|
excelBuilder: null,
|
|
},
|
|
|
|
customdocument: {
|
|
pdfTemplate: buildCustomDocumentTemplate,
|
|
excelBuilder: null,
|
|
},
|
|
|
|
creditnote: {
|
|
pdfTemplate: buildCreditNoteTemplate,
|
|
excelBuilder: null,
|
|
},
|
|
};
|
|
|
|
console.log("📋 Registry initialized with keys:", Object.keys(registry));
|
|
|
|
for (const [key, entry] of Object.entries(registry)) {
|
|
if (typeof entry.pdfTemplate !== "function") delete registry[key];
|
|
}
|
|
|
|
module.exports = registry;
|