mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Customize bank form for brasil
This commit is contained in:
parent
399b90f5cd
commit
bb3c950833
6 changed files with 52 additions and 13 deletions
|
@ -44,6 +44,7 @@ public class BankUtil {
|
|||
switch (countryCode) {
|
||||
case "GB":
|
||||
case "US":
|
||||
case "BR":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
@ -54,6 +55,7 @@ public class BankUtil {
|
|||
switch (countryCode) {
|
||||
case "GB":
|
||||
case "US":
|
||||
case "BR":
|
||||
log.warn("BankId must not be used for country " + countryCode);
|
||||
default:
|
||||
return "Bank nr. or BIC/SWIFT:";
|
||||
|
@ -66,6 +68,7 @@ public class BankUtil {
|
|||
switch (countryCode) {
|
||||
case "GB":
|
||||
case "US":
|
||||
case "BR":
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
|
@ -78,6 +81,8 @@ public class BankUtil {
|
|||
return "UK Sort code:";
|
||||
case "US":
|
||||
return "Routing Number:";
|
||||
case "BR":
|
||||
return "Branch code:";
|
||||
case "CA":
|
||||
return "Transit Number:";
|
||||
default:
|
||||
|
@ -98,6 +103,7 @@ public class BankUtil {
|
|||
switch (countryCode) {
|
||||
case "GB":
|
||||
case "US":
|
||||
case "BR":
|
||||
return "Account number:";
|
||||
default:
|
||||
return "Account nr. or IBAN:";
|
||||
|
@ -108,6 +114,7 @@ public class BankUtil {
|
|||
public static boolean isAccountTypeRequired(String countryCode) {
|
||||
switch (countryCode) {
|
||||
case "US":
|
||||
case "BR":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -117,6 +124,7 @@ public class BankUtil {
|
|||
public static String getAccountTypeLabel(String countryCode) {
|
||||
switch (countryCode) {
|
||||
case "US":
|
||||
case "BR":
|
||||
return "Account type:";
|
||||
default:
|
||||
return "";
|
||||
|
@ -126,6 +134,7 @@ public class BankUtil {
|
|||
public static List<String> getAccountTypeValues(String countryCode) {
|
||||
switch (countryCode) {
|
||||
case "US":
|
||||
case "BR":
|
||||
return Arrays.asList("Checking", "Savings");
|
||||
default:
|
||||
return new ArrayList<>();
|
||||
|
@ -147,7 +156,7 @@ public class BankUtil {
|
|||
public static String getHolderIdLabel(String countryCode) {
|
||||
switch (countryCode) {
|
||||
case "BR":
|
||||
return "CPF Number:";
|
||||
return "Tax Registration Number (CPF):";
|
||||
case "CL":
|
||||
return "RUT Number:";
|
||||
default:
|
||||
|
|
|
@ -77,16 +77,22 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Country of bank:", CountryUtil.getNameAndCode(countryCode));
|
||||
|
||||
String bankCodeLabel = BankUtil.getBankIdLabel(countryCode);
|
||||
if (BankUtil.isBankNameRequired(countryCode) && BankUtil.isBankIdRequired(countryCode))
|
||||
String branchCodeLabel = BankUtil.getBranchIdLabel(countryCode);
|
||||
boolean branchCodeDisplayed = false;
|
||||
if (BankUtil.isBankNameRequired(countryCode) && BankUtil.isBankIdRequired(countryCode)) {
|
||||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Bank name / " + bankCodeLabel,
|
||||
bankAccountContractData.getBankName() + " / " + bankAccountContractData.getBankId());
|
||||
else if (BankUtil.isBankNameRequired(countryCode))
|
||||
} else if (BankUtil.isBankNameRequired(countryCode) && !BankUtil.isBankIdRequired(countryCode) && BankUtil.isBranchIdRequired(countryCode)) {
|
||||
branchCodeDisplayed = true;
|
||||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Bank name / " + branchCodeLabel,
|
||||
bankAccountContractData.getBankName() + " / " + bankAccountContractData.getBranchId());
|
||||
} else if (BankUtil.isBankNameRequired(countryCode)) {
|
||||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Bank name:", bankAccountContractData.getBankName());
|
||||
else if (BankUtil.isBankIdRequired(countryCode))
|
||||
} else if (BankUtil.isBankIdRequired(countryCode)) {
|
||||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankCodeLabel, bankAccountContractData.getBankId());
|
||||
}
|
||||
|
||||
String accountNrLabel = BankUtil.getAccountNrLabel(countryCode);
|
||||
String branchCodeLabel = BankUtil.getBranchIdLabel(countryCode);
|
||||
String accountTypeLabel = BankUtil.getAccountTypeLabel(countryCode);
|
||||
|
||||
String accountTypeString = "";
|
||||
|
@ -94,13 +100,14 @@ abstract class BankForm extends PaymentMethodForm {
|
|||
|
||||
if (BankUtil.isAccountTypeRequired(countryCode)) {
|
||||
accountTypeString = " (" + bankAccountContractData.getAccountType() + ")";
|
||||
accountTypeLabelString = " (" + accountTypeLabel + ")";
|
||||
accountTypeLabelString = " (" + accountTypeLabel.substring(0, accountTypeLabel.length() - 1) + "):";
|
||||
}
|
||||
|
||||
if (BankUtil.isBranchIdRequired(countryCode))
|
||||
if (!branchCodeDisplayed && BankUtil.isBranchIdRequired(countryCode))
|
||||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, branchCodeLabel, bankAccountContractData.getBranchId());
|
||||
if (BankUtil.isAccountNrRequired(countryCode))
|
||||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, accountNrLabel + accountTypeLabelString, bankAccountContractData.getAccountNr() + accountTypeString);
|
||||
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, accountNrLabel.substring(0, accountNrLabel.length() - 1) +
|
||||
accountTypeLabelString, bankAccountContractData.getAccountNr() + accountTypeString);
|
||||
|
||||
return gridRow;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ public final class AccountNrValidator extends BankValidator {
|
|||
return super.validate(input);
|
||||
else
|
||||
return new ValidationResult(false, BSResources.get("validation.accountNr", "4 - 17"));
|
||||
case "BR":
|
||||
if (isStringInRange(input, 1, 20))
|
||||
return super.validate(input);
|
||||
else
|
||||
return new ValidationResult(false, BSResources.get("validation.accountNrChars", "1 - 20"));
|
||||
default:
|
||||
return super.validate(input);
|
||||
}
|
||||
|
|
|
@ -23,17 +23,25 @@ import io.bitsquare.locale.BSResources;
|
|||
public final class BranchIdValidator extends BankValidator {
|
||||
@Override
|
||||
public ValidationResult validate(String input) {
|
||||
int length;
|
||||
switch (countryCode) {
|
||||
case "GB":
|
||||
if (isNumberWithFixedLength(input, 6))
|
||||
length = 6;
|
||||
if (isNumberWithFixedLength(input, length))
|
||||
return super.validate(input);
|
||||
else
|
||||
return new ValidationResult(false, BSResources.get("validation.sortCode", "Sort code", 6));
|
||||
return new ValidationResult(false, BSResources.get("validation.sortCodeNumber", "Sort code", length));
|
||||
case "US":
|
||||
if (isNumberWithFixedLength(input, 9))
|
||||
length = 9;
|
||||
if (isNumberWithFixedLength(input, length))
|
||||
return super.validate(input);
|
||||
else
|
||||
return new ValidationResult(false, BSResources.get("validation.sortCode", "Routing number", 9));
|
||||
return new ValidationResult(false, BSResources.get("validation.sortCodeNumber", "Routing number", length));
|
||||
case "BR":
|
||||
if (isStringInRange(input, 2, 6))
|
||||
return super.validate(input);
|
||||
else
|
||||
return new ValidationResult(false, BSResources.get("validation.sortCodeChars", "Branch code", "2 - 6"));
|
||||
default:
|
||||
return super.validate(input);
|
||||
}
|
||||
|
|
|
@ -77,4 +77,12 @@ public class InputValidator {
|
|||
protected boolean isNumberInRange(String input, int minLength, int maxLength) {
|
||||
return isPositiveNumber(input) && input.length() >= minLength && input.length() <= maxLength;
|
||||
}
|
||||
|
||||
protected boolean isStringWithFixedLength(String input, int length) {
|
||||
return input != null && input.length() == length;
|
||||
}
|
||||
|
||||
protected boolean isStringInRange(String input, int minLength, int maxLength) {
|
||||
return input != null && input.length() >= minLength && input.length() <= maxLength;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,10 @@ validation.btc.toSmall=Input results in a bitcoin value with a fraction of the s
|
|||
validation.btc.toLarge=Input larger as maximum trading amount of {0} is not allowed.
|
||||
validation.passwordTooShort=The password you entered is too short. It needs to have min. 8 characters.
|
||||
validation.passwordTooLong=The password you entered is too long. It cannot be longer as 50 characters.
|
||||
validation.sortCode={0} must consist of {1} numbers
|
||||
validation.sortCodeNumber={0} must consist of {1} numbers
|
||||
validation.sortCodeChars={0} must consist of {1} characters
|
||||
validation.accountNr=Account number must consist of {0} numbers
|
||||
validation.accountNrChars=Account number must consist of {0} characters
|
||||
|
||||
# Create offer
|
||||
createOffer.amount.prompt=Enter amount in BTC
|
||||
|
|
Loading…
Add table
Reference in a new issue