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';
|
||||
import { round } from 'mathjs';
|
||||
@ -21,7 +21,12 @@ import { SaleCategoryDetailDatasource } from './sale-category-detail-datasource'
|
||||
})
|
||||
export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: UntypedFormGroup;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
discountLimit: FormControl<number>;
|
||||
tax: FormControl<string>;
|
||||
}>;
|
||||
|
||||
taxes: Tax[] = [];
|
||||
item: SaleCategory = new SaleCategory();
|
||||
products: BehaviorSubject<Product[]> = new BehaviorSubject<Product[]>([]);
|
||||
@ -32,15 +37,14 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private fb: UntypedFormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: SaleCategoryService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
discountLimit: '',
|
||||
tax: '',
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
discountLimit: new FormControl<number>(100, { nonNullable: true }),
|
||||
tax: new FormControl<string>('', { nonNullable: true }),
|
||||
});
|
||||
}
|
||||
|
||||
@ -58,7 +62,7 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form.setValue({
|
||||
name: this.item.name,
|
||||
discountLimit: this.item.discountLimit * 100,
|
||||
tax: this.item.tax ? this.item.tax.id : '',
|
||||
tax: this.item.tax?.id ?? '',
|
||||
});
|
||||
}
|
||||
|
||||
@ -109,8 +113,8 @@ export class SaleCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
getItem(): SaleCategory {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.discountLimit = round(+formModel.discountLimit / 100, 5);
|
||||
this.item.name = formModel.name ?? '';
|
||||
this.item.discountLimit = round((formModel.discountLimit ?? 100) / 100, 5);
|
||||
if (this.item.tax === null || this.item.tax === undefined) {
|
||||
this.item.tax = new Tax();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user