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:
tanshu committed 2020-12-16 11:49:22 +05:30
1 parent e229ecefa2
commit e4500f0d46
48 files changed
+353 -277

No files matched your search

@@ -63,8 +63,8 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
code: this.item.code || '(Auto)',
name: this.item.name || '',
units: this.item.units || '',
menuCategory: this.item.menuCategory.id ? this.item.menuCategory.id : '',
saleCategory: this.item.saleCategory.id ? this.item.saleCategory.id : '',
menuCategory: this.item.menuCategory ? this.item.menuCategory.id : '',
saleCategory: this.item.saleCategory ? this.item.saleCategory.id : '',
price: this.item.price || '',
hasHappyHour: this.item.hasHappyHour,
isNotAvailable: this.item.isNotAvailable,
@@ -121,7 +121,13 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
const formModel = this.form.value;
this.item.name = formModel.name;
this.item.units = formModel.units;
if (this.item.menuCategory === null || this.item.menuCategory === undefined) {
this.item.menuCategory = new MenuCategory();
}
this.item.menuCategory.id = formModel.menuCategory;
if (this.item.saleCategory === null || this.item.saleCategory === undefined) {
this.item.saleCategory = new SaleCategory();
}
this.item.saleCategory.id = formModel.saleCategory;
this.item.price = +formModel.price;
this.item.hasHappyHour = formModel.hasHappyHour;
@@ -2,6 +2,7 @@ import { DataSource } from '@angular/cdk/collections';
import { merge, Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { MenuCategory } from '../../core/menu-category';
import { Product } from '../../core/product';
export class ProductListDataSource extends DataSource<Product> {
@@ -44,9 +45,9 @@ export class ProductListDataSource extends DataSource<Product> {
// eslint-disable-next-line class-methods-use-this
private getFilteredData(data: Product[], filter: string): Product[] {
if (filter === undefined) {
if (filter === null || filter === undefined || filter === '') {
return data;
}
return data.filter((x) => x.menuCategory.id === filter);
return data.filter((x) => (x.menuCategory as MenuCategory).id === filter);
}
}
@@ -85,7 +85,7 @@ export class ProductListComponent implements OnInit {
this.list = this.dataSource.filteredData;
} else {
this.list = this.list
.filter((x) => x.menuCategory.id !== this.dataSource.filterValue)
.filter((x) => (x.menuCategory as MenuCategory).id !== this.dataSource.filterValue)
.concat(this.dataSource.filteredData);
}
this.data.next(this.list);