Skip to content

Commit

Permalink
FINERACT-2081: Rework Loan Account data
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsaghy committed Aug 15, 2024
1 parent 22b10d9 commit 2a445a5
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 902 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@
import java.time.LocalDate;
import java.util.Collection;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Data;

@Data
@AllArgsConstructor
@ToString
@Getter
@Setter
public final class CollectionData {

private BigDecimal availableDisbursementAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,108 +18,58 @@
*/
package org.apache.fineract.portfolio.loanaccount.data;

import java.math.BigDecimal;
import java.time.LocalDate;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
* Immutable data object represent the important time-line events of a loan application and loan.
* Data object represent the important time-line events of a loan application and loan.
*/
@Getter
@RequiredArgsConstructor
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class LoanApplicationTimelineData {

private final LocalDate submittedOnDate;
private final String submittedByUsername;
private final String submittedByFirstname;
private final String submittedByLastname;
private final LocalDate rejectedOnDate;
private final String rejectedByUsername;
private final String rejectedByFirstname;
private final String rejectedByLastname;
private final LocalDate withdrawnOnDate;
private final String withdrawnByUsername;
private final String withdrawnByFirstname;
private final String withdrawnByLastname;
private final LocalDate approvedOnDate;
private final String approvedByUsername;
private final String approvedByFirstname;
private final String approvedByLastname;
private final LocalDate expectedDisbursementDate;
private final LocalDate actualDisbursementDate;
private final String disbursedByUsername;
private final String disbursedByFirstname;
private final String disbursedByLastname;
private final LocalDate closedOnDate;
private final String closedByUsername;
private final String closedByFirstname;
private final String closedByLastname;
private LocalDate submittedOnDate;
private String submittedByUsername;
private String submittedByFirstname;
private String submittedByLastname;
private LocalDate rejectedOnDate;
private String rejectedByUsername;
private String rejectedByFirstname;
private String rejectedByLastname;
private LocalDate withdrawnOnDate;
private String withdrawnByUsername;
private String withdrawnByFirstname;
private String withdrawnByLastname;
private LocalDate approvedOnDate;
private String approvedByUsername;
private String approvedByFirstname;
private String approvedByLastname;
private LocalDate expectedDisbursementDate;
private LocalDate actualDisbursementDate;
private String disbursedByUsername;
private String disbursedByFirstname;
private String disbursedByLastname;
private LocalDate closedOnDate;
private String closedByUsername;
private String closedByFirstname;
private String closedByLastname;

private final LocalDate actualMaturityDate;
private final LocalDate expectedMaturityDate;
private final LocalDate writeOffOnDate;
private final String writeOffByUsername;
private final String writeOffByFirstname;
private final String writeOffByLastname;
private LocalDate actualMaturityDate;
private LocalDate expectedMaturityDate;
private LocalDate writeOffOnDate;
private String writeOffByUsername;
private String writeOffByFirstname;
private String writeOffByLastname;

private final LocalDate chargedOffOnDate;
private final String chargedOffByUsername;
private final String chargedOffByFirstname;
private final String chargedOffByLastname;

public static LoanApplicationTimelineData templateDefault(final LocalDate expectedDisbursementDate) {

final LocalDate submittedOnDate = null;
final String submittedByUsername = null;
final String submittedByFirstname = null;
final String submittedByLastname = null;
final LocalDate rejectedOnDate = null;
final String rejectedByUsername = null;
final String rejectedByFirstname = null;
final String rejectedByLastname = null;
final LocalDate withdrawnOnDate = null;
final String withdrawnByUsername = null;
final String withdrawnByFirstname = null;
final String withdrawnByLastname = null;
final LocalDate approvedOnDate = null;
final String approvedByUsername = null;
final String approvedByFirstname = null;
final String approvedByLastname = null;
final LocalDate actualDisbursementDate = null;
final String disbursedByUsername = null;
final String disbursedByFirstname = null;
final String disbursedByLastname = null;
final LocalDate closedOnDate = null;
final String closedByUsername = null;
final String closedByFirstname = null;
final String closedByLastname = null;
final LocalDate expectedMaturityDate = null;
final LocalDate writeOffOnDate = null;
final String writeOffByUsername = null;
final String writeOffByFirstname = null;
final String writeOffByLastname = null;
final LocalDate chargedOffOnDate = null;
final String chargedOffByUsername = null;
final String chargedOffByFirstname = null;
final String chargedOffByLastname = null;
final LocalDate actualMaturityDate = null;

return new LoanApplicationTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname, submittedByLastname,
rejectedOnDate, rejectedByUsername, rejectedByFirstname, rejectedByLastname, withdrawnOnDate, withdrawnByUsername,
withdrawnByFirstname, withdrawnByLastname, approvedOnDate, approvedByUsername, approvedByFirstname, approvedByLastname,
expectedDisbursementDate, actualDisbursementDate, disbursedByUsername, disbursedByFirstname, disbursedByLastname,
closedOnDate, closedByUsername, closedByFirstname, closedByLastname, actualMaturityDate, expectedMaturityDate,
writeOffOnDate, writeOffByUsername, writeOffByFirstname, writeOffByLastname, chargedOffOnDate, chargedOffByUsername,
chargedOffByFirstname, chargedOffByLastname);
}

public RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData(final CurrencyData currency, final BigDecimal principal,
final BigDecimal approvedPrincipal, final BigDecimal inArrearsTolerance, final BigDecimal totalFeeChargesAtDisbursement) {
return new RepaymentScheduleRelatedLoanData(this.expectedDisbursementDate, this.actualDisbursementDate, currency, principal,
inArrearsTolerance, totalFeeChargesAtDisbursement);
}
private LocalDate chargedOffOnDate;
private String chargedOffByUsername;
private String chargedOffByFirstname;
private String chargedOffByLastname;

public LocalDate getDisbursementDate() {
LocalDate disbursementDate = this.expectedDisbursementDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,35 @@
*/
package org.apache.fineract.portfolio.loanaccount.data;

import lombok.Getter;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.portfolio.calendar.data.CalendarData;

@Getter
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class LoanInterestRecalculationData {

private final Long id;
private final Long loanId;
private final EnumOptionData interestRecalculationCompoundingType;
private final EnumOptionData rescheduleStrategyType;
private final CalendarData calendarData;
private final EnumOptionData recalculationRestFrequencyType;
private final Integer recalculationRestFrequencyInterval;
private final EnumOptionData recalculationRestFrequencyNthDay;
private final EnumOptionData recalculationRestFrequencyWeekday;
private final Integer recalculationRestFrequencyOnDay;
private final EnumOptionData recalculationCompoundingFrequencyType;
private final Integer recalculationCompoundingFrequencyInterval;
private final EnumOptionData recalculationCompoundingFrequencyNthDay;
private final EnumOptionData recalculationCompoundingFrequencyWeekday;
private final Integer recalculationCompoundingFrequencyOnDay;
private final Boolean isCompoundingToBePostedAsTransaction;
private final CalendarData compoundingCalendarData;
private final Boolean allowCompoundingOnEod;
private Long id;
private Long loanId;
private EnumOptionData interestRecalculationCompoundingType;
private EnumOptionData rescheduleStrategyType;
private CalendarData calendarData;
private EnumOptionData recalculationRestFrequencyType;
private Integer recalculationRestFrequencyInterval;
private EnumOptionData recalculationRestFrequencyNthDay;
private EnumOptionData recalculationRestFrequencyWeekday;
private Integer recalculationRestFrequencyOnDay;
private EnumOptionData recalculationCompoundingFrequencyType;
private Integer recalculationCompoundingFrequencyInterval;
private EnumOptionData recalculationCompoundingFrequencyNthDay;
private EnumOptionData recalculationCompoundingFrequencyWeekday;
private Integer recalculationCompoundingFrequencyOnDay;
private Boolean isCompoundingToBePostedAsTransaction;
private CalendarData compoundingCalendarData;
private Boolean allowCompoundingOnEod;

public LoanInterestRecalculationData(final Long id, final Long loanId, final EnumOptionData interestRecalculationCompoundingType,
final EnumOptionData rescheduleStrategyType, final CalendarData calendarData,
Expand Down Expand Up @@ -73,17 +77,8 @@ public LoanInterestRecalculationData(final Long id, final Long loanId, final Enu
this.allowCompoundingOnEod = allowCompoundingOnEod;
}

public static LoanInterestRecalculationData withCalendarData(final LoanInterestRecalculationData recalculationData,
final CalendarData calendarData, CalendarData compoundingCalendarData) {
return new LoanInterestRecalculationData(recalculationData.id, recalculationData.loanId,
recalculationData.interestRecalculationCompoundingType, recalculationData.rescheduleStrategyType, calendarData,
recalculationData.recalculationRestFrequencyType, recalculationData.recalculationRestFrequencyInterval,
recalculationData.recalculationRestFrequencyNthDay, recalculationData.recalculationRestFrequencyWeekday,
recalculationData.recalculationRestFrequencyOnDay, compoundingCalendarData,
recalculationData.recalculationCompoundingFrequencyType, recalculationData.recalculationCompoundingFrequencyInterval,
recalculationData.recalculationCompoundingFrequencyNthDay, recalculationData.recalculationCompoundingFrequencyWeekday,
recalculationData.recalculationCompoundingFrequencyOnDay, recalculationData.isCompoundingToBePostedAsTransaction,
recalculationData.allowCompoundingOnEod);
public LoanInterestRecalculationData withCalendarData(final CalendarData calendarData, CalendarData compoundingCalendarData) {
return this.setCalendarData(calendarData).setCompoundingCalendarData(compoundingCalendarData);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void populateLoansTable(Sheet addGuarantorSheet, String dateFormat) {
dateCellStyle.setDataFormat(df);
int rowIndex = 1;
Row row;
Collections.sort(loans, LoanAccountData.ClientNameComparator);
loans.sort(LoanAccountData.LOAN_ACCOUNT_DATA_COMPARATOR_BY_CLIENT_NAME);
for (LoanAccountData loan : loans) {
if (addGuarantorSheet.getRow(rowIndex) == null) {
row = addGuarantorSheet.createRow(rowIndex++);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface GroupReadPlatformService {
Collection<GroupGeneralData> retrieveGroupsForLookup(Long officeId);

GroupGeneralData retrieveGroupWithClosureReasons();

GroupGeneralData retrieveGroupAndMembersDetails(Long groupId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@
import org.apache.fineract.organisation.office.service.OfficeReadPlatformService;
import org.apache.fineract.organisation.staff.data.StaffData;
import org.apache.fineract.organisation.staff.service.StaffReadPlatformService;
import org.apache.fineract.portfolio.calendar.data.CalendarData;
import org.apache.fineract.portfolio.client.data.ClientData;
import org.apache.fineract.portfolio.client.service.ClientReadPlatformService;
import org.apache.fineract.portfolio.group.api.GroupingTypesApiConstants;
import org.apache.fineract.portfolio.group.data.CenterData;
import org.apache.fineract.portfolio.group.data.GroupGeneralData;
import org.apache.fineract.portfolio.group.data.GroupRoleData;
import org.apache.fineract.portfolio.group.domain.GroupTypes;
import org.apache.fineract.portfolio.group.exception.GroupNotFoundException;
import org.apache.fineract.useradministration.domain.AppUser;
Expand Down Expand Up @@ -74,6 +77,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
private final DatabaseSpecificSQLGenerator sqlGenerator;
private final PaginationParametersDataValidator paginationParametersDataValidator;
private final ColumnValidator columnValidator;
private final ClientReadPlatformService clientReadPlatformService;

@Override
public GroupGeneralData retrieveTemplate(final Long officeId, final boolean isCenterGroup, final boolean staffInSelectedOfficeOnly) {
Expand Down Expand Up @@ -246,6 +250,23 @@ public GroupGeneralData retrieveGroupWithClosureReasons() {
return GroupGeneralData.withClosureReasons(closureReasons);
}

@Override
public GroupGeneralData retrieveGroupAndMembersDetails(Long groupId) {
GroupGeneralData groupAccount = retrieveOne(groupId);

// get group associations
final Collection<ClientData> membersOfGroup = clientReadPlatformService.retrieveActiveClientMembersOfGroup(groupId);
if (!CollectionUtils.isEmpty(membersOfGroup)) {
final Collection<ClientData> activeClientMembers = null;
final Collection<CalendarData> calendarsData = null;
final CalendarData collectionMeetingCalendar = null;
final Collection<GroupRoleData> groupRoles = null;
groupAccount = GroupGeneralData.withAssocations(groupAccount, membersOfGroup, activeClientMembers, groupRoles, calendarsData,
collectionMeetingCalendar);
}
return groupAccount;
}

private static final class GroupLookupDataMapper implements RowMapper<GroupGeneralData> {

public static final String G_ID_AS_ID_G_ACCOUNT_NO_AS_ACCOUNT_NO_G_DISPLAY_NAME_AS_DISPLAY_NAME_FROM_M_GROUP_G_WHERE_G_LEVEL_ID_2 = "g.id as id, g.account_no as accountNo, g.display_name as displayName from m_group g where g.level_id = 2 ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ public GroupReadPlatformService groupReadPlatformService(JdbcTemplate jdbcTempla
OfficeReadPlatformService officeReadPlatformService, StaffReadPlatformService staffReadPlatformService,
CenterReadPlatformService centerReadPlatformService, CodeValueReadPlatformService codeValueReadPlatformService,
PaginationHelper paginationHelper, DatabaseSpecificSQLGenerator sqlGenerator,
PaginationParametersDataValidator paginationParametersDataValidator, ColumnValidator columnValidator) {
PaginationParametersDataValidator paginationParametersDataValidator, ColumnValidator columnValidator,
ClientReadPlatformService clientReadPlatformService) {
return new GroupReadPlatformServiceImpl(jdbcTemplate, context, officeReadPlatformService, staffReadPlatformService,
centerReadPlatformService, codeValueReadPlatformService, paginationHelper, sqlGenerator, paginationParametersDataValidator,
columnValidator);
columnValidator, clientReadPlatformService);
}

@Bean
Expand Down
Loading

0 comments on commit 2a445a5

Please sign in to comment.