new param for service fare, fare type id
This commit is contained in:
@ -88,6 +88,7 @@ export class ServiceFareController {
|
|||||||
service_class_id: Joi.string().uuid().required().label("Service Class ID"),
|
service_class_id: Joi.string().uuid().required().label("Service Class ID"),
|
||||||
service_id: Joi.string().uuid().required().label("Service ID"),
|
service_id: Joi.string().uuid().required().label("Service ID"),
|
||||||
fare: Joi.number().min(0).required().label("Fare"),
|
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);
|
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());
|
let service = await ServiceModel.list({ "Service.id": param.service_id }).then((q) => q.getOne());
|
||||||
if (!service) throw { message: "Service not found" };
|
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 = {
|
// let filter = {
|
||||||
// serviceClassId: param.service_class_id,
|
// serviceClassId: param.service_class_id,
|
||||||
// serviceId: param.service_id,
|
// serviceId: param.service_id,
|
||||||
@ -109,6 +113,7 @@ export class ServiceFareController {
|
|||||||
serviceFare.serviceClass = serviceClass;
|
serviceFare.serviceClass = serviceClass;
|
||||||
serviceFare.service = service;
|
serviceFare.service = service;
|
||||||
serviceFare.fare = String(param.fare);
|
serviceFare.fare = String(param.fare);
|
||||||
|
serviceFare.faretype = param.faretype;
|
||||||
serviceFare.created_by = req.auth.data.name;
|
serviceFare.created_by = req.auth.data.name;
|
||||||
serviceFare.updated_by = req.auth.data.name;
|
serviceFare.updated_by = req.auth.data.name;
|
||||||
await queryRunner.manager.save(serviceFare);
|
await queryRunner.manager.save(serviceFare);
|
||||||
@ -172,6 +177,7 @@ export class ServiceFareController {
|
|||||||
service_class_id: Joi.string().uuid().required().label("Service Class ID"),
|
service_class_id: Joi.string().uuid().required().label("Service Class ID"),
|
||||||
service_id: Joi.string().uuid().required().label("Service ID"),
|
service_id: Joi.string().uuid().required().label("Service ID"),
|
||||||
fare: Joi.number().min(0).required().label("Fare"),
|
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);
|
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());
|
let serviceFare = await ServiceFareModel.list({ "ServiceFare.id": param.id }).then((q) => q.getOne());
|
||||||
if (!serviceFare) throw { message: "Service Fare " + Language.lang.failed_not_found };
|
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 = {
|
// let filter = {
|
||||||
// serviceClassId: param.service_class_id,
|
// serviceClassId: param.service_class_id,
|
||||||
// serviceId: param.service_id,
|
// serviceId: param.service_id,
|
||||||
@ -195,6 +204,7 @@ export class ServiceFareController {
|
|||||||
serviceFare.serviceClass = serviceClass;
|
serviceFare.serviceClass = serviceClass;
|
||||||
serviceFare.service = service;
|
serviceFare.service = service;
|
||||||
serviceFare.fare = String(param.fare);
|
serviceFare.fare = String(param.fare);
|
||||||
|
serviceFare.faretype = param.faretype;
|
||||||
serviceFare.updated_by = req.auth.data.name;
|
serviceFare.updated_by = req.auth.data.name;
|
||||||
await queryRunner.manager.save(serviceFare);
|
await queryRunner.manager.save(serviceFare);
|
||||||
|
|
||||||
|
|||||||
@ -147,6 +147,7 @@ const doc = {
|
|||||||
serviceFare: {
|
serviceFare: {
|
||||||
$service_class_id: "uuid-string",
|
$service_class_id: "uuid-string",
|
||||||
$service_id: "uuid-string",
|
$service_id: "uuid-string",
|
||||||
|
$faretype: "uuid-string",
|
||||||
$fare: 100000
|
$fare: 100000
|
||||||
},
|
},
|
||||||
servicePackage: {
|
servicePackage: {
|
||||||
|
|||||||
Reference in New Issue
Block a user