Refactored customer discount and choose discount. They were using the same schema unnecessarily which was leading to confusion.

This commit is contained in:
2023-03-06 21:04:44 +05:30
parent c5eaeb1497
commit 516b22ed1c
15 changed files with 66 additions and 42 deletions

View File

@ -50,7 +50,7 @@ export class DiscountComponent {
new FormGroup({
name: new FormControl(x.name, { nonNullable: true }),
discount: new FormControl(x.discount * 100, {
validators: [Validators.min(0), Validators.max(x.discountLimit * 100)],
validators: [Validators.min(0), Validators.max(x.limit * 100)],
nonNullable: true,
}),
}),
@ -68,7 +68,7 @@ export class DiscountComponent {
if (control.pristine && control.value === 0) {
this.list.splice(i, 1);
} else {
item.discount = Math.max(Math.min(round(control.value / 100, 5), item.discountLimit), 0);
item.discount = Math.max(Math.min(round(control.value / 100, 5), item.limit), 0);
}
}
this.dialogRef.close(this.list);