Fix: Add Tax was not working as TaxIn required a name with length more than 1.

This commit is contained in:
2020-12-21 08:02:36 +05:30
parent f65c19ce1a
commit 4386ee45b8
6 changed files with 97 additions and 87 deletions

View File

@ -2,6 +2,7 @@ import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angula
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { round } from 'mathjs';
import { Tax } from '../../core/tax';
import { ToasterService } from '../../core/toaster.service';
@ -44,7 +45,7 @@ export class TaxDetailComponent implements OnInit, AfterViewInit {
this.item = item;
this.form.setValue({
name: this.item.name || '',
rate: this.item.rate || '',
rate: this.item.rate * 100,
});
}
@ -96,7 +97,7 @@ export class TaxDetailComponent implements OnInit, AfterViewInit {
getItem(): Tax {
const formModel = this.form.value;
this.item.name = formModel.name;
this.item.rate = +formModel.rate;
this.item.rate = round(+formModel.rate / 100, 5);
return this.item;
}
}