Feature: Tax Regimes are added so that different bills with different series can be printed for Different regimes such as VAT and GST
Chore: Model relationships updated to make them simpler Chore: Bill printing majorly refactored for it Due to the sheer depth of the changes. There can be showstoppers. Please test it carefully
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@ -16,7 +16,14 @@ import { ModifierService } from '../modifier.service';
|
||||
})
|
||||
export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('name', { static: true }) nameElement?: ElementRef;
|
||||
form: UntypedFormGroup;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
showInBill: FormControl<boolean>;
|
||||
price: FormControl<number>;
|
||||
modifierCategory: FormControl<string>;
|
||||
isActive: FormControl<boolean>;
|
||||
}>;
|
||||
|
||||
modifierCategories: ModifierCategory[] = [];
|
||||
item: Modifier = new Modifier();
|
||||
|
||||
@ -24,17 +31,16 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private fb: UntypedFormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: ModifierService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
showInBill: '',
|
||||
price: '',
|
||||
modifierCategory: '',
|
||||
isActive: '',
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
showInBill: new FormControl<boolean>(true, { nonNullable: true }),
|
||||
price: new FormControl<number>(0, { nonNullable: true }),
|
||||
modifierCategory: new FormControl<string>('', { nonNullable: true }),
|
||||
isActive: new FormControl<boolean>(true, { nonNullable: true }),
|
||||
});
|
||||
}
|
||||
|
||||
@ -49,9 +55,9 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
showItem(item: Modifier) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name || '',
|
||||
name: this.item.name ?? '',
|
||||
showInBill: this.item.showInBill,
|
||||
price: this.item.price || '',
|
||||
price: this.item.price ?? 0,
|
||||
isActive: this.item.isActive,
|
||||
modifierCategory: this.item.modifierCategory ? (this.item.modifierCategory.id as string) : '',
|
||||
});
|
||||
@ -104,10 +110,10 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
getItem(): Modifier {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.showInBill = formModel.showInBill;
|
||||
this.item.price = +formModel.price;
|
||||
this.item.isActive = formModel.isActive;
|
||||
this.item.name = formModel.name ?? '';
|
||||
this.item.showInBill = formModel.showInBill ?? false;
|
||||
this.item.price = formModel.price ?? 0;
|
||||
this.item.isActive = formModel.isActive ?? true;
|
||||
this.item.modifierCategory = new ModifierCategory({ id: formModel.modifierCategory });
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@ -20,19 +20,18 @@ export class ModifierListComponent implements OnInit {
|
||||
filter: BehaviorSubject<string> = new BehaviorSubject('');
|
||||
data: BehaviorSubject<Modifier[]> = new BehaviorSubject<Modifier[]>([]);
|
||||
dataSource: ModifierListDataSource = new ModifierListDataSource(this.filter, this.data);
|
||||
form: UntypedFormGroup;
|
||||
form: FormGroup<{
|
||||
modifierCategory: FormControl<string | null>;
|
||||
}>;
|
||||
|
||||
list: Modifier[] = [];
|
||||
modifierCategories: ModifierCategory[] = [];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['name', 'showInBill', 'price', 'isActive', 'modifierCategory'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private fb: UntypedFormBuilder,
|
||||
private router: Router,
|
||||
) {
|
||||
this.form = this.fb.group({
|
||||
modifierCategory: '',
|
||||
constructor(private route: ActivatedRoute, private router: Router) {
|
||||
this.form = new FormGroup({
|
||||
modifierCategory: new FormControl<string | null>(''),
|
||||
});
|
||||
this.data.subscribe((data: Modifier[]) => {
|
||||
this.list = data;
|
||||
|
||||
Reference in New Issue
Block a user