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:
@ -16,7 +16,7 @@
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex="75">
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name">
|
||||
<input matInput #name placeholder="Name" formControlName="name">
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="25">
|
||||
<mat-label>Units</mat-label>
|
||||
@ -43,18 +43,18 @@
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Product Type</mat-label>
|
||||
<mat-select placeholder="Product Group" formControlName="productGroup">
|
||||
<mat-option *ngFor="let pg of productGroups" [value]="pg.id">
|
||||
{{ pg.name }}
|
||||
<mat-label>Menu Category</mat-label>
|
||||
<mat-select placeholder="Menu Category" formControlName="menuCategory">
|
||||
<mat-option *ngFor="let mc of menuCategories" [value]="mc.id">
|
||||
{{ mc.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Tax</mat-label>
|
||||
<mat-select placeholder="Tax" formControlName="tax">
|
||||
<mat-option *ngFor="let t of taxes" [value]="t.id">
|
||||
{{ t.name }}
|
||||
<mat-label>Sale Category</mat-label>
|
||||
<mat-select placeholder="Sale Category" formControlName="saleCategory">
|
||||
<mat-option *ngFor="let sc of saleCategories" [value]="sc.id">
|
||||
{{ sc.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@ -3,11 +3,11 @@ import { ToasterService } from '../../core/toaster.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ProductService } from '../product.service';
|
||||
import { Product } from '../../core/product';
|
||||
import { ProductGroup } from '../../core/product-group';
|
||||
import { MenuCategory } from '../../core/menu-category';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { Tax } from "../../core/tax";
|
||||
import { SaleCategory } from "../../core/sale-category";
|
||||
|
||||
@Component({
|
||||
selector: 'app-product-detail',
|
||||
@ -17,8 +17,8 @@ import { Tax } from "../../core/tax";
|
||||
export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('name', { static: true }) nameElement: ElementRef;
|
||||
form: FormGroup;
|
||||
productGroups: ProductGroup[];
|
||||
taxes: Tax[];
|
||||
menuCategories: MenuCategory[];
|
||||
saleCategories: SaleCategory[];
|
||||
item: Product;
|
||||
|
||||
constructor(
|
||||
@ -37,8 +37,8 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
code: {value: '', disabled: true},
|
||||
name: '',
|
||||
units: '',
|
||||
productGroup: '',
|
||||
tax: '',
|
||||
menuCategory: '',
|
||||
saleCategory: '',
|
||||
price: '',
|
||||
hasHappyHour: '',
|
||||
isNotAvailable: '',
|
||||
@ -49,9 +49,10 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: Product, productGroups: ProductGroup[], taxes: Tax[] }) => {
|
||||
this.productGroups = data.productGroups;
|
||||
this.taxes = data.taxes;
|
||||
.subscribe((data: { item: Product, menuCategories: MenuCategory[], saleCategories: SaleCategory[] }) => {
|
||||
this.menuCategories = data.menuCategories;
|
||||
this.saleCategories = data.saleCategories;
|
||||
console.log(this.saleCategories);
|
||||
this.showItem(data.item);
|
||||
});
|
||||
}
|
||||
@ -62,8 +63,8 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
code: this.item.code || '(Auto)',
|
||||
name: this.item.name || '',
|
||||
units: this.item.units || '',
|
||||
productGroup: this.item.tax.id ? this.item.tax.id : '',
|
||||
tax: this.item.productGroup.id ? this.item.productGroup.id : '',
|
||||
menuCategory: this.item.menuCategory.id ? this.item.menuCategory.id : '',
|
||||
saleCategory: this.item.saleCategory.id ? this.item.saleCategory.id : '',
|
||||
price: this.item.price || '',
|
||||
hasHappyHour: this.item.hasHappyHour,
|
||||
isNotAvailable: this.item.isNotAvailable,
|
||||
@ -121,8 +122,8 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.units = formModel.units;
|
||||
this.item.productGroup.id = formModel.productGroup;
|
||||
this.item.tax.id = formModel.tax;
|
||||
this.item.menuCategory.id = formModel.menuCategory;
|
||||
this.item.saleCategory.id = formModel.saleCategory;
|
||||
this.item.price = +formModel.price;
|
||||
this.item.hasHappyHour = formModel.hasHappyHour;
|
||||
this.item.isNotAvailable = formModel.isNotAvailable;
|
||||
|
||||
@ -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;'});
|
||||
|
||||
@ -8,8 +8,8 @@ import { ProductDetailComponent } from './product-detail/product-detail.componen
|
||||
import { ProductListComponent } from './product-list/product-list.component';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { ProductGroupListResolver } from '../product-group/product-group-list-resolver.service';
|
||||
import { TaxListResolver } from "../taxes/tax-list-resolver.service";
|
||||
import { MenuCategoryListResolver } from '../menu-category/menu-category-list-resolver.service';
|
||||
import { SaleCategoryListResolver } from "../sale-category/sale-category-list-resolver.service";
|
||||
|
||||
const productRoutes: Routes = [
|
||||
{
|
||||
@ -21,7 +21,7 @@ const productRoutes: Routes = [
|
||||
},
|
||||
resolve: {
|
||||
list: ProductListResolver,
|
||||
productGroups: ProductGroupListResolver
|
||||
menuCategories: MenuCategoryListResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -33,8 +33,8 @@ const productRoutes: Routes = [
|
||||
},
|
||||
resolve: {
|
||||
item: ProductResolver,
|
||||
productGroups: ProductGroupListResolver,
|
||||
taxes: TaxListResolver
|
||||
menuCategories: MenuCategoryListResolver,
|
||||
saleCategories: SaleCategoryListResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -46,8 +46,8 @@ const productRoutes: Routes = [
|
||||
},
|
||||
resolve: {
|
||||
item: ProductResolver,
|
||||
productGroups: ProductGroupListResolver,
|
||||
taxes: TaxListResolver
|
||||
menuCategories: MenuCategoryListResolver,
|
||||
saleCategories: SaleCategoryListResolver
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user