Skip to content

Commit

Permalink
Merge pull request #12025 from transcom/B-18645-Move-grade-to-Orders-…
Browse files Browse the repository at this point in the history
…From-Allowances-MAIN

B-18645 main
  • Loading branch information
deandreJones authored Feb 27, 2024
2 parents b1c0dcc + 66861ee commit 58cc95e
Show file tree
Hide file tree
Showing 29 changed files with 230 additions and 67 deletions.
12 changes: 12 additions & 0 deletions pkg/gen/ghcapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions pkg/gen/ghcmessages/counseling_update_order_payload.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions pkg/gen/ghcmessages/update_order_payload.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions pkg/services/order/order_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ func orderFromTOOPayload(_ appcontext.AppContext, existingOrder models.Order, pa
order.AmendedOrdersAcknowledgedAt = &acknowledgedAt
}

if payload.Grade != nil {
order.Grade = (*internalmessages.OrderPayGrade)(payload.Grade)
// Calculate new DBWeightAuthorized based on the new grade
weightAllotment := models.GetWeightAllotment(*order.Grade)
weight := weightAllotment.TotalWeightSelf
// Payload does not have this information, retrieve dependents from the existing order
if existingOrder.HasDependents && *order.Entitlement.DependentsAuthorized {
// Only utilize dependent weight authorized if dependents are both present and authorized
weight = weightAllotment.TotalWeightSelfPlusDependents
}
order.Entitlement.DBAuthorizedWeight = &weight
}

return order
}

Expand Down Expand Up @@ -348,6 +361,19 @@ func orderFromCounselingPayload(existingOrder models.Order, payload ghcmessages.
order.OrdersType = internalmessages.OrdersType(*payload.OrdersType)
}

if payload.Grade != nil {
order.Grade = (*internalmessages.OrderPayGrade)(payload.Grade)
// Calculate new DBWeightAuthorized based on the new grade
weightAllotment := models.GetWeightAllotment(*order.Grade)
weight := weightAllotment.TotalWeightSelf
// Payload does not have this information, retrieve dependents from the existing order
if existingOrder.HasDependents && *order.Entitlement.DependentsAuthorized {
// Only utilize dependent weight authorized if dependents are both present and authorized
weight = weightAllotment.TotalWeightSelfPlusDependents
}
order.Entitlement.DBAuthorizedWeight = &weight
}

