Skip to content

Commit

Permalink
fix: getRecentProjects() method of add-edit-expense page (#3194)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunaj5 authored Sep 2, 2024
1 parent 172dbfe commit b71a844
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/app/fyle/add-edit-expense/add-edit-expense-5.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
unflattenedExpWoProject,
unflattenedExpenseWithCCCGroupId2,
unflattenedTxnData,
unflattenedTxnWithCategory,
} from 'src/app/core/mock-data/unflattened-txn.data';
import { CostCenter } from 'src/app/core/models/v1/cost-center.model';
import { AccountsService } from 'src/app/core/services/accounts.service';
Expand Down Expand Up @@ -814,8 +815,8 @@ export function TestCases5(getTestBed) {
component.activeCategories$ = of(sortedCategory);
component.recentlyUsedValues$ = of(recentlyUsedRes);
component.isProjectCategoryRestrictionsEnabled$ = of(true);
component.etxn$ = of(unflattenedTxnWithCategory);
authService.getEou.and.resolveTo(apiEouRes);
component.fg.controls.category.setValue(orgCategoryData);
recentlyUsedItemsService.getRecentlyUsedProjects.and.returnValue(of(recentlyUsedProjectRes));
fixture.detectChanges();

Expand All @@ -825,7 +826,7 @@ export function TestCases5(getTestBed) {
expect(recentlyUsedItemsService.getRecentlyUsedProjects).toHaveBeenCalledOnceWith({
recentValues: recentlyUsedRes,
eou: apiEouRes,
categoryIds: component.fg.controls.category.value && component.fg.controls.category.value.id,
categoryIds: [`${unflattenedTxnWithCategory.tx.org_category_id}`],
isProjectCategoryRestrictionsEnabled: true,
activeCategoryList: sortedCategory,
});
Expand Down
8 changes: 4 additions & 4 deletions src/app/fyle/add-edit-expense/add-edit-expense.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1621,14 +1621,14 @@ export class AddEditExpensePage implements OnInit {
eou: this.authService.getEou(),
activeCategories: this.activeCategories$,
isProjectCategoryRestrictionsEnabled: this.isProjectCategoryRestrictionsEnabled$,
selectedCategoryId: this.etxn$.pipe(map((etxn) => etxn.tx.org_category_id)),
}).pipe(
switchMap(({ recentValues, eou, activeCategories, isProjectCategoryRestrictionsEnabled }) => {
const formControl = this.getFormControl('category') as { value: OrgCategory };
const categoryId = formControl.value && (formControl.value.id as unknown as string[]);
switchMap(({ recentValues, eou, activeCategories, isProjectCategoryRestrictionsEnabled, selectedCategoryId }) => {
const categoryId = `${selectedCategoryId}` || null;
return this.recentlyUsedItemsService.getRecentlyUsedProjects({
recentValues,
eou,
categoryIds: categoryId,
categoryIds: [categoryId],
isProjectCategoryRestrictionsEnabled,
activeCategoryList: activeCategories,
});
Expand Down

0 comments on commit b71a844

Please sign in to comment.