Skip to content

Commit

Permalink
Add buyers payment account name to trade screen
Browse files Browse the repository at this point in the history
In case the buyer has setup multiple accounts for a payment method
we show the used payment account for that offer in the trade screen.

See: #1733
  • Loading branch information
ManfredKarrer committed Sep 28, 2018
1 parent bd44aea commit 2b5731c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ portfolio.pending.step2_buyer.f2f=Please contact the BTC seller by the provided
portfolio.pending.step2_buyer.startPaymentUsing=Start payment using {0}
portfolio.pending.step2_buyer.amountToTransfer=Amount to transfer:
portfolio.pending.step2_buyer.sellersAddress=Seller''s {0} address:
portfolio.pending.step2_buyer.buyerAccount=Your payment account to be used
portfolio.pending.step2_buyer.paymentStarted=Payment started
portfolio.pending.step2_buyer.warn=You still have not done your {0} payment!\nPlease note that the trade has to be completed by {1} otherwise the trade will be investigated by the arbitrator.
portfolio.pending.step2_buyer.openForDispute=You have not completed your payment!\nThe max. period for the trade has elapsed.\n\nPlease contact the arbitrator for opening a dispute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ public PaymentAccountPayload getSellersPaymentAccountPayload() {
return null;
}

@Nullable
public PaymentAccountPayload getBuyersPaymentAccountPayload() {
if (getTrade() != null && getTrade().getContract() != null)
return getTrade().getContract().getBuyerPaymentAccountPayload();
else
return null;
}

public String getReference() {
return getOffer() != null ? getOffer().getShortId() : "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
TableView<PendingTradesListItem> tableView;
@FXML
TableColumn<PendingTradesListItem, PendingTradesListItem> priceColumn, volumeColumn, amountColumn, avatarColumn, marketColumn, roleColumn, paymentMethodColumn, tradeIdColumn, dateColumn;
@FXML

private SortedList<PendingTradesListItem> sortedList;
private TradeSubView selectedSubView;
Expand Down Expand Up @@ -215,7 +214,7 @@ protected void activate() {
selectedSubView = model.dataModel.tradeManager.isBuyer(model.dataModel.getOffer()) ?
new BuyerSubView(model) : new SellerSubView(model);

selectedSubView.setMinHeight(430);
selectedSubView.setMinHeight(440);
VBox.setVgrow(selectedSubView, Priority.ALWAYS);
if (root.getChildren().size() == 1)
root.getChildren().add(selectedSubView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import bisq.core.trade.Contract;
import bisq.core.trade.Trade;
import bisq.core.trade.closed.ClosedTradableManager;
import bisq.core.user.User;
import bisq.core.util.BSFormatter;
import bisq.core.util.BsqFormatter;
import bisq.core.util.validation.BtcAddressValidator;
Expand Down Expand Up @@ -91,6 +92,8 @@ enum SellerState implements State {
public final P2PService p2PService;
private final ClosedTradableManager closedTradableManager;
public final Clock clock;
@Getter
private final User user;

private final ObjectProperty<BuyerState> buyerState = new SimpleObjectProperty<>();
private final ObjectProperty<SellerState> sellerState = new SimpleObjectProperty<>();
Expand All @@ -112,7 +115,8 @@ public PendingTradesViewModel(PendingTradesDataModel dataModel,
P2PService p2PService,
ClosedTradableManager closedTradableManager,
AccountAgeWitnessService accountAgeWitnessService,
Clock clock) {
Clock clock,
User user) {
super(dataModel);

this.btcFormatter = btcFormatter;
Expand All @@ -122,6 +126,7 @@ public PendingTradesViewModel(PendingTradesDataModel dataModel,
this.closedTradableManager = closedTradableManager;
this.accountAgeWitnessService = accountAgeWitnessService;
this.clock = clock;
this.user = user;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.network.MessageState;
import bisq.core.offer.Offer;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.PaymentAccountUtil;
import bisq.core.payment.payload.CashDepositAccountPayload;
import bisq.core.payment.payload.CryptoCurrencyAccountPayload;
import bisq.core.payment.payload.F2FAccountPayload;
Expand All @@ -80,6 +83,8 @@
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;

import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;

public class BuyerStep2View extends TradeStepView {
Expand Down Expand Up @@ -285,6 +290,25 @@ protected void addContent() {
FormBuilder.addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
Res.getWithCol("shared.reasonForPayment"), model.dataModel.getReference());

Trade trade = model.getTrade();
if (trade != null && model.getUser().getPaymentAccounts() != null) {
Offer offer = trade.getOffer();
List<PaymentAccount> possiblePaymentAccounts = PaymentAccountUtil.getPossiblePaymentAccounts(offer,
model.getUser().getPaymentAccounts());
PaymentAccountPayload buyersPaymentAccountPayload = model.dataModel.getBuyersPaymentAccountPayload();
if (buyersPaymentAccountPayload != null && possiblePaymentAccounts.size() > 1) {
String id = buyersPaymentAccountPayload.getId();
possiblePaymentAccounts.stream()
.filter(paymentAccount -> paymentAccount.getId().equals(id))
.findFirst()
.ifPresent(paymentAccount -> {
String accountName = paymentAccount.getAccountName();
FormBuilder.addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
Res.getWithCol("portfolio.pending.step2_buyer.buyerAccount"), accountName);
});
}
}

GridPane.setRowSpan(accountTitledGroupBg, gridRow - 3);

Tuple3<Button, BusyAnimation, Label> tuple3 = FormBuilder.addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow,
Expand Down

0 comments on commit 2b5731c

Please sign in to comment.