Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
import org.apache.fineract.creditapplication.data.CreditApplicationData;
import org.apache.fineract.creditapplication.data.CreditApplicationSearchRequest;
import org.apache.fineract.creditapplication.data.CreditOriginationBoardData;
import org.apache.fineract.creditapplication.data.CreditOriginationDashboardData;
import org.apache.fineract.creditapplication.data.CreditOriginationDashboardRequest;
import org.apache.fineract.creditapplication.service.CreditApplicationReadPlatformService;
import org.apache.fineract.creditapplication.service.CreditOriginationBoardReadPlatformService;
import org.apache.fineract.creditapplication.service.CreditOriginationDashboardReadPlatformService;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.springframework.stereotype.Component;
Expand All @@ -38,6 +41,8 @@ public class CreditApplicationApiResource {
private final PlatformSecurityContext context;
private final CreditApplicationReadPlatformService readPlatformService;
private final CreditOriginationBoardReadPlatformService originationBoardReadPlatformService;
private final CreditOriginationDashboardReadPlatformService
originationDashboardReadPlatformService;

@GET
@Produces(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -66,4 +71,19 @@ public CreditOriginationBoardData retrieveOriginationBoard(
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
return originationBoardReadPlatformService.retrieve(creditApplicationId);
}

@GET
@Path("/origination-dashboard")
@Produces(MediaType.APPLICATION_JSON)
@Operation(
summary = "Retrieve the credit origination dashboard",
description =
"Read-only, office-scoped KPIs, nine-phase distribution and a paginated list of"
+ " applications stalled for more than seven calendar days in their current phase."
+ " Aggregates only include applications visible in the user's office hierarchy.")
public CreditOriginationDashboardData retrieveOriginationDashboard(
@BeanParam final CreditOriginationDashboardRequest request) {
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
return originationDashboardReadPlatformService.retrieve(request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright since 2026 Mifos Initiative
*
* <p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy
* of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.apache.fineract.creditapplication.data;

import java.time.LocalDate;
import java.time.OffsetDateTime;

/**
* Calendar-day aging of the current stage, measured from the authoritative stage-entry timestamp
* (UTC date) to the tenant business date. Status is ON_TIME, STALLED (strictly more than
* thresholdDays), UNKNOWN (missing, invalid or future entry evidence) or NOT_APPLICABLE (servicing
* or inactive applications).
*/
public record CreditOriginationAgingData(
String stage,
OffsetDateTime enteredOn,
String enteredOnSource,
LocalDate businessDate,
Long daysInStage,
String status,
int thresholdDays,
String unit) {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@

import java.util.List;

/** Read model for the nine-phase credit-origination board. */
/**
* Read model for the nine-phase credit-origination board. The responsible staff member is the
* Fineract loan officer assigned to the application, when one is assigned.
*/
public record CreditOriginationBoardData(
Long creditApplicationId,
Long clientId,
Long loanId,
Long prospectId,
String currentStage,
List<CreditOriginationStageData> stages) {}
List<CreditOriginationStageData> stages,
Long officeId,
Long productId,
Long responsibleStaffId,
String responsibleStaffName,
CreditOriginationAgingData currentStageAging) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Copyright since 2026 Mifos Initiative
*
* <p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy
* of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.apache.fineract.creditapplication.data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.List;
import org.apache.fineract.infrastructure.core.service.Page;

/**
* Office-scoped origination dashboard. The population is every active client credit application
* (Fineract loan pending approval, approved or active) whose current phase is not inactive. Counts
* named *Applications count credit applications; counts named *Prospects count distinct clients,
* each of which resolves to at most one prospect registration (its latest).
*/
public record CreditOriginationDashboardData(
LocalDate businessDate,
int stalledThresholdDays,
String agingUnit,
Long officeId,
Long productId,
Summary summary,
List<StageDistribution> stages,
Page<StalledApplication> stalledApplications) {

/** progressRate stays null until the business defines its formula (availability UNDEFINED). */
public record Summary(
long activeProspects,
long activeApplications,
long stalledProspects,
long stalledApplications,
long unknownAgingApplications,
long parametricScoreProspects,
long parametricScoreApplications,
BigDecimal progressRate,
String progressRateAvailability) {}

/** statusAvailability is DERIVED or EVENTS_ONLY (needs published stage events). */
public record StageDistribution(
String code,
String displayName,
int order,
long prospectCount,
long applicationCount,
long stalledProspectCount,
long stalledApplicationCount,
long unknownAgingApplicationCount,
String statusAvailability) {}

public record StalledApplication(
Long prospectId,
Long creditApplicationId,
Long clientId,
String customerName,
String currentStage,
String currentStageStatus,
OffsetDateTime enteredOn,
long daysInStage,
Long responsibleStaffId,
String responsibleStaffName,
Long officeId,
Long productId) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright since 2026 Mifos Initiative
*
* <p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy
* of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.apache.fineract.creditapplication.data;

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.QueryParam;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/** Query parameters accepted by the global credit-origination dashboard. */
@Getter
@Setter
@NoArgsConstructor
public class CreditOriginationDashboardRequest {

@QueryParam("officeId")
@Parameter(description = "Client office; must be inside the authenticated user's hierarchy")
private Long officeId;

@QueryParam("productId")
private Long productId;

@DefaultValue("0")
@QueryParam("offset")
@Parameter(description = "Offset into the stalled-application list")
private Integer offset = 0;

@DefaultValue("50")
@QueryParam("limit")
@Parameter(description = "Page size of the stalled-application list (1-200)")
private Integer limit = 50;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright since 2026 Mifos Initiative
*
* <p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy
* of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.apache.fineract.creditapplication.data;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* Parametric-score evidence components. SAT, Credit Bureau and Syntage are mandatory before the
* PARAMETRIC_SCORE stage may complete; RUG and RPC are informational and never block progression.
*/
@Getter
@RequiredArgsConstructor
public enum CreditOriginationScoreComponent {
SAT("SAT - Tax Authority", true),
CREDIT_BUREAU("Credit Bureau (Buro)", true),
SYNTAGE("Syntage Score", true),
RUG("RUG - Movable Collateral Registry", false),
RPC("RPC - Public Commercial Registry", false);

private final String displayName;
private final boolean required;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright since 2026 Mifos Initiative
*
* <p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy
* of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.apache.fineract.creditapplication.data;

import java.time.OffsetDateTime;

/**
* Latest published evidence for one parametric-score component. Status is UNAVAILABLE when no
* evidence was ever published; provider payloads are never exposed, only their references.
*/
public record CreditOriginationScoreComponentData(
String code,
String displayName,
boolean required,
String status,
String evidenceSource,
String evidenceReference,
OffsetDateTime occurredOn,
OffsetDateTime lastUpdatedOn,
String reason) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright since 2026 Mifos Initiative
*
* <p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy
* of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.apache.fineract.creditapplication.data;

import java.time.OffsetDateTime;

/**
* Internal command used by scoring integrations to publish component upload/validation evidence.
*/
public record CreditOriginationScoreComponentEventCommand(
Long creditApplicationId,
Long clientId,
CreditOriginationScoreComponent component,
String status,
OffsetDateTime occurredOn,
Long actorId,
String source,
String sourceReference,
String eventKey,
String reason) {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/** Stable, ordered credit-origination phase identifiers. */
/**
* Stable, ordered credit-origination phase identifiers. Phases with {@code eventsOnly} have no
* Fineract fallback and only progress through published stage events.
*/
@Getter
@RequiredArgsConstructor
public enum CreditOriginationStageCode {
ONBOARDING("Commercial registration or onboarding"),
COMPLIANCE("File / Compliance"),
PARAMETRIC_SCORE("Parametric Score / Credit"),
FILE_INTEGRATION("Integration of complete file"),
CREDIT_ANALYSIS("Credit analysis"),
APPROVAL("Approval / Committee"),
LEGAL_INSTRUMENTATION("Legal Instrumentation and Validation"),
DISBURSEMENT("Administration / Dispersal / Committee"),
RECOVERY("Recovery / Collection");
ONBOARDING("Commercial registration or onboarding", false),
COMPLIANCE("File / Compliance", false),
PARAMETRIC_SCORE("Parametric Score / Credit", true),
FILE_INTEGRATION("Integration of complete file", true),
CREDIT_ANALYSIS("Credit analysis", true),
APPROVAL("Approval / Committee", false),
LEGAL_INSTRUMENTATION("Legal Instrumentation and Validation", true),
DISBURSEMENT("Administration / Dispersal / Committee", false),
RECOVERY("Recovery / Collection", false);

private final String displayName;
private final boolean eventsOnly;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@
package org.apache.fineract.creditapplication.data;

import java.time.OffsetDateTime;
import java.util.List;

/**
* One board phase. pendingRequirements and scoreComponents are null when the backend has no
* authoritative requirement model for the phase (currently every phase except PARAMETRIC_SCORE).
*/
public record CreditOriginationStageData(
String code,
String displayName,
String status,
OffsetDateTime completedOn,
CreditOriginationStageDetailsData details) {}
CreditOriginationStageDetailsData details,
OffsetDateTime enteredOn,
OffsetDateTime lastUpdatedOn,
List<String> pendingRequirements,
List<CreditOriginationScoreComponentData> scoreComponents) {}
Loading
Loading