mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
add country specific labels
This commit is contained in:
parent
31fb0fafa4
commit
70e166e99b
2 changed files with 103 additions and 49 deletions
|
@ -20,28 +20,64 @@ package io.bitsquare.locale;
|
|||
public class BankUtil {
|
||||
|
||||
public static boolean requiresHolderId(String countryCode) {
|
||||
if (countryCode != null) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "BR":
|
||||
case "CL":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO set country specific labels
|
||||
public static String getBankCodeLabel(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
default:
|
||||
return "Bank nr.(BIC/SWIFT):";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO set country specific labels
|
||||
public static String getBranchCodeLabel(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "US":
|
||||
return "Routing Number:";
|
||||
case "GB":
|
||||
return "Sort Number:";
|
||||
case "CA":
|
||||
return "Transit Number:";
|
||||
default:
|
||||
return "Branch nr. (optional):";
|
||||
}
|
||||
}
|
||||
|
||||
//TODO set country specific labels
|
||||
public static String getAccountNrLabel(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
default:
|
||||
return "Account nr.(IBAN):";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getHolderIdLabel(String countryCode) {
|
||||
if (countryCode != null) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "BR":
|
||||
return "CPF Number:";
|
||||
case "CL":
|
||||
return "RUT Number:";
|
||||
default:
|
||||
return "Holder ID:";
|
||||
}
|
||||
} else {
|
||||
return "Holder ID:";
|
||||
return "Personal ID:";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.components.paymentmethods;
|
||||
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.common.util.Tuple3;
|
||||
import io.bitsquare.common.util.Tuple4;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
|
@ -46,6 +47,9 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
private TextField currencyTextField;
|
||||
private Label holderIdLabel;
|
||||
private InputTextField holderNameInputTextField;
|
||||
private Label bankIdLabel;
|
||||
private Label branchIdLabel;
|
||||
private Label accountNrLabel;
|
||||
|
||||
static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
|
||||
BankAccountContractData bankAccountContractData = (BankAccountContractData) paymentAccountContractData;
|
||||
|
@ -106,12 +110,17 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
});
|
||||
countryComboBox.setOnAction(e -> {
|
||||
Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null) {
|
||||
paymentAccount.setCountry(selectedItem);
|
||||
String countryCode = selectedItem.code;
|
||||
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
|
||||
paymentAccount.setSingleTradeCurrency(currency);
|
||||
currencyTextField.setText(currency.getNameAndCode());
|
||||
|
||||
bankIdLabel.setText(BankUtil.getBankCodeLabel(bankAccountContractData.getCountryCode()));
|
||||
branchIdLabel.setText(BankUtil.getBranchCodeLabel(bankAccountContractData.getCountryCode()));
|
||||
accountNrLabel.setText(BankUtil.getAccountNrLabel(bankAccountContractData.getCountryCode()));
|
||||
|
||||
if (holderIdInputTextField != null) {
|
||||
boolean requiresHolderId = BankUtil.requiresHolderId(countryCode);
|
||||
if (requiresHolderId) {
|
||||
|
@ -133,12 +142,15 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
updateFromInputs();
|
||||
|
||||
onCountryChanged();
|
||||
}
|
||||
});
|
||||
|
||||
regionComboBox.setOnAction(e -> {
|
||||
Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null) {
|
||||
countryComboBox.setDisable(false);
|
||||
countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem)));
|
||||
}
|
||||
});
|
||||
|
||||
addAcceptedBanksForAddAccount();
|
||||
|
@ -153,7 +165,9 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
|
||||
});
|
||||
|
||||
bankIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Bank number:").second;
|
||||
Tuple2<Label, InputTextField> tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBankCodeLabel(""));
|
||||
bankIdLabel = tuple2.first;
|
||||
bankIdInputTextField = tuple2.second;
|
||||
bankIdInputTextField.setValidator(inputValidator);
|
||||
bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
bankAccountContractData.setBankId(newValue);
|
||||
|
@ -161,15 +175,20 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
|
||||
});
|
||||
|
||||
branchIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Branch number:").second;
|
||||
branchIdInputTextField.setValidator(inputValidator);
|
||||
tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchCodeLabel(""));
|
||||
branchIdLabel = tuple2.first;
|
||||
|
||||
branchIdInputTextField = tuple2.second;
|
||||
branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
bankAccountContractData.setBranchId(newValue);
|
||||
updateFromInputs();
|
||||
|
||||
});
|
||||
|
||||
accountNrInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Account number:").second;
|
||||
tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(""));
|
||||
accountNrLabel = tuple2.first;
|
||||
|
||||
accountNrInputTextField = tuple2.second;
|
||||
accountNrInputTextField.setValidator(inputValidator);
|
||||
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
bankAccountContractData.setAccountNr(newValue);
|
||||
|
@ -242,7 +261,6 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
&& inputValidator.validate(bankAccountContractData.getHolderName()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBankName()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBankId()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBranchId()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getAccountNr()).isValid
|
||||
&& holderIdValid
|
||||
&& paymentAccount.getSingleTradeCurrency() != null
|
||||
|
|
Loading…
Add table
Reference in a new issue