2025-06-12 06:55:17 +00:00
|
|
|
import { ILogger, ModuleParams } from "@erp/core/api";
|
2025-05-04 20:06:57 +00:00
|
|
|
import { Application, NextFunction, Request, Response, Router } from "express";
|
|
|
|
|
import { Sequelize } from "sequelize";
|
2025-06-11 15:13:44 +00:00
|
|
|
import { buildListCustomerInvoicesController } from "../../presentation";
|
2025-05-04 20:06:57 +00:00
|
|
|
|
2025-06-12 06:55:17 +00:00
|
|
|
export const customerInvoicesRouter = (params: ModuleParams) => {
|
|
|
|
|
const { app, database, baseRoutePath, logger } = params as {
|
2025-05-04 20:06:57 +00:00
|
|
|
app: Application;
|
|
|
|
|
database: Sequelize;
|
|
|
|
|
baseRoutePath: string;
|
2025-06-12 06:55:17 +00:00
|
|
|
logger: ILogger;
|
2025-05-04 20:06:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const routes: Router = Router({ mergeParams: true });
|
|
|
|
|
|
|
|
|
|
routes.get(
|
|
|
|
|
"/",
|
|
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2025-06-11 15:13:44 +00:00
|
|
|
buildListCustomerInvoicesController(database).execute(req, res, next);
|
2025-05-04 20:06:57 +00:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2025-06-12 06:55:17 +00:00
|
|
|
app.use(`${baseRoutePath}/customer-invoices`, routes);
|
2025-06-11 13:13:21 +00:00
|
|
|
|
2025-05-20 10:08:24 +00:00
|
|
|
/*routes.get(
|
2025-06-12 06:55:17 +00:00
|
|
|
"/:customerInvoiceId",
|
2025-05-04 20:06:57 +00:00
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2025-06-11 15:13:44 +00:00
|
|
|
buildGetCustomerInvoiceController(database).execute(req, res, next);
|
2025-05-04 20:06:57 +00:00
|
|
|
}
|
2025-05-20 10:08:24 +00:00
|
|
|
);*/
|
2025-05-04 20:06:57 +00:00
|
|
|
|
|
|
|
|
/*routes.post(
|
|
|
|
|
"/",
|
2025-06-11 15:13:44 +00:00
|
|
|
validateAndParseBody(ICreateCustomerInvoiceRequestSchema, { sanitize: false }),
|
2025-05-04 20:06:57 +00:00
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2025-06-11 15:13:44 +00:00
|
|
|
buildCreateCustomerInvoiceController(database).execute(req, res, next);
|
2025-05-04 20:06:57 +00:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
routes.put(
|
2025-06-12 06:55:17 +00:00
|
|
|
"/:customerInvoiceId",
|
2025-06-11 15:13:44 +00:00
|
|
|
validateAndParseBody(IUpdateCustomerInvoiceRequestSchema),
|
2025-05-04 20:06:57 +00:00
|
|
|
checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2025-06-11 15:13:44 +00:00
|
|
|
buildUpdateCustomerInvoiceController().execute(req, res, next);
|
2025-05-04 20:06:57 +00:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
routes.delete(
|
2025-06-12 06:55:17 +00:00
|
|
|
"/:customerInvoiceId",
|
2025-06-11 15:13:44 +00:00
|
|
|
validateAndParseBody(IDeleteCustomerInvoiceRequestSchema),
|
2025-05-04 20:06:57 +00:00
|
|
|
checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2025-06-11 15:13:44 +00:00
|
|
|
buildDeleteCustomerInvoiceController().execute(req, res, next);
|
2025-05-04 20:06:57 +00:00
|
|
|
}
|
|
|
|
|
);*/
|
|
|
|
|
};
|