5757import org .apache .fineract .infrastructure .security .service .PlatformSecurityContext ;
5858import org .apache .fineract .portfolio .loanaccount .data .LoanRepaymentScheduleInstallmentData ;
5959import org .apache .fineract .portfolio .loanaccount .data .LoanTransactionData ;
60+ import org .apache .fineract .portfolio .loanaccount .domain .LoanTransactionType ;
6061import org .apache .fineract .portfolio .loanaccount .service .LoanChargePaidByReadPlatformService ;
6162import org .apache .fineract .portfolio .loanaccount .service .LoanReadPlatformService ;
6263import org .apache .fineract .portfolio .paymenttype .data .PaymentTypeData ;
@@ -110,12 +111,14 @@ private boolean is(final String commandParam, final String commandValue) {
110111 @ Produces ({ MediaType .APPLICATION_JSON })
111112 @ Operation (summary = "Retrieve Loan Transaction Template" , description = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n "
112113 + "\n " + "Field Defaults\n " + "Allowed Value Lists\n \n " + "Example Requests:\n " + "\n "
113- + "loans/1/transactions/template?command=repayment" + "\n " + "loans/1/transactions/template?command=waiveinterest" + "\n "
114- + "loans/1/transactions/template?command=writeoff" + "\n " + "loans/1/transactions/template?command=close-rescheduled" + "\n "
115- + "loans/1/transactions/template?command=close" + "\n " + "loans/1/transactions/template?command=disburse" + "\n "
116- + "loans/1/transactions/template?command=disburseToSavings" + "\n " + "loans/1/transactions/template?command=recoverypayment"
117- + "\n " + "loans/1/transactions/template?command=prepayLoan" + "\n " + "loans/1/transactions/template?command=refundbycash" + "\n "
118- + "loans/1/transactions/template?command=refundbytransfer" + "\n " + "loans/1/transactions/template?command=foreclosure" + "\n "
114+ + "loans/1/transactions/template?command=repayment" + "loans/1/transactions/template?command=merchantIssuedRefund"
115+ + "loans/1/transactions/template?command=payoutRefund" + "loans/1/transactions/template?command=goodwillCredit" + "\n "
116+ + "loans/1/transactions/template?command=waiveinterest" + "\n " + "loans/1/transactions/template?command=writeoff" + "\n "
117+ + "loans/1/transactions/template?command=close-rescheduled" + "\n " + "loans/1/transactions/template?command=close" + "\n "
118+ + "loans/1/transactions/template?command=disburse" + "\n " + "loans/1/transactions/template?command=disburseToSavings" + "\n "
119+ + "loans/1/transactions/template?command=recoverypayment" + "\n " + "loans/1/transactions/template?command=prepayLoan" + "\n "
120+ + "loans/1/transactions/template?command=refundbycash" + "\n " + "loans/1/transactions/template?command=refundbytransfer" + "\n "
121+ + "loans/1/transactions/template?command=foreclosure" + "\n "
119122 + "loans/1/transactions/template?command=creditBalanceRefund (returned 'amount' field will have the overpaid value" )
120123 @ ApiResponses ({
121124 @ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (schema = @ Schema (implementation = LoanTransactionsApiResourceSwagger .GetLoansLoanIdTransactionsTemplateResponse .class ))) })
@@ -130,6 +133,18 @@ public String retrieveTransactionTemplate(@PathParam("loanId") @Parameter(descri
130133 LoanTransactionData transactionData = null ;
131134 if (is (commandParam , "repayment" )) {
132135 transactionData = this .loanReadPlatformService .retrieveLoanTransactionTemplate (loanId );
136+ } else if (is (commandParam , "merchantIssuedRefund" )) {
137+ LocalDate transactionDate = DateUtils .getLocalDateOfTenant ();
138+ transactionData = this .loanReadPlatformService .retrieveLoanPrePaymentTemplate (LoanTransactionType .MERCHANT_ISSUED_REFUND ,
139+ loanId , transactionDate );
140+ } else if (is (commandParam , "payoutRefund" )) {
141+ LocalDate transactionDate = DateUtils .getLocalDateOfTenant ();
142+ transactionData = this .loanReadPlatformService .retrieveLoanPrePaymentTemplate (LoanTransactionType .PAYOUT_REFUND , loanId ,
143+ transactionDate );
144+ } else if (is (commandParam , "goodwillCredit" )) {
145+ LocalDate transactionDate = DateUtils .getLocalDateOfTenant ();
146+ transactionData = this .loanReadPlatformService .retrieveLoanPrePaymentTemplate (LoanTransactionType .GOODWILL_CREDIT , loanId ,
147+ transactionDate );
133148 } else if (is (commandParam , "waiveinterest" )) {
134149 transactionData = this .loanReadPlatformService .retrieveWaiveInterestDetails (loanId );
135150 } else if (is (commandParam , "writeoff" )) {
@@ -156,7 +171,8 @@ public String retrieveTransactionTemplate(@PathParam("loanId") @Parameter(descri
156171 transactionDate = LocalDate .ofInstant (transactionDateParam .getDate ("transactionDate" , dateFormat , locale ).toInstant (),
157172 DateUtils .getDateTimeZoneOfTenant ());
158173 }
159- transactionData = this .loanReadPlatformService .retrieveLoanPrePaymentTemplate (loanId , transactionDate );
174+ transactionData = this .loanReadPlatformService .retrieveLoanPrePaymentTemplate (LoanTransactionType .REPAYMENT , loanId ,
175+ transactionDate );
160176 } else if (is (commandParam , "refundbycash" )) {
161177 transactionData = this .loanReadPlatformService .retrieveRefundByCashTemplate (loanId );
162178 } else if (is (commandParam , "refundbytransfer" )) {
@@ -209,15 +225,17 @@ public String retrieveTransaction(@PathParam("loanId") @Parameter(description =
209225 @ Consumes ({ MediaType .APPLICATION_JSON })
210226 @ Produces ({ MediaType .APPLICATION_JSON })
211227 @ Operation (summary = "Significant Loan Transactions" , description = "This API covers the major loan transaction functionality\n \n "
212- + "Example Requests:\n " + "\n " + "loans/1/transactions/template?command=repayment" + " | Make a Repayment | \n "
213- + "loans/1/transactions/template?command=waiveinterest" + " | Waive Interest | \n "
214- + "loans/1/transactions/template?command=writeoff" + " | Write-off Loan | \n "
215- + "loans/1/transactions/template?command=close-rescheduled" + " | Close Rescheduled Loan | \n "
216- + "loans/1/transactions/template?command=close" + " | Close Loan | \n " + "loans/1/transactions/template?command=undowriteoff"
217- + " | Undo Loan Write-off | \n " + "loans/1/transactions/template?command=recoverypayment" + " | Make Recovery Payment | \n "
218- + "loans/1/transactions/template?command=refundByCash" + " | Make a Refund of an Active Loan by Cash | \n "
219- + "loans/1/transactions/template?command=foreclosure" + " | Foreclosure of an Active Loan | \n "
220- + "loans/1/transactions/template?command=creditBalanceRefund" + " | Credit Balance Refund" + " | \n " )
228+ + "Example Requests:\n " + "\n " + "loans/1/transactions?command=repayment" + " | Make a Repayment | \n "
229+ + "loans/1/transactions?command=merchantIssuedRefund" + " | Merchant Issued Refund | \n "
230+ + "loans/1/transactions?command=payoutRefund" + " | Payout Refund | \n " + "loans/1/transactions?command=goodwillCredit"
231+ + " | Goodwil Credit | \n " + "loans/1/transactions?command=waiveinterest" + " | Waive Interest | \n "
232+ + "loans/1/transactions?command=writeoff" + " | Write-off Loan | \n " + "loans/1/transactions?command=close-rescheduled"
233+ + " | Close Rescheduled Loan | \n " + "loans/1/transactions?command=close" + " | Close Loan | \n "
234+ + "loans/1/transactions?command=undowriteoff" + " | Undo Loan Write-off | \n " + "loans/1/transactions?command=recoverypayment"
235+ + " | Make Recovery Payment | \n " + "loans/1/transactions?command=refundByCash"
236+ + " | Make a Refund of an Active Loan by Cash | \n " + "loans/1/transactions?command=foreclosure"
237+ + " | Foreclosure of an Active Loan | \n " + "loans/1/transactions?command=creditBalanceRefund" + " | Credit Balance Refund"
238+ + " | \n " )
221239 @ RequestBody (required = true , content = @ Content (schema = @ Schema (implementation = LoanTransactionsApiResourceSwagger .PostLoansLoanIdTransactionsRequest .class )))
222240 @ ApiResponses ({
223241 @ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (schema = @ Schema (implementation = LoanTransactionsApiResourceSwagger .PostLoansLoanIdTransactionsResponse .class ))) })
@@ -231,6 +249,15 @@ public String executeLoanTransaction(@PathParam("loanId") @Parameter(description
231249 if (is (commandParam , "repayment" )) {
232250 final CommandWrapper commandRequest = builder .loanRepaymentTransaction (loanId ).build ();
233251 result = this .commandsSourceWritePlatformService .logCommandSource (commandRequest );
252+ } else if (is (commandParam , "merchantIssuedRefund" )) {
253+ final CommandWrapper commandRequest = builder .loanMerchantIssuedRefundTransaction (loanId ).build ();
254+ result = this .commandsSourceWritePlatformService .logCommandSource (commandRequest );
255+ } else if (is (commandParam , "payoutRefund" )) {
256+ final CommandWrapper commandRequest = builder .loanPayoutRefundTransaction (loanId ).build ();
257+ result = this .commandsSourceWritePlatformService .logCommandSource (commandRequest );
258+ } else if (is (commandParam , "goodwillCredit" )) {
259+ final CommandWrapper commandRequest = builder .loanGoodwillCreditTransaction (loanId ).build ();
260+ result = this .commandsSourceWritePlatformService .logCommandSource (commandRequest );
234261 } else if (is (commandParam , "waiveinterest" )) {
235262 final CommandWrapper commandRequest = builder .waiveInterestPortionTransaction (loanId ).build ();
236263 result = this .commandsSourceWritePlatformService .logCommandSource (commandRequest );
0 commit comments