apps/web: add check min bonus
This commit is contained in:
parent
194292c083
commit
5347c3ef6c
@ -10,8 +10,17 @@ export function createValidationSchema(context: ValidationContext) {
|
||||
return ValuesSchema.pick({ product: true, saleBonus: true }).superRefine(
|
||||
async ({ product, saleBonus }, ctx) => {
|
||||
const coefficient = await getCoefficient(product);
|
||||
const minBonus = (coefficient?.evo_correction_coefficient || 0) * 100;
|
||||
const maxBonus = (coefficient?.evo_sot_coefficient || 0) * 100;
|
||||
|
||||
if (round(saleBonus, 2) < round(minBonus, 2)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Бонус не может быть ниже установленного по СОТ',
|
||||
path: ['tbxSaleBonus'],
|
||||
});
|
||||
}
|
||||
|
||||
if (round(saleBonus, 2) > round(maxBonus, 2)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user