Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B-22368-INT add closeout counselor label to move history #14750

Merged
merged 11 commits into from
Feb 11, 2025
Merged
2 changes: 2 additions & 0 deletions src/constants/MoveHistory/Database/FieldMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ export default {
approved_at: 'Approved at',
counseling_office_name: 'Counseling office',
assigned_sc: 'Counselor assigned',
assigned_sc_ppm: 'Closeout counselor assigned',
assigned_too: 'Task ordering officer assigned',
assigned_tio: 'Task invoicing officer assigned',
re_assigned_sc: 'Counselor reassigned',
re_assigned_sc_ppm: 'Closeout counselor reassigned',
re_assigned_too: 'Task ordering officer reassigned',
re_assigned_tio: 'Task invoicing officer reassigned',
available_to_prime_at: 'Available to Prime at',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import React from 'react';
import o from 'constants/MoveHistory/UIDisplay/Operations';
import a from 'constants/MoveHistory/Database/Actions';
import t from 'constants/MoveHistory/Database/Tables';
import { MOVE_STATUSES } from 'shared/constants';

export default {
action: a.UPDATE,
eventName: o.deleteAssignedOfficeUser,
tableName: t.moves,
getEventNameDisplay: () => 'Updated move',
getDetails: ({ changedValues }) => {
if (changedValues.sc_assigned_id === null) return <>Counselor unassigned</>;
getDetails: ({ changedValues, oldValues }) => {
if (changedValues.sc_assigned_id === null && oldValues?.status === MOVE_STATUSES.NEEDS_SERVICE_COUNSELING)
return <>Counselor unassigned</>;
if (changedValues.sc_assigned_id === null && oldValues?.status !== MOVE_STATUSES.NEEDS_SERVICE_COUNSELING)
return <>Closeout counselor unassigned</>;
if (changedValues.too_assigned_id === null) return <>Task ordering officer unassigned</>;
if (changedValues.tio_assigned_id === null) return <>Task invoicing officer unassigned</>;
return <>Unassigned</>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { screen, render } from '@testing-library/react';

import e from 'constants/MoveHistory/EventTemplates/UpdateAssignedOfficeUser/DeleteAssignedOfficeUser';
import getTemplate from 'constants/MoveHistory/TemplateManager';
import { MOVE_STATUSES } from 'shared/constants';

describe('When given a move that has been unassigned', () => {
const historyRecord = {
Expand All @@ -26,8 +27,15 @@ describe('When given a move that has been unassigned', () => {
});

describe('displays the proper details for', () => {
it('closeout counselor', () => {
const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Closeout counselor unassigned')).toBeInTheDocument();
});
it('services counselor', () => {
const template = getTemplate(historyRecord);
historyRecord.oldValues = { status: MOVE_STATUSES.NEEDS_SERVICE_COUNSELING };

render(template.getDetails(historyRecord));
expect(screen.getByText('Counselor unassigned')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { screen, render } from '@testing-library/react';

import e from 'constants/MoveHistory/EventTemplates/UpdateAssignedOfficeUser/UpdateAssignedOfficeUser';
import getTemplate from 'constants/MoveHistory/TemplateManager';
import { MOVE_STATUSES } from 'shared/constants';

describe('When given a move that has been assigned', () => {
const historyRecord = {
Expand All @@ -13,6 +14,7 @@ describe('When given a move that has been assigned', () => {
},
oldValues: {
sc_assigned_id: null,
status: MOVE_STATUSES.NEEDS_SERVICE_COUNSELING,
},
context: [{ assigned_office_user_last_name: 'Daniels', assigned_office_user_first_name: 'Jayden' }],
};
Expand All @@ -30,14 +32,47 @@ describe('When given a move that has been assigned', () => {
});

describe('displays the proper details for', () => {
it('services counselor', () => {
it('assignment of a services counselor', () => {
const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Counselor assigned')).toBeInTheDocument();
expect(screen.getByText(': Daniels, Jayden')).toBeInTheDocument();
});
it('task ordering officer', () => {
it('reassignment of a services counselor', () => {
const template = getTemplate(historyRecord);
historyRecord.oldValues = {
sc_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64',
status: MOVE_STATUSES.NEEDS_SERVICE_COUNSELING,
};

render(template.getDetails(historyRecord));
expect(screen.getByText('Counselor reassigned')).toBeInTheDocument();
expect(screen.getByText(': Daniels, Jayden')).toBeInTheDocument();
});
it('assignment of a closeout counselor', () => {
const template = getTemplate(historyRecord);
historyRecord.oldValues = {
sc_assigned_id: null,
status: MOVE_STATUSES.SERVICE_COUNSELING_COMPLETED,
};

render(template.getDetails(historyRecord));
expect(screen.getByText('Closeout counselor assigned')).toBeInTheDocument();
expect(screen.getByText(': Daniels, Jayden')).toBeInTheDocument();
});
it('reassignment of a closeout counselor', () => {
const template = getTemplate(historyRecord);
historyRecord.oldValues = {
sc_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64',
status: MOVE_STATUSES.SERVICE_COUNSELING_COMPLETED,
};

render(template.getDetails(historyRecord));
expect(screen.getByText('Closeout counselor reassigned')).toBeInTheDocument();
expect(screen.getByText(': Daniels, Jayden')).toBeInTheDocument();
});
it('assignment of a task ordering officer', () => {
historyRecord.changedValues = { too_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137' };
historyRecord.oldValues = { too_assigned_id: null };
historyRecord.context = [
Expand All @@ -50,7 +85,20 @@ describe('When given a move that has been assigned', () => {
expect(screen.getByText('Task ordering officer assigned')).toBeInTheDocument();
expect(screen.getByText(': Robinson, Brian')).toBeInTheDocument();
});
it('task invoicing officer', () => {
it('reassignment of a task ordering officer', () => {
historyRecord.changedValues = { too_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137' };
historyRecord.oldValues = { too_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64' };
historyRecord.context = [
{ assigned_office_user_last_name: 'Robinson', assigned_office_user_first_name: 'Brian' },
];

const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Task ordering officer reassigned')).toBeInTheDocument();
expect(screen.getByText(': Robinson, Brian')).toBeInTheDocument();
});
it('assignment of a task invoicing officer', () => {
historyRecord.changedValues = { tio_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137' };
historyRecord.oldValues = { tio_assigned_id: null };
historyRecord.context = [{ assigned_office_user_last_name: 'Luvu', assigned_office_user_first_name: 'Frankie' }];
Expand All @@ -61,5 +109,16 @@ describe('When given a move that has been assigned', () => {
expect(screen.getByText('Task invoicing officer assigned')).toBeInTheDocument();
expect(screen.getByText(': Luvu, Frankie')).toBeInTheDocument();
});
it('reassignment of a task invoicing officer', () => {
historyRecord.changedValues = { tio_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137' };
historyRecord.oldValues = { tio_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64' };
historyRecord.context = [{ assigned_office_user_last_name: 'Luvu', assigned_office_user_first_name: 'Frankie' }];

const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Task invoicing officer reassigned')).toBeInTheDocument();
expect(screen.getByText(': Luvu, Frankie')).toBeInTheDocument();
});
});
});
11 changes: 8 additions & 3 deletions src/utils/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DEPARTMENT_INDICATOR_OPTIONS } from 'constants/departmentIndicators';
import { SERVICE_MEMBER_AGENCY_LABELS } from 'content/serviceMemberAgencies';
import { ORDERS_TYPE_OPTIONS, ORDERS_TYPE_DETAILS_OPTIONS } from 'constants/orders';
import { PAYMENT_REQUEST_STATUS_LABELS } from 'constants/paymentRequestStatus';
import { DEFAULT_EMPTY_VALUE } from 'shared/constants';
import { DEFAULT_EMPTY_VALUE, MOVE_STATUSES } from 'shared/constants';

/**
* Formats number into a dollar string. Eg. $1,234.12
Expand Down Expand Up @@ -609,8 +609,13 @@ export const formatAssignedOfficeUserFromContext = (historyRecord) => {
const name = `${context[0].assigned_office_user_last_name}, ${context[0].assigned_office_user_first_name}`;

if (changedValues?.sc_assigned_id) {
if (oldValues.sc_assigned_id === null) newValues.assigned_sc = name;
if (oldValues.sc_assigned_id !== null) newValues.re_assigned_sc = name;
if (oldValues.status === MOVE_STATUSES.NEEDS_SERVICE_COUNSELING) {
if (oldValues.sc_assigned_id === null) newValues.assigned_sc = name;
if (oldValues.sc_assigned_id !== null) newValues.re_assigned_sc = name;
} else {
if (oldValues.sc_assigned_id === null) newValues.assigned_sc_ppm = name;
if (oldValues.sc_assigned_id !== null) newValues.re_assigned_sc_ppm = name;
}
}
if (changedValues?.too_assigned_id) {
if (oldValues.too_assigned_id === null) newValues.assigned_too = name;
Expand Down
94 changes: 91 additions & 3 deletions src/utils/formatters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as formatters from './formatters';
import { formatQAReportID } from './formatters';

import PAYMENT_REQUEST_STATUS from 'constants/paymentRequestStatus';
import { MOVE_STATUSES } from 'shared/constants';

describe('formatters', () => {
describe('format date for customer app', () => {
Expand Down Expand Up @@ -350,13 +351,14 @@ describe('formatters', () => {
});

describe('formatAssignedOfficeUserFromContext', () => {
it('properly formats an SCs name', () => {
it(`properly formats a Services Counselor's name for assignment`, () => {
const values = {
changedValues: {
sc_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
sc_assigned_id: null,
status: MOVE_STATUSES.NEEDS_SERVICE_COUNSELING,
},
context: [{ assigned_office_user_last_name: 'Daniels', assigned_office_user_first_name: 'Jayden' }],
};
Expand All @@ -367,8 +369,61 @@ describe('formatAssignedOfficeUserFromContext', () => {
assigned_sc: 'Daniels, Jayden',
});
});
it(`properly formats a Services Counselor's name for reassignment`, () => {
const values = {
changedValues: {
sc_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
sc_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64',
status: MOVE_STATUSES.NEEDS_SERVICE_COUNSELING,
},
context: [{ assigned_office_user_last_name: 'Daniels', assigned_office_user_first_name: 'Jayden' }],
};

const result = formatters.formatAssignedOfficeUserFromContext(values);

it('properly formats a TOOs name', () => {
expect(result).toEqual({
re_assigned_sc: 'Daniels, Jayden',
});
});
it(`properly formats a Closeout Counselor's name for assignment`, () => {
const values = {
changedValues: {
sc_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
sc_assigned_id: null,
status: MOVE_STATUSES.SERVICE_COUNSELING_COMPLETED,
},
context: [{ assigned_office_user_last_name: 'Daniels', assigned_office_user_first_name: 'Jayden' }],
};

const result = formatters.formatAssignedOfficeUserFromContext(values);

expect(result).toEqual({
assigned_sc_ppm: 'Daniels, Jayden',
});
});
it(`properly formats a Closeout Counselor's name for reassignment`, () => {
const values = {
changedValues: {
sc_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
sc_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64',
status: MOVE_STATUSES.SERVICE_COUNSELING_COMPLETED,
},
context: [{ assigned_office_user_last_name: 'Daniels', assigned_office_user_first_name: 'Jayden' }],
};

const result = formatters.formatAssignedOfficeUserFromContext(values);

expect(result).toEqual({
re_assigned_sc_ppm: 'Daniels, Jayden',
});
});
it('properly formats a TOOs name for assignment', () => {
const values = {
changedValues: {
too_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
Expand All @@ -385,8 +440,24 @@ describe('formatAssignedOfficeUserFromContext', () => {
assigned_too: 'McLaurin, Terry',
});
});
it('properly formats a TOOs name for reassignment', () => {
const values = {
changedValues: {
too_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
too_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64',
},
context: [{ assigned_office_user_last_name: 'McLaurin', assigned_office_user_first_name: 'Terry' }],
};

const result = formatters.formatAssignedOfficeUserFromContext(values);

it('properly formats a TIOs name', () => {
expect(result).toEqual({
re_assigned_too: 'McLaurin, Terry',
});
});
it('properly formats a TIOs name for assignment', () => {
const values = {
changedValues: {
tio_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
Expand All @@ -403,6 +474,23 @@ describe('formatAssignedOfficeUserFromContext', () => {
assigned_tio: 'Robinson, Brian',
});
});
it('properly formats a TIOs name for reassignment', () => {
const values = {
changedValues: {
tio_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
tio_assigned_id: '759a87ad-dc75-4b34-b551-d31309a79f64',
},
context: [{ assigned_office_user_last_name: 'Robinson', assigned_office_user_first_name: 'Brian' }],
};

const result = formatters.formatAssignedOfficeUserFromContext(values);

expect(result).toEqual({
re_assigned_tio: 'Robinson, Brian',
});
});
});

describe('constructSCOrderOconusFields', () => {
Expand Down