Abhishek6122008 commented on PR #6174:
URL: https://github.com/apache/fineract/pull/6174#issuecomment-5919808319

   @adamsaghy Sure. `acc_product_mapping` contains mappings for both loan 
(`product_type = 1`) and savings (`product_type = 2`) products, and their 
product IDs can overlap.
   
   In `SavingAccountMapperForInterestPosting`, `apm` and `apm1` already filter 
by `product_type = 2`, but `apm2`, `apm3` and `apm4` don't:
   
   ```sql
   left join acc_product_mapping apm2 on apm2.product_id = sp.id and 
apm2.financial_account_type = 18
   left join acc_product_mapping apm3 on apm3.product_id = sp.id and 
apm3.financial_account_type = 11
   left join acc_product_mapping apm4 on apm4.product_id = sp.id and 
apm4.financial_account_type = 17
   ```
   
   Since types 11, 17 and 18 are also used by loans, these joins can pick up a 
loan mapping when the product IDs are the same. This can either give us the 
wrong GL account or produce multiple rows.
   
   For example, if savings product `1` has no `INTEREST_PAYABLE` (17) mapping 
but loan product `1` has `CHARGE_OFF_FRAUD_EXPENSE` (17), the job gets the 
loan's GL account instead of `0`, so it doesn't fail but can post interest to 
the wrong account.
   
   So I think we should add `product_type = 2` to these three joins as well, 
keeping them consistent with `apm` and `apm1`.
   


-- 
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]

Reply via email to