From e51b3e213b9eb9d07d823d571ac867bfcf34f778 Mon Sep 17 00:00:00 2001 From: Brian Manley Date: Tue, 21 Jan 2025 21:54:00 +0000 Subject: [PATCH 1/2] B-22239 show previous info for deleted agent in move history --- .../UpdateMTOShipmentAgent.module.scss | 7 +++ .../updateMTOShipmentAgent.jsx | 29 ++++++++- .../updateMTOShipmentAgent.test.jsx | 60 ++++++++++++++++++- 3 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/UpdateMTOShipmentAgent.module.scss diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/UpdateMTOShipmentAgent.module.scss b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/UpdateMTOShipmentAgent.module.scss new file mode 100644 index 00000000000..f1d4df13283 --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/UpdateMTOShipmentAgent.module.scss @@ -0,0 +1,7 @@ +@import 'shared/styles/colors'; + +.shipmentType { + display: block; + color: $base; + margin-bottom: 8px 0; +} diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx index 72a1f7974a1..3789096e2db 100644 --- a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx +++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx @@ -1,6 +1,9 @@ import React from 'react'; +import styles from './UpdateMTOShipmentAgent.module.scss'; + import { formatMoveHistoryAgent } from 'utils/formatters'; +import fieldMappings from 'constants/MoveHistory/Database/FieldMappings'; import o from 'constants/MoveHistory/UIDisplay/Operations'; import a from 'constants/MoveHistory/Database/Actions'; import t from 'constants/MoveHistory/Database/Tables'; @@ -26,10 +29,34 @@ const formatChangedValues = (historyRecord) => { return { ...historyRecord, changedValues: newChangedValues }; }; +const formatDeletedAgentRecord = (historyRecord) => { + const mtoShipmentLabel = getMtoShipmentLabel(historyRecord); + const historyLabel = `${mtoShipmentLabel.shipment_type} shipment #${mtoShipmentLabel.shipment_locator}`; + const agentTypeFieldName = historyRecord.oldValues.agent_type.toLowerCase(); + const agentType = fieldMappings[agentTypeFieldName]; + const agent = formatMoveHistoryAgent(historyRecord.oldValues)[agentTypeFieldName]; + + return ( + <> + + Deleted {agentType} on {historyLabel} + +
+ {agentType}: {agent} +
+ + ); +}; + export default { action: a.UPDATE, eventName: o.updateMTOShipment, tableName: t.mto_agents, getEventNameDisplay: () => 'Updated shipment', - getDetails: (historyRecord) => , + getDetails: (historyRecord) => { + if (historyRecord.changedValues.deleted_at) { + return formatDeletedAgentRecord(historyRecord); + } + return ; + }, }; diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx index bc2681fd996..c293dcc3c5d 100644 --- a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx +++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx @@ -41,6 +41,46 @@ describe('when given an mto shipment agents update with mto agents table history }, context: [{ shipment_type: 'HHG', shipment_locator: 'RQ38D4-01', shipment_id_abbr: 'a1b2c' }], }, + DELETED_RECEIVING_AGENT: { + action: 'UPDATE', + eventName: 'updateMTOShipment', + tableName: 'mto_agents', + changedValues: { + deleted_at: '2025-01-21T15:39:24.890356+00:00', + email: null, + first_name: null, + last_name: null, + phone: null, + }, + oldValues: { + agent_type: 'RECEIVING_AGENT', + email: 'john.smith@email.com', + first_name: 'John', + last_name: 'Smith', + phone: '555-765-4321', + }, + context: [{ shipment_type: 'HHG', shipment_locator: 'RQ38D4-01', shipment_id_abbr: 'a1b2c' }], + }, + DELETED_RELEASING_AGENT: { + action: 'UPDATE', + eventName: 'updateMTOShipment', + tableName: 'mto_agents', + changedValues: { + deleted_at: '2025-01-21T16:39:24.890356+00:00', + email: null, + first_name: null, + last_name: null, + phone: null, + }, + oldValues: { + agent_type: 'RELEASING_AGENT', + email: 'jane.smith@email.com', + first_name: 'Jane', + last_name: 'Smith', + phone: '555-123-4567', + }, + context: [{ shipment_type: 'NTS', shipment_locator: 'RQ38D4-01', shipment_id_abbr: 'a1b2c' }], + }, }; describe('when agent type is Releasing', () => { @@ -75,7 +115,7 @@ describe('when given an mto shipment agents update with mto agents table history expect(screen.getAllByText('HHG shipment #RQ38D4-01')); }); - it('it displays the proper labeled details for the given releasing agent', () => { + it('it displays the proper labeled details for the given receiving agent', () => { const template = getTemplate(historyRecord.RECEIVE); render(template.getDetails(historyRecord.RECEIVE)); @@ -83,4 +123,22 @@ describe('when given an mto shipment agents update with mto agents table history expect(screen.getByText(': Nancy Drew, 555-555-5555, nancy@email.com')).toBeInTheDocument(); }); }); + + describe('when agent is deleted', () => { + it('displays deleted receiving agent', () => { + const template = getTemplate(historyRecord.DELETED_RECEIVING_AGENT); + render(template.getDetails(historyRecord.DELETED_RECEIVING_AGENT)); + expect(screen.getByText('Deleted Receiving agent on HHG shipment #RQ38D4-01')).toBeInTheDocument(); + expect(screen.getByText('Receiving agent')).toBeInTheDocument(); + expect(screen.getByText(': John Smith, 555-765-4321, john.smith@email.com')).toBeInTheDocument(); + }); + + it('displays deleted releasing agent', () => { + const template = getTemplate(historyRecord.DELETED_RELEASING_AGENT); + render(template.getDetails(historyRecord.DELETED_RELEASING_AGENT)); + expect(screen.getByText('Deleted Releasing agent on NTS shipment #RQ38D4-01')).toBeInTheDocument(); + expect(screen.getByText('Releasing agent')).toBeInTheDocument(); + expect(screen.getByText(': Jane Smith, 555-123-4567, jane.smith@email.com')).toBeInTheDocument(); + }); + }); }); From c20bc41e0fdc547acda1974c3600888c9b35534f Mon Sep 17 00:00:00 2001 From: Daniel Jordan Date: Wed, 22 Jan 2025 21:01:58 +0000 Subject: [PATCH 2/2] a merge conflict I'll never recover from --- pkg/services/ghcrateengine/intl_shipping_and_linehaul_pricer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/ghcrateengine/intl_shipping_and_linehaul_pricer.go b/pkg/services/ghcrateengine/intl_shipping_and_linehaul_pricer.go index d912b5f5fd6..9c0b5a913f4 100644 --- a/pkg/services/ghcrateengine/intl_shipping_and_linehaul_pricer.go +++ b/pkg/services/ghcrateengine/intl_shipping_and_linehaul_pricer.go @@ -49,7 +49,7 @@ func (p intlShippingAndLinehaulPricer) Price(appCtx appcontext.AppContext, contr return 0, nil, fmt.Errorf("could not find contract year with contract ID: %s and date: %s: %w", contract.ID, referenceDate, err) } - basePrice := float64(perUnitCents) + basePrice := float64(perUnitCents) / 100 escalatedPrice := basePrice * contractYear.EscalationCompounded escalatedPrice = math.Round(escalatedPrice*100) / 100 totalEscalatedPrice := escalatedPrice * weight.ToCWTFloat64()