Skip to content

Commit

Permalink
Merge branch 'master' into fyle-86cv5kvqp-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Chethan-Fyle authored May 27, 2024
2 parents db77503 + 1bcbf2e commit a018b3b
Show file tree
Hide file tree
Showing 13 changed files with 493 additions and 451 deletions.
65 changes: 53 additions & 12 deletions src/app/core/mock-data/platform-report.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ export const platformReportData: Report = deepFreeze({
state: ApprovalState.APPROVAL_DONE,
},
],
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
created_at: new Date('2023-07-11T16:24:01.335Z'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: undefined,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -108,16 +111,22 @@ export const allReportsPaginated1: PlatformApiResponse<Report[]> = deepFreeze({
{
amount: 100,
approvals: [],
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -147,7 +156,7 @@ export const allReportsPaginated1: PlatformApiResponse<Report[]> = deepFreeze({
last_approved_at: null,
last_paid_at: null,
last_resubmitted_at: null,
last_submitted_at: null,
last_submitted_at: new Date('2023-02-01T13:02:35.097839+00:00'),
next_approver_user_ids: null,
num_expenses: 0,
org_id: 'orNVthTo2Zyo',
Expand All @@ -173,13 +182,16 @@ export const allReportsPaginated1: PlatformApiResponse<Report[]> = deepFreeze({
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -261,13 +273,16 @@ export const allReportsPaginatedWithApproval: PlatformApiResponse<Report[]> = de
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -323,13 +338,16 @@ export const allReportsPaginatedWithApproval: PlatformApiResponse<Report[]> = de
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -392,13 +410,16 @@ export const filteredReportsData: PlatformApiResponse<Report[]> = deepFreeze({
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -461,13 +482,16 @@ export const allReportsPaginated2: PlatformApiResponse<Report[]> = deepFreeze({
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -523,13 +547,16 @@ export const allReportsPaginated2: PlatformApiResponse<Report[]> = deepFreeze({
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -589,13 +616,16 @@ export const submittedReportData: Report = deepFreeze({
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -671,13 +701,16 @@ export const submittedReportDataWithApproval: Report = deepFreeze({
created_at: new Date('2023-07-11T06:19:28.260142+00:00'),
currency: 'USD',
employee: {
org_name: 'Staging Loaded',
level: null,
mobile: '123456098',
ach_account: {
added: true,
verified: null,
},
business_unit:
'A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed A very long Business Unit indeed',
code: null,
code: '101',
department: {
code: null,
display_name: '0000000 / arun',
Expand Down Expand Up @@ -738,6 +771,14 @@ export const expectedSingleReport: Report[] = deepFreeze([allReportsPaginated1.d

export const expectedReportsSinglePage: Report[] = deepFreeze([...allReportsPaginated1.data]);

export const sentBackReportData: Report = deepFreeze({ ...submittedReportData, state: 'APPROVER_INQUIRY' });

export const reportWithExpenses: Report = deepFreeze({
...platformReportData,
num_expenses: 3,
amount: 100,
});

export const expectedReportsSinglePageWithApproval: Report[] = deepFreeze([...allReportsPaginatedWithApproval.data]);

export const expectedReportsSinglePageFiltered: Report[] = deepFreeze([...filteredReportsData.data]);
Expand Down
12 changes: 6 additions & 6 deletions src/app/core/models/platform/v1/level.model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export interface Level {
id: string;
org_id: string;
created_at: Date;
updated_at: Date;
org_id?: string;
created_at?: Date;
updated_at?: Date;
name: string;
band: string;
code: string;
description: string;
is_enabled: boolean;
code?: string;
description?: string;
is_enabled?: boolean;
}
6 changes: 5 additions & 1 deletion src/app/core/models/platform/v1/report.model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ReportApprovals } from '../report-approvals.model';
import { Level } from './level.model';

export interface Report {
id: string;
org_id: string;
created_at: Date;
created_at: Date | string;
updated_at: Date;
user_id: string;
user: {
Expand Down Expand Up @@ -42,7 +43,10 @@ export interface Report {
};
code: string;
org_id: string;
org_name: string;
department_id: string;
level: Level;
mobile: string;
department: {
id: string;
code: string;
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/report.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ describe('ReportService', () => {

it('updateReportPurpose(): should update the report purpose', (done) => {
spenderPlatformV1ApiService.post.and.returnValue(of(platformReportData));
reportService.updateReportPurpose(reportData1).subscribe((res) => {
reportService.updateReportPurpose(platformReportData).subscribe((res) => {
expect(res).toEqual(platformReportData);
expect(spenderPlatformV1ApiService.post).toHaveBeenCalledOnceWith('/reports', {
data: {
Expand All @@ -670,7 +670,7 @@ describe('ReportService', () => {

it('approverUpdateReportPurpose(): should update the report purpose for approver', (done) => {
approverPlatformApiService.post.and.returnValue(of(platformReportData));
reportService.approverUpdateReportPurpose(reportData1).subscribe((res) => {
reportService.approverUpdateReportPurpose(platformReportData).subscribe((res) => {
expect(res).toEqual(platformReportData);
expect(approverPlatformApiService.post).toHaveBeenCalledOnceWith('/reports', {
data: {
Expand Down
16 changes: 8 additions & 8 deletions src/app/core/services/report.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ export class ReportService {
@CacheBuster({
cacheBusterNotifier: reportsCacheBuster$,
})
updateReportPurpose(erpt: ExtendedReport): Observable<Report> {
updateReportPurpose(report: Report): Observable<Report> {
const params = {
data: {
id: erpt.rp_id,
source: erpt.rp_source,
purpose: erpt.rp_purpose,
id: report.id,
source: report.source,
purpose: report.purpose,
},
};
return this.spenderPlatformV1ApiService.post('/reports', params);
Expand Down Expand Up @@ -579,12 +579,12 @@ export class ReportService {
);
}

approverUpdateReportPurpose(erpt: ExtendedReport): Observable<Report> {
approverUpdateReportPurpose(report: Report): Observable<Report> {
const params: { data: Pick<Report, 'id' | 'source' | 'purpose'> } = {
data: {
id: erpt.rp_id,
source: erpt.rp_source,
purpose: erpt.rp_purpose,
id: report.id,
source: report.source,
purpose: report.purpose,
},
};
return this.approverPlatformApiService.post('/reports', params);
Expand Down
Loading

0 comments on commit a018b3b

Please sign in to comment.