Piotr Wargulak created FINERACT-3002:
----------------------------------------

             Summary: Working Capital loan transactions accept amounts with 
more decimals than the currency
                 Key: FINERACT-3002
                 URL: https://issues.apache.org/jira/browse/FINERACT-3002
             Project: Apache Fineract
          Issue Type: Bug
            Reporter: Piotr Wargulak
            Assignee: Piotr Wargulak


{{WorkingCapitalLoanDataValidator}} checks the transaction amounts of a Working 
Capital loan for being positive only. An amount finer than the loan's currency 
is stored and posted as given: a repayment of 339.735 on a 2-decimal currency 
is stored as 339.735 and its journal entry is 339.735. The product and the 
application amounts are already refused in that case 
({{{}WorkingCapitalAmountScaleValidator.validateNotFinerThanCurrency{}}}, used 
by the product and application validators).

Affected requests: disbursement ({{{}transactionAmount{}}}, 
{{{}discountAmount{}}}), repayment / goodwill credit / payout refund, recovery 
payment, credit balance refund, discount fee and its adjustment, adjust 
transaction and adjust by delta.

Not covered by the fix below, for a follow-up: the charge adjustment {{amount}} 
({{{}WorkingCapitalLoanChargeDataValidator#validateChargeAdjustmentRequest{}}} 
receives no loan, so no currency), and principal / discount at create, modify 
and approval, which book nothing themselves (the disbursement check covers what 
is booked).

*Steps to reproduce*
 # Create a Working Capital loan in a currency with 2 decimals and disburse it.
 # {{POST /working-capital-loans/\{id}/transactions?command=repayment}} with 
{{{}"transactionAmount": 339.735{}}}.
 # The request succeeds; the transaction and its journal entry carry 339.735.

*Proposed fix:* 
call {{validateNotFinerThanCurrency}} with the loan's currency digits for each 
of these amounts, which answers 400 
{{{}validation.msg.WORKINGCAPITALLOAN.<param>.scale.is.greater.than.<digits>{}}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to