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:
2023-03-05 23:50:41 +05:30
parent 802eded568
commit e46fe7f90e
141 changed files with 2196 additions and 891 deletions
@@ -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;
}