2025-11-11 18:57:04 +00:00
|
|
|
|
import type { IModuleServer, ModuleParams } from "@erp/core/api";
|
|
|
|
|
|
|
2026-02-07 22:07:23 +00:00
|
|
|
|
import { models } from "./infrastructure";
|
|
|
|
|
|
import { issuedInvoicesRouter } from "./infrastructure/express/issued-invoices/issued-invoices.routes";
|
2025-06-11 15:13:44 +00:00
|
|
|
|
|
2025-06-12 06:55:17 +00:00
|
|
|
|
export const customerInvoicesAPIModule: IModuleServer = {
|
|
|
|
|
|
name: "customer-invoices",
|
2025-06-11 15:13:44 +00:00
|
|
|
|
version: "1.0.0",
|
2025-09-03 10:41:12 +00:00
|
|
|
|
dependencies: ["customers"],
|
2025-06-11 15:13:44 +00:00
|
|
|
|
|
2025-08-12 15:09:04 +00:00
|
|
|
|
async init(params: ModuleParams) {
|
2026-02-07 22:07:23 +00:00
|
|
|
|
const { logger, env } = params;
|
|
|
|
|
|
|
|
|
|
|
|
//proformasRouter(params);
|
|
|
|
|
|
|
|
|
|
|
|
issuedInvoicesRouter({
|
|
|
|
|
|
...params,
|
|
|
|
|
|
services: issuedInvoicesServices,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-09-03 10:41:12 +00:00
|
|
|
|
logger.info("🚀 CustomerInvoices module initialized", { label: this.name });
|
2025-06-11 15:13:44 +00:00
|
|
|
|
},
|
2025-09-24 17:30:35 +00:00
|
|
|
|
|
2026-02-07 22:07:23 +00:00
|
|
|
|
async registerDependencies(
|
|
|
|
|
|
params: ModuleParams & {
|
2025-09-24 17:30:35 +00:00
|
|
|
|
getService: (name: string) => any;
|
2026-02-07 22:07:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
) {
|
|
|
|
|
|
const { logger, getService } = params;
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
// 1️⃣ Obtener dependencias CORE
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
const coreDocuments = getService("core.documents");
|
|
|
|
|
|
const transactionManager = getService("core.transactionManager");
|
|
|
|
|
|
|
|
|
|
|
|
if (!coreDocuments) {
|
|
|
|
|
|
throw new Error("core.documents service not available");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
// 2️⃣ Construir DI del módulo
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
issuedInvoicesServices = buildIssuedInvoicesDI({
|
|
|
|
|
|
coreDocuments,
|
|
|
|
|
|
transactionManager,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
// 3️⃣ Exponer servicios del módulo
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2025-09-24 17:30:35 +00:00
|
|
|
|
|
2025-06-12 06:55:17 +00:00
|
|
|
|
logger.info("🚀 CustomerInvoices module dependencies registered", {
|
2025-09-03 10:41:12 +00:00
|
|
|
|
label: this.name,
|
2025-06-12 06:55:17 +00:00
|
|
|
|
});
|
2025-09-24 17:30:35 +00:00
|
|
|
|
|
2025-06-11 15:13:44 +00:00
|
|
|
|
return {
|
|
|
|
|
|
models,
|
|
|
|
|
|
services: {
|
2026-02-07 22:07:23 +00:00
|
|
|
|
issuedInvoices: issuedInvoicesServices,
|
2025-06-11 15:13:44 +00:00
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
2025-06-12 06:55:17 +00:00
|
|
|
|
|
|
|
|
|
|
export default customerInvoicesAPIModule;
|