fix custom amounts for dispute result

This commit is contained in:
woodser 2025-05-29 17:07:20 -04:00 committed by woodser
parent 85ee6787cd
commit dd65cdca13

View file

@ -25,6 +25,7 @@ import haveno.common.handlers.ResultHandler;
import haveno.common.util.Tuple2;
import haveno.common.util.Tuple3;
import haveno.core.api.CoreDisputesService;
import haveno.core.api.CoreDisputesService.PayoutSuggestion;
import haveno.core.locale.Res;
import haveno.core.support.SupportType;
import haveno.core.support.dispute.Dispute;
@ -138,6 +139,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
public void show(Dispute dispute) {
this.dispute = dispute;
this.trade = tradeManager.getTrade(dispute.getTradeId());
this.payoutSuggestion = null;
rowIndex = -1;
width = 1150;
@ -243,7 +245,6 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
reasonWasPeerWasLateRadioButton.setDisable(true);
reasonWasTradeAlreadySettledRadioButton.setDisable(true);
applyPayoutAmounts(tradeAmountToggleGroup.selectedToggleProperty().get());
applyTradeAmountRadioButtonStates();
}
@ -724,6 +725,10 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
private void applyTradeAmountRadioButtonStates() {
if (payoutSuggestion == null) {
payoutSuggestion = getPayoutSuggestionFromDisputeResult();
}
BigInteger buyerPayoutAmount = disputeResult.getBuyerPayoutAmountBeforeCost();
BigInteger sellerPayoutAmount = disputeResult.getSellerPayoutAmountBeforeCost();
@ -748,4 +753,20 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
break;
}
}
// TODO: Persist the payout suggestion to DisputeResult like Bisq upstream?
// That would be a better design, but it's not currently needed.
private PayoutSuggestion getPayoutSuggestionFromDisputeResult() {
if (disputeResult.getBuyerPayoutAmountBeforeCost().equals(BigInteger.ZERO)) {
return PayoutSuggestion.SELLER_GETS_ALL;
} else if (disputeResult.getSellerPayoutAmountBeforeCost().equals(BigInteger.ZERO)) {
return PayoutSuggestion.BUYER_GETS_ALL;
} else if (disputeResult.getBuyerPayoutAmountBeforeCost().equals(trade.getAmount().add(trade.getBuyer().getSecurityDeposit()))) {
return PayoutSuggestion.BUYER_GETS_TRADE_AMOUNT;
} else if (disputeResult.getSellerPayoutAmountBeforeCost().equals(trade.getAmount().add(trade.getSeller().getSecurityDeposit()))) {
return PayoutSuggestion.SELLER_GETS_TRADE_AMOUNT;
} else {
return PayoutSuggestion.CUSTOM;
}
}
}