adamsaghy commented on code in PR #4144:
URL: https://github.com/apache/fineract/pull/4144#discussion_r1851724833
##########
fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java:
##########
@@ -455,4 +560,39 @@ 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.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection("ChargeOffReasons",
Review Comment:
This throws `CodeValueNotFoundException` exception if it does not found the
code value, so `codeValue` will never be null.
--
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]