diff --git a/pkg/services/invoice/process_edi997.go b/pkg/services/invoice/process_edi997.go index c67fbc1227b..27f65603b2a 100644 --- a/pkg/services/invoice/process_edi997.go +++ b/pkg/services/invoice/process_edi997.go @@ -2,6 +2,7 @@ package invoice import ( "fmt" + "time" "github.com/gofrs/uuid" "go.uber.org/zap" @@ -105,6 +106,8 @@ func (e *edi997Processor) ProcessFile(appCtx appcontext.AppContext, _ string, st } paymentRequest.Status = models.PaymentRequestStatusTppsReceived + ReceivedByGexAt := time.Now() + paymentRequest.ReceivedByGexAt = &ReceivedByGexAt err = txnAppCtx.DB().Update(&paymentRequest) if err != nil { txnAppCtx.Logger().Error("failure updating payment request", zap.Error(err)) diff --git a/pkg/services/invoice/process_edi997_test.go b/pkg/services/invoice/process_edi997_test.go index 7287b043c7f..39d4c34cba3 100644 --- a/pkg/services/invoice/process_edi997_test.go +++ b/pkg/services/invoice/process_edi997_test.go @@ -196,6 +196,7 @@ IEA*1*000000995 err = suite.DB().Where("id = ?", paymentRequest.ID).First(&updatedPR) suite.NoError(err) suite.Equal(models.PaymentRequestStatusTppsReceived, updatedPR.Status) + suite.NotNil(updatedPR.ReceivedByGexAt) }) suite.Run("can handle 997 and 858 with same ICN", func() { @@ -250,6 +251,7 @@ IEA*1*000000995 err = suite.DB().Where("id = ?", paymentRequest.ID).First(&updatedPR) suite.FatalNoError(err) suite.Equal(models.PaymentRequestStatusTppsReceived, updatedPR.Status) + suite.NotNil(updatedPR.ReceivedByGexAt) }) suite.Run("does not error out if edi with same icn is processed for the same payment request", func() { @@ -304,6 +306,7 @@ IEA*1*000000995 err = suite.DB().Where("id = ?", paymentRequest.ID).First(&updatedPR) suite.FatalNoError(err) suite.Equal(models.PaymentRequestStatusTppsReceived, updatedPR.Status) + suite.NotNil(updatedPR.ReceivedByGexAt) }) suite.Run("doesn't update a payment request status after processing an invalid EDI997", func() { @@ -345,6 +348,7 @@ IEA*1*000000022 err = suite.DB().Where("id = ?", paymentRequest.ID).First(&updatedPR) suite.NoError(err) suite.Equal(models.PaymentRequestStatusSentToGex, updatedPR.Status) + suite.Nil(updatedPR.ReceivedByGexAt) }) suite.Run("throw an error when edi997 is missing a transaction set", func() { diff --git a/src/components/Office/PaymentRequestCard/PaymentRequestCard.jsx b/src/components/Office/PaymentRequestCard/PaymentRequestCard.jsx index 8e1ed250eec..88ab4ab916d 100644 --- a/src/components/Office/PaymentRequestCard/PaymentRequestCard.jsx +++ b/src/components/Office/PaymentRequestCard/PaymentRequestCard.jsx @@ -265,12 +265,8 @@ const PaymentRequestCard = ({ ); }; - const renderPaymentRequestDetailsForStatus = (paymentRequestStatus) => { - if ( - (paymentRequestStatus === PAYMENT_REQUEST_STATUS.PAID || - paymentRequestStatus === PAYMENT_REQUEST_STATUS.EDI_ERROR) && - tppsInvoiceSellerPaidDate - ) { + const renderApprovedRejectedPaymentRequestDetails = () => { + if (approvedAmount > 0 || rejectedAmount > 0) { return (
{approvedAmount > 0 && ( @@ -293,6 +289,20 @@ const PaymentRequestCard = ({
)} + + ); + } + return null; + }; + + const renderPaymentRequestDetailsForStatus = (paymentRequestStatus) => { + if ( + (paymentRequestStatus === PAYMENT_REQUEST_STATUS.PAID || + paymentRequestStatus === PAYMENT_REQUEST_STATUS.EDI_ERROR) && + tppsInvoiceSellerPaidDate + ) { + return ( +
{tppsInvoiceAmountPaidTotalMillicents > 0 && (
@@ -313,22 +323,12 @@ const PaymentRequestCard = ({ ) { return (
- {approvedAmount > 0 && ( + {paymentRequest.receivedByGexAt && (
-
+

{toDollarString(formatCents(approvedAmount))}

- Received - on {formatDateFromIso(paymentRequest.receivedByGexAt, 'DD MMM YYYY')} -
-
- )} - {rejectedAmount > 0 && ( -
- -
-

{toDollarString(formatCents(rejectedAmount))}

- Rejected + TPPS Received on {formatDateFromIso(paymentRequest.receivedByGexAt, 'DD MMM YYYY')}
@@ -336,36 +336,7 @@ const PaymentRequestCard = ({
); } - if ( - paymentRequestStatus === PAYMENT_REQUEST_STATUS.REVIEWED || - paymentRequestStatus === PAYMENT_REQUEST_STATUS.REVIEWED_AND_ALL_SERVICE_ITEMS_REJECTED || - paymentRequestStatus === PAYMENT_REQUEST_STATUS.EDI_ERROR - ) { - return ( -
- {approvedAmount > 0 && ( -
- -
-

{toDollarString(formatCents(approvedAmount))}

- Accepted - on {formatDateFromIso(paymentRequest.reviewedAt, 'DD MMM YYYY')} -
-
- )} - {rejectedAmount > 0 && ( -
- -
-

{toDollarString(formatCents(rejectedAmount))}

- Rejected - on {formatDateFromIso(paymentRequest.reviewedAt, 'DD MMM YYYY')} -
-
- )} -
- ); - } + if ( paymentRequestStatus === PAYMENT_REQUEST_STATUS.SENT_TO_GEX || (paymentRequestStatus === PAYMENT_REQUEST_STATUS.EDI_ERROR && approvedAmount > 0) @@ -373,7 +344,7 @@ const PaymentRequestCard = ({ return (
-
+

{toDollarString(formatCents(approvedAmount))}

Sent to GEX @@ -395,7 +366,7 @@ const PaymentRequestCard = ({
); } - return
; + return null; }; return ( @@ -420,7 +391,10 @@ const PaymentRequestCard = ({
-
{paymentRequest.status && renderPaymentRequestDetailsForStatus(paymentRequest.status)}
+
+ {paymentRequest.status && renderApprovedRejectedPaymentRequestDetails(paymentRequest)} + {paymentRequest.status && renderPaymentRequestDetailsForStatus(paymentRequest.status)} +
{paymentRequest.status === PAYMENT_REQUEST_STATUS.PENDING && renderReviewServiceItemsBtnForTIOandTOO()}
{ediErrorsExistForPaymentRequest && renderEDIErrorDetails()} diff --git a/src/components/Office/PaymentRequestCard/PaymentRequestCard.test.jsx b/src/components/Office/PaymentRequestCard/PaymentRequestCard.test.jsx index 04486d323c7..1443e72d928 100644 --- a/src/components/Office/PaymentRequestCard/PaymentRequestCard.test.jsx +++ b/src/components/Office/PaymentRequestCard/PaymentRequestCard.test.jsx @@ -601,7 +601,7 @@ describe('PaymentRequestCard', () => { createdAt: '2020-12-01T00:00:00.000Z', mtoServiceItemID: 'f8c2f97f-99e7-4fb1-9cc4-473debd24dbc', priceCents: 2000001, - status: 'DENIED', + status: 'APPROVED', }, { id: '39474c6a-69b6-4501-8e08-670a12512a5f', @@ -626,6 +626,14 @@ describe('PaymentRequestCard', () => { ); expect(sentToGex.find({ 'data-testid': 'tag' }).contains('Sent to GEX')).toBe(true); expect(sentToGex.find({ 'data-testid': 'sentToGexDetails' }).exists()).toBe(true); + // displays the sent to gex sum, milmove accepted amount, and milmove rejected amount + expect(sentToGex.find({ 'data-testid': 'sentToGexDetailsDollarAmountTotal' }).contains('$20,000.01')).toBe(true); + expect(sentToGex.find({ 'data-testid': 'milMoveAcceptedDetailsDollarAmountTotal' }).contains('$20,000.01')).toBe( + true, + ); + expect(sentToGex.find({ 'data-testid': 'milMoveRejectedDetailsDollarAmountTotal' }).contains('$40,000.01')).toBe( + true, + ); }); it('renders - for the date it was sent to gex if sentToGexAt is null', () => { @@ -653,13 +661,14 @@ describe('PaymentRequestCard', () => { paymentRequestNumber: '1843-9061-2', status: 'TPPS_RECEIVED', moveTaskOrder: move, + receivedByGexAt: '2020-12-01T00:00:00.000Z', serviceItems: [ { id: '09474c6a-69b6-4501-8e08-670a12512a5f', createdAt: '2020-12-01T00:00:00.000Z', mtoServiceItemID: 'f8c2f97f-99e7-4fb1-9cc4-473debd24dbc', priceCents: 2000001, - status: 'DENIED', + status: 'APPROVED', }, { id: '39474c6a-69b6-4501-8e08-670a12512a5f', @@ -681,6 +690,16 @@ describe('PaymentRequestCard', () => { , ); expect(receivedByGex.find({ 'data-testid': 'tag' }).contains('TPPS Received')).toBe(true); + // displays the tpps received sum, milmove accepted amount, and milmove rejected amount + expect(receivedByGex.find({ 'data-testid': 'tppsReceivedDetailsDollarAmountTotal' }).contains('$20,000.01')).toBe( + true, + ); + expect( + receivedByGex.find({ 'data-testid': 'milMoveAcceptedDetailsDollarAmountTotal' }).contains('$20,000.01'), + ).toBe(true); + expect( + receivedByGex.find({ 'data-testid': 'milMoveRejectedDetailsDollarAmountTotal' }).contains('$40,000.01'), + ).toBe(true); }); it('renders the paid status tag for paid request', () => {