diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts index 2cbf30fbf3..6668fc9955 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts @@ -499,7 +499,8 @@ export function TestCases3(getTestBed) { expect(res).toEqual(orgCategoryListItemData1); }); - expect(component.getFormValues).toHaveBeenCalledTimes(1); + // 2 times because we have changed the project value twice + expect(component.getFormValues).toHaveBeenCalledTimes(2); })); it('should set up filtered categories and set default billable value if project is removed', fakeAsync(() => { @@ -520,7 +521,7 @@ export function TestCases3(getTestBed) { expect(res).toEqual(orgCategoryListItemData1); }); - expect(component.getFormValues).toHaveBeenCalledTimes(1); + expect(component.getFormValues).toHaveBeenCalledTimes(2); })); }); diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index 20d5be8b53..abede06024 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -455,7 +455,6 @@ export class AddEditMileagePage implements OnInit { } setupFilteredCategories(activeCategories$: Observable): void { - const formValue = this.getFormValues(); this.filteredCategories$ = this.fg.controls.project.valueChanges.pipe( tap(() => { if (!this.fg.controls.project.value) { @@ -478,6 +477,8 @@ export class AddEditMileagePage implements OnInit { ); this.filteredCategories$.subscribe((categories) => { + const formValue = this.getFormValues(); + if ( formValue.sub_category && formValue.sub_category.id && diff --git a/src/app/fyle/add-edit-per-diem/add-edit-per-diem-2.page.spec.ts b/src/app/fyle/add-edit-per-diem/add-edit-per-diem-2.page.spec.ts index ff5489585e..00cfd41fcd 100644 --- a/src/app/fyle/add-edit-per-diem/add-edit-per-diem-2.page.spec.ts +++ b/src/app/fyle/add-edit-per-diem/add-edit-per-diem-2.page.spec.ts @@ -268,6 +268,7 @@ export function TestCases2(getTestBed) { perDiemCategories: [perDiemCategory], }) ); + spyOn(component.fg, 'updateValueAndValidity'); component.etxn$ = of(unflattenedTxnData); categoriesService.getAll.and.returnValue(of([mockCategoryData])); customFieldsService.standardizeCustomFields.and.returnValue(cloneDeep(expectedTxnCustomProperties)); diff --git a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts index 9bdc7a0deb..5187cacba4 100644 --- a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts +++ b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts @@ -694,8 +694,10 @@ export class AddEditPerDiemPage implements OnInit { ), map((categories) => categories.map((category) => ({ label: category.sub_category, value: category }))) ); - const formValue = this.getFormValues(); + this.filteredCategories$.subscribe((categories) => { + const formValue = this.getFormValues(); + if ( formValue.sub_category && formValue.sub_category.id &&