fix(SPG-573) Validasi season period tipe specific days - sekalipun harinya berbeda masih terkena validasi, seharusnya bisa disimpan
parent
3bb6ed1082
commit
4b31dd40b5
|
@ -31,7 +31,7 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
||||||
query.andWhere('data.id != :dataId', { dataId: data.id })
|
query.andWhere('data.id != :dataId', { dataId: data.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
const datas = await query
|
let datas = await query
|
||||||
.andWhere('data.priority = :priority', { priority: priority })
|
.andWhere('data.priority = :priority', { priority: priority })
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets(query => {
|
new Brackets(query => {
|
||||||
|
@ -54,14 +54,25 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
||||||
return query;
|
return query;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.getCount();
|
.getMany();
|
||||||
|
|
||||||
if (datas > 0) {
|
if (priority == 2) {
|
||||||
throw new UnprocessableEntityException({
|
datas = datas?.filter(item => {
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
const sameDate = item.days.filter((day) => {
|
||||||
message: `Failed! there is another season period in same range date`,
|
return data.days.some((day2) => {
|
||||||
error: 'Unprocessable Entity',
|
return day == day2;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
return sameDate.length > 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (datas.length > 0) {
|
||||||
|
throw new UnprocessableEntityException({
|
||||||
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
message: `Failed! there is another season period in same range date`,
|
||||||
|
error: 'Unprocessable Entity',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return priority;
|
return priority;
|
||||||
|
|
Loading…
Reference in New Issue