Skip to content

Commit

Permalink
Merge pull request #13726 from transcom/B-21016-tpps-received-totals-…
Browse files Browse the repository at this point in the history
…MAIN

B-21016 tpps received totals main
  • Loading branch information
cameroncaci authored Sep 20, 2024
2 parents 9899047 + 0f801a6 commit a4faf0c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 54 deletions.
3 changes: 3 additions & 0 deletions pkg/services/invoice/process_edi997.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package invoice

import (
"fmt"
"time"

"github.com/gofrs/uuid"
"go.uber.org/zap"
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions pkg/services/invoice/process_edi997_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
78 changes: 26 additions & 52 deletions src/components/Office/PaymentRequestCard/PaymentRequestCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div data-testid="tppsPaidDetails">
{approvedAmount > 0 && (
Expand All @@ -293,6 +289,20 @@ const PaymentRequestCard = ({
</div>
</div>
)}
</div>
);
}
return null;
};

const renderPaymentRequestDetailsForStatus = (paymentRequestStatus) => {
if (
(paymentRequestStatus === PAYMENT_REQUEST_STATUS.PAID ||
paymentRequestStatus === PAYMENT_REQUEST_STATUS.EDI_ERROR) &&
tppsInvoiceSellerPaidDate
) {
return (
<div data-testid="tppsPaidDetails">
{tppsInvoiceAmountPaidTotalMillicents > 0 && (
<div className={styles.amountAccepted}>
<FontAwesomeIcon icon="check" />
Expand All @@ -313,67 +323,28 @@ const PaymentRequestCard = ({
) {
return (
<div>
{approvedAmount > 0 && (
{paymentRequest.receivedByGexAt && (
<div className={styles.amountAccepted}>
<FontAwesomeIcon icon="check" />
<div>
<div data-testid="tppsReceivedDetailsDollarAmountTotal">
<h2>{toDollarString(formatCents(approvedAmount))}</h2>
<span>Received</span>
<span> on {formatDateFromIso(paymentRequest.receivedByGexAt, 'DD MMM YYYY')}</span>
</div>
</div>
)}
{rejectedAmount > 0 && (
<div className={styles.amountRejected}>
<FontAwesomeIcon icon="times" />
<div>
<h2>{toDollarString(formatCents(rejectedAmount))}</h2>
<span>Rejected</span>
<span>TPPS Received</span>
<span> on {formatDateFromIso(paymentRequest.receivedByGexAt, 'DD MMM YYYY')}</span>
</div>
</div>
)}
</div>
);
}
if (
paymentRequestStatus === PAYMENT_REQUEST_STATUS.REVIEWED ||
paymentRequestStatus === PAYMENT_REQUEST_STATUS.REVIEWED_AND_ALL_SERVICE_ITEMS_REJECTED ||
paymentRequestStatus === PAYMENT_REQUEST_STATUS.EDI_ERROR
) {
return (
<div>
{approvedAmount > 0 && (
<div className={styles.amountAccepted}>
<FontAwesomeIcon icon="check" />
<div>
<h2>{toDollarString(formatCents(approvedAmount))}</h2>
<span>Accepted</span>
<span> on {formatDateFromIso(paymentRequest.reviewedAt, 'DD MMM YYYY')}</span>
</div>
</div>
)}
{rejectedAmount > 0 && (
<div className={styles.amountRejected}>
<FontAwesomeIcon icon="times" />
<div>
<h2>{toDollarString(formatCents(rejectedAmount))}</h2>
<span>Rejected</span>
<span> on {formatDateFromIso(paymentRequest.reviewedAt, 'DD MMM YYYY')}</span>
</div>
</div>
)}
</div>
);
}

if (
paymentRequestStatus === PAYMENT_REQUEST_STATUS.SENT_TO_GEX ||
(paymentRequestStatus === PAYMENT_REQUEST_STATUS.EDI_ERROR && approvedAmount > 0)
) {
return (
<div className={styles.amountAccepted} data-testid="sentToGexDetails">
<FontAwesomeIcon icon="check" />
<div>
<div data-testid="sentToGexDetailsDollarAmountTotal">
<h2>{toDollarString(formatCents(approvedAmount))}</h2>
<span>Sent to GEX </span>
<span data-testid="sentToGexDate">
Expand All @@ -395,7 +366,7 @@ const PaymentRequestCard = ({
</div>
);
}
return <div />;
return null;
};

return (
Expand All @@ -420,7 +391,10 @@ const PaymentRequestCard = ({
</span>
</div>
<div className={styles.totalReviewed}>
<div>{paymentRequest.status && renderPaymentRequestDetailsForStatus(paymentRequest.status)}</div>
<div>
{paymentRequest.status && renderApprovedRejectedPaymentRequestDetails(paymentRequest)}
{paymentRequest.status && renderPaymentRequestDetailsForStatus(paymentRequest.status)}
</div>
{paymentRequest.status === PAYMENT_REQUEST_STATUS.PENDING && renderReviewServiceItemsBtnForTIOandTOO()}
</div>
{ediErrorsExistForPaymentRequest && renderEDIErrorDetails()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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',
Expand All @@ -681,6 +690,16 @@ describe('PaymentRequestCard', () => {
</MockProviders>,
);
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', () => {
Expand Down

0 comments on commit a4faf0c

Please sign in to comment.