Product Group renamed to Menu Category
Extracted Product Group -> Group_type to a a new object called Sale Category. Moved tax from product to Sale Category for uniform taxes on types of sales.
This commit is contained in:
@ -41,7 +41,7 @@ export class ProductListDataSource extends DataSource<Product> {
|
||||
private getFilteredData(data: Product[]): Product[] {
|
||||
const filter = (this.filterValue === undefined) ? "" : this.filterValue;
|
||||
return data.filter(x => {
|
||||
return x.productGroup.id === filter || filter === "";
|
||||
return x.menuCategory.id === filter || filter === "";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -18,10 +18,10 @@
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Product Type</mat-label>
|
||||
<mat-select placeholder="Product Group" formControlName="productGroup" (selectionChange)="filterOn($event)">
|
||||
<mat-select placeholder="Menu Category" formControlName="menuCategory" (selectionChange)="filterOn($event)">
|
||||
<mat-option>-- All Products --</mat-option>
|
||||
<mat-option *ngFor="let pg of productGroups" [value]="pg.id">
|
||||
{{ pg.name }}
|
||||
<mat-option *ngFor="let mc of menuCategories" [value]="mc.id">
|
||||
{{ mc.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
@ -41,16 +41,16 @@
|
||||
<mat-cell *matCellDef="let row">{{row.price | currency:'INR'}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Product Group Column -->
|
||||
<ng-container matColumnDef="productGroup">
|
||||
<mat-header-cell *matHeaderCellDef>Product Group</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.productGroup.name}}</mat-cell>
|
||||
<!-- Menu Category Column -->
|
||||
<ng-container matColumnDef="menuCategory">
|
||||
<mat-header-cell *matHeaderCellDef>Menu Category</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.menuCategory.name}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Tax Column -->
|
||||
<ng-container matColumnDef="tax">
|
||||
<mat-header-cell *matHeaderCellDef>Tax</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.tax.rate | percent:'1.2-2'}} {{row.tax.name}}</mat-cell>
|
||||
<!-- Sale Category Column -->
|
||||
<ng-container matColumnDef="saleCategory">
|
||||
<mat-header-cell *matHeaderCellDef>Sale Category</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.saleCategory.name}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Info Column -->
|
||||
|
||||
@ -8,7 +8,7 @@ import { Product } from '../../core/product';
|
||||
import { ToCsvService } from "../../shared/to-csv.service";
|
||||
import { ToasterService } from "../../core/toaster.service";
|
||||
import { ProductService } from "../product.service";
|
||||
import { ProductGroup } from "../../core/product-group";
|
||||
import { MenuCategory } from "../../core/menu-category";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
|
||||
@Component({
|
||||
@ -23,9 +23,9 @@ export class ProductListComponent implements OnInit {
|
||||
form: FormGroup;
|
||||
list: Product[];
|
||||
data: BehaviorSubject<Product[]>;
|
||||
productGroups: ProductGroup[];
|
||||
menuCategories: MenuCategory[];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['name', 'price', 'productGroup', 'tax', 'info', 'quantity'];
|
||||
displayedColumns: string[] = ['name', 'price', 'menuCategory', 'saleCategory', 'info', 'quantity'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@ -36,7 +36,7 @@ export class ProductListComponent implements OnInit {
|
||||
private ser: ProductService
|
||||
) {
|
||||
this.form = this.fb.group({
|
||||
productGroup: ''
|
||||
menuCategory: ''
|
||||
});
|
||||
this.filter = new BehaviorSubject("");
|
||||
this.data = new BehaviorSubject([]);
|
||||
@ -51,9 +51,9 @@ export class ProductListComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Product[], productGroups: ProductGroup[] }) => {
|
||||
.subscribe((data: { list: Product[], menuCategories: MenuCategory[] }) => {
|
||||
this.data.next(data.list);
|
||||
this.productGroups = data.productGroups;
|
||||
this.menuCategories = data.menuCategories;
|
||||
});
|
||||
this.dataSource = new ProductListDataSource(this.filter, this.data);
|
||||
}
|
||||
@ -83,8 +83,8 @@ export class ProductListComponent implements OnInit {
|
||||
Name: 'name',
|
||||
Units: 'units',
|
||||
Price: 'price',
|
||||
ProductGroup: 'productGroup',
|
||||
Tax: 'tax'
|
||||
MenuCategory: 'menuCategory',
|
||||
SaleCategory: 'saleCategory'
|
||||
};
|
||||
|
||||
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.viewData)], {type: 'text/csv;charset=utf-8;'});
|
||||
|
||||
Reference in New Issue
Block a user