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,25 +17,6 @@
|
||||
<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"
|
||||
|
||||
@ -29,7 +29,6 @@ export class MenuCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
discountLimit: '',
|
||||
isActive: '',
|
||||
});
|
||||
}
|
||||
@ -45,7 +44,6 @@ export class MenuCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name,
|
||||
discountLimit: this.item.discountLimit,
|
||||
isActive: this.item.isActive,
|
||||
});
|
||||
}
|
||||
@ -98,7 +96,6 @@ export class MenuCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
getItem(): MenuCategory {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.discountLimit = +formModel.discountLimit;
|
||||
this.item.isActive = formModel.isActive;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@ -24,12 +24,6 @@
|
||||
>
|
||||
</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>
|
||||
|
||||
<!-- Is Active Column -->
|
||||
<ng-container matColumnDef="isActive">
|
||||
<mat-header-cell *matHeaderCellDef>Active?</mat-header-cell>
|
||||
|
||||
@ -21,7 +21,7 @@ export class MenuCategoryListComponent implements OnInit {
|
||||
data: BehaviorSubject<MenuCategory[]> = new BehaviorSubject<MenuCategory[]>(this.list);
|
||||
dataSource: MenuCategoryListDatasource = new MenuCategoryListDatasource(this.data);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'discountLimit', 'isActive', 'isFixture'];
|
||||
displayedColumns = ['name', 'isActive', 'isFixture'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@ -37,9 +37,6 @@ export class MenuCategoryListComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: MenuCategory[] };
|
||||
data.list.forEach((x) => {
|
||||
x.discountLimit /= 100;
|
||||
});
|
||||
this.data.next(data.list);
|
||||
});
|
||||
this.dataSource = new MenuCategoryListDatasource(this.data);
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { BeerSaleReport } from '../beer-sale-report/beer-sale-report';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { MenuCategory } from '../core/menu-category';
|
||||
|
||||
@ -27,9 +28,13 @@ export class MenuCategoryService {
|
||||
) as Observable<MenuCategory>;
|
||||
}
|
||||
|
||||
list(): Observable<MenuCategory[]> {
|
||||
list(shoudHaveActiveProducts: boolean | undefined = false): Observable<MenuCategory[]> {
|
||||
const options = { params: new HttpParams() };
|
||||
if (shoudHaveActiveProducts !== undefined) {
|
||||
options.params = options.params.set('p', 'true');
|
||||
}
|
||||
return this.http
|
||||
.get<MenuCategory[]>(`${url}/list`)
|
||||
.get<MenuCategory[]>(`${url}/list`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<MenuCategory[]>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user