Merge pull request #6177 from xyzmaker123/fix-edit-account-npe

Fix NPE on edition of CBM FasterPayments and USPostal accounts
This commit is contained in:
Christoph Atteneder 2022-04-28 11:19:46 +02:00 committed by GitHub
commit f5bb7a03fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -141,7 +141,7 @@ public class CashByMailForm extends PaymentMethodForm {
@Override @Override
public void updateAllInputsValid() { public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid() allInputsValid.set(isAccountNameValid()
&& !postalAddressTextArea.getText().isEmpty() && !cashByMailAccount.getPostalAddress().isEmpty()
&& inputValidator.validate(cashByMailAccount.getContact()).isValid && inputValidator.validate(cashByMailAccount.getContact()).isValid
&& paymentAccount.getSingleTradeCurrency() != null); && paymentAccount.getSingleTradeCurrency() != null);
} }

View File

@ -60,6 +60,8 @@ public class FasterPaymentsForm extends PaymentMethodForm {
private InputTextField holderNameInputTextField; private InputTextField holderNameInputTextField;
private InputTextField accountNrInputTextField; private InputTextField accountNrInputTextField;
private InputTextField sortCodeInputTextField; private InputTextField sortCodeInputTextField;
private final BranchIdValidator branchIdValidator;
private final AccountNrValidator accountNrValidator;
public FasterPaymentsForm(PaymentAccount paymentAccount, public FasterPaymentsForm(PaymentAccount paymentAccount,
AccountAgeWitnessService accountAgeWitnessService, AccountAgeWitnessService accountAgeWitnessService,
@ -69,6 +71,8 @@ public class FasterPaymentsForm extends PaymentMethodForm {
CoinFormatter formatter) { CoinFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.fasterPaymentsAccount = (FasterPaymentsAccount) paymentAccount; this.fasterPaymentsAccount = (FasterPaymentsAccount) paymentAccount;
this.branchIdValidator = new BranchIdValidator("GB");
this.accountNrValidator = new AccountNrValidator("GB");
} }
@Override @Override
@ -84,14 +88,14 @@ public class FasterPaymentsForm extends PaymentMethodForm {
// do not translate as it is used in English only // do not translate as it is used in English only
sortCodeInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, UK_SORT_CODE); sortCodeInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, UK_SORT_CODE);
sortCodeInputTextField.setValidator(inputValidator); sortCodeInputTextField.setValidator(inputValidator);
sortCodeInputTextField.setValidator(new BranchIdValidator("GB")); sortCodeInputTextField.setValidator(branchIdValidator);
sortCodeInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { sortCodeInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
fasterPaymentsAccount.setSortCode(newValue); fasterPaymentsAccount.setSortCode(newValue);
updateFromInputs(); updateFromInputs();
}); });
accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.accountNr")); accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.accountNr"));
accountNrInputTextField.setValidator(new AccountNrValidator("GB")); accountNrInputTextField.setValidator(accountNrValidator);
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
fasterPaymentsAccount.setAccountNr(newValue); fasterPaymentsAccount.setAccountNr(newValue);
updateFromInputs(); updateFromInputs();
@ -134,9 +138,9 @@ public class FasterPaymentsForm extends PaymentMethodForm {
@Override @Override
public void updateAllInputsValid() { public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid() allInputsValid.set(isAccountNameValid()
&& holderNameInputTextField.getValidator().validate(fasterPaymentsAccount.getHolderName()).isValid && inputValidator.validate(fasterPaymentsAccount.getHolderName()).isValid
&& sortCodeInputTextField.getValidator().validate(fasterPaymentsAccount.getSortCode()).isValid && branchIdValidator.validate(fasterPaymentsAccount.getSortCode()).isValid
&& accountNrInputTextField.getValidator().validate(fasterPaymentsAccount.getAccountNr()).isValid && accountNrValidator.validate(fasterPaymentsAccount.getAccountNr()).isValid
&& fasterPaymentsAccount.getTradeCurrencies().size() > 0); && fasterPaymentsAccount.getTradeCurrencies().size() > 0);
} }
} }

View File

@ -118,7 +118,7 @@ public class USPostalMoneyOrderForm extends PaymentMethodForm {
public void updateAllInputsValid() { public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid() allInputsValid.set(isAccountNameValid()
&& usPostalMoneyOrderValidator.validate(usPostalMoneyOrderAccount.getPostalAddress()).isValid && usPostalMoneyOrderValidator.validate(usPostalMoneyOrderAccount.getPostalAddress()).isValid
&& !postalAddressTextArea.getText().isEmpty() && !usPostalMoneyOrderAccount.getPostalAddress().isEmpty()
&& inputValidator.validate(usPostalMoneyOrderAccount.getHolderName()).isValid && inputValidator.validate(usPostalMoneyOrderAccount.getHolderName()).isValid
&& usPostalMoneyOrderAccount.getTradeCurrencies().size() > 0); && usPostalMoneyOrderAccount.getTradeCurrencies().size() > 0);
} }