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,12 @@ import { DeviceService } from '../device.service';
|
||||
})
|
||||
export class DeviceDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: UntypedFormGroup;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
section: FormControl<string | null>;
|
||||
enabled: FormControl<boolean>;
|
||||
}>;
|
||||
|
||||
sections: Section[] = [];
|
||||
item: Device = new Device();
|
||||
|
||||
@ -24,15 +29,14 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private fb: UntypedFormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: DeviceService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
section: '',
|
||||
enabled: '',
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
section: new FormControl<string | null>(null),
|
||||
enabled: new FormControl<boolean>(false, { nonNullable: true }),
|
||||
});
|
||||
}
|
||||
|
||||
@ -47,7 +51,7 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
|
||||
showItem(item: Device) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name || '',
|
||||
name: this.item.name ?? '',
|
||||
section: this.item.section.id ? this.item.section.id : '',
|
||||
enabled: this.item.enabled,
|
||||
});
|
||||
@ -100,9 +104,9 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
getItem(): Device {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.section.id = formModel.section;
|
||||
this.item.enabled = formModel.enabled;
|
||||
this.item.name = formModel.name ?? '';
|
||||
this.item.section.id = formModel.section ?? '';
|
||||
this.item.enabled = formModel.enabled ?? true;
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user