Skip to content

Commit

Permalink
Merge pull request #12976 from transcom/B-19889-UI-estimatedprice-MAIN
Browse files Browse the repository at this point in the history
B 19889 UI estimatedprice main
  • Loading branch information
cameroncaci authored Jun 10, 2024
2 parents ae9395b + 44e0faf commit 5d36987
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 3 deletions.
10 changes: 10 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.

3 changes: 3 additions & 0 deletions pkg/gen/ghcmessages/m_t_o_service_item.go

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

1 change: 1 addition & 0 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,7 @@ func MTOServiceItemModel(s *models.MTOServiceItem, storer storage.FileStorer) *g
ConvertToCustomerExpense: *handlers.FmtBool(s.CustomerExpense),
CustomerExpenseReason: handlers.FmtStringPtr(s.CustomerExpenseReason),
SitDeliveryMiles: handlers.FmtIntPtrToInt64(s.SITDeliveryMiles),
EstimatedPrice: handlers.FmtCost(s.PricingEstimate),
StandaloneCrate: s.StandaloneCrate,
}
}
Expand Down
20 changes: 19 additions & 1 deletion src/components/Office/ServiceItemDetails/ServiceItemDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ShipmentShape } from 'types/shipment';
import { SitStatusShape } from 'types/sitStatusShape';
import { formatDateWithUTC } from 'shared/dates';
import { formatCityStateAndPostalCode } from 'utils/shipmentDisplay';
import { formatWeight, convertFromThousandthInchToInch } from 'utils/formatters';
import { formatWeight, convertFromThousandthInchToInch, formatCents, toDollarString } from 'utils/formatters';

function generateDetailText(details, id, className) {
const detailList = Object.keys(details).map((detail) => (
Expand Down Expand Up @@ -453,6 +453,24 @@ const ServiceItemDetails = ({ id, code, details, serviceRequestDocs, shipment, s
);
break;
}
case 'DLH':
case 'DSH':
case 'FSC':
case 'DOP':
case 'DDP':
case 'DPK':
case 'DUPK': {
detailSection = (
<div>
<dl>
{generateDetailText({
'Estimated Price': details.estimatedPrice ? toDollarString(formatCents(details.estimatedPrice)) : '-',
})}
</dl>
</div>
);
break;
}
default:
detailSection = (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const details = {
state: 'FL',
streetAddress1: 'MacDill',
},
estimatedPrice: 2800,
};

const submittedServiceItemDetails = {
Expand Down Expand Up @@ -405,3 +406,43 @@ describe('ServiceItemDetails Crating Rejected', () => {
expect(downloadLink).toBeInstanceOf(HTMLAnchorElement);
});
});

describe('ServiceItemDetails Estimated Price for DLH, DSH, FSC, DOP, DDP, DPK, DUPK', () => {
it.each([['DLH'], ['DSH'], ['FSC'], ['DOP'], ['DDP'], ['DPK'], ['DUPK']])(
'renders the formatted estimated price field for the service items',
(code) => {
render(
<ServiceItemDetails
id="1"
code={code}
details={details}
shipment={shipment}
serviceRequestDocs={serviceRequestDocs}
/>,
);

expect(screen.getByText('Estimated Price:')).toBeInTheDocument();
expect(screen.getByText('$28.00')).toBeInTheDocument();
},
);

const noEstimatePriceDetails = {};

it.each([['DLH'], ['DSH'], ['FSC'], ['DOP'], ['DDP'], ['DPK'], ['DUPK']])(
'renders - for estimated price when price is not in details',
(code) => {
render(
<ServiceItemDetails
id="1"
code={code}
details={noEstimatePriceDetails}
shipment={shipment}
serviceRequestDocs={serviceRequestDocs}
/>,
);

expect(screen.getByText('Estimated Price:')).toBeInTheDocument();
expect(screen.getByText('-')).toBeInTheDocument();
},
);
});
28 changes: 26 additions & 2 deletions src/components/Office/ServiceItemsTable/ServiceItemsTable.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('ServiceItemsTable', () => {
},
};

it('renders with no details', () => {
it('renders with no estimated price when no estimated price exists', () => {
const serviceItems = [
{
id: 'abc123',
Expand All @@ -41,7 +41,31 @@ describe('ServiceItemsTable', () => {
/>
</MockProviders>,
);
expect(wrapper.find('td').at(1).text()).toBe('—');
expect(wrapper.find('td').at(1).text()).toBe('Estimated Price: -');
});

it('renders with estimated price shown when estimated price', () => {
const serviceItems = [
{
id: 'abc123',
submittedAt: '2020-11-20',
serviceItem: 'Fuel Surcharge',
code: 'FSC',
details: {
estimatedPrice: 2314,
},
},
];
const wrapper = mount(
<MockProviders>
<ServiceItemsTable
{...defaultProps}
statusForTableType={SERVICE_ITEM_STATUS.SUBMITTED}
serviceItems={serviceItems}
/>
</MockProviders>,
);
expect(wrapper.find('td').at(1).text()).toBe('Estimated Price: $23.14');
});

it('renders a thumbnail image with dimensions for item and crating', () => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/Office/MoveTaskOrder/MoveTaskOrder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const MoveTaskOrder = (props) => {
sitRequestedDelivery: item.sitRequestedDelivery,
sitDeliveryMiles: item.sitDeliveryMiles,
status: item.status,
estimatedPrice: item.estimatedPrice,
standaloneCrate: item.standaloneCrate,
};

Expand Down
1 change: 1 addition & 0 deletions src/types/serviceItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const ServiceItemDetailsShape = PropTypes.shape({
customerContacts: PropTypes.arrayOf(MTOServiceItemCustomerContactShape),
estimatedWeight: PropTypes.number,
status: PropTypes.string,
estimatedPrice: PropTypes.number,
}),
sitAddressUpdates: PropTypes.arrayOf(SitAddressUpdatesShape),
});
Expand Down
4 changes: 4 additions & 0 deletions swagger-def/definitions/MTOServiceItem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ properties:
x-nullable: true
serviceRequestDocuments:
$ref: 'ServiceRequestDocuments.yaml'
estimatedPrice:
type: integer
format: cents
x-nullable: true
4 changes: 4 additions & 0 deletions swagger/ghc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7100,6 +7100,10 @@ definitions:
x-nullable: true
serviceRequestDocuments:
$ref: '#/definitions/ServiceRequestDocuments'
estimatedPrice:
type: integer
format: cents
x-nullable: true
MTOServiceItems:
description: A list of service items connected to this shipment.
type: array
Expand Down

0 comments on commit 5d36987

Please sign in to comment.