return order
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/services/order/order_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() {
reportByDate := strfmt.Date(time.Now().Add(72 * time.Hour))
deptIndicator := ghcmessages.DeptIndicatorCOASTGUARD
ordersTypeDetail := ghcmessages.OrdersTypeDetail("INSTRUCTION_20_WEEKS")
grade := ghcmessages.GradeO5

body := ghcmessages.CounselingUpdateOrderPayload{
IssueDate: &dateIssued,
Expand All @@ -449,6 +450,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() {
OrdersTypeDetail: &ordersTypeDetail,
Tac: handlers.FmtString("E19A"),
Sac: nullable.NewString("987654321"),
Grade: &grade,
}

eTag := etag.GenerateEtag(order.UpdatedAt)
Expand All @@ -471,6 +473,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() {
suite.EqualValues(body.DepartmentIndicator, updatedOrder.DepartmentIndicator)
suite.EqualValues(body.Tac, updatedOrder.TAC)
suite.EqualValues(body.Sac.Value, updatedOrder.SAC)
suite.Equal(*updatedOrder.Entitlement.DBAuthorizedWeight, 16000)
})

suite.Run("Rolls back transaction if Order is invalid", func() {
Expand Down
5 changes: 2 additions & 3 deletions playwright/tests/office/qaecsr/csrFlows.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ test.describe('Customer Support User Flows', () => {
await expect(page.locator('select[name="ordersTypeDetail"]')).toBeDisabled();
await expect(page.locator('input[name="tac"]')).toBeDisabled();
await expect(page.locator('input[name="sac"]')).toBeDisabled();
await expect(page.locator('select[name="payGrade"]')).toBeDisabled();
// no save button should exist
await expect(page.getByRole('button', { name: 'Save' })).toHaveCount(0);
});
Expand All @@ -157,11 +158,9 @@ test.describe('Customer Support User Flows', () => {
await expect(page.locator('input[name="storageInTransit"]')).toBeDisabled();
await expect(page.locator('input[name="organizationalClothingAndIndividualEquipment"]')).toBeDisabled();

// read only grade and authorized weight
// read only authorized weight
await expect(page.locator('select[name=agency]')).toBeDisabled();
await expect(page.locator('select[name=agency]')).toBeDisabled();
await expect(page.locator('select[name="grade"]')).toBeDisabled();
await expect(page.locator('select[name="grade"]')).toBeDisabled();
await expect(page.locator('input[name="dependentsAuthorized"]')).toBeDisabled();

// no save button should exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EntitlementShape } from 'types/order';
import { formatWeight } from 'utils/formatters';
import Hint from 'components/Hint';

const AllowancesDetailForm = ({ header, entitlements, payGradeOptions, branchOptions, formIsDisabled }) => {
const AllowancesDetailForm = ({ header, entitlements, branchOptions, formIsDisabled }) => {
return (
<div className={styles.AllowancesDetailForm}>
{header && <h3 data-testid="header">{header}</h3>}
Expand Down Expand Up @@ -71,15 +71,6 @@ const AllowancesDetailForm = ({ header, entitlements, payGradeOptions, branchOpt
showDropdownPlaceholderText={false}
isDisabled={formIsDisabled}
/>
<DropdownInput
data-testid="payGradeInput"
name="grade"
label="Pay grade"
id="payGradeInput"
options={payGradeOptions}
showDropdownPlaceholderText={false}
isDisabled={formIsDisabled}
/>
<MaskedTextField
data-testid="sitInput"
defaultValue="0"
Expand Down Expand Up @@ -121,7 +112,6 @@ const AllowancesDetailForm = ({ header, entitlements, payGradeOptions, branchOpt

AllowancesDetailForm.propTypes = {
entitlements: EntitlementShape.isRequired,
payGradeOptions: DropdownArrayOf.isRequired,
branchOptions: DropdownArrayOf.isRequired,
header: PropTypes.string,
formIsDisabled: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ jest.mock('formik', () => ({

const { Formik } = jest.requireActual('formik');

const payGradeOptions = [
{ key: 'E_1', value: 'E-1' },
{ key: 'E_2', value: 'E-2' },
{ key: 'E_3', value: 'E-3' },
{ key: 'E_4', value: 'E-4' },
{ key: 'E_5', value: 'E-5' },
{ key: 'E_6', value: 'E-6' },
{ key: 'E_7', value: 'E-7' },
{ key: 'E_8', value: 'E-8' },
{ key: 'E_9', value: 'E-9' },
];

const branchOptions = [
{ key: 'Army', value: 'Army' },
{ key: 'Navy', value: 'Navy' },
Expand All @@ -83,11 +71,7 @@ describe('AllowancesDetailForm', () => {
it('renders the form', async () => {
render(
<Formik initialValues={initialValues}>
<AllowancesDetailForm
entitlements={entitlements}
payGradeOptions={payGradeOptions}
branchOptions={branchOptions}
/>
<AllowancesDetailForm entitlements={entitlements} branchOptions={branchOptions} />
</Formik>,
);

Expand All @@ -99,11 +83,7 @@ describe('AllowancesDetailForm', () => {
it('renders the pro-gear hints', async () => {
render(
<Formik initialValues={initialValues}>
<AllowancesDetailForm
entitlements={entitlements}
payGradeOptions={payGradeOptions}
branchOptions={branchOptions}
/>
<AllowancesDetailForm entitlements={entitlements} branchOptions={branchOptions} />
</Formik>,
);

Expand All @@ -114,12 +94,7 @@ describe('AllowancesDetailForm', () => {
it('renders the title header', async () => {
render(
<Formik initialValues={initialValues}>
<AllowancesDetailForm
entitlements={entitlements}
payGradeOptions={payGradeOptions}
branchOptions={branchOptions}
header="Test Header"
/>
<AllowancesDetailForm entitlements={entitlements} branchOptions={branchOptions} header="Test Header" />
</Formik>,
);

Expand Down
Loading

0 comments on commit 58cc95e

Please sign in to comment.