Skip to content

Commit 4090d16

Browse files
authored
feat: infra changes for date, time and currency centralization (#4014)
* add stuff * reference updates * pipe changes * reference changes * comment changes * revert to separate styles for amount and symbol * minor * fix tests * minor * minor * minor * eslint * minor * minor * minor * minor * minor * minor * use currency.js * minor * minor * minor * minor
1 parent 8e83554 commit 4090d16

File tree

68 files changed

+784
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+784
-333
lines changed

package-lock.json

Lines changed: 186 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"cordova-plugin-ionic": "^5.5.3",
7878
"cordova-plugin-native-spinner": "^1.1.4",
7979
"cordova-plugin-smartlook": "github:smartlook/cordova-smartlook",
80+
"currency.js": "^2.0.4",
8081
"dayjs": "^1.11.7",
8182
"dotenv": "^16.0.1",
8283
"driver.js": "^1.3.5",

src/app/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { InjectionToken } from '@angular/core';
22
import { BehaviorSubject } from 'rxjs';
3+
import { FormatPreferences } from './core/models/format-preferences.model';
34

45
export const PAGINATION_SIZE = new InjectionToken<number>('API Pagination size');
56

67
export const DEVICE_PLATFORM = new InjectionToken<'android' | 'ios' | 'web'>('Device Platform');
78

89
export const TIMEZONE = new InjectionToken<BehaviorSubject<string>>('UTC');
10+
11+
export const FORMAT_PREFERENCES = new InjectionToken<FormatPreferences>('FORMAT_PREFERENCES');

src/app/core/mock-data/task.data.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const draftExpenseTaskSample = deepFreeze({
2020

2121
export const draftExpenseTaskSample2 = deepFreeze({
2222
hideAmount: true,
23-
amount: '76234.47',
23+
amount: '76234.47',
2424
count: 339,
2525
header: 'Complete 339 expenses',
2626
subheader: 'Fill in missing details for incomplete expenses',
@@ -49,7 +49,7 @@ export const potentailDuplicateTaskSample = deepFreeze({
4949

5050
export const teamReportTaskSample = deepFreeze({
5151
hideAmount: true,
52-
amount: '5177243929.65',
52+
amount: '5177243929.65',
5353
count: 2,
5454
header: "Approve team's 2 reports",
5555
subheader: 'Approve pending reports from your team.',
@@ -64,7 +64,7 @@ export const teamReportTaskSample = deepFreeze({
6464

6565
export const sentBackReportTaskSample = deepFreeze({
6666
hideAmount: true,
67-
amount: '4500.00',
67+
amount: '4500.00',
6868
count: 2,
6969
header: 'Review sent back reports',
7070
subheader: 'Fix issues in your reports to resubmit.',
@@ -79,7 +79,7 @@ export const sentBackReportTaskSample = deepFreeze({
7979

8080
export const sentBackReportTaskSingularSample = deepFreeze({
8181
hideAmount: true,
82-
amount: '4500.00',
82+
amount: '4500.00',
8383
count: 1,
8484
header: 'Review sent back report',
8585
subheader: 'Fix issues in your report to resubmit.',
@@ -109,7 +109,7 @@ export const unreportedExpenseTaskSample = deepFreeze({
109109

110110
export const unreportedExpenseTaskSample2 = deepFreeze({
111111
hideAmount: true,
112-
amount: '30.00',
112+
amount: '30.00',
113113
count: 3,
114114
header: 'Add 3 expenses to report',
115115
subheader: 'Add complete expenses to a report and submit.',
@@ -124,7 +124,7 @@ export const unreportedExpenseTaskSample2 = deepFreeze({
124124

125125
export const unsubmittedReportTaskSample = deepFreeze({
126126
hideAmount: true,
127-
amount: '93165.91',
127+
amount: '93165.91',
128128
count: 2,
129129
header: 'Submit 2 expense reports',
130130
subheader: 'Submit reports for approval.',
@@ -139,7 +139,7 @@ export const unsubmittedReportTaskSample = deepFreeze({
139139

140140
export const sentBackAdvanceTaskSample = deepFreeze({
141141
hideAmount: true,
142-
amount: '123370000.00',
142+
amount: '123370000.00',
143143
count: 5,
144144
header: 'Review sent back advances',
145145
subheader: 'Fix issues in your advances to resubmit.',
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface FormatPreferences {
2+
timeFormat: string;
3+
currencyFormat: {
4+
placement: 'before' | 'after';
5+
thousandSeparator: string;
6+
decimalSeparator: string;
7+
};
8+
}

src/app/core/services/custom-inputs.service.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { expensesWithDependentFields } from '../mock-data/dependent-field-expens
1717
import { CustomInput } from '../models/custom-input.model';
1818
import { mockExpenseData } from '../mock-data/expense-field.data';
1919
import { getTranslocoTestingModule } from '../testing/transloco-testing.utils';
20+
import { getFormatPreferenceProviders } from '../testing/format-preference-providers.utils';
2021

2122
describe('CustomInputsService', () => {
2223
let customInputsService: CustomInputsService;
@@ -42,6 +43,7 @@ describe('CustomInputsService', () => {
4243
useValue: authServiceSpy,
4344
},
4445
DatePipe,
46+
...getFormatPreferenceProviders(),
4547
],
4648
});
4749

src/app/core/services/custom-inputs.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,7 @@ export class CustomInputsService {
209209
}
210210

211211
private formatDateCustomProperty(customProperty: CustomField): string {
212-
return customProperty.value
213-
? this.datePipe.transform(<string | number | Date>customProperty.value, 'MMM dd, yyyy')
214-
: '-';
212+
return customProperty.value ? this.datePipe.transform(<string | number | Date>customProperty.value) : '-';
215213
}
216214

217215
private formatMultiselectCustomProperty(customProperty: CustomField): string {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('ReportService', () => {
124124
spyOn(reportService, 'getReportAutoSubmissionDetails').and.returnValue(of(apiReportAutoSubmissionDetails));
125125

126126
reportService.getAutoSubmissionReportName().subscribe((res) => {
127-
expect(res).toEqual('(Automatic Submission On Feb 1)');
127+
expect(res).toEqual('(Automatic Submission On Feb 1, 2023)');
128128
expect(reportService.getReportAutoSubmissionDetails).toHaveBeenCalledTimes(1);
129129
done();
130130
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class ReportService {
100100
const nextReportAutoSubmissionDate = reportAutoSubmissionDetails.data?.next_at;
101101
if (nextReportAutoSubmissionDate) {
102102
return this.translocoService.translate('services.report.automaticSubmissionOnDate', {
103-
date: this.datePipe.transform(nextReportAutoSubmissionDate, 'MMM d'),
103+
date: this.datePipe.transform(nextReportAutoSubmissionDate),
104104
});
105105
}
106106
return null;

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ describe('TasksService', () => {
916916
expect(sentBackAdvanceTask).toEqual([
917917
{
918918
hideAmount: true,
919-
amount: '123370000.00',
919+
amount: '123370000.00',
920920
count: 1,
921921
header: 'Review sent back advance',
922922
subheader: 'Fix issues in your advance to resubmit.',
@@ -957,7 +957,7 @@ describe('TasksService', () => {
957957
expect(sentBackReportTask).toEqual([
958958
{
959959
hideAmount: true,
960-
amount: '44.53',
960+
amount: '44.53',
961961
count: 2,
962962
header: 'Review sent back reports',
963963
subheader: 'Fix issues in your reports to resubmit.',
@@ -995,7 +995,7 @@ describe('TasksService', () => {
995995
expect(tasks).toEqual([
996996
{
997997
hideAmount: true,
998-
amount: '132573333762.37',
998+
amount: '132573333762.37',
999999
count: 1,
10001000
header: 'Complete 1 expense',
10011001
subheader: 'Fill in missing details for incomplete expense',
@@ -1015,9 +1015,8 @@ describe('TasksService', () => {
10151015
.withArgs({
10161016
value: unsubmittedReportsResponse[0].aggregates[1].function_value,
10171017
currencyCode: homeCurrency,
1018-
skipSymbol: true,
10191018
})
1020-
.and.returnValue('0.00');
1019+
.and.returnValue('0.00');
10211020

10221021
const tasks = tasksService.mapAggregateToUnsubmittedReportTask(
10231022
{
@@ -1030,7 +1029,7 @@ describe('TasksService', () => {
10301029
expect(tasks).toEqual([
10311030
{
10321031
hideAmount: true,
1033-
amount: '0.00',
1032+
amount: '0.00',
10341033
count: 1,
10351034
header: 'Submit 1 expense report',
10361035
subheader: 'Submit report for approval.',
@@ -1071,7 +1070,7 @@ describe('TasksService', () => {
10711070
expect(tasks).toEqual([
10721071
{
10731072
hideAmount: true,
1074-
amount: '733479.83',
1073+
amount: '733479.83',
10751074
count: 1,
10761075
header: "Approve team's 1 report",
10771076
subheader: 'Approve pending report from your team.',

0 commit comments

Comments
 (0)