Skip to content
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 v2/expenses from personal cards page to platform #3201

Merged
merged 15 commits into from
Sep 12, 2024
18 changes: 2 additions & 16 deletions src/app/core/mock-data/filter.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,9 @@ import deepFreeze from 'deep-freeze-strict';

import { FilterOptionType } from 'src/app/shared/components/fy-filters/filter-option-type.enum';
import { FilterOptions } from 'src/app/shared/components/fy-filters/filter-options.interface';
import { PersonalCardFilter } from '../models/personal-card-filters.model';

type Filter = Partial<{
amount: number;
createdOn: Partial<{
name?: string;
customDateStart?: Date;
customDateEnd?: Date;
}>;
updatedOn: Partial<{
name?: string;
customDateStart?: Date;
customDateEnd?: Date;
}>;
transactionType: string;
}>;

export const filterData1: Filter = deepFreeze({
export const filterData1: Partial<PersonalCardFilter> = deepFreeze({
createdOn: {
name: 'custom',
customDateStart: new Date('2023-02-20T00:00:00.000Z'),
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/models/filter-query-params.model.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export interface FilterQueryParams {
or?: string[];
or?: string[] | string;
tx_report_id?: string;
corporate_credit_card_account_number?: string;
tx_num_files?: string;
and?: string;
tx_state?: string;
btxn_status?: string;
ba_id?: string;
}
5 changes: 5 additions & 0 deletions src/app/core/models/personal-card-date-filter.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface PersonalCardDateFilter {
name?: string;
customDateStart?: Date;
customDateEnd?: Date;
}
18 changes: 6 additions & 12 deletions src/app/core/models/personal-card-filters.model.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { PersonalCardDateFilter } from './personal-card-date-filter.model';

export interface PersonalCardFilter {
amount?: number;
createdOn?: {
name?: string;
customDateStart?: Date;
customDateEnd?: Date;
};
updatedOn?: {
name?: string;
customDateStart?: Date;
customDateEnd?: Date;
};
transactionType?: string;
amount: number;
createdOn: PersonalCardDateFilter;
updatedOn: PersonalCardDateFilter;
transactionType: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface PersonalCardsDateParams {
pageNumber: number;
queryParams: {
ba_id?: string;
btxn_status?: string;
or?: string;
};
sortParam: string;
sortDir: string;
searchString: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { APIQueryParams } from './query-params.model';
export interface ExpensesQueryParams extends APIQueryParams {
report_id?: string;
state?: string;
split_group_id?: string;
searchString?: string;
queryParams?: Record<string, string | string[] | boolean>;
}
26 changes: 5 additions & 21 deletions src/app/core/services/personal-cards.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ describe('PersonalCardsService', () => {
const filters = {
createdOn: {
name: 'custom',
customDateStart: '2023-02-21T00:00:00.000Z',
customDateEnd: '2023-02-23T00:00:00.000Z',
customDateStart: new Date('2023-02-21T00:00:00.000Z'),
customDateEnd: new Date('2023-02-23T00:00:00.000Z'),
},
};

Expand Down Expand Up @@ -785,9 +785,9 @@ describe('PersonalCardsService', () => {

const filters = {
updatedOn: {
name: DateFilters.lastMonth,
customDateStart: '2023-02-21T00:00:00.000Z',
customDateEnd: '2023-02-23T00:00:00.000Z',
name: DateFilters.lastMonth as string,
customDateStart: new Date('2023-02-21T00:00:00.000Z'),
customDateEnd: new Date('2023-02-23T00:00:00.000Z'),
},
};

Expand All @@ -814,22 +814,6 @@ describe('PersonalCardsService', () => {
});
});

it('getExpenseDetails(): should get expense details', (done) => {
apiV2Service.get.and.returnValue(of(etxncData));

const txnSplitGroupID = 'txOJVaaPxo9O';

personalCardsService.getExpenseDetails(txnSplitGroupID).subscribe((res) => {
expect(res).toEqual(etxncData.data[0]);
expect(apiV2Service.get).toHaveBeenCalledOnceWith('/expenses', {
params: {
tx_split_group_id: `eq.${txnSplitGroupID}`,
},
});
done();
});
});

it('fetchTransactions(): should fetch transactions', (done) => {
expenseAggregationService.post.and.returnValue(of(apiPersonalCardTxnsRes));
const accountId = 'baccLesaRlyvLY';
Expand Down
Loading
Loading