FINERACT-2455: WC - Transaction - Prepay Loan - #6385
Conversation
160ef6a to
2e88f6c
Compare
galovics
left a comment
There was a problem hiding this comment.
The transactionDate parameter is accepted, validated, parsed, and echoed back in the response - but never actually used to compute anything. The template amount is just balance.getTotalOutstanding() as it stands right now, so for a WC loan where penalties and discount fee accrue daily and backdated transactions are allowed, a payoff quote for any date other than today is going to be wrong with no way for the caller to tell. Either the payoff needs to be computed as of transactionDate (which is what I'd expect from something called "prepay" - including whatever the intended treatment of unearned discount fee is on an early settlement), or the parameter should be dropped until it does something.
Two more concrete issues:
repository.getReferenceById(loanId)returns a lazy proxy - an unknownloanIdwon't fail here, it'll throwEntityNotFoundExceptionon first property access (getCurrency()), which has no exception mapper and surfaces as a 500 instead of a 404.retrieveOnein the same class does this correctly viafindByIdWithFullDetails(...).orElseThrow(...)- worth reusing that pattern here, especially sincegetCurrency()and the balance can both be null in general.- The new Swagger response DTO (
WorkingCapitalLoanTransactionTemplateResponse) doesn't match what the endpoint actually returns - it declaresid(which the data class doesn't have) and omitscurrency(which it does). The generated client will always getnullfor a field that never exists and won't expose the one that does.
Smaller things: the permission check happens after loan resolution rather than before (every other endpoint in this resource does it the other way), and this also introduces a second, parallel "template" mechanism on the same resource ({loanId}/transactions/template?command=X vs. the existing {loanId}/template?templateType=X) with different query param names and different backing services for the same concept - worth confirming that's intentional rather than folding prepayLoan into the existing one.
Recommendation: CHANGES_REQUESTED
Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.