Skip to content

Commit

Permalink
feat: Migrated getETxnUnflattened transaction service method to platf…
Browse files Browse the repository at this point in the history
…orm (#2737)

* Migrated getETxnUnflattened transaction service method to platform

* Updated transformExpenses method of transaction service and its usage

* removed not used method initCCCTxn

* minor changes added model for corporateCardTransaction response

* update in key mapping, removed not used key and added required key

* Updated the usage of switch map to map

* update in markCCCPeronal and dismissCCE flow

* test: Update unit test for add edit mileage (#2747)

* Updated unit tests for add-edit-mileage

* updated the mock data by removing not required keys

* updated the mock data

* Updated the missing type for mock data

* update the types in add-edit mileage file for etxn

* test: Updated unit tests for add-edit expense page (#2748)

* Updated unit tests for add-edit expense page

* Update in transform expense key mapping

* update the sourceAccountTypePublicMapping method

* test: Updated unit tests for add-edit per-diem page (#2749)

* Updated unit tests for add-edit per-diem page

* test: Updated unit tests for task component (#2750)

* Updated unit tests for task component

* test: Updated unit tests for switch org page (#2751)

* Updated unit tests for switch org page

* test: Updated unit tests for deep link redirection (#2752)

* Updated unit tests for deep link redirection

* test: Updated unit tests for expenses card and expenses card v2 component (#2753)

* Updated unit tests for expenses card and expenses card v2 component

* test: Updated unit tests for Transaction, Transaction-outbox, CCC Expense Service and Split Expense Page Unit Tests (#2754)

* Updated unit tests for Transaction, Transaction-outbox, Corporate Credit Card Expense Service and Split Expense Page Unit Tests

* Added mock data for track expense properties

* clean up of not used methods and variable

* feat: Migrated the method getAllExpenses to platform (#2759)

* Migrated the method getAllExpenses to platform

* feat: Migrated the method getEtxn to platform (#2760)

* Migrated the method getEtxn to platform

* updated concat map and of combo to map

* feat: Migrated the method getEtxnc to platform (#2761)

* Migrated the method getEtxnc to platform

* updated the return of observable to map

* feat: Migrated the method getAllEtxnc to platform (#2762)

* Migrated the method getAllEtxnc to platform

* feat: Migrated the method getTransactionStats to platform (#2764)

* Migrated the method getTransactionStats to platform

* test: fixed unit test for the methods getEtxnc, getTransactionStats, getEtxn and getAllETxnc migrated to platform (#2802)

* Updated the unit test for the getEtxn, getEtxnc, getAllETxnc and getTransactionStats methods migration

* fix: cleanup of depreacted keys and methods (#2803)

* cleanup of depreacted keys and methods

* minor updates in comments

* test: fixed unit tests after cleanup for deprecated keys and methods (#2805)

* test: fixed unit tests after cleanup for deprecated keys and methods

* fixed the date unit tests

* fixed the date unit tests-1

* update the file name to corporate-card-transaction-response

* fixed unit tests for matchedCCTransaction date
  • Loading branch information
devendrafyle committed Mar 7, 2024
1 parent 57a05b5 commit 7642a9f
Show file tree
Hide file tree
Showing 84 changed files with 4,586 additions and 1,322 deletions.
23 changes: 17 additions & 6 deletions src/app/auth/switch-org/switch-org.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ import { FyZeroStateComponent } from 'src/app/shared/components/fy-zero-state/fy
import { click, getAllElementsBySelector, getElementBySelector, getTextContent } from 'src/app/core/dom-helpers';
import { globalCacheBusterNotifier } from 'ts-cacheable';
import { TransactionService } from 'src/app/core/services/transaction.service';
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service';
import { DeepLinkService } from 'src/app/core/services/deep-link.service';
import { unflattenedTxnData } from 'src/app/core/mock-data/unflattened-txn.data';
import { platformExpenseData } from 'src/app/core/mock-data/platform/v1/expense.data';
import { transformedExpenseData } from 'src/app/core/mock-data/transformed-expense.data';

const roles = ['OWNER', 'USER', 'FYLER'];
const email = '[email protected]';
Expand Down Expand Up @@ -68,6 +70,7 @@ describe('SwitchOrgPage', () => {
let snackbarProperties: jasmine.SpyObj<SnackbarPropertiesService>;
let routerAuthService: jasmine.SpyObj<RouterAuthService>;
let transactionService: jasmine.SpyObj<TransactionService>;
let expensesService: jasmine.SpyObj<ExpensesService>;
let deepLinkService: jasmine.SpyObj<DeepLinkService>;

beforeEach(waitForAsync(() => {
Expand Down Expand Up @@ -102,7 +105,8 @@ describe('SwitchOrgPage', () => {
const matSnackBarSpy = jasmine.createSpyObj('MatSnackBar', ['openFromComponent']);
const snackbarPropertiesSpy = jasmine.createSpyObj('SnackbarPropertiesService', ['setSnackbarProperties']);
const routerAuthServiceSpy = jasmine.createSpyObj('RouterAuthService', ['resendVerificationLink']);
const transactionServiceSpy = jasmine.createSpyObj('TransactionService', ['getETxnUnflattened']);
const transactionServiceSpy = jasmine.createSpyObj('TransactionService', ['transformExpense']);
const expensesServiceSpy = jasmine.createSpyObj('ExpensesService', ['getExpenseById']);
const deepLinkServiceSpy = jasmine.createSpyObj('DeepLinkService', ['getExpenseRoute']);

TestBed.configureTestingModule({
Expand Down Expand Up @@ -208,6 +212,10 @@ describe('SwitchOrgPage', () => {
provide: TransactionService,
useValue: transactionServiceSpy,
},
{
provide: ExpensesService,
useValue: expensesServiceSpy,
},
{
provide: DeepLinkService,
useValue: deepLinkServiceSpy,
Expand Down Expand Up @@ -241,6 +249,7 @@ describe('SwitchOrgPage', () => {
routerAuthService = TestBed.inject(RouterAuthService) as jasmine.SpyObj<RouterAuthService>;
deepLinkService = TestBed.inject(DeepLinkService) as jasmine.SpyObj<DeepLinkService>;
transactionService = TestBed.inject(TransactionService) as jasmine.SpyObj<TransactionService>;
expensesService = TestBed.inject(ExpensesService) as jasmine.SpyObj<ExpensesService>;

component.searchRef = fixture.debugElement.query(By.css('#search'));
component.searchOrgsInput = fixture.debugElement.query(By.css('.smartlook-show'));
Expand Down Expand Up @@ -350,15 +359,16 @@ describe('SwitchOrgPage', () => {
userEventService.clearTaskCache.and.returnValue();
recentLocalStorageItemsService.clearRecentLocalStorageCache.and.returnValue();
authService.getEou.and.resolveTo(apiEouRes);
transactionService.getETxnUnflattened.and.returnValue(of(unflattenedTxnData));
expensesService.getExpenseById.and.returnValue(of(platformExpenseData));
transactionService.transformExpense.and.returnValue(transformedExpenseData);
deepLinkService.getExpenseRoute.and.returnValue(['/', 'enterprise', 'add_edit_expense']);

spyOn(component, 'setSentryUser').and.returnValue();
spyOn(globalCacheBusterNotifier, 'next').and.returnValue();
});

it('should redirect to expense page if txn found in org', fakeAsync(() => {
const txnId = 'tx3qHxFNgRcZ';
const txnId = 'txvslh8aQMbu';
const orgId = 'orNVthTo2Zyo';
component.redirectToExpensePage(orgId, txnId);

Expand All @@ -373,10 +383,11 @@ describe('SwitchOrgPage', () => {
expect(authService.getEou).toHaveBeenCalledOnceWith();

expect(component.setSentryUser).toHaveBeenCalledOnceWith(apiEouRes);
expect(transactionService.getETxnUnflattened).toHaveBeenCalledOnceWith(txnId);
expect(expensesService.getExpenseById).toHaveBeenCalledOnceWith(txnId);
expect(transactionService.transformExpense).toHaveBeenCalledOnceWith(platformExpenseData);
expect(loaderService.hideLoader).toHaveBeenCalledOnceWith();

expect(deepLinkService.getExpenseRoute).toHaveBeenCalledOnceWith(unflattenedTxnData);
expect(deepLinkService.getExpenseRoute).toHaveBeenCalledOnceWith(transformedExpenseData);
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'add_edit_expense', { id: txnId }]);
}));

Expand Down
8 changes: 6 additions & 2 deletions src/app/auth/switch-org/switch-org.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { ResendEmailVerification } from 'src/app/core/models/resend-email-verifi
import { RouterAuthService } from 'src/app/core/services/router-auth.service';
import { TransactionService } from 'src/app/core/services/transaction.service';
import { DeepLinkService } from 'src/app/core/services/deep-link.service';
import { UnflattenedTransaction } from 'src/app/core/models/unflattened-transaction.model';
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service';

@Component({
selector: 'app-switch-org',
Expand Down Expand Up @@ -82,7 +84,8 @@ export class SwitchOrgPage implements OnInit, AfterViewChecked {
private snackbarProperties: SnackbarPropertiesService,
private routerAuthService: RouterAuthService,
private transactionService: TransactionService,
private deepLinkService: DeepLinkService
private deepLinkService: DeepLinkService,
private expensesService: ExpensesService
) {}

ngOnInit() {
Expand Down Expand Up @@ -191,8 +194,9 @@ export class SwitchOrgPage implements OnInit, AfterViewChecked {
}),
switchMap((eou) => {
this.setSentryUser(eou);
return this.transactionService.getETxnUnflattened(txnId);
return this.expensesService.getExpenseById(txnId);
}),
map((expense) => this.transactionService.transformExpense(expense)),
finalize(() => this.loaderService.hideLoader())
)
.subscribe({
Expand Down
261 changes: 261 additions & 0 deletions src/app/core/mock-data/corporate-card-transaction-response.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
import { CorporateCardTransactionRes } from '../models/platform/v1/corporate-card-transaction-res.model';
import { TransactionStatus } from '../models/platform/v1/expense.model';

export const ccTransactionResponseData: CorporateCardTransactionRes = {
data: {
amount: 205.21,
assignor_user: null,
assignor_user_id: null,
auto_suggested_expense_ids: [],
can_delete: false,
category: null,
code: '6c4a6dcb15a94c0e976dcd1a507dcfd0',
corporate_card: {
bank_name: 'DSR',
card_number: '7620',
id: 'bacck9WlgA11Uh',
masked_number: '7620',
user_email: '[email protected]',
user_full_name: 'Devendra Singh Rana',
},
corporate_card_id: 'bacck9WlgA11Uh',
created_at: new Date('2024-01-23T12:17:34.473632+00:00'),
currency: 'USD',
description: null,
foreign_amount: null,
foreign_currency: null,
id: 'btxnBdS2Kpvzhy',
is_assigned: true,
is_auto_matched: true,
is_dismissed: false,
is_exported: false,
is_marked_personal: true,
last_assigned_at: new Date('2024-01-23T12:18:51.470532+00:00'),
last_auto_matched_at: new Date('2024-01-23T12:20:06.279340+00:00'),
last_dismissed_at: null,
last_marked_personal_at: new Date('2024-02-12T12:36:16.437731+00:00'),
last_user_matched_at: null,
matched_expense_ids: [],
matched_expenses: [],
mcc: null,
merchant: 'test description',
metadata: {
merchant_category_code: '',
flight_merchant_category_code: '',
flight_supplier_name: '',
flight_travel_agency_name: '',
flight_ticket_number: '',
flight_total_fare: 0,
flight_travel_date: undefined,
flight_service_class: '',
flight_carrier_code: '',
flight_fare_base_code: '',
flight_trip_leg_number: '',
hotel_merchant_category_code: '',
hotel_supplier_name: '',
hotel_checked_in_at: undefined,
hotel_nights: 0,
hotel_checked_out_at: undefined,
hotel_country: '',
hotel_city: '',
hotel_total_fare: 0,
fleet_product_merchant_category_code: '',
fleet_product_supplier_name: '',
fleet_service_merchant_category_code: '',
fleet_service_supplier_name: '',
car_rental_merchant_category_code: '',
car_rental_supplier_name: '',
car_rental_started_at: undefined,
car_rental_days: 0,
car_rental_ended_at: undefined,
general_ticket_issued_at: undefined,
general_ticket_number: '',
general_issuing_carrier: '',
general_travel_agency_name: '',
general_travel_agency_code: '',
general_ticket_total_fare: 0,
general_ticket_total_tax: 0,
merchant_address: '',
},
org_id: 'oroLKHBYQVvj',
post_date: null,
settlement_id: null,
spent_at: new Date('2018-06-06T00:00:00+00:00'),
statement_id: 'stmt2K9aLunGU4',
updated_at: new Date('2024-02-12T12:36:16.437742+00:00'),
user: {
email: '[email protected]',
full_name: 'Devendra Singh Rana',
id: 'usvMoPfCC9Xw',
},
user_id: 'usvMoPfCC9Xw',
},
};

export const ccTransactionResponseData1: CorporateCardTransactionRes = {
data: {
...ccTransactionResponseData.data,
id: 'btxnSte7sVQCM8',
},
};

export const unmatchCCCExpenseResponseData: CorporateCardTransactionRes = {
data: {
amount: 260.37,
assignor_user: null,
assignor_user_id: null,
auto_suggested_expense_ids: [],
can_delete: true,
category: null,
code: 'b1d89f85d1f44a22981e4b4c8b1af435',
corporate_card: {
bank_name: 'DSR',
card_number: '7620',
id: 'bacck9WlgA11Uh',
masked_number: '7620',
user_email: '[email protected]',
user_full_name: 'Devendra Singh Rana',
},
corporate_card_id: 'bacck9WlgA11Uh',
created_at: new Date('2024-01-23T12:17:31.316675+00:00'),
currency: 'USD',
description: null,
foreign_amount: null,
foreign_currency: null,
id: 'btxnSte7sVQCM8',
is_assigned: true,
is_auto_matched: false,
is_dismissed: false,
is_exported: false,
is_marked_personal: false,
last_assigned_at: new Date('2024-01-23T12:18:51.470532+00:00'),
last_auto_matched_at: new Date('2024-01-23T12:19:50.298547+00:00'),
last_dismissed_at: null,
last_marked_personal_at: null,
last_user_matched_at: new Date('2024-02-13T03:10:49.432011+00:00'),
matched_expense_ids: ['txmF3wgfj0Bs'],
matched_expenses: [
{
amount: 260.37,
category_display_name: 'Unspecified',
currency: 'USD',
foreign_amount: null,
foreign_currency: null,
id: 'txmF3wgfj0Bs',
merchant: 'test description',
no_of_files: 0,
purpose: null,
seq_num: 'E/2024/01/T/39',
spent_at: new Date('2018-07-04T00:00:00+00:00'),
state: 'DRAFT',
},
],
mcc: null,
merchant: 'test description',
metadata: {
merchant_category_code: '',
flight_merchant_category_code: '',
flight_supplier_name: '',
flight_travel_agency_name: '',
flight_ticket_number: '',
flight_total_fare: 0,
flight_travel_date: undefined,
flight_service_class: '',
flight_carrier_code: '',
flight_fare_base_code: '',
flight_trip_leg_number: '',
hotel_merchant_category_code: '',
hotel_supplier_name: '',
hotel_checked_in_at: undefined,
hotel_nights: 0,
hotel_checked_out_at: undefined,
hotel_country: '',
hotel_city: '',
hotel_total_fare: 0,
fleet_product_merchant_category_code: '',
fleet_product_supplier_name: '',
fleet_service_merchant_category_code: '',
fleet_service_supplier_name: '',
car_rental_merchant_category_code: '',
car_rental_supplier_name: '',
car_rental_started_at: undefined,
car_rental_days: 0,
car_rental_ended_at: undefined,
general_ticket_issued_at: undefined,
general_ticket_number: '',
general_issuing_carrier: '',
general_travel_agency_name: '',
general_travel_agency_code: '',
general_ticket_total_fare: 0,
general_ticket_total_tax: 0,
merchant_address: '',
},
org_id: 'oroLKHBYQVvj',
post_date: null,
settlement_id: null,
spent_at: new Date('2018-07-04T00:00:00+00:00'),
statement_id: 'stmt2K9aLunGU4',
transaction_status: TransactionStatus.PENDING,
updated_at: new Date('2024-02-13T03:10:49.432028+00:00'),
user: {
email: '[email protected]',
full_name: 'Devendra Singh Rana',
id: 'usvMoPfCC9Xw',
},
user_id: 'usvMoPfCC9Xw',
},
};

export const matchCCCExpenseResponseData: CorporateCardTransactionRes = {
data: {
amount: 260.37,
assignor_user: null,
assignor_user_id: null,
auto_suggested_expense_ids: [],
can_delete: true,
category: null,
code: 'b1d89f85d1f44a22981e4b4c8b1af435',
corporate_card: {
bank_name: 'DSR',
card_number: '7620',
id: 'bacck9WlgA11Uh',
masked_number: '7620',
user_email: '[email protected]',
user_full_name: 'Devendra Singh Rana',
},
corporate_card_id: 'bacck9WlgA11Uh',
created_at: new Date('2024-01-23T12:17:31.316675+00:00'),
currency: 'USD',
description: null,
foreign_amount: null,
foreign_currency: null,
id: 'btxnSte7sVQCM8',
is_assigned: true,
is_auto_matched: true,
is_dismissed: false,
is_exported: false,
is_marked_personal: false,
last_assigned_at: new Date('2024-01-23T12:18:51.470532+00:00'),
last_auto_matched_at: new Date('2024-01-23T12:19:50.298547+00:00'),
last_dismissed_at: null,
last_marked_personal_at: null,
last_user_matched_at: null,
matched_expense_ids: [],
matched_expenses: [],
mcc: null,
merchant: 'test description',
org_id: 'oroLKHBYQVvj',
post_date: null,
settlement_id: null,
spent_at: new Date('2018-07-04T00:00:00+00:00'),
statement_id: 'stmt2K9aLunGU4',
transaction_status: TransactionStatus.PENDING,
updated_at: new Date('2024-02-13T03:10:48.454767+00:00'),
user: {
email: '[email protected]',
full_name: 'Devendra Singh Rana',
id: 'usvMoPfCC9Xw',
},
user_id: 'usvMoPfCC9Xw',
},
};
9 changes: 9 additions & 0 deletions src/app/core/mock-data/duplicate-sets.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ export const duplicateSetData3: DuplicateSet = {
export const duplicateSetData4: DuplicateSet = {
transaction_ids: ['tx5fBcPBAxLv'],
};

export const duplicateSetData5: DuplicateSet = {
fields: ['field1', 'field2'],
transaction_ids: ['txal5xGjbZ1R'],
};

export const duplicateSetData6: DuplicateSet = {
transaction_ids: ['txal5xGjbZ1R'],
};
Loading

0 comments on commit 7642a9f

Please sign in to comment.