mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +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 class BankUtil {
|
||||||
|
|
||||||
public static boolean requiresHolderId(String countryCode) {
|
public static boolean requiresHolderId(String countryCode) {
|
||||||
if (countryCode != null) {
|
if (countryCode == null)
|
||||||
|
countryCode = "";
|
||||||
switch (countryCode) {
|
switch (countryCode) {
|
||||||
case "BR":
|
case "BR":
|
||||||
|
case "CL":
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
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) {
|
public static String getHolderIdLabel(String countryCode) {
|
||||||
if (countryCode != null) {
|
if (countryCode == null)
|
||||||
|
countryCode = "";
|
||||||
switch (countryCode) {
|
switch (countryCode) {
|
||||||
case "BR":
|
case "BR":
|
||||||
return "CPF Number:";
|
return "CPF Number:";
|
||||||
|
case "CL":
|
||||||
|
return "RUT Number:";
|
||||||
default:
|
default:
|
||||||
return "Holder ID:";
|
return "Personal ID:";
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return "Holder ID:";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package io.bitsquare.gui.components.paymentmethods;
|
package io.bitsquare.gui.components.paymentmethods;
|
||||||
|
|
||||||
|
import io.bitsquare.common.util.Tuple2;
|
||||||
import io.bitsquare.common.util.Tuple3;
|
import io.bitsquare.common.util.Tuple3;
|
||||||
import io.bitsquare.common.util.Tuple4;
|
import io.bitsquare.common.util.Tuple4;
|
||||||
import io.bitsquare.gui.components.InputTextField;
|
import io.bitsquare.gui.components.InputTextField;
|
||||||
|
@ -46,6 +47,9 @@ abstract class BankForm extends PaymentMethodForm {
|
||||||
private TextField currencyTextField;
|
private TextField currencyTextField;
|
||||||
private Label holderIdLabel;
|
private Label holderIdLabel;
|
||||||
private InputTextField holderNameInputTextField;
|
private InputTextField holderNameInputTextField;
|
||||||
|
private Label bankIdLabel;
|
||||||
|
private Label branchIdLabel;
|
||||||
|
private Label accountNrLabel;
|
||||||
|
|
||||||
static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
|
static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
|
||||||
BankAccountContractData bankAccountContractData = (BankAccountContractData) paymentAccountContractData;
|
BankAccountContractData bankAccountContractData = (BankAccountContractData) paymentAccountContractData;
|
||||||
|
@ -106,12 +110,17 @@ abstract class BankForm extends PaymentMethodForm {
|
||||||
});
|
});
|
||||||
countryComboBox.setOnAction(e -> {
|
countryComboBox.setOnAction(e -> {
|
||||||
Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem();
|
Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem != null) {
|
||||||
paymentAccount.setCountry(selectedItem);
|
paymentAccount.setCountry(selectedItem);
|
||||||
String countryCode = selectedItem.code;
|
String countryCode = selectedItem.code;
|
||||||
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
|
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
|
||||||
paymentAccount.setSingleTradeCurrency(currency);
|
paymentAccount.setSingleTradeCurrency(currency);
|
||||||
currencyTextField.setText(currency.getNameAndCode());
|
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) {
|
if (holderIdInputTextField != null) {
|
||||||
boolean requiresHolderId = BankUtil.requiresHolderId(countryCode);
|
boolean requiresHolderId = BankUtil.requiresHolderId(countryCode);
|
||||||
if (requiresHolderId) {
|
if (requiresHolderId) {
|
||||||
|
@ -133,12 +142,15 @@ abstract class BankForm extends PaymentMethodForm {
|
||||||
updateFromInputs();
|
updateFromInputs();
|
||||||
|
|
||||||
onCountryChanged();
|
onCountryChanged();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
regionComboBox.setOnAction(e -> {
|
regionComboBox.setOnAction(e -> {
|
||||||
Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem();
|
Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem != null) {
|
||||||
countryComboBox.setDisable(false);
|
countryComboBox.setDisable(false);
|
||||||
countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem)));
|
countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem)));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addAcceptedBanksForAddAccount();
|
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.setValidator(inputValidator);
|
||||||
bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
bankAccountContractData.setBankId(newValue);
|
bankAccountContractData.setBankId(newValue);
|
||||||
|
@ -161,15 +175,20 @@ abstract class BankForm extends PaymentMethodForm {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
branchIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Branch number:").second;
|
tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchCodeLabel(""));
|
||||||
branchIdInputTextField.setValidator(inputValidator);
|
branchIdLabel = tuple2.first;
|
||||||
|
|
||||||
|
branchIdInputTextField = tuple2.second;
|
||||||
branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
bankAccountContractData.setBranchId(newValue);
|
bankAccountContractData.setBranchId(newValue);
|
||||||
updateFromInputs();
|
updateFromInputs();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
accountNrInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Account number:").second;
|
tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(""));
|
||||||
|
accountNrLabel = tuple2.first;
|
||||||
|
|
||||||
|
accountNrInputTextField = tuple2.second;
|
||||||
accountNrInputTextField.setValidator(inputValidator);
|
accountNrInputTextField.setValidator(inputValidator);
|
||||||
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
bankAccountContractData.setAccountNr(newValue);
|
bankAccountContractData.setAccountNr(newValue);
|
||||||
|
@ -242,7 +261,6 @@ abstract class BankForm extends PaymentMethodForm {
|
||||||
&& inputValidator.validate(bankAccountContractData.getHolderName()).isValid
|
&& inputValidator.validate(bankAccountContractData.getHolderName()).isValid
|
||||||
&& inputValidator.validate(bankAccountContractData.getBankName()).isValid
|
&& inputValidator.validate(bankAccountContractData.getBankName()).isValid
|
||||||
&& inputValidator.validate(bankAccountContractData.getBankId()).isValid
|
&& inputValidator.validate(bankAccountContractData.getBankId()).isValid
|
||||||
&& inputValidator.validate(bankAccountContractData.getBranchId()).isValid
|
|
||||||
&& inputValidator.validate(bankAccountContractData.getAccountNr()).isValid
|
&& inputValidator.validate(bankAccountContractData.getAccountNr()).isValid
|
||||||
&& holderIdValid
|
&& holderIdValid
|
||||||
&& paymentAccount.getSingleTradeCurrency() != null
|
&& paymentAccount.getSingleTradeCurrency() != null
|
||||||
|
|
Loading…
Add table
Reference in a new issue