Uecko_ERP/modules/customer-invoices/src/api/index.ts

51 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-06-11 15:13:44 +00:00
import { IModuleServer, ModuleParams } from "@erp/core/api";
2025-09-24 17:30:35 +00:00
import { UniqueID } from "@repo/rdx-ddd";
import { Transaction } from "sequelize";
2025-06-12 06:55:17 +00:00
import { customerInvoicesRouter, models } from "./infrastructure";
2025-09-24 17:30:35 +00:00
import { buildCustomerInvoiceDependencies } from "./infrastructure/dependencies";
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
async init(params: ModuleParams) {
2025-06-11 15:13:44 +00:00
// const contacts = getService<ContactsService>("contacts");
const { logger } = params;
2025-06-12 06:55:17 +00:00
customerInvoicesRouter(params);
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
async registerDependencies(params) {
2025-09-24 17:30:35 +00:00
const { logger, listServices } = params; /* = ModuleParams & {
getService: (name: string) => any;
};*/
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
logger.info(listServices());
//getService()
const deps = buildCustomerInvoiceDependencies(params);
2025-06-11 15:13:44 +00:00
return {
models,
services: {
2025-09-24 17:30:35 +00:00
getInvoiceByIdInCompany: (
companyId: UniqueID,
invoiceId: UniqueID,
transaction?: Transaction
) => {
const { service } = deps;
return service.getInvoiceByIdInCompany(companyId, invoiceId, transaction);
},
2025-06-11 15:13:44 +00:00
},
};
},
};
2025-06-12 06:55:17 +00:00
export default customerInvoicesAPIModule;