2025-06-24 18:38:57 +00:00
|
|
|
import { ILogger, ModuleParams, validateRequest } 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-24 18:38:57 +00:00
|
|
|
import {
|
|
|
|
|
CreateCustomerInvoiceCommandSchema,
|
2025-06-26 18:25:38 +00:00
|
|
|
DeleteCustomerInvoiceByIdQuerySchema,
|
|
|
|
|
DeleteCustomerInvoiceByIdQuerySchema as GetCustomerInvoiceByIdQuerySchema,
|
2025-06-24 18:38:57 +00:00
|
|
|
} from "../../../common/dto";
|
2025-06-26 14:35:53 +00:00
|
|
|
import {
|
|
|
|
|
buildCreateCustomerInvoicesController,
|
2025-06-26 18:25:38 +00:00
|
|
|
buildDeleteCustomerInvoiceController,
|
2025-06-26 18:05:33 +00:00
|
|
|
buildGetCustomerInvoiceController,
|
2025-06-26 14:35:53 +00:00
|
|
|
buildListCustomerInvoicesController,
|
|
|
|
|
} from "../../controllers";
|
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,
|
2025-08-11 17:49:52 +00:00
|
|
|
validateRequest(CustomerInvoiceListCriteriaSchema, "params"),
|
2025-05-04 20:06:57 +00:00
|
|
|
(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-26 18:05:33 +00:00
|
|
|
routes.get(
|
|
|
|
|
"/:id",
|
2025-05-04 20:06:57 +00:00
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
2025-06-26 18:05:33 +00:00
|
|
|
validateRequest(GetCustomerInvoiceByIdQuerySchema, "params"),
|
2025-05-04 20:06:57 +00:00
|
|
|
(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-06-26 18:05:33 +00:00
|
|
|
);
|
2025-05-04 20:06:57 +00:00
|
|
|
|
2025-06-24 18:38:57 +00:00
|
|
|
routes.post(
|
2025-05-04 20:06:57 +00:00
|
|
|
"/",
|
|
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
2025-06-24 18:38:57 +00:00
|
|
|
validateRequest(CreateCustomerInvoiceCommandSchema),
|
2025-05-04 20:06:57 +00:00
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2025-06-26 14:35:53 +00:00
|
|
|
buildCreateCustomerInvoicesController(database).execute(req, res, next);
|
2025-05-04 20:06:57 +00:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2025-06-24 18:38: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
|
|
|
}
|
2025-06-26 18:25:38 +00:00
|
|
|
);*/
|
2025-05-04 20:06:57 +00:00
|
|
|
|
|
|
|
|
routes.delete(
|
2025-06-26 18:25:38 +00:00
|
|
|
"/:id",
|
|
|
|
|
//checkTabContext,
|
2025-05-04 20:06:57 +00:00
|
|
|
//checkUser,
|
2025-06-26 18:25:38 +00:00
|
|
|
validateRequest(DeleteCustomerInvoiceByIdQuerySchema, "params"),
|
2025-05-04 20:06:57 +00:00
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2025-06-26 18:25:38 +00:00
|
|
|
buildDeleteCustomerInvoiceController(database).execute(req, res, next);
|
2025-05-04 20:06:57 +00:00
|
|
|
}
|
2025-06-26 18:25:38 +00:00
|
|
|
);
|
2025-06-24 18:38:57 +00:00
|
|
|
|
|
|
|
|
app.use(`${baseRoutePath}/customer-invoices`, routes);
|
2025-05-04 20:06:57 +00:00
|
|
|
};
|