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:
1 parent
e229ecefa2
commit
e4500f0d46
48 files changed
+353
-277
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Discount Limit Column -->
|
||||
<ng-container matColumnDef="discountLimit">
|
||||
<mat-header-cell *matHeaderCellDef>Discount Limit</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.discountLimit | percent: '1.2-2' }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Tax Column -->
|
||||
<ng-container matColumnDef="tax">
|
||||
<mat-header-cell *matHeaderCellDef>Tax</mat-header-cell>
|
||||
|
||||
@@ -20,7 +20,7 @@ export class SaleCategoryListComponent implements OnInit {
|
||||
dataSource: SaleCategoryListDatasource = new SaleCategoryListDatasource(this.data);
|
||||
list: SaleCategory[] = [];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'tax'];
|
||||
displayedColumns = ['name', 'discountLimit', 'tax'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
|
||||
@@ -33,11 +33,11 @@ export class SaleCategoryService {
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<SaleCategory[]>;
|
||||
}
|
||||
|
||||
listForDiscount(): Observable<{ name: string; discount: number }[]> {
|
||||
listForDiscount(): Observable<{ name: string; discount: number; discountLimit: number }[]> {
|
||||
return this.http
|
||||
.get<{ name: string; discount: number }[]>(`${url}/for-discount`)
|
||||
.get<{ name: string; discount: number; discountLimit: number }[]>(`${url}/for-discount`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<
|
||||
{ name: string; discount: number }[]
|
||||
{ name: string; discount: number; discountLimit: number }[]
|
||||
>;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user