Fix: Ledger and product ledger on init would fail because account/product ledger was null. Fixed

This commit is contained in:
tanshu committed 2022-07-18 23:41:09 +05:30
1 parent 836858deb1
commit e02cdfbe9c
10 files changed
+27 -25

No files matched your search

+10 -8
View File
@@ -69,7 +69,7 @@ export class LedgerComponent implements OnInit, AfterViewInit {
this.info = data.info;
this.calculateTotals();
this.form.setValue({
account: this.info.account.name,
account: this.info.account?.name ?? '',
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
});
@@ -108,7 +108,7 @@ export class LedgerComponent implements OnInit, AfterViewInit {
}
selected(event: MatAutocompleteSelectedEvent): void {
this.info.account = event.option.value;
this.info.account = event.option.value as Account;
}
selectRow(id: string): void {
@@ -117,12 +117,14 @@ export class LedgerComponent implements OnInit, AfterViewInit {
show() {
const info = this.getInfo();
this.router.navigate(['ledger', info.account.id], {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate,
},
});
if (info.account) {
this.router.navigate(['ledger', info.account.id], {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate,
},
});
}
}
getInfo(): Ledger {