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,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,13 @@ import { TableService } from '../table.service';
})
export class TableDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: UntypedFormGroup;
form: FormGroup<{
name: FormControl<string>;
seats: FormControl<number>;
section: FormControl<string>;
isActive: FormControl<boolean>;
}>;
sections: Section[] = [];
item: Table = new Table();
@ -24,16 +30,15 @@ export class TableDetailComponent implements OnInit, AfterViewInit {
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private fb: UntypedFormBuilder,
private toaster: ToasterService,
private ser: TableService,
) {
// Create form
this.form = this.fb.group({
name: '',
seats: '',
section: '',
isActive: '',
this.form = new FormGroup({
name: new FormControl<string>('', { nonNullable: true }),
seats: new FormControl<number>(0, { nonNullable: true }),
section: new FormControl<string>('', { nonNullable: true }),
isActive: new FormControl<boolean>(true, { nonNullable: true }),
});
}
@ -50,7 +55,7 @@ export class TableDetailComponent implements OnInit, AfterViewInit {
this.form.setValue({
name: this.item.name,
seats: this.item.seats,
section: this.item.section ? this.item.section.id : '',
section: this.item.section?.id ?? '',
isActive: this.item.isActive,
});
}
@ -102,13 +107,13 @@ export class TableDetailComponent implements OnInit, AfterViewInit {
getItem(): Table {
const formModel = this.form.value;
this.item.name = formModel.name;
this.item.seats = +formModel.seats;
this.item.name = formModel.name ?? '';
this.item.seats = formModel.seats ?? 0;
if (this.item.section === null || this.item.section === undefined) {
this.item.section = new Section();
}
this.item.section.id = formModel.section;
this.item.isActive = formModel.isActive;
this.item.isActive = formModel.isActive ?? true;
return this.item;
}
}