Skip to content

Commit effc159

Browse files
devendraranadevendrafyle
authored andcommitted
fix: Hidden null and empty action details (#4045)
* fix: Added the test case and hidden null and empty details * minor fixes * fixed the comments
1 parent d81134c commit effc159

File tree

8 files changed

+218
-62
lines changed

8 files changed

+218
-62
lines changed

src/app/core/services/status.service.spec.ts

Lines changed: 128 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ describe('StatusService', () => {
2929
'services.status.approverAdded': 'Approver added',
3030
'services.status.approverPending': 'Approver pending',
3131
'services.status.approverRemoved': 'Approver removed',
32+
'services.status.approvalsReset': 'Approvals reset',
33+
'services.status.cardExpenseMerged': 'Card expense merged',
3234
'services.status.cardExpenseRemoved': 'Card expense removed',
3335
'services.status.cardTransactionMatched': 'Card transaction matched',
3436
'services.status.criticalPolicyViolation': 'Critical policy violation found',
@@ -37,6 +39,7 @@ describe('StatusService', () => {
3739
'services.status.duplicateIssueResolved': 'Duplicate(s) issue resolved',
3840
'services.status.expense': 'Expense',
3941
'services.status.expenseAdded': 'Expense added',
42+
'services.status.expenseApproved': 'Expense approved',
4043
'services.status.expenseAutomaticallyMerged': 'Expense automatically merged',
4144
'services.status.expenseIssues': 'Expense issues',
4245
'services.status.expenseMatched': 'Expense matched',
@@ -45,10 +48,12 @@ describe('StatusService', () => {
4548
'services.status.expenseRemoved': 'Expense removed',
4649
'services.status.expenseReportApproved': 'Expense report approved',
4750
'services.status.expenseRuleApplied': 'Expense rule applied',
51+
'services.status.expenseSplit': 'Expense split',
4852
'services.status.expenseUnlinked': 'Expense unlinked',
4953
'services.status.expenseUnmatched': 'Expense unmatched',
5054
'services.status.expenseVerificationUndone': 'Expense verification undone',
5155
'services.status.expenseVerified': 'Expense verified',
56+
'services.status.expensesAdded': 'Expense(s) added',
5257
'services.status.expensesMergedToThisExpense': '{{count}} expenses merged to this expense',
5358
'services.status.failedToRunPolicies': 'Failed to run policies',
5459
'services.status.flagged': 'Flagged',
@@ -247,10 +252,10 @@ describe('StatusService', () => {
247252
expect(result.icon).toBe('check');
248253
});
249254

250-
it('should return "Expense" for matched by comments', () => {
255+
it('should return "Expense matched" for matched by comments', () => {
251256
const comment = 'Expense matched by John Doe [email protected]';
252257
const result = statusService.getStatusCategory(comment, 'transactions');
253-
expect(result.category).toBe('Expense');
258+
expect(result.category).toBe('Expense matched');
254259
expect(result.icon).toBe('check');
255260
});
256261

@@ -303,10 +308,10 @@ describe('StatusService', () => {
303308
expect(result.icon).toBe('check');
304309
});
305310

306-
it('should return "Expense report approved" for approved by admin comments', () => {
311+
it('should return "Reports approved" for approved by admin comments', () => {
307312
const comment = 'Expense report approved by admin';
308313
const result = statusService.getStatusCategory(comment, 'reports');
309-
expect(result.category).toBe('Expense report approved');
314+
expect(result.category).toBe('Reports approved');
310315
expect(result.icon).toBe('check');
311316
});
312317

@@ -345,4 +350,123 @@ describe('StatusService', () => {
345350
expect(result.us_full_name).toBeNull();
346351
expect(result.us_email).toBeNull();
347352
});
353+
354+
it('should return "Expense merged" for generic merged comments', () => {
355+
const comment = 'Expense merged by [email protected]';
356+
const result = statusService.getStatusCategory(comment, 'transactions');
357+
expect(result.category).toBe('Expense merged');
358+
expect(result.icon).toBe('check');
359+
});
360+
361+
it('should return "Card expense merged" for expense merged automatically comments', () => {
362+
const comment = 'Expense merged automatically by system';
363+
const result = statusService.getStatusCategory(comment, 'transactions');
364+
expect(result.category).toBe('Card expense merged');
365+
expect(result.icon).toBe('check');
366+
});
367+
368+
it('should return "Expense(s) added" for expense(s) added to report comments', () => {
369+
const comment = 'expense(s) added to report by [email protected]';
370+
const result = statusService.getStatusCategory(comment, 'reports');
371+
expect(result.category).toBe('Expense(s) added');
372+
expect(result.icon).toBe('check');
373+
});
374+
375+
it('should return "Report name changed" for name was changed from comments', () => {
376+
const comment = 'Report name was changed from "Old Name" to "New Name"';
377+
const result = statusService.getStatusCategory(comment, 'reports');
378+
expect(result.category).toBe('Report name changed');
379+
expect(result.icon).toBe('check');
380+
});
381+
382+
it('should return "Unflagged" for unflagged comments', () => {
383+
const comment = 'Expense unflagged by [email protected]';
384+
const result = statusService.getStatusCategory(comment, 'transactions');
385+
expect(result.category).toBe('Unflagged');
386+
expect(result.icon).toBe('check');
387+
});
388+
389+
it('should return "Flagged" for flagged comments', () => {
390+
const comment = 'Expense flagged by system';
391+
const result = statusService.getStatusCategory(comment, 'transactions');
392+
expect(result.category).toBe('Flagged');
393+
expect(result.icon).toBe('danger-outline');
394+
});
395+
396+
it('should return "Expense split" for expense split comments', () => {
397+
const comment = 'Expense split by [email protected]';
398+
const result = statusService.getStatusCategory(comment, 'transactions');
399+
expect(result.category).toBe('Expense split');
400+
expect(result.icon).toBe('check');
401+
});
402+
403+
it('should return "Verified" for generic verified comments', () => {
404+
const comment = 'Report verified by [email protected]';
405+
const result = statusService.getStatusCategory(comment, 'reports');
406+
expect(result.category).toBe('Verified');
407+
expect(result.icon).toBe('check');
408+
});
409+
410+
it('should return "Approvals reset" for approvals reset comments', () => {
411+
const comment = 'Approvals reset by [email protected]';
412+
const result = statusService.getStatusCategory(comment, 'reports');
413+
expect(result.category).toBe('Approvals reset');
414+
expect(result.icon).toBe('check');
415+
});
416+
417+
it('should return "Policies ran successfully" for policies ran successfully comments', () => {
418+
const comment = 'Policies ran successfully on this expense';
419+
const result = statusService.getStatusCategory(comment, 'transactions');
420+
expect(result.category).toBe('Policies ran successfully');
421+
expect(result.icon).toBe('check');
422+
});
423+
424+
it('should return "Card transaction matched" for auto-matched by comments', () => {
425+
const comment = 'Expense auto-matched by system';
426+
const result = statusService.getStatusCategory(comment, 'transactions');
427+
expect(result.category).toBe('Card transaction matched');
428+
expect(result.icon).toBe('check');
429+
});
430+
431+
it('should return "Expense unmatched" for unmatched by comments', () => {
432+
const comment = 'Expense unmatched by [email protected]';
433+
const result = statusService.getStatusCategory(comment, 'transactions');
434+
expect(result.category).toBe('Expense unmatched');
435+
expect(result.icon).toBe('check');
436+
});
437+
438+
it('should return "Approver pending" for approver_pending comments', () => {
439+
const comment = 'approver_pending status set by system';
440+
const result = statusService.getStatusCategory(comment, 'reports');
441+
expect(result.category).toBe('Approver pending');
442+
expect(result.icon).toBe('check');
443+
});
444+
445+
it('should return "Processing payment" for payment_processing comments', () => {
446+
const comment = 'payment_processing status set by system';
447+
const result = statusService.getStatusCategory(comment, 'reports');
448+
expect(result.category).toBe('Processing payment');
449+
expect(result.icon).toBe('check');
450+
});
451+
452+
it('should return "Expense issues" for expense issues comments', () => {
453+
const comment = 'Expense issues detected by system';
454+
const result = statusService.getStatusCategory(comment, 'transactions');
455+
expect(result.category).toBe('Expense issues');
456+
expect(result.icon).toBe('danger-outline');
457+
});
458+
459+
it('should return "Duplicate detected" for expense is a possible duplicate comments', () => {
460+
const comment = 'This expense is a possible duplicate of another expense';
461+
const result = statusService.getStatusCategory(comment, 'transactions');
462+
expect(result.category).toBe('Duplicate detected');
463+
expect(result.icon).toBe('danger-outline');
464+
});
465+
466+
it('should return "Duplicate(s) issue resolved" for duplicate expense(s) with similar details comments', () => {
467+
const comment = 'duplicate expense(s) with similar details have been resolved';
468+
const result = statusService.getStatusCategory(comment, 'transactions');
469+
expect(result.category).toBe('Duplicate(s) issue resolved');
470+
expect(result.icon).toBe('check');
471+
});
348472
});

src/app/core/services/status.service.ts

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ export class StatusService {
6262
icon: 'check',
6363
};
6464
break;
65+
case lowerCaseComment.includes('expense merged automatically') ||
66+
lowerCaseComment.includes('automatically merged'):
67+
statusCategory = {
68+
category: this.translocoService.translate('services.status.cardExpenseMerged'),
69+
icon: 'check',
70+
};
71+
break;
6572
case lowerCaseComment.includes('merged'):
6673
statusCategory = {
6774
category: this.translocoService.translate('services.status.expenseMerged'),
@@ -112,6 +119,12 @@ export class StatusService {
112119
};
113120
}
114121
break;
122+
case lowerCaseComment.includes('expense(s) added to report'):
123+
statusCategory = {
124+
category: this.translocoService.translate('services.status.expensesAdded'),
125+
icon: 'check',
126+
};
127+
break;
115128
case lowerCaseComment.includes('added to the report'):
116129
statusCategory = {
117130
category: this.translocoService.translate('services.status.expenseAdded'),
@@ -124,7 +137,8 @@ export class StatusService {
124137
icon: 'check',
125138
};
126139
break;
127-
case lowerCaseComment.includes('added') || lowerCaseComment.includes('attached to expense'):
140+
case (lowerCaseComment.includes('attachment') && lowerCaseComment.includes('added')) ||
141+
(lowerCaseComment.includes('receipt') && lowerCaseComment.includes('attached to expense')):
128142
statusCategory = {
129143
category: this.translocoService.translate('services.status.receiptAttached'),
130144
icon: 'check',
@@ -142,7 +156,8 @@ export class StatusService {
142156
icon: 'check',
143157
};
144158
break;
145-
case lowerCaseComment.includes('deleted') || lowerCaseComment.includes('removed from expense'):
159+
case (lowerCaseComment.includes('attachment') && lowerCaseComment.includes('deleted')) ||
160+
(lowerCaseComment.includes('receipt') && lowerCaseComment.includes('removed from expense')):
146161
statusCategory = {
147162
category: this.translocoService.translate('services.status.receiptRemoved'),
148163
icon: 'check',
@@ -167,7 +182,7 @@ export class StatusService {
167182
icon: 'check',
168183
};
169184
break;
170-
case lowerCaseComment.includes('removed by') || lowerCaseComment.includes('removed approver'):
185+
case lowerCaseComment.includes('removed') && lowerCaseComment.includes('approver'):
171186
statusCategory = {
172187
category: this.translocoService.translate('services.status.approverRemoved'),
173188
icon: 'check',
@@ -203,12 +218,24 @@ export class StatusService {
203218
icon: 'check',
204219
};
205220
break;
221+
case lowerCaseComment.includes('expense split'):
222+
statusCategory = {
223+
category: this.translocoService.translate('services.status.expenseSplit'),
224+
icon: 'check',
225+
};
226+
break;
206227
case lowerCaseComment.includes('verified'):
207228
statusCategory = {
208229
category: this.translocoService.translate('services.status.verified'),
209230
icon: 'check',
210231
};
211232
break;
233+
case lowerCaseComment.includes('approvals reset'):
234+
statusCategory = {
235+
category: this.translocoService.translate('services.status.approvalsReset'),
236+
icon: 'check',
237+
};
238+
break;
212239
case lowerCaseComment.includes('approver_inquiry') || lowerCaseComment.includes('report was sent back'):
213240
statusCategory = {
214241
category: this.translocoService.translate('services.status.typeSentBack', { type }),
@@ -221,12 +248,6 @@ export class StatusService {
221248
icon: 'check',
222249
};
223250
break;
224-
case lowerCaseComment.includes('approved by admin'):
225-
statusCategory = {
226-
category: this.translocoService.translate('services.status.expenseReportApproved'),
227-
icon: 'check',
228-
};
229-
break;
230251
case lowerCaseComment.includes('approved'):
231252
statusCategory = {
232253
category: this.translocoService.translate('services.status.typeApproved', { type }),
@@ -263,6 +284,12 @@ export class StatusService {
263284
icon: 'check',
264285
};
265286
break;
287+
case lowerCaseComment.includes('expense approved') || lowerCaseComment.includes('expense was approved'):
288+
statusCategory = {
289+
category: this.translocoService.translate('services.status.expenseApproved'),
290+
icon: 'check',
291+
};
292+
break;
266293
case lowerCaseComment.includes('auto-matched by'):
267294
statusCategory = {
268295
category: this.translocoService.translate('services.status.cardTransactionMatched'),
@@ -277,7 +304,7 @@ export class StatusService {
277304
break;
278305
case lowerCaseComment.includes('matched by'):
279306
statusCategory = {
280-
category: this.translocoService.translate('services.status.expense'),
307+
category: this.translocoService.translate('services.status.expenseMatched'),
281308
icon: 'check',
282309
};
283310
break;
@@ -318,7 +345,8 @@ export class StatusService {
318345
icon: 'check',
319346
};
320347
break;
321-
case lowerCaseComment.includes('expense amount capped by system due to policy'):
348+
case lowerCaseComment.includes('expense amount capped by system') ||
349+
lowerCaseComment.includes('policy caps amount'):
322350
statusCategory = {
323351
category: this.translocoService.translate('services.status.policyCappedAmount'),
324352
icon: 'danger-outline',

src/app/core/test-data/status.service.spec.data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ export const updateReponseWithFlattenedEStatus: ExtendedStatus[] = deepFreeze([
884884
isSelfComment: false,
885885
isOthersComment: true,
886886
st: {
887-
category: 'Receipt removed',
887+
category: 'Others',
888888
icon: 'check',
889889
},
890890
},
@@ -924,7 +924,7 @@ export const updateReponseWithFlattenedEStatus: ExtendedStatus[] = deepFreeze([
924924
isSelfComment: false,
925925
isOthersComment: true,
926926
st: {
927-
category: 'Receipt attached',
927+
category: 'Others',
928928
icon: 'check',
929929
},
930930
},
@@ -1224,7 +1224,7 @@ export const updateReponseWithFlattenedEStatus: ExtendedStatus[] = deepFreeze([
12241224
isSelfComment: false,
12251225
isOthersComment: true,
12261226
st: {
1227-
category: 'Expense',
1227+
category: 'Expense matched',
12281228
icon: 'check',
12291229
},
12301230
},
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@if (isValueList) {
1+
@if (shouldShowDetails() && isValueList()) {
22
<div class="statuses-diff">
33
<div class="statuses-diff--expense-issues">
44
@if (key() === 'Please contact your admin to configure the following') {
@@ -8,22 +8,22 @@
88
<span class="statuses-diff--violating-txns">{{ key() | snakeCaseToSpaceCase }}</span>
99
}
1010
@if (key() !== 'Please contact your admin to configure the following' && key() !== 'Violating Transactions') {
11-
<span class="text-capitalize">{{ key() | snakeCaseToSpaceCase }}</span>
11+
<span class="text-sentence-case">{{ key() | snakeCaseToSpaceCase }}</span>
1212
}
1313
</div>
1414
<ul class="statuses-diff--values-list">
1515
@for (detail of value(); track detail) {
1616
<div>
17-
<li class="text-capitalize">{{ detail }}</li>
17+
<li class="text-sentence-case">{{ detail }}</li>
1818
</div>
1919
}
2020
</ul>
2121
</div>
2222
}
23-
@if (!isValueList) {
23+
@if (shouldShowDetails() && !isValueList()) {
2424
<div>
25-
<li class="text-capitalize">
26-
{{ key() === 'vehicle type' ? ('statusesDiff.mileageRateName' | transloco) : key() }} : {{ displayValue }}
25+
<li class="text-sentence-case">
26+
{{ key() === 'vehicle type' ? ('statusesDiff.mileageRateName' | transloco) : key() }} : {{ displayValue() }}
2727
</li>
2828
</div>
2929
}

0 commit comments

Comments
 (0)