Skip to content

Commit d5d2f28

Browse files
PP-13622 Fix incorrect negation for won disputes in CSV files
With this change, we are fixing a bug for which disputed amounts are shown as negative numbers in the CSV files. The logic will now consider also the state of the dispute and present the value as positive when the dispute has been won by the service. Further information in Jira. https://payments-platform.atlassian.net/browse/PP-13622
1 parent 556bcd7 commit d5d2f28

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/main/java/uk/gov/pay/ledger/transaction/model/CsvTransactionFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import static org.apache.commons.text.WordUtils.capitalizeFully;
3232
import static uk.gov.pay.ledger.transaction.model.TransactionType.DISPUTE;
3333
import static uk.gov.pay.ledger.transaction.model.TransactionType.REFUND;
34+
import static uk.gov.pay.ledger.transaction.state.TransactionState.WON;
3435
import static uk.gov.pay.ledger.util.JsonParser.safeGetAsBoolean;
3536
import static uk.gov.pay.ledger.util.JsonParser.safeGetAsLong;
3637
import static uk.gov.pay.ledger.util.JsonParser.safeGetAsString;
@@ -154,7 +155,10 @@ public Map<String, Object> toMap(TransactionEntity transactionEntity) {
154155
getPaymentTransactionAttributes(transactionEntity, transactionDetails.get("payment_details"))
155156
);
156157
result.put(FIELD_GOVUK_PAYMENT_ID, transactionEntity.getParentExternalId());
157-
result.put(FIELD_AMOUNT, penceToCurrency(transactionEntity.getAmount() * -1));
158+
boolean isRefundOrNotWonDispute= transactionEntity.getState() != WON;
159+
if (isRefundOrNotWonDispute) {
160+
result.put(FIELD_AMOUNT, penceToCurrency(transactionEntity.getAmount() * -1));
161+
}
158162
}
159163

160164
result.put(FIELD_PROVIDER_ID, sanitiseAgainstSpreadsheetFormulaInjection(transactionEntity.getGatewayTransactionId()));

0 commit comments

Comments
 (0)