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
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& !postalAddressTextArea.getText().isEmpty()
&& !cashByMailAccount.getPostalAddress().isEmpty()
&& inputValidator.validate(cashByMailAccount.getContact()).isValid
&& paymentAccount.getSingleTradeCurrency() != null);
}

View File

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

View File

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