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

fix: migrate list personal card transactions to platform #3279

Merged
merged 16 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions src/app/core/mock-data/personal-card-txns.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import deepFreeze from 'deep-freeze-strict';

import { PersonalCardTxn } from '../models/personal_card_txn.model';
import { ApiV2Response } from '../models/v2/api-v2-response.model';
import { PlatformApiResponse } from '../models/platform/platform-api-response.model';
import { PlatformPersonalCardTxn } from '../models/platform/platform-personal-card-txn.model';
import { PlatformPersonalCardTxnState } from '../models/platform/platform-personal-card-txn-state.enum';
import { PlatformPersonalCardMatchedExpense } from '../models/platform/platform-personal-card-matched-expense.model';
import { TxnDetail } from '../models/v2/txn-detail.model';
import { PlatformPersonalCardQueryParams } from '../models/platform/platform-personal-card-query-params.model';

export const apiPersonalCardTxnsRes: ApiV2Response<PersonalCardTxn> = deepFreeze({
count: 1,
Expand Down Expand Up @@ -79,3 +85,148 @@ export const matchedPersonalCardTxn: PersonalCardTxn = deepFreeze({
},
],
});

export const platformPersonalCardTxns: PlatformApiResponse<PlatformPersonalCardTxn[]> = deepFreeze({
count: 2,
data: [
{
amount: 200.0,
category: 'Restaurants/Dining',
created_at: new Date('2024-11-21T05:27:51.863181+00:00'),
currency: 'USD',
description: 'mocha',
external_transaction_id: '57690734',
foreign_amount: null,
foreign_currency: null,
id: 'btxndbZdAth0x4',
matched_expense_ids: ['txjhfqMX9YuB'],
matched_expenses: [
{
amount: 200,
category_display_name: 'Unspecified',
currency: 'USD',
foreign_amount: null,
foreign_currency: null,
id: 'txjhfqMX9YuB',
merchant: 'Mocha',
no_of_files: 0,
purpose: 'mocha',
seq_num: 'E/2024/11/T/7',
spent_at: new Date('2024-09-22T00:00:00+00:00'),
state: 'COMPLETE',
},
],
merchant: 'Mocha',
org_id: 'orrb8EW1zZsy',
personal_card_id: 'bacczUA0bUKVTD',
spent_at: new Date('2024-09-22T00:00:00+00:00'),
state: 'MATCHED' as PlatformPersonalCardTxnState,
sumrender marked this conversation as resolved.
Show resolved Hide resolved
updated_at: new Date('2024-11-26T04:44:17.825002+00:00'),
user_id: 'us2KhpQLpzX4',
},
],
offset: 0,
});

export const transformedPlatformPersonalCardTxns: Partial<ApiV2Response<PersonalCardTxn>> = deepFreeze({
count: 2,
offset: 0,
data: [
{
btxn_id: 'btxndbZdAth0x4',
btxn_created_at: new Date('2024-11-21T05:27:51.863Z'),
btxn_updated_at: new Date('2024-11-26T04:44:17.825Z'),
ba_id: 'bacczUA0bUKVTD',
btxn_amount: 200,
btxn_currency: 'USD',
btxn_description: 'mocha',
btxn_external_id: '57690734',
btxn_transaction_dt: new Date('2024-09-22T00:00:00.000Z'),
btxn_orig_amount: null,
btxn_orig_currency: null,
btxn_status: 'MATCHED',
btxn_vendor: 'Mocha',
tx_split_group_id: 'txjhfqMX9YuB',
btxn_transaction_type: 'debit',
ba_account_number: 'manually add',
txn_details: [
{
amount: 200,
currency: 'USD',
expense_number: 'E/2024/11/T/7',
category_display_name: 'Unspecified',
id: 'txjhfqMX9YuB',
num_files: 0,
purpose: 'mocha',
state: 'COMPLETE',
txn_dt: new Date('2024-09-22T00:00:00.000Z'),
},
],
},
],
});

export const matchedExpensesPlatform: PlatformPersonalCardMatchedExpense[] = deepFreeze([
{
amount: 200,
category_display_name: 'Unspecified',
currency: 'USD',
foreign_amount: null,
foreign_currency: null,
id: 'txjhfqMX9YuB',
merchant: 'Mocha',
no_of_files: 0,
purpose: 'mocha',
seq_num: 'E/2024/11/T/7',
spent_at: new Date('2024-09-22T00:00:00+00:00'),
state: 'COMPLETE',
},
]);

export const transformedMatchedExpenses: TxnDetail[] = deepFreeze([
{
amount: 200,
currency: 'USD',
expense_number: 'E/2024/11/T/7',
category_display_name: 'Unspecified',
id: 'txjhfqMX9YuB',
num_files: 0,
purpose: 'mocha',
state: 'COMPLETE',
txn_dt: new Date('2024-09-22T00:00:00.000Z'),
},
]);

