Fix: Ledger and product ledger on init would fail because account/product ledger was null. Fixed
This commit is contained in:
parent
836858deb1
commit
e02cdfbe9c
@ -106,7 +106,7 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selected(event: MatAutocompleteSelectedEvent): void {
|
selected(event: MatAutocompleteSelectedEvent): void {
|
||||||
this.info.employee = event.option.value;
|
this.info.employee = event.option.value as Employee;
|
||||||
}
|
}
|
||||||
|
|
||||||
getClass(index: number) {
|
getClass(index: number) {
|
||||||
|
@ -138,7 +138,7 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
employeeSelected(event: MatAutocompleteSelectedEvent): void {
|
employeeSelected(event: MatAutocompleteSelectedEvent): void {
|
||||||
this.employee = event.option.value;
|
this.employee = event.option.value as Employee;
|
||||||
}
|
}
|
||||||
|
|
||||||
addRow() {
|
addRow() {
|
||||||
|
@ -57,7 +57,7 @@ export class IssueDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
batchSelected(event: MatAutocompleteSelectedEvent): void {
|
batchSelected(event: MatAutocompleteSelectedEvent): void {
|
||||||
this.batch = event.option.value;
|
this.batch = event.option.value as Batch;
|
||||||
}
|
}
|
||||||
|
|
||||||
accept(): void {
|
accept(): void {
|
||||||
|
@ -331,7 +331,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
batchSelected(event: MatAutocompleteSelectedEvent): void {
|
batchSelected(event: MatAutocompleteSelectedEvent): void {
|
||||||
this.batch = event.option.value;
|
this.batch = event.option.value as Batch;
|
||||||
}
|
}
|
||||||
|
|
||||||
goToVoucher(id: string) {
|
goToVoucher(id: string) {
|
||||||
|
@ -61,7 +61,7 @@ export class JournalDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
accountSelected(event: MatAutocompleteSelectedEvent): void {
|
accountSelected(event: MatAutocompleteSelectedEvent): void {
|
||||||
const account = event.option.value;
|
const account = event.option.value as Account;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.accountSer.balance(account.id as string, this.data.date).subscribe((v) => {
|
this.accountSer.balance(account.id as string, this.data.date).subscribe((v) => {
|
||||||
this.accBal = v;
|
this.accBal = v;
|
||||||
|
@ -329,7 +329,7 @@ export class JournalComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
accountSelected(event: MatAutocompleteSelectedEvent): void {
|
accountSelected(event: MatAutocompleteSelectedEvent): void {
|
||||||
const account = event.option.value;
|
const account = event.option.value as Account;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
const date = moment(this.form.value.date).format('DD-MMM-YYYY');
|
const date = moment(this.form.value.date).format('DD-MMM-YYYY');
|
||||||
this.accountSer.balance(account.id as string, date).subscribe((v) => {
|
this.accountSer.balance(account.id as string, date).subscribe((v) => {
|
||||||
|
@ -69,7 +69,7 @@ export class LedgerComponent implements OnInit, AfterViewInit {
|
|||||||
this.info = data.info;
|
this.info = data.info;
|
||||||
this.calculateTotals();
|
this.calculateTotals();
|
||||||
this.form.setValue({
|
this.form.setValue({
|
||||||
account: this.info.account.name,
|
account: this.info.account?.name ?? '',
|
||||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||||
finishDate: moment(this.info.finishDate, '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 {
|
selected(event: MatAutocompleteSelectedEvent): void {
|
||||||
this.info.account = event.option.value;
|
this.info.account = event.option.value as Account;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectRow(id: string): void {
|
selectRow(id: string): void {
|
||||||
@ -117,12 +117,14 @@ export class LedgerComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
show() {
|
show() {
|
||||||
const info = this.getInfo();
|
const info = this.getInfo();
|
||||||
this.router.navigate(['ledger', info.account.id], {
|
if (info.account) {
|
||||||
queryParams: {
|
this.router.navigate(['ledger', info.account.id], {
|
||||||
startDate: info.startDate,
|
queryParams: {
|
||||||
finishDate: info.finishDate,
|
startDate: info.startDate,
|
||||||
},
|
finishDate: info.finishDate,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getInfo(): Ledger {
|
getInfo(): Ledger {
|
||||||
|
@ -5,13 +5,12 @@ import { LedgerItem } from './ledger-item';
|
|||||||
export class Ledger {
|
export class Ledger {
|
||||||
startDate: string;
|
startDate: string;
|
||||||
finishDate: string;
|
finishDate: string;
|
||||||
account: Account;
|
account?: Account;
|
||||||
body: LedgerItem[];
|
body: LedgerItem[];
|
||||||
|
|
||||||
public constructor(init?: Partial<Ledger>) {
|
public constructor(init?: Partial<Ledger>) {
|
||||||
this.startDate = '';
|
this.startDate = '';
|
||||||
this.finishDate = '';
|
this.finishDate = '';
|
||||||
this.account = new Account();
|
|
||||||
this.body = [];
|
this.body = [];
|
||||||
Object.assign(this, init);
|
Object.assign(this, init);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ export class ProductLedgerComponent implements OnInit, AfterViewInit {
|
|||||||
this.info = data.info;
|
this.info = data.info;
|
||||||
this.calculateTotals();
|
this.calculateTotals();
|
||||||
this.form.setValue({
|
this.form.setValue({
|
||||||
product: this.info.product.name,
|
product: this.info.product?.name ?? '',
|
||||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||||
});
|
});
|
||||||
@ -136,12 +136,14 @@ export class ProductLedgerComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
show() {
|
show() {
|
||||||
const info = this.getInfo();
|
const info = this.getInfo();
|
||||||
this.router.navigate(['product-ledger', info.product.id], {
|
if (info.product) {
|
||||||
queryParams: {
|
this.router.navigate(['product-ledger', info.product.id], {
|
||||||
startDate: info.startDate,
|
queryParams: {
|
||||||
finishDate: info.finishDate,
|
startDate: info.startDate,
|
||||||
},
|
finishDate: info.finishDate,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getInfo(): ProductLedger {
|
getInfo(): ProductLedger {
|
||||||
|
@ -5,13 +5,12 @@ import { ProductLedgerItem } from './product-ledger-item';
|
|||||||
export class ProductLedger {
|
export class ProductLedger {
|
||||||
startDate: string;
|
startDate: string;
|
||||||
finishDate: string;
|
finishDate: string;
|
||||||
product: Product;
|
product?: Product;
|
||||||
body: ProductLedgerItem[];
|
body: ProductLedgerItem[];
|
||||||
|
|
||||||
public constructor(init?: Partial<ProductLedger>) {
|
public constructor(init?: Partial<ProductLedger>) {
|
||||||
this.startDate = '';
|
this.startDate = '';
|
||||||
this.finishDate = '';
|
this.finishDate = '';
|
||||||
this.product = new Product();
|
|
||||||
this.body = [];
|
this.body = [];
|
||||||
Object.assign(this, init);
|
Object.assign(this, init);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user