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 })
|
||||
}
|
||||
|
||||
const datas = await query
|
||||
let datas = await query
|
||||
.andWhere('data.priority = :priority', { priority: priority })
|
||||
.andWhere(
|
||||
new Brackets(query => {
|
||||
|
@ -54,14 +54,25 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
|||
return query;
|
||||
})
|
||||
)
|
||||
.getCount();
|
||||
.getMany();
|
||||
|
||||
if (datas > 0) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! there is another season period in same range date`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
if (priority == 2) {
|
||||
datas = datas?.filter(item => {
|
||||
const sameDate = item.days.filter((day) => {
|
||||
return data.days.some((day2) => {
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue