adamsaghy commented on code in PR #5580:
URL: https://github.com/apache/fineract/pull/5580#discussion_r2906265203


##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloanproduct/api/WorkingCapitalLoanAmortizationScheduleApiResource.java:
##########
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.portfolio.workingcapitalloanproduct.api;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.fineract.portfolio.workingcapitalloanproduct.data.ProjectedAmortizationScheduleData;
+import 
org.apache.fineract.portfolio.workingcapitalloanproduct.data.ProjectedAmortizationScheduleGenerateRequest;
+import 
org.apache.fineract.portfolio.workingcapitalloanproduct.service.WorkingCapitalLoanAmortizationScheduleReadService;
+import 
org.apache.fineract.portfolio.workingcapitalloanproduct.service.WorkingCapitalLoanAmortizationScheduleWriteService;
+import org.springframework.stereotype.Component;
+
+@Path("/v1/working-capital-loans")
+@Component
+@Tag(name = "Working Capital Loans", description = "Working Capital Loan 
operations including projected amortization schedule.")
+@RequiredArgsConstructor
+public class WorkingCapitalLoanAmortizationScheduleApiResource {
+
+    private final WorkingCapitalLoanAmortizationScheduleReadService 
readService;
+    private final WorkingCapitalLoanAmortizationScheduleWriteService 
writeService;
+
+    @GET
+    @Path("{loanId}/amortization-schedule")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(summary = "Retrieve Projected Amortization Schedule", 
description = """
+            Returns the projected amortization schedule for a Working Capital 
Loan.
+
+            The schedule contains per-installment details including expected 
and forecast payments, \
+            discount factors, NPV values, balances, expected and actual 
amortization amounts, \
+            income modifications, and deferred balance.
+
+            Example Request:
+
+            working-capital-loans/1/amortization-schedule""")
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = 
ProjectedAmortizationScheduleData.class))),
+            @ApiResponse(responseCode = "404", description = "Working Capital 
Loan or schedule not found") })
+    public ProjectedAmortizationScheduleData retrieveAmortizationSchedule(
+            @PathParam("loanId") @Parameter(description = "loanId") final Long 
loanId) {
+        return readService.retrieveAmortizationSchedule(loanId);
+    }
+
+    // TODO: This is a temporary testing endpoint. In the real implementation, 
the amortization
+    // schedule will be generated as part of the loan approve/disburse 
lifecycle and parameters
+    // will come from the loan entity and its product — not from the request 
body.
+    // Replace this once the full WCL lifecycle is implemented.
+    @POST
+    @Path("{loanId}/amortization-schedule")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(summary = "Generate and save Projected Amortization Schedule 
(testing)", description = """
+            Generates a projected amortization schedule from the provided 
parameters \
+            and saves it for the given Working Capital Loan.
+
+            NOTE: This is a temporary testing endpoint. In the real flow, the 
schedule will be \
+            generated during loan approval/disbursement from the loan and 
product data.""")
+    @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"),
+            @ApiResponse(responseCode = "404", description = "Working Capital 
Loan not found") })
+    public void generateAmortizationSchedule(@PathParam("loanId") 
@Parameter(description = "loanId") final Long loanId,

Review Comment:
   You should create an `WorkingCapitalLoanAmortizationScheduleApiResource` 
with test profile, which ensures this is used only for testing.



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