return savingsAccountCharges;
}
private void validateSavingsCharges(final Set<SavingsAccountCharge> charges, final String productCurrencyCode) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME);
boolean isOneWithdrawalPresent = false;
boolean isOneAnnualPresent = false;
for (SavingsAccountCharge charge : charges) {
if (!charge.hasCurrencyCodeOf(productCurrencyCode)) {
baseDataValidator.reset().parameter("currency").value(charge.getCharge().getId())
.failWithCodeNoParameterAddedToErrorCode("currency.and.charge.currency.not.same");
}
if (charge.isWithdrawalFee()) {
if (isOneWithdrawalPresent) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("multiple.withdrawal.fee.per.account.not.supported");
}
isOneWithdrawalPresent = true;
}
if (charge.isAnnualFee()) {
if (isOneAnnualPresent) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("multiple.annual.fee.per.account.not.supported");
}
isOneAnnualPresent = true;
}
}
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }