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';
|
||||
|
||||
@ -17,7 +17,13 @@ import { SettleOptionService } from '../settle-option.service';
|
||||
})
|
||||
export class SettleOptionDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: UntypedFormGroup;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
voucherType: FormControl<number>;
|
||||
reportingLevel: FormControl<number>;
|
||||
hasReason: FormControl<boolean>;
|
||||
}>;
|
||||
|
||||
item: SettleOption = new SettleOption();
|
||||
voucherTypes: { id: number; name: string }[];
|
||||
reportingLevel: { id: number; name: string }[];
|
||||
@ -26,16 +32,15 @@ export class SettleOptionDetailComponent implements OnInit, AfterViewInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private fb: UntypedFormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: SettleOptionService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
voucherType: '',
|
||||
reportingLevel: '',
|
||||
hasReason: '',
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl('', { nonNullable: true }),
|
||||
voucherType: new FormControl(0, { nonNullable: true }),
|
||||
reportingLevel: new FormControl(0, { nonNullable: true }),
|
||||
hasReason: new FormControl(false, { nonNullable: true }),
|
||||
});
|
||||
this.voucherTypes = Object.keys(VoucherType)
|
||||
.filter((e) => !isNaN(+e))
|
||||
@ -109,10 +114,10 @@ export class SettleOptionDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
getItem(): SettleOption {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.voucherType = formModel.voucherType;
|
||||
this.item.reportingLevel = formModel.reportingLevel;
|
||||
this.item.hasReason = formModel.hasReason;
|
||||
this.item.name = formModel.name ?? '';
|
||||
this.item.voucherType = formModel.voucherType ?? 0;
|
||||
this.item.reportingLevel = formModel.reportingLevel ?? 0;
|
||||
this.item.hasReason = formModel.hasReason ?? false;
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user