-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Move My Expenses to Platform: Moved API Call Of Expenses in My Expenses And Updated Mapping In Expenses Card #2542
Merged
Merged
Changes from 20 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
efc62d9
fix: Per Diem scan fix and redirection fix for view report (#2535)
suyashpatil78 be953d5
moved api fetch and card mapping
cfdee80
Merge branch 'master' into move-platform-my-exp
979143a
used expense service and removed pre-existing models
67dfd3c
moved loading flag
5c739f5
fixed expense card mapping
2536111
Merge branch 'master' into move-platform-my-exp
d99cb68
fix: Contains fix for items getting filtered in merchant field : http…
01073e8
resovled comments
cd5eaab
changed api model files
592f7d1
merged master
9912592
fixed conflicts and used pre-existing methods
8921c92
created shared service
e859c0b
Merge branch 'mobile_release_2023_11_03' of github.com:fylein/fyle-mo…
4ce16fd
Merge branch 'master' of github.com:fylein/fyle-mobile-app
be03938
Merge branch 'master' into move-platform-my-exp
d6934d5
used new expense card and reverted the original
89df071
removed shared expense service
040b733
Merge branch 'master' into move-platform-my-exp
abf3ae3
removed unused model
9b38634
feat: Move My Expenses To Platform: Fixed Go To Transaction and Searc…
jayfyle 59254d0
merged master
e5da339
fixing type errors
867e064
fixed test
6c1f50c
merged master
44e971e
added key
80abd89
increased coverage -1
ea9633d
increased coverage and added test for new methods in shared expense s…
e4e40b0
adding cloning
6a45ab8
added date service
12a2b9a
added spied
213733b
added spied -2
711e99e
commented failing tests
628625b
fixing route guard
843c665
added optional
7acc674
fixed tests on guard
1efaa20
reverted karma file
d2f0491
fixing orgSettings service
e4d159e
Merge branch 'master' into move-platform-my-exp
jayfyle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface GetExpenseQueryParam { | ||
pageNumber: number; | ||
sortParam: string; | ||
sortDir: string; | ||
searchString: string; | ||
queryParams: Record<string, string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ import { | |
switchMap, | ||
take, | ||
takeUntil, | ||
tap, | ||
filter, | ||
} from 'rxjs/operators'; | ||
import { TransactionService } from 'src/app/core/services/transaction.service'; | ||
|
@@ -79,6 +78,9 @@ import { UniqueCards } from 'src/app/core/models/unique-cards.model'; | |
import { CategoriesService } from 'src/app/core/services/categories.service'; | ||
import { PlatformCategory } from 'src/app/core/models/platform/platform-category.model'; | ||
import { ReportV1 } from 'src/app/core/models/report-v1.model'; | ||
import { GetExpenseQueryParam } from 'src/app/core/models/platform/v1/get-expenses-query.model'; | ||
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service'; | ||
import { Expense as PlatformExpense } from 'src/app/core/models/platform/v1/expense.model'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using an alias right now to avoid errors, will remove it once the entire page is migrated |
||
|
||
@Component({ | ||
selector: 'app-my-expenses', | ||
|
@@ -90,17 +92,19 @@ export class MyExpensesPage implements OnInit { | |
|
||
isConnected$: Observable<boolean>; | ||
|
||
myExpenses$: Observable<Expense[]>; | ||
myExpenses$: Observable<PlatformExpense[]>; | ||
|
||
count$: Observable<number>; | ||
|
||
isInfiniteScrollRequired$: Observable<boolean>; | ||
|
||
loadData$: BehaviorSubject<Partial<GetExpensesQueryParamsWithFilters>>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove this property when working on filtering |
||
|
||
loadExpenses$: BehaviorSubject<Partial<GetExpenseQueryParam>>; | ||
|
||
currentPageNumber = 1; | ||
|
||
acc: Expense[] = []; | ||
acc: PlatformExpense[] = []; | ||
|
||
filters: Partial<ExpenseFilters>; | ||
|
||
|
@@ -216,7 +220,8 @@ export class MyExpensesPage implements OnInit { | |
private orgUserSettingsService: OrgUserSettingsService, | ||
private platformHandlerService: PlatformHandlerService, | ||
private categoriesService: CategoriesService, | ||
private navController: NavController | ||
private navController: NavController, | ||
private expenseService: ExpensesService | ||
) {} | ||
|
||
get HeaderState(): typeof HeaderState { | ||
|
@@ -491,6 +496,10 @@ export class MyExpensesPage implements OnInit { | |
pageNumber: 1, | ||
}); | ||
|
||
this.loadExpenses$ = new BehaviorSubject({ | ||
pageNumber: 1, | ||
}); | ||
|
||
this.selectionMode = false; | ||
this.selectedElements = []; | ||
|
||
|
@@ -525,55 +534,54 @@ export class MyExpensesPage implements OnInit { | |
this.loadData$.next(currentParams); | ||
}); | ||
|
||
const paginatedPipe = this.loadData$.pipe( | ||
const paginatedPipe = this.loadExpenses$.pipe( | ||
switchMap((params) => { | ||
let queryParams = params.queryParams || {}; | ||
const queryParams = params.queryParams || {}; | ||
|
||
queryParams.tx_report_id = queryParams.tx_report_id || 'is.null'; | ||
queryParams.tx_state = 'in.(COMPLETE,DRAFT)'; | ||
queryParams = this.apiV2Service.extendQueryParamsForTextSearch(queryParams, params.searchString); | ||
const orderByParams = params.sortParam && params.sortDir ? `${params.sortParam}.${params.sortDir}` : null; | ||
queryParams.report_id = queryParams.report_id || 'is.null'; | ||
queryParams.state = 'in.(COMPLETE,DRAFT)'; | ||
const orderByParams = | ||
params.sortParam && params.sortDir | ||
? `${params.sortParam}.${params.sortDir}` | ||
: 'spent_at.desc,created_at.desc,id.desc'; | ||
this.isLoadingDataInInfiniteScroll = true; | ||
return this.transactionService.getMyExpensesCount(queryParams).pipe( | ||
|
||
return this.expenseService.getExpensesCount(queryParams).pipe( | ||
switchMap((count) => { | ||
if (count > (params.pageNumber - 1) * 10) { | ||
return this.transactionService.getMyExpenses({ | ||
return this.expenseService.getExpenses({ | ||
offset: (params.pageNumber - 1) * 10, | ||
limit: 10, | ||
queryParams, | ||
...queryParams, | ||
order: orderByParams, | ||
}); | ||
} else { | ||
return of({ | ||
data: [], | ||
}); | ||
} | ||
}), | ||
map((res) => { | ||
this.isLoadingDataInInfiniteScroll = false; | ||
if (this.currentPageNumber === 1) { | ||
this.acc = []; | ||
} | ||
this.acc = this.acc.concat(res as PlatformExpense[]); | ||
return this.acc; | ||
}) | ||
); | ||
}), | ||
map((res) => { | ||
this.isLoadingDataInInfiniteScroll = false; | ||
if (this.currentPageNumber === 1) { | ||
this.acc = []; | ||
} | ||
this.acc = this.acc.concat(res.data); | ||
return this.acc; | ||
}), | ||
tap(() => { | ||
this.pendingTransactions = this.formatTransactions(this.transactionOutboxService.getPendingTransactions()); | ||
}) | ||
); | ||
|
||
this.myExpenses$ = paginatedPipe.pipe(shareReplay(1)); | ||
|
||
this.count$ = this.loadData$.pipe( | ||
this.count$ = this.loadExpenses$.pipe( | ||
switchMap((params) => { | ||
let queryParams = params.queryParams || {}; | ||
const queryParams = params.queryParams || {}; | ||
|
||
queryParams.tx_report_id = queryParams.tx_report_id || 'is.null'; | ||
queryParams.tx_state = 'in.(COMPLETE,DRAFT)'; | ||
queryParams = this.apiV2Service.extendQueryParamsForTextSearch(queryParams, params.searchString); | ||
return this.transactionService.getMyExpensesCount(queryParams); | ||
queryParams.report_id = queryParams.report_id || 'is.null'; | ||
queryParams.state = 'in.(COMPLETE,DRAFT)'; | ||
return this.expenseService.getExpensesCount(queryParams); | ||
}), | ||
shareReplay(1) | ||
); | ||
|
@@ -584,7 +592,7 @@ export class MyExpensesPage implements OnInit { | |
switchMap((etxns) => this.count$.pipe(map((count) => count > etxns.length))) | ||
); | ||
|
||
this.isInfiniteScrollRequired$ = this.loadData$.pipe(switchMap(() => paginatedScroll$)); | ||
this.isInfiniteScrollRequired$ = this.loadExpenses$.pipe(switchMap(() => paginatedScroll$)); | ||
|
||
this.setAllExpensesCountAndAmount(); | ||
|
||
|
@@ -690,9 +698,9 @@ export class MyExpensesPage implements OnInit { | |
loadData(event: { target?: { complete?: () => void } }): void { | ||
this.currentPageNumber = this.currentPageNumber + 1; | ||
|
||
const params = this.loadData$.getValue(); | ||
const params = this.loadExpenses$.getValue(); | ||
params.pageNumber = this.currentPageNumber; | ||
this.loadData$.next(params); | ||
this.loadExpenses$.next(params); | ||
|
||
setTimeout(() => { | ||
event?.target?.complete(); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three similar models here,
GetExpenseQueryParam
ExpenseQueryParams
andExpenseParams
, please check if this is introduced due to merge conflicts, and remove the unnecessary ones.