Breaking: Discount is applicable on sale category and not on menu category
Fix the import, etc on this. While entering discount in sale, it checks the max allowed.
This commit is contained in:
@ -17,6 +17,25 @@
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Discount Limit</mat-label>
|
||||
<input
|
||||
matInput
|
||||
type="number"
|
||||
placeholder="Discount Limit"
|
||||
formControlName="discountLimit"
|
||||
class="right-align"
|
||||
/>
|
||||
<span matSuffix>%</span>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
|
||||
@ -2,6 +2,7 @@ import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angula
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { round } from 'mathjs';
|
||||
|
||||
import { SaleCategory } from '../../core/sale-category';
|
||||
import { Tax } from '../../core/tax';
|
||||
@ -31,6 +32,7 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
discountLimit: '',
|
||||
tax: '',
|
||||
});
|
||||
}
|
||||
@ -47,7 +49,8 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name,
|
||||
tax: this.item.tax.id ? this.item.tax.id : '',
|
||||
discountLimit: this.item.discountLimit * 100,
|
||||
tax: this.item.tax ? this.item.tax.id : '',
|
||||
});
|
||||
}
|
||||
|
||||
@ -99,6 +102,10 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
getItem(): SaleCategory {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.discountLimit = round(+formModel.discountLimit / 100, 5);
|
||||
if (this.item.tax === null || this.item.tax === undefined) {
|
||||
this.item.tax = new Tax();
|
||||
}
|
||||
this.item.tax.id = formModel.tax;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user