Instanceof operator was not working so changed the way of checking it
This commit is contained in:
@ -45,7 +45,7 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
});
|
||||
// Listen to Product Autocomplete Change
|
||||
this.products = this.form.controls.product.valueChanges.pipe(
|
||||
map((x) => (x instanceof ProductSku ? x.name : x)),
|
||||
map((x) => ((x as ProductSku).name !== undefined ? (x as ProductSku).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
||||
@ -94,7 +94,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.accBal = null;
|
||||
// Listen to Account Autocomplete Change
|
||||
this.accounts = this.form.controls.account.valueChanges.pipe(
|
||||
map((x) => (x instanceof Account ? x.name : x)),
|
||||
map((x) => ((x as Account).name !== undefined ? (x as Account).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
@ -329,7 +329,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
getVoucher(): Voucher {
|
||||
const formModel = this.form.value;
|
||||
this.voucher.date = moment(formModel.date).format('DD-MMM-YYYY');
|
||||
if (formModel.account instanceof Account) {
|
||||
if (formModel.account !== null && typeof formModel.account !== 'string') {
|
||||
this.voucher.vendor = formModel.account;
|
||||
}
|
||||
this.voucher.narration = formModel.narration!;
|
||||
|
||||
Reference in New Issue
Block a user