Skip to content

Commit

Permalink
Merge branch 'B-21423-Prime-Int-SIT-Service-Item' into INT-B-21423-Pr…
Browse files Browse the repository at this point in the history
…ime-Int-SIT-Service-Item
  • Loading branch information
MInthavongsay committed Jan 31, 2025
2 parents 33fb49c + fd6e178 commit 31578b9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pkg/handlers/primeapiv3/payloads/payload_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ func validateReasonDestSIT(m primev3messages.MTOServiceItemDestSIT) *validate.Er
return verrs
}

// validateReasonDestSIT validates that International Destination SIT service items have required Reason field
// validateReasonInternationalDestSIT validates that International Destination SIT service items have required Reason field
func validateReasonInternationalDestSIT(m primev3messages.MTOServiceItemInternationalDestSIT) *validate.Errors {
verrs := validate.NewErrors()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,23 +296,23 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() {
// Test successful check for SIT departure service item - IDDSIT
suite.Run("checkSITDeparture w/ IDDSIT - success", func() {
// Under test: checkSITDeparture checks that the service item is a
// DDDSIT or DOPSIT if the user is trying to update the
// IDDSIT or IOPSIT if the user is trying to update the
// SITDepartureDate
// Set up: Create an old and new DDDSIT, with a new date and try to update.
// Expected outcome: Success if both are DDDSIT
oldDDDSIT := factory.BuildMTOServiceItem(nil, []factory.Customization{
// Set up: Create an old and new IDDSIT, with a new date and try to update.
// Expected outcome: Success if both are IDDSIT
oldIDDSIT := factory.BuildMTOServiceItem(nil, []factory.Customization{
{
Model: models.ReService{
Code: models.ReServiceCodeIDDSIT,
},
},
}, nil)
newDDDSIT := oldDDDSIT
newDDDSIT.SITDepartureDate = &now
newIDDSIT := oldIDDSIT
newIDDSIT.SITDepartureDate = &now

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newDDDSIT,
oldServiceItem: oldDDDSIT,
updatedServiceItem: newIDDSIT,
oldServiceItem: oldIDDSIT,
verrs: validate.NewErrors(),
}
err := serviceItemData.checkSITDeparture(suite.AppContextForTest())
Expand All @@ -321,7 +321,7 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() {
suite.NoVerrs(serviceItemData.verrs)
})

// Test successful check for SIT departure service item - DDDSIT
// Test successful check for SIT departure service item - IDDSIT
suite.Run("checkSITDeparture w/ IDDSIT - success", func() {
// Under test: checkSITDeparture checks that the service item is a
// IDDSIT or IOPSIT if the user is trying to update the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ func (suite *UpdateSitEntryDateServiceSuite) TestUpdateSitEntryDate() {
})

suite.Run("Not Found Error - international", func() {
ddfServiceItem, _ := setupInternationalModels()
idfServiceItem, _ := setupInternationalModels()
notFoundServiceItem := models.SITEntryDateUpdate{
ID: ddfServiceItem.ID,
SITEntryDate: ddfServiceItem.SITEntryDate,
ID: idfServiceItem.ID,
SITEntryDate: idfServiceItem.SITEntryDate,
}
notFoundUUID, err := uuid.NewV4()
suite.NoError(err)
Expand Down Expand Up @@ -144,24 +144,24 @@ func (suite *UpdateSitEntryDateServiceSuite) TestUpdateSitEntryDate() {
})

suite.Run("Successful update of service items - international", func() {
ddfServiceItem, ddaServiceItem := setupInternationalModels()
idfServiceItem, idaServiceItem := setupInternationalModels()
updatedServiceItem := models.SITEntryDateUpdate{
ID: ddfServiceItem.ID,
SITEntryDate: ddfServiceItem.SITEntryDate,
ID: idfServiceItem.ID,
SITEntryDate: idfServiceItem.SITEntryDate,
}
newSitEntryDate := time.Date(2020, time.December, 02, 0, 0, 0, 0, time.UTC)
newSitEntryDateNextDay := newSitEntryDate.Add(24 * time.Hour)

updatedServiceItem.SITEntryDate = &newSitEntryDate
ddaServiceItem.SITEntryDate = &newSitEntryDateNextDay
idaServiceItem.SITEntryDate = &newSitEntryDateNextDay

changedServiceItem, err := updater.UpdateSitEntryDate(suite.AppContextForTest(), &updatedServiceItem)

suite.NoError(err)
suite.NotNil(updatedServiceItem)
suite.Equal(ddfServiceItem.ID, updatedServiceItem.ID)
suite.Equal(idfServiceItem.ID, updatedServiceItem.ID)
suite.Equal(updatedServiceItem.SITEntryDate.Local(), changedServiceItem.SITEntryDate.Local())
suite.Equal(ddaServiceItem.SITEntryDate.Local(), newSitEntryDateNextDay.Local())
suite.Equal(idaServiceItem.SITEntryDate.Local(), newSitEntryDateNextDay.Local())
})

}
38 changes: 32 additions & 6 deletions src/components/Office/ServiceItemsTable/ServiceItemsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ServiceItemDetailsShape } from '../../../types/serviceItems';
import styles from './ServiceItemsTable.module.scss';

import { SERVICE_ITEM_STATUS } from 'shared/constants';
import { SERVICE_ITEM_CODES } from 'constants/serviceItems';
import { ALLOWED_RESUBMISSION_SI_CODES, ALLOWED_SIT_UPDATE_SI_CODES } from 'constants/sitUpdates';
import { formatDateFromIso } from 'utils/formatters';
import ServiceItemDetails from 'components/Office/ServiceItemDetails/ServiceItemDetails';
Expand All @@ -30,19 +31,37 @@ import { nullSafeStringCompare } from 'utils/string';
// destination SIT
function sortServiceItems(items) {
// Prioritize service items with codes 'DSH' (shorthaul) and 'DLH' (linehaul) to be at the top of the list
const haulTypeServiceItemCodes = ['DSH', 'DLH'];
const haulTypeServiceItemCodes = [SERVICE_ITEM_CODES.DSH, SERVICE_ITEM_CODES.DLH];
const haulTypeServiceItems = items.filter((item) => haulTypeServiceItemCodes.includes(item.code));
const sortedHaulTypeServiceItems = haulTypeServiceItems.sort(
(a, b) => haulTypeServiceItemCodes.indexOf(a.code) - haulTypeServiceItemCodes.indexOf(b.code),
);
// Filter and sort destination SIT. Code index is also the sort order
const destinationServiceItemCodes = ['DDFSIT', 'DDASIT', 'DDDSIT', 'DDSFSC', 'IDFSIT', 'IDASIT', 'IDDSIT', 'IDSFSC'];
const destinationServiceItemCodes = [
SERVICE_ITEM_CODES.DDFSIT,
SERVICE_ITEM_CODES.DDASIT,
SERVICE_ITEM_CODES.DDDSIT,
SERVICE_ITEM_CODES.DDSFSC,
SERVICE_ITEM_CODES.IDFSIT,
SERVICE_ITEM_CODES.IDASIT,
SERVICE_ITEM_CODES.IDDSIT,
SERVICE_ITEM_CODES.IDSFSC,
];
const destinationServiceItems = items.filter((item) => destinationServiceItemCodes.includes(item.code));
const sortedDestinationServiceItems = destinationServiceItems.sort(
(a, b) => destinationServiceItemCodes.indexOf(a.code) - destinationServiceItemCodes.indexOf(b.code),
);
// Filter origin SIT. Code index is also the sort order
const originServiceItemCodes = ['DOFSIT', 'DOASIT', 'DOPSIT', 'DOSFSC', 'IOFSIT', 'IOASIT', 'IOPSIT', 'IOSFSC'];
const originServiceItemCodes = [
SERVICE_ITEM_CODES.DOFSIT,
SERVICE_ITEM_CODES.DOASIT,
SERVICE_ITEM_CODES.DOPSIT,
SERVICE_ITEM_CODES.DOSFSC,
SERVICE_ITEM_CODES.IOFSIT,
SERVICE_ITEM_CODES.IOASIT,
SERVICE_ITEM_CODES.IOPSIT,
SERVICE_ITEM_CODES.IOSFSC,
];
const originServiceItems = items.filter((item) => originServiceItemCodes.includes(item.code));
const sortedOriginServiceItems = originServiceItems.sort(
(a, b) => originServiceItemCodes.indexOf(a.code) - originServiceItemCodes.indexOf(b.code),
Expand Down Expand Up @@ -202,7 +221,7 @@ const ServiceItemsTable = ({
// we don't want to display the "Accept" button for a DLH or DSH service item that was rejected by a shorthaul to linehaul change or vice versa
let rejectedDSHorDLHServiceItem = false;
if (
(serviceItem.code === 'DLH' || serviceItem.code === 'DSH') &&
(serviceItem.code === SERVICE_ITEM_CODES.DLH || serviceItem.code === SERVICE_ITEM_CODES.DSH) &&
serviceItem.details.rejectionReason ===
'Automatically rejected due to change in delivery address affecting the ZIP code qualification for short haul / line haul.'
) {
Expand All @@ -215,7 +234,9 @@ const ServiceItemsTable = ({
<td className={styles.nameAndDate}>
<div className={styles.codeName}>
<span className={styles.serviceItemName}>{serviceItem.serviceItem}</span>
{(code === 'DCRT' || code === 'ICRT') && serviceItem.details.standaloneCrate && ' - Standalone'}
{(code === SERVICE_ITEM_CODES.DCRT || code === SERVICE_ITEM_CODES.ICRT) &&
serviceItem.details.standaloneCrate &&
' - Standalone'}
{ALLOWED_RESUBMISSION_SI_CODES.includes(code) && resubmittedToolTip.isResubmitted ? (
<ToolTip
data-testid="toolTipResubmission"
Expand Down Expand Up @@ -308,7 +329,12 @@ const ServiceItemsTable = ({
className="text-blue usa-button--unstyled margin-left-1"
disabled={hasPaymentRequestBeenMade || isMoveLocked}
onClick={() => {
if (code === 'DDFSIT' || code === 'DOFSIT' || code === 'IDFSIT' || code === 'IOFSIT') {
if (
code === SERVICE_ITEM_CODES.DDFSIT ||
code === SERVICE_ITEM_CODES.DOFSIT ||
code === SERVICE_ITEM_CODES.IDFSIT ||
code === SERVICE_ITEM_CODES.IOFSIT
) {
handleShowEditSitEntryDateModal(id, mtoShipmentID);
} else {
handleShowEditSitAddressModal(id, mtoShipmentID);
Expand Down

0 comments on commit 31578b9

Please sign in to comment.