mansi75 commented on code in PR #6106:
URL: https://github.com/apache/fineract/pull/6106#discussion_r3571295581
##########
fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java:
##########
@@ -613,10 +613,18 @@ private void savePaymentChannelToFundSourceMapping(final
Long productId, final L
*/
private void saveChargeToFundSourceMapping(final Long productId, final
Long chargeId, final Long incomeAccountId,
final PortfolioProductType portfolioProductType, final boolean
isPenalty) {
- final Charge charge =
this.chargeRepositoryWrapper.findOneWithNotFoundDetection(chargeId);
+ // The accounting module no longer loads the Charge entity (it is
decoupled from the charge domain), so the
+ // existence check that loading the entity used to provide is restored
here with a lightweight JDBC lookup.
+ // This keeps acc_product_mapping.charge_id from persisting orphaned
references without reintroducing a
+ // compile-time dependency on the charge module.
// TODO Vishwas: Need to validate if given charge is fee or Penalty
// based on input condition
+ final Integer chargeCount = this.jdbcTemplate.queryForObject("select
count(*) from m_charge where id = ?", Integer.class, chargeId);
+ if (chargeCount == null || chargeCount == 0) {
+ throw new ResourceNotFoundException("error.msg.charge.id.invalid",
"Charge with identifier " + chargeId + " does not exist",
+ new Object[] { chargeId });
+ }
Review Comment:
I'll remove it. Charge id validation belongs upstream, before the id
reaches the mapping helper.
--
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]