Skip to content

Commit

Permalink
fix: bug fixes in mileage perdiem (#2884)
Browse files Browse the repository at this point in the history
* fix: test fix for master branch

* fix: bugs in milaege and per diem

* minor

* minor
  • Loading branch information
suyashpatil78 committed Apr 22, 2024
1 parent d87bacc commit c667b6b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -520,7 +521,7 @@ export function TestCases3(getTestBed) {
expect(res).toEqual(orgCategoryListItemData1);
});

expect(component.getFormValues).toHaveBeenCalledTimes(1);
expect(component.getFormValues).toHaveBeenCalledTimes(2);
}));
});

Expand Down
3 changes: 2 additions & 1 deletion src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ export class AddEditMileagePage implements OnInit {
}

setupFilteredCategories(activeCategories$: Observable<OrgCategory[]>): void {
const formValue = this.getFormValues();
this.filteredCategories$ = this.fg.controls.project.valueChanges.pipe(
tap(() => {
if (!this.fg.controls.project.value) {
Expand All @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 3 additions & 1 deletion src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit c667b6b

Please sign in to comment.