Dhanno98 commented on code in PR #5940:
URL: https://github.com/apache/fineract/pull/5940#discussion_r3501060314


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccountTransaction.java:
##########
@@ -114,7 +114,7 @@ public static ShareAccountTransaction 
createChargeTransaction(final LocalDate tr
         final BigDecimal unitPrice = null;
         final Integer status = PurchasedSharesStatusType.APPROVED.getValue();
         final Integer type = 
PurchasedSharesStatusType.CHARGE_PAYMENT.getValue();
-        BigDecimal amount = charge.percentageOrAmount();
+        BigDecimal amount = charge.amoutOutstanding();

Review Comment:
   Yes. The reason is that `percentageOrAmount()` returns the original 
configured charge value, before currency rounding is applied.
   
   For example, if the configured charge amount is `19.8` for a currency with 
`0` decimal places, then:
   
   * `amountOrPercentage = 19.8` (original configured value)
   * `amount = 20` (rounded amount)
   * `amountOutstanding = 20` (rounded outstanding amount)
   
   `createChargeTransaction()` represents the actual charge transaction, so it 
should use the rounded charge amount that is actually applied to the account, 
not the original unrounded configured value.
   
   Using `percentageOrAmount()` was causing the transaction to be created with 
the unrounded value, whereas `amountOutstanding()` reflects the rounded amount 
that was charged and therefore keeps the transaction consistent with the charge 
itself.



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