From e7806a72d60b26f5007839ae1ea3d4ac2dd1b462 Mon Sep 17 00:00:00 2001 From: Arjun Date: Mon, 5 Feb 2024 21:19:29 +0530 Subject: [PATCH 1/8] fix: Filter the mileage rates by employee allowed mileage rates only if the employee mileage restriction flag is enabled --- src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index 9f94c64432..0503fc6cb8 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -1373,11 +1373,12 @@ export class AddEditMileagePage implements OnInit { this.mileageRates$ = forkJoin({ orgUserMileageSettings: this.mileageService.getOrgUserMileageSettings(), allMileageRates: this.mileageRateService.getAllMileageRates(), + orgSettings: orgSettings$, }).pipe( - map(({ orgUserMileageSettings, allMileageRates }) => { + map(({ orgUserMileageSettings, allMileageRates, orgSettings }) => { let enabledMileageRates = this.mileageRatesService.filterEnabledMileageRates(allMileageRates); const mileageRateSettings = orgUserMileageSettings?.mileage_rate_labels || []; - if (mileageRateSettings.length > 0) { + if (orgSettings.mileage?.enable_individual_mileage_rates && mileageRateSettings.length > 0) { enabledMileageRates = enabledMileageRates.filter((rate) => mileageRateSettings.includes(rate.vehicle_type)); } return enabledMileageRates; From 64d3927f0eb485888b6afa12df35b35e1b6405bc Mon Sep 17 00:00:00 2001 From: aastha Date: Tue, 6 Feb 2024 08:54:22 +0530 Subject: [PATCH 2/8] Minor --- src/app/core/models/card-details-amount-response.ts | 3 +++ src/app/core/models/card-details-response.model.ts | 4 ---- src/app/core/services/virtual-cards.service.ts | 11 ++++++----- 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 src/app/core/models/card-details-amount-response.ts diff --git a/src/app/core/models/card-details-amount-response.ts b/src/app/core/models/card-details-amount-response.ts new file mode 100644 index 0000000000..d3693057e3 --- /dev/null +++ b/src/app/core/models/card-details-amount-response.ts @@ -0,0 +1,3 @@ +export interface CardDetailsAmountResponse { + current_amount: number; +} diff --git a/src/app/core/models/card-details-response.model.ts b/src/app/core/models/card-details-response.model.ts index 2b23fe0c38..8975bd1321 100644 --- a/src/app/core/models/card-details-response.model.ts +++ b/src/app/core/models/card-details-response.model.ts @@ -3,7 +3,3 @@ export interface CardDetailsResponse { cvv: string; expiry_date: Date; } - -export interface CardDetailsAmountResponse { - current_amount: number; -} diff --git a/src/app/core/services/virtual-cards.service.ts b/src/app/core/services/virtual-cards.service.ts index ca0b93aa38..790cc793b0 100644 --- a/src/app/core/services/virtual-cards.service.ts +++ b/src/app/core/services/virtual-cards.service.ts @@ -2,7 +2,8 @@ import { Injectable } from '@angular/core'; import { SpenderPlatformV1ApiService } from './spender-platform-v1-api.service'; import { Observable, map } from 'rxjs'; import { VirtualCardsRequest } from '../models/virtual-cards-request.model'; -import { CardDetailsAmountResponse, CardDetailsResponse } from '../models/card-details-response.model'; +import { CardDetailsResponse } from '../models/card-details-response.model'; +import { CardDetailsAmountResponse } from '../models/card-details-amount-response'; @Injectable({ providedIn: 'root', @@ -13,20 +14,20 @@ export class VirtualCardsService { getCardDetailsById(virtualCardRequestPayload: VirtualCardsRequest): Observable { return this.spenderPlatformV1ApiService .post<{ - data: CardDetailsResponse + data: CardDetailsResponse; }>('/virtual_cards/show_card_details', { data: virtualCardRequestPayload, }) .pipe(map((response) => response.data)); } - getCurrentAmountById(virtualCardRequestPayload: VirtualCardsRequest): Observable { + getCurrentAmountById(virtualCardRequestPayload: VirtualCardsRequest): Observable { return this.spenderPlatformV1ApiService .post<{ - data: CardDetailsAmountResponse + data: CardDetailsAmountResponse; }>('/virtual_cards/get_current_amount', { data: virtualCardRequestPayload, }) - .pipe(map((response) => response.data.current_amount)); + .pipe(map((response) => response.data)); } } From 2bd002008176bc080768868c65ca06088f0a7249 Mon Sep 17 00:00:00 2001 From: aastha Date: Tue, 6 Feb 2024 08:58:48 +0530 Subject: [PATCH 3/8] Minor --- .../services/virtual-cards.service.spec.ts | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/core/services/virtual-cards.service.spec.ts b/src/app/core/services/virtual-cards.service.spec.ts index f549762b7e..72727cce70 100644 --- a/src/app/core/services/virtual-cards.service.spec.ts +++ b/src/app/core/services/virtual-cards.service.spec.ts @@ -1,16 +1,30 @@ import { TestBed } from '@angular/core/testing'; import { VirtualCardsService } from './virtual-cards.service'; +import { SpenderPlatformV1ApiService } from './spender-platform-v1-api.service'; describe('VirtualCardsService', () => { - let service: VirtualCardsService; + let virtualCardsService: VirtualCardsService; + let spenderPlatformV1ApiService: jasmine.SpyObj; beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(VirtualCardsService); + const spenderPlatformV1ApiServiceSpy = jasmine.createSpyObj('SpenderPlatformV1ApiService', ['post']); + TestBed.configureTestingModule({ + providers: [ + VirtualCardsService, + { + provide: SpenderPlatformV1ApiService, + useValue: spenderPlatformV1ApiServiceSpy, + }, + ], + }); + spenderPlatformV1ApiService = TestBed.inject( + SpenderPlatformV1ApiService + ) as jasmine.SpyObj; + virtualCardsService = TestBed.inject(VirtualCardsService); }); it('should be created', () => { - expect(service).toBeTruthy(); + expect(virtualCardsService).toBeTruthy(); }); }); From d75cd7d5490e812efd3da223c3a489490c274f07 Mon Sep 17 00:00:00 2001 From: Aastha Bist Date: Tue, 6 Feb 2024 20:24:47 +0530 Subject: [PATCH 4/8] Update virtual-card.component.html --- .../virtual-card/virtual-card.component.html | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/app/shared/components/virtual-card/virtual-card.component.html b/src/app/shared/components/virtual-card/virtual-card.component.html index bf7cd0d044..e17c782b9a 100644 --- a/src/app/shared/components/virtual-card/virtual-card.component.html +++ b/src/app/shared/components/virtual-card/virtual-card.component.html @@ -29,32 +29,29 @@ -