Fix: Autocomplete could fuck up and was definitely doing it in product.

When checking for .name, it would error out if the input was null

Fix: Journal addRow reset would reset Debit/Credit
This commit is contained in:
2022-07-17 14:31:19 +05:30
parent 9f70ec2917
commit bddd5ec749
17 changed files with 104 additions and 127 deletions
@@ -7,7 +7,7 @@ import { Hotkey, HotkeysService } from 'angular2-hotkeys';
import { round } from 'mathjs';
import * as moment from 'moment';
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, switchMap } from 'rxjs/operators';
import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';
import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
@@ -84,7 +84,6 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
this.accBal = null;
// Listen to Account Autocomplete Change
this.accounts = this.form.controls.addRow.controls.account.valueChanges.pipe(
map((x) => (x !== null && x.length >= 1 ? x : null)),
debounceTime(150),
distinctUntilChanged(),
switchMap((x) => (x === null ? observableOf([]) : this.accountSer.autocomplete(x))),
@@ -334,8 +333,8 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
});
}
displayFn(account?: Account): string {
return account ? account.name : '';
displayFn(account?: Account | string): string {
return !account ? '' : typeof account === 'string' ? account : account.name;
}
accountSelected(event: MatAutocompleteSelectedEvent): void {