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 2197 additions and 892 deletions

View File

@ -1,6 +1,6 @@
import { NestedTreeControl } from '@angular/cdk/tree';
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 { MatTreeNestedDataSource } from '@angular/material/tree';
import { ActivatedRoute, Router } from '@angular/router';
@ -21,7 +21,13 @@ import { NodeItem } from '../node-item';
})
export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: UntypedFormGroup;
form: FormGroup<{
name: FormControl<string>;
minimum: FormControl<number>;
maximum: FormControl<number | null>;
isActive: FormControl<boolean>;
}>;
item: ModifierCategory = new ModifierCategory();
treeControl = new NestedTreeControl<NodeItem>((node: NodeItem) => node.children);
dataSource = new MatTreeNestedDataSource<NodeItem>();
@ -31,17 +37,16 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: UntypedFormBuilder,
private toaster: ToasterService,
private dialog: MatDialog,
private ser: ModifierCategoryService,
) {
// Create form
this.form = this.fb.group({
name: '',
minimum: '',
maximum: '',
isActive: '',
this.form = new FormGroup({
name: new FormControl<string>('', { nonNullable: true }),
minimum: new FormControl<number>(0, { nonNullable: true }),
maximum: new FormControl<number | null>(null),
isActive: new FormControl<boolean>(true, { nonNullable: true }),
});
this.dataSource.data = [];
}
@ -68,9 +73,9 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
this.item = item;
this.dataSource.data = tree;
this.form.patchValue({
name: this.item.name || '',
minimum: `${this.item.minimum}`,
maximum: `${this.item.maximum}`,
name: this.item.name ?? '',
minimum: this.item.minimum,
maximum: this.item.maximum,
isActive: this.item.isActive,
});
this.products = new Map();
@ -139,10 +144,10 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
getItem(): ModifierCategory {
const formModel = this.form.value;
this.item.name = formModel.name;
this.item.minimum = +formModel.minimum;
this.item.maximum = +formModel.maximum;
this.item.isActive = formModel.isActive;
this.item.name = formModel.name ?? '';
this.item.minimum = formModel.minimum ?? 0;
this.item.maximum = formModel.maximum ?? null;
this.item.isActive = formModel.isActive ?? true;
return this.item;
}