export const publicQueryParams = deepFreeze({
btxn_status: 'MATCHED',
ba_id: 'btxndbZdAth0x4',
_search_document: 'fts.query',
amount: '100',
or: ['amount', 'state'],
});

export const platformQueryParams: PlatformPersonalCardQueryParams = deepFreeze({
state: 'MATCHED',
personal_card_id: 'btxndbZdAth0x4',
amount: '100',
or: ['amount', 'state'],
q: 'query',
});

export const publicTxnsConfig = deepFreeze({
offset: 0,
limit: 10,
queryParams: {
btxn_status: 'in.(MATCHED)',
ba_id: 'eq.baccLesaRlyvLY',
},
});
sumrender marked this conversation as resolved.
Show resolved Hide resolved

export const platformTxnsConfig = deepFreeze({
offset: 0,
limit: 10,
queryParams: {
state: 'in.(MATCHED)',
personal_card_id: 'eq.baccLesaRlyvLY',
},
});
sumrender marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions src/app/core/mock-data/personal-cards.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import deepFreeze from 'deep-freeze-strict';
import { ApiV2Response } from '../models/api-v2.model';
import { PersonalCard } from '../models/personal_card.model';
import { PlatformApiResponse } from '../models/platform/platform-api-response.model';
import { PersonalCardPlatform } from '../models/personal_card_platform.model';
import { PlatformPersonalCard } from '../models/platform/platform-personal-card.model';

export const apiLinkedAccRes: ApiV2Response<PersonalCard> = deepFreeze({
count: 11,
Expand Down Expand Up @@ -72,7 +72,7 @@ export const deletePersonalCardRes: PersonalCard = deepFreeze({
updated_at: new Date('2022-05-31T07:40:58.190907'),
});

export const deletePersonalCardPlatformRes: PlatformApiResponse<PersonalCardPlatform> = deepFreeze({
export const deletePersonalCardPlatformRes: PlatformApiResponse<PlatformPersonalCard> = deepFreeze({
data: {
account_type: 'SAVINGS',
bank_name: 'Dag Site',
Expand Down Expand Up @@ -165,7 +165,7 @@ export const linkedAccountRes2: PersonalCard[] = deepFreeze([
},
]);

export const platformApiLinkedAccRes: PlatformApiResponse<PersonalCardPlatform[]> = deepFreeze({
export const platformApiLinkedAccRes: PlatformApiResponse<PlatformPersonalCard[]> = deepFreeze({
count: 2,
data: [
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/models/personal_card_txn.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { TxnDetail } from './v2/txn-detail.model';
export interface PersonalCardTxn {
_search_document?: string;
ba_account_number: string;
ba_bank_name: string;
ba_bank_name?: string;
ba_id: string;
ba_mask?: string;
ba_nickname: string;
ba_nickname?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? are these keys not present in the platform response?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes boss, not present in platform response

btxn_amount: number;
btxn_created_at: Date;
btxn_currency: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export interface PlatformPersonalCardMatchedExpense {
id: string;
currency: string;
amount: number;
spent_at: Date;
merchant: string;
foreign_currency: string | null;
foreign_amount: number | null;
purpose: string;
state: string;
seq_num: string;
no_of_files: number;
category_display_name: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface PlatformPersonalCardQueryParams {
state?: string;
sumrender marked this conversation as resolved.
Show resolved Hide resolved
personal_card_id?: string;
q?: string;
amount?: string;
or?: string[];
}
sumrender marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum PlatformPersonalCardTxnState {
INITIALIZED = 'INITIALIZED',
MATCHED = 'MATCHED',
HIDDEN = 'HIDDEN',
}
sumrender marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { PlatformPersonalCardMatchedExpense } from './platform-personal-card-matched-expense.model';
import { PlatformPersonalCardTxnState } from './platform-personal-card-txn-state.enum';

export interface PlatformPersonalCardTxn {
id: string;
org_id: string;
user_id: string;
personal_card_id: string;
amount: number;
sumrender marked this conversation as resolved.
Show resolved Hide resolved
currency: string;
foreign_amount: string | null;
foreign_currency: string | null;
spent_at: Date;
category: string;
merchant: string;
state: PlatformPersonalCardTxnState;
description: string;
external_transaction_id: string;
matched_expense_ids: string[];
matched_expenses: PlatformPersonalCardMatchedExpense[];
sumrender marked this conversation as resolved.
Show resolved Hide resolved
created_at: Date;
updated_at: Date;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface PersonalCardPlatform {
export interface PlatformPersonalCard {
account_type: string;
bank_name: string;
card_number: string;
sumrender marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading
Loading