new param for service fare, fare type id

This commit is contained in:
wayanrivan
2026-03-25 14:06:50 +07:00
parent a1df4a08f9
commit 4f3074f8f8
2 changed files with 11 additions and 0 deletions

View File

@ -88,6 +88,7 @@ export class ServiceFareController {
service_class_id: Joi.string().uuid().required().label("Service Class ID"),
service_id: Joi.string().uuid().required().label("Service ID"),
fare: Joi.number().min(0).required().label("Fare"),
faretype: Joi.string().uuid().required().label("Fare Type ID"),
});
let param: any = await schema.validateAsync(req.body);
@ -98,6 +99,9 @@ export class ServiceFareController {
let service = await ServiceModel.list({ "Service.id": param.service_id }).then((q) => q.getOne());
if (!service) throw { message: "Service not found" };
let fareType = await OrmHelper.DB.getRepository("FareType").createQueryBuilder("FareType").where("FareType.id = :id", { id: param.faretype }).getOne();
if (!fareType) throw { message: "Fare Type not found" };
// let filter = {
// serviceClassId: param.service_class_id,
// serviceId: param.service_id,
@ -109,6 +113,7 @@ export class ServiceFareController {
serviceFare.serviceClass = serviceClass;
serviceFare.service = service;
serviceFare.fare = String(param.fare);
serviceFare.faretype = param.faretype;
serviceFare.created_by = req.auth.data.name;
serviceFare.updated_by = req.auth.data.name;
await queryRunner.manager.save(serviceFare);
@ -172,6 +177,7 @@ export class ServiceFareController {
service_class_id: Joi.string().uuid().required().label("Service Class ID"),
service_id: Joi.string().uuid().required().label("Service ID"),
fare: Joi.number().min(0).required().label("Fare"),
faretype: Joi.string().uuid().required().label("Fare Type ID"),
});
let param: any = await schema.validateAsync(req.body);
@ -185,6 +191,9 @@ export class ServiceFareController {
let serviceFare = await ServiceFareModel.list({ "ServiceFare.id": param.id }).then((q) => q.getOne());
if (!serviceFare) throw { message: "Service Fare " + Language.lang.failed_not_found };
let fareType = await OrmHelper.DB.getRepository("FareType").createQueryBuilder("FareType").where("FareType.id = :id", { id: param.faretype }).getOne();
if (!fareType) throw { message: "Fare Type not found" };
// let filter = {
// serviceClassId: param.service_class_id,
// serviceId: param.service_id,
@ -195,6 +204,7 @@ export class ServiceFareController {
serviceFare.serviceClass = serviceClass;
serviceFare.service = service;
serviceFare.fare = String(param.fare);
serviceFare.faretype = param.faretype;
serviceFare.updated_by = req.auth.data.name;
await queryRunner.manager.save(serviceFare);

View File

@ -147,6 +147,7 @@ const doc = {
serviceFare: {
$service_class_id: "uuid-string",
$service_id: "uuid-string",
$faretype: "uuid-string",
$fare: 100000
},
servicePackage: {