kulminsky commented on code in PR #4144:
URL: https://github.com/apache/fineract/pull/4144#discussion_r1852058913
##########
fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java:
##########
@@ -455,4 +552,37 @@ public void deleteProductToGLAccountMapping(final Long
loanProductId, final Port
this.accountMappingRepository.deleteAllInBatch(productToGLAccountMappings);
}
}
+
+ public void validateChargeOffMappingsInDatabase(final List<JsonObject>
mappings) {
+ final List<ApiParameterError> validationErrors = new ArrayList<>();
+
+ for (JsonObject jsonObject : mappings) {
+ final Long expenseGlAccountId = this.fromApiJsonHelper
+
.extractLongNamed(LoanProductAccountingParams.EXPENSE_GL_ACCOUNT_ID.getValue(),
jsonObject);
+ final Long chargeOffReasonCodeValueId = this.fromApiJsonHelper
+
.extractLongNamed(LoanProductAccountingParams.CHARGE_OFF_REASON_CODE_VALUE_ID.getValue(),
jsonObject);
+
+ // Validation: chargeOffReasonCodeValueId must exist in the
database
+ CodeValue codeValue =
this.codeValueRepository.findByCodeNameAndId("ChargeOffReasons",
chargeOffReasonCodeValueId);
+ if (codeValue == null) {
+
validationErrors.add(ApiParameterError.parameterError("validation.msg.chargeoffreason.invalid",
+ "Charge-off reason with ID " +
chargeOffReasonCodeValueId + " does not exist",
+
LoanProductAccountingParams.CHARGE_OFF_REASONS_TO_EXPENSE.getValue()));
+ }
+
+ // Validation: expenseGLAccountId must exist as a valid Expense GL
account
+ final Optional<GLAccount> glAccount =
accountRepository.findById(expenseGlAccountId);
Review Comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]