Improve auto-naming of accounts

This commit is contained in:
Manfred Karrer 2016-08-07 13:54:35 +02:00
parent 8dba40c3f0
commit 4db16760f0
9 changed files with 23 additions and 22 deletions

View file

@ -52,7 +52,7 @@ public class BankUtil {
case "BR": case "BR":
return "Bank name:"; return "Bank name:";
default: default:
return "Bank name (optional):"; return isBankNameRequired(countryCode) ? "Bank name:" : "Bank name (optional):";
} }
} }
@ -83,7 +83,7 @@ public class BankUtil {
case "HK": case "HK":
return "Bank code:"; return "Bank code:";
default: default:
return "Bank ID (e.g. BIC or SWIFT) (optional):"; return isBankIdRequired(countryCode) ? "Bank ID (e.g. BIC or SWIFT):" : "Bank ID (e.g. BIC or SWIFT) (optional):";
} }
} }
@ -120,7 +120,7 @@ public class BankUtil {
case "CA": case "CA":
return "Transit Number:"; return "Transit Number:";
default: default:
return "Branch nr. (optional):"; return isBranchIdRequired(countryCode) ? "Branch nr.:" : "Branch nr. (optional):";
} }
} }

View file

@ -73,9 +73,9 @@ public class AliPayForm extends PaymentMethodForm {
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) { if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String accountNr = accountNrInputTextField.getText(); String accountNr = accountNrInputTextField.getText();
accountNr = StringUtils.abbreviate(accountNr, 5); accountNr = StringUtils.abbreviate(accountNr, 9);
String method = BSResources.get(paymentAccount.getPaymentMethod().getId()); String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(", ").concat(accountNr)); accountNameTextField.setText(method.concat(": ").concat(accountNr));
} }
} }

View file

@ -470,27 +470,27 @@ abstract class BankForm extends PaymentMethodForm {
countryCode = ""; countryCode = "";
if (BankUtil.isBankIdRequired(countryCode)) { if (BankUtil.isBankIdRequired(countryCode)) {
bankId = bankIdInputTextField.getText(); bankId = bankIdInputTextField.getText();
if (bankId.length() > 6) if (bankId.length() > 9)
bankId = StringUtils.abbreviate(bankId, 9); bankId = StringUtils.abbreviate(bankId, 9);
} else if (BankUtil.isBranchIdRequired(countryCode)) { } else if (BankUtil.isBranchIdRequired(countryCode)) {
bankId = branchIdInputTextField.getText(); bankId = branchIdInputTextField.getText();
if (bankId.length() > 6) if (bankId.length() > 9)
bankId = StringUtils.abbreviate(bankId, 9); bankId = StringUtils.abbreviate(bankId, 9);
} else if (BankUtil.isBankNameRequired(countryCode)) { } else if (BankUtil.isBankNameRequired(countryCode)) {
bankId = bankNameInputTextField.getText(); bankId = bankNameInputTextField.getText();
if (bankId.length() > 6) if (bankId.length() > 9)
bankId = StringUtils.abbreviate(bankId, 9); bankId = StringUtils.abbreviate(bankId, 9);
} }
String accountNr = accountNrInputTextField.getText(); String accountNr = accountNrInputTextField.getText();
if (accountNr.length() > 6) if (accountNr.length() > 9)
accountNr = StringUtils.abbreviate(accountNr, 9); accountNr = StringUtils.abbreviate(accountNr, 9);
String method = BSResources.get(paymentAccount.getPaymentMethod().getId()); String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
if (bankId != null) if (bankId != null && !bankId.isEmpty())
accountNameTextField.setText(method.concat(", ").concat(bankId).concat(", ").concat(accountNr)); accountNameTextField.setText(method.concat(": ").concat(bankId).concat(", ").concat(accountNr));
else else
accountNameTextField.setText(method.concat(", ").concat(accountNr)); accountNameTextField.setText(method.concat(": ").concat(accountNr));
} }
} }

View file

@ -100,7 +100,7 @@ public class CryptoCurrencyForm extends PaymentMethodForm {
String address = addressInputTextField.getText(); String address = addressInputTextField.getText();
address = StringUtils.abbreviate(address, 9); address = StringUtils.abbreviate(address, 9);
String currency = paymentAccount.getSingleTradeCurrency() != null ? paymentAccount.getSingleTradeCurrency().getCode() : "?"; String currency = paymentAccount.getSingleTradeCurrency() != null ? paymentAccount.getSingleTradeCurrency().getCode() : "?";
accountNameTextField.setText(method.concat(", ").concat(currency).concat(", ").concat(address)); accountNameTextField.setText(currency.concat(": ").concat(address));
} }
} }

View file

@ -117,9 +117,9 @@ public class OKPayForm extends PaymentMethodForm {
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) { if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String accountNr = accountNrInputTextField.getText(); String accountNr = accountNrInputTextField.getText();
accountNr = StringUtils.abbreviate(accountNr, 5); accountNr = StringUtils.abbreviate(accountNr, 9);
String method = BSResources.get(paymentAccount.getPaymentMethod().getId()); String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(", ").concat(accountNr)); accountNameTextField.setText(method.concat(": ").concat(accountNr));
} }
} }

View file

@ -75,9 +75,9 @@ public class PerfectMoneyForm extends PaymentMethodForm {
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) { if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String accountNr = accountNrInputTextField.getText(); String accountNr = accountNrInputTextField.getText();
accountNr = StringUtils.abbreviate(accountNr, 5); accountNr = StringUtils.abbreviate(accountNr, 9);
String method = BSResources.get(paymentAccount.getPaymentMethod().getId()); String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(", ").concat(accountNr)); accountNameTextField.setText(method.concat(": ").concat(accountNr));
} }
} }

View file

@ -280,12 +280,12 @@ public class SepaForm extends PaymentMethodForm {
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) { if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String iban = ibanInputTextField.getText(); String iban = ibanInputTextField.getText();
if (iban.length() > 5) if (iban.length() > 9)
iban = StringUtils.abbreviate(iban, 5); iban = StringUtils.abbreviate(iban, 9);
String method = BSResources.get(paymentAccount.getPaymentMethod().getId()); String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
String country = ((CountryBasedPaymentAccount) paymentAccount).getCountry() != null ? ((CountryBasedPaymentAccount) paymentAccount).getCountry().code : "?"; String country = ((CountryBasedPaymentAccount) paymentAccount).getCountry() != null ? ((CountryBasedPaymentAccount) paymentAccount).getCountry().code : "?";
String currency = paymentAccount.getSingleTradeCurrency() != null ? paymentAccount.getSingleTradeCurrency().getCode() : "?"; String currency = paymentAccount.getSingleTradeCurrency() != null ? paymentAccount.getSingleTradeCurrency().getCode() : "?";
accountNameTextField.setText(method.concat(", ").concat(currency).concat(", ").concat(country).concat(", ").concat(iban)); accountNameTextField.setText(method.concat(" (").concat(currency).concat("/").concat(country).concat("): ").concat(iban));
} }
} }

View file

@ -82,9 +82,9 @@ public class SwishForm extends PaymentMethodForm {
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) { if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String mobileNr = mobileNrInputTextField.getText(); String mobileNr = mobileNrInputTextField.getText();
mobileNr = StringUtils.abbreviate(mobileNr, 5); mobileNr = StringUtils.abbreviate(mobileNr, 9);
String method = BSResources.get(paymentAccount.getPaymentMethod().getId()); String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(", ").concat(mobileNr)); accountNameTextField.setText(method.concat(": ").concat(mobileNr));
} }
} }

View file

@ -763,6 +763,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
paymentAccountsComboBox = addLabelComboBox(gridPane, gridRow, "Payment account:", Layout.FIRST_ROW_DISTANCE).second; paymentAccountsComboBox = addLabelComboBox(gridPane, gridRow, "Payment account:", Layout.FIRST_ROW_DISTANCE).second;
paymentAccountsComboBox.setPromptText("Select payment account"); paymentAccountsComboBox.setPromptText("Select payment account");
paymentAccountsComboBox.setMinWidth(300);
editOfferElements.add(paymentAccountsComboBox); editOfferElements.add(paymentAccountsComboBox);
// we display either currencyComboBox (multi currency account) or currencyTextField (single) // we display either currencyComboBox (multi currency account) or currencyTextField (single)