Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha committed Dec 18, 2024
1 parent df6dc31 commit ffe935e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/core/services/tasks.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ describe('TasksService', () => {

describe('getAddCorporateCardTask(): ', () => {
it('should return add corporate card task when no cards are enrolled', (done) => {
orgSettingsService.get.and.returnValue(of(orgSettingsRes));
corporateCreditCardExpenseService.getCorporateCards.and.returnValue(of([statementUploadedCard]));
const addCcSpy = spyOn(tasksService, 'mapAddCorporateCardTask');

Expand Down
11 changes: 8 additions & 3 deletions src/app/core/services/tasks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,15 @@ export class TasksService {
}

getAddCorporateCardTask(): Observable<DashboardTask[]> {
return this.corporateCreditCardExpenseService.getCorporateCards().pipe(
map((cards) => {
return forkJoin([this.orgSettingsService.get(), this.corporateCreditCardExpenseService.getCorporateCards()]).pipe(
map(([orgSettings, cards]) => {
const isRtfEnabled =
(orgSettings.visa_enrollment_settings.allowed && orgSettings.visa_enrollment_settings.enabled) ||
(orgSettings.mastercard_enrollment_settings.allowed && orgSettings.mastercard_enrollment_settings.enabled);
const isCCCEnabled =
orgSettings.corporate_credit_card_settings.allowed && orgSettings.corporate_credit_card_settings.enabled;
const rtfCards = cards.filter((card) => card.is_visa_enrolled || card.is_mastercard_enrolled);
if (rtfCards.length === 0) {
if (isRtfEnabled && isCCCEnabled && rtfCards.length === 0) {
return this.mapAddCorporateCardTask();
} else {
return [] as DashboardTask[];
Expand Down

0 comments on commit ffe935e

Please sign in to comment.