Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/FBR-506: Reporte Grupal de Cobranzas y Saldos por Financista #378

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 @@ -38,5 +38,7 @@ public interface PrequalificationReadPlatformService {

Collection<GroupPrequalificationData> retrievePrequalificationGroupsMappings(Long groupId);

Collection<GroupPrequalificationData> retrieveGroupByPrequalificationId(Long prequalificationId);

Collection<GroupPrequalificationData> retrievePrequalificationIndividualMappings(Long clientId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ public Collection<GroupPrequalificationData> retrievePrequalificationGroupsMappi
return prequalificationGroups;
}

@Override
public Collection<GroupPrequalificationData> retrieveGroupByPrequalificationId(Long prequalificationId) {
final String sql = "select " + this.mappingsMapper.schema() + " where PG.id = ? ";
Collection<GroupPrequalificationData> prequalificationGroups = this.jdbcTemplate.query(sql, this.mappingsMapper,
new Object[] { prequalificationId });
return prequalificationGroups;
}

@Override
public Collection<GroupPrequalificationData> retrievePrequalificationIndividualMappings(final Long clientId) {
final String sql = "select " + this.prequalificationIndividualMappingsMapper.schema() + " WHERE mc.id = ? AND mpg.status = 600";
Expand Down Expand Up @@ -562,7 +570,7 @@ private static final class PrequalificationsGroupMappingsMapper implements RowMa

PrequalificationsGroupMappingsMapper() {
this.schema = " PG.id AS id, PG.prequalification_number AS prequalificationNumber, PG.group_name AS groupName, "
+ "PG.status, LP.name AS productName, " + "PG.created_at, AU.firstname, AU.lastname "
+ "PG.status, LP.name AS productName, " + "PG.created_at, AU.firstname, AU.lastname, MG.id AS groupId "
+ "from m_group_prequalification_relationship GR " + "inner join m_group MG on MG.id = GR.group_id "
+ "inner join m_prequalification_group PG on PG.id = GR.prequalification_id "
+ "inner join m_product_loan LP on LP.id = PG.product_id " + "INNER JOIN m_appuser AU ON AU.id = PG.added_by " + "";
Expand All @@ -577,13 +585,14 @@ public GroupPrequalificationData mapRow(final ResultSet rs, final int rowNum) th
final Integer statusEnum = JdbcSupport.getInteger(rs, "status");
final EnumOptionData status = PreQualificationsEnumerations.status(statusEnum);
final Long id = JdbcSupport.getLong(rs, "id");
final Long groupId = JdbcSupport.getLong(rs, "groupId");
final String prequalificationNumber = rs.getString("prequalificationNumber");
String groupName = rs.getString("groupName");
final String productName = rs.getString("productName");
final LocalDate createdAt = JdbcSupport.getLocalDate(rs, "created_at");
final String addedBy = rs.getString("firstname") + " " + rs.getString("lastname");
return GroupPrequalificationData.simpeGroupData(id, prequalificationNumber, status, groupName, productName, addedBy, createdAt,
null);
groupId);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,18 @@ private LoanApplicationTerms assembleLoanApplicationTermsFrom(final JsonElement
numberOfDays = configurationDomainService.retreivePeroidInNumberOfDaysForSkipMeetingDate().intValue();
}
}
if ((loanType.isJLGAccount() || loanType.isGroupAccount()) && calendar != null) {
validateRepaymentsStartDateWithMeetingDates(calculatedRepaymentsStartingFromDate, calendar, isSkipMeetingOnFirstDay,
numberOfDays);

/*
* If disbursement is synced on meeting, make sure disbursement date is on a meeting date
*/
if (synchDisbursement != null && synchDisbursement.booleanValue()) {
validateDisbursementDateWithMeetingDates(expectedDisbursementDate, calendar, isSkipMeetingOnFirstDay, numberOfDays);
final boolean isMeetingMandatoryForJLGLoans = this.configurationDomainService.isMeetingMandatoryForJLGLoans();
if (Boolean.TRUE.equals(isMeetingMandatoryForJLGLoans)) {
if ((loanType.isJLGAccount() || loanType.isGroupAccount()) && calendar != null) {
validateRepaymentsStartDateWithMeetingDates(calculatedRepaymentsStartingFromDate, calendar, isSkipMeetingOnFirstDay,
numberOfDays);

/*
* If disbursement is synced on meeting, make sure disbursement date is on a meeting date
*/
if (synchDisbursement != null && synchDisbursement.booleanValue()) {
validateDisbursementDateWithMeetingDates(expectedDisbursementDate, calendar, isSkipMeetingOnFirstDay, numberOfDays);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ public final class LoanApplicationCommandFromApiJsonHelper {
LoanApiConstants.relativeNumberParamName, LoanApiConstants.yearsInCommunityParamName, LoanApiConstants.PREQUALIFICATION_ID,
LoanApiConstants.cupoIdParameterName, LoanApiConstants.externalLoansParamName, LoanApiConstants.CASE_ID,
LoanApiConstants.paymentCapacityParamName, LoanApiConstants.facilitatorParamName, LoanApiConstants.maidenNameParamName,
LoanApiConstants.politicallyExposedParamName, LoanApiConstants.otherIncomeParamName, LoanApiConstants.currentLoansParamName, LoanApiConstants.dateOfBirthParamName,
LoanApiConstants.businessActivityParamName, LoanApiConstants.LOAN_ADDITIONAL_DATA, "borrowerCycle", "isBulkImport"));
LoanApiConstants.politicallyExposedParamName, LoanApiConstants.otherIncomeParamName, LoanApiConstants.currentLoansParamName,
LoanApiConstants.dateOfBirthParamName, LoanApiConstants.businessActivityParamName, LoanApiConstants.LOAN_ADDITIONAL_DATA,
"borrowerCycle", "isBulkImport"));

private final FromJsonHelper fromApiJsonHelper;
private final CalculateLoanScheduleQueryFromApiJsonHelper apiJsonHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@
import org.apache.fineract.organisation.bankcheque.domain.BankChequeStatus;
import org.apache.fineract.organisation.bankcheque.domain.Cheque;
import org.apache.fineract.organisation.bankcheque.domain.ChequeBatchRepositoryWrapper;
import org.apache.fineract.organisation.prequalification.data.GroupPrequalificationData;
import org.apache.fineract.organisation.prequalification.data.LoanAdditionalData;
import org.apache.fineract.organisation.prequalification.domain.LoanAdditionProperties;
import org.apache.fineract.organisation.prequalification.domain.LoanAdditionalPropertiesRepository;
import org.apache.fineract.organisation.prequalification.domain.PrequalificationGroup;
import org.apache.fineract.organisation.prequalification.domain.PrequalificationGroupRepositoryWrapper;
import org.apache.fineract.organisation.prequalification.exception.PrequalificationNotProvidedException;
import org.apache.fineract.organisation.prequalification.service.BureauValidationWritePlatformServiceImpl;
import org.apache.fineract.organisation.prequalification.service.PrequalificationReadPlatformService;
import org.apache.fineract.organisation.staff.domain.Staff;
import org.apache.fineract.portfolio.account.domain.AccountAssociationType;
import org.apache.fineract.portfolio.account.domain.AccountAssociations;
Expand Down Expand Up @@ -133,7 +134,6 @@
import org.apache.fineract.portfolio.loanaccount.domain.LoanCollateralManagement;
import org.apache.fineract.portfolio.loanaccount.domain.LoanDisbursementDetails;
import org.apache.fineract.portfolio.loanaccount.domain.LoanLifecycleStateMachine;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallmentRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleTransactionProcessorFactory;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
Expand Down Expand Up @@ -171,7 +171,6 @@
import org.apache.fineract.portfolio.savings.data.GroupSavingsIndividualMonitoringAccountData;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountAssembler;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper;
import org.apache.fineract.portfolio.savings.service.GSIMReadPlatformService;
import org.apache.fineract.portfolio.savings.service.SavingsAccountWritePlatformService;
import org.apache.fineract.useradministration.domain.AppUser;
Expand Down Expand Up @@ -244,11 +243,9 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
private BitaCoraMasterRepository bitaCoraMasterRepository;

private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;

private final SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper;
private final AppUserRepository appUserRepository;
private final BureauValidationWritePlatformServiceImpl bureauValidationWritePlatformService;
private final LoanAdditionalPropertiesRepository loanAdditionalPropertiesRepository;
private final PrequalificationReadPlatformService prequalificationReadPlatformService;

@Autowired
public LoanApplicationWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, final FromJsonHelper fromJsonHelper,
Expand All @@ -264,7 +261,6 @@ public LoanApplicationWritePlatformServiceJpaRepositoryImpl(final PlatformSecuri
final LoanRepaymentScheduleTransactionProcessorFactory loanRepaymentScheduleTransactionProcessorFactory,
final CalendarRepository calendarRepository, final CalendarInstanceRepository calendarInstanceRepository,
final SavingsAccountAssembler savingsAccountAssembler, final AccountAssociationsRepository accountAssociationsRepository,
final LoanRepaymentScheduleInstallmentRepository repaymentScheduleInstallmentRepository,
final LoanReadPlatformService loanReadPlatformService, final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository,
final BusinessEventNotifierService businessEventNotifierService, final ConfigurationDomainService configurationDomainService,
final LoanScheduleAssembler loanScheduleAssembler, final LoanUtilService loanUtilService,
Expand All @@ -281,10 +277,9 @@ public LoanApplicationWritePlatformServiceJpaRepositoryImpl(final PlatformSecuri
ChequeBatchRepositoryWrapper chequeBatchRepositoryWrapper,
PrequalificationGroupRepositoryWrapper prequalificationGroupRepositoryWrapper,
final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
final SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper,
final BureauValidationWritePlatformServiceImpl bureauValidationWritePlatformService,
final LoanAdditionalPropertiesRepository loanAdditionalPropertiesRepository,
final GroupLoanAdditionalsRepository groupLoanAdditionalsRepository) {
final GroupLoanAdditionalsRepository groupLoanAdditionalsRepository,
PrequalificationReadPlatformService prequalificationReadPlatformService) {
this.context = context;
this.fromJsonHelper = fromJsonHelper;
this.loanApplicationTransitionApiJsonValidator = loanApplicationTransitionApiJsonValidator;
Expand Down Expand Up @@ -332,11 +327,10 @@ public LoanApplicationWritePlatformServiceJpaRepositoryImpl(final PlatformSecuri
this.chequeBatchRepositoryWrapper = chequeBatchRepositoryWrapper;
this.prequalificationGroupRepositoryWrapper = prequalificationGroupRepositoryWrapper;
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
this.savingsAccountRepositoryWrapper = savingsAccountRepositoryWrapper;
this.groupLoanAdditionalsRepository = groupLoanAdditionalsRepository;
this.appUserRepository = appUserRepository;
this.bureauValidationWritePlatformService = bureauValidationWritePlatformService;
this.loanAdditionalPropertiesRepository = loanAdditionalPropertiesRepository;
this.prequalificationReadPlatformService = prequalificationReadPlatformService;
}

private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
Expand Down Expand Up @@ -524,6 +518,16 @@ public CommandProcessingResult submitApplication(final JsonCommand command) {

final PrequalificationGroup prequalificationGroup = newLoanApplication.getPrequalificationGroup();
if (prequalificationGroup != null && prequalificationGroup.isPrequalificationTypeGroup()) {
Collection<GroupPrequalificationData> prequalificationDataList = this.prequalificationReadPlatformService
.retrieveGroupByPrequalificationId(prequalificationGroup.getId());
if (!CollectionUtils.isEmpty(prequalificationDataList)) {
GroupPrequalificationData prequalificationData = new ArrayList<>(prequalificationDataList).get(0);
final Long prequalificationGroupId = prequalificationData.getGroupId();
if (prequalificationGroupId != null) {
final Group groupPrequalification = this.groupRepository.findOneWithNotFoundDetection(prequalificationGroupId);
newLoanApplication.updateGroup(groupPrequalification);
}
}
GroupLoanAdditionals groupLoanAdditionals = GroupLoanAdditionals.assembleFromJson(command, newLoanApplication, facilitator);
addExternalLoans(groupLoanAdditionals, command);
this.groupLoanAdditionalsRepository.save(groupLoanAdditionals);
Expand Down Expand Up @@ -1489,7 +1493,21 @@ public CommandProcessingResult modifyApplication(final Long loanId, final JsonCo
officeSpecificLoanProductValidation(existingLoanApplication.getLoanProduct().getId(), OfficeId);
}

if (prequalificationGroup.isPrequalificationTypeGroup()) {
Collection<GroupPrequalificationData> prequalificationDataList = this.prequalificationReadPlatformService
.retrieveGroupByPrequalificationId(prequalificationGroup.getId());
if (!CollectionUtils.isEmpty(prequalificationDataList)) {
GroupPrequalificationData prequalificationData = new ArrayList<>(prequalificationDataList).get(0);
final Long prequalificationGroupId = prequalificationData.getGroupId();
if (prequalificationGroupId != null) {
final Group groupPrequalification = this.groupRepository.findOneWithNotFoundDetection(prequalificationGroupId);
existingLoanApplication.updateGroup(groupPrequalification);
}
}
}

if (prequalificationGroup.isPrequalificationTypeIndividual()) {
existingLoanApplication.updateGroup(null);
final JsonElement loanAdditionalDataJson = command.jsonElement(LoanApiConstants.LOAN_ADDITIONAL_DATA);
if (loanAdditionalDataJson != null && loanAdditionalDataJson.isJsonObject()) {
this.fromApiJsonDeserializer.validateLoanAdditionalData(command);
Expand Down Expand Up @@ -2562,8 +2580,11 @@ public CommandProcessingResult approveApplication(final Long loanId, final JsonC
numberOfDays = configurationDomainService.retreivePeroidInNumberOfDaysForSkipMeetingDate().intValue();
}
}
this.loanScheduleAssembler.validateDisbursementDateWithMeetingDates(expectedDisbursementDate, calendar,
isSkipRepaymentOnFirstMonth, numberOfDays);
final boolean isMeetingMandatoryForJLGLoans = this.configurationDomainService.isMeetingMandatoryForJLGLoans();
if (Boolean.TRUE.equals(isMeetingMandatoryForJLGLoans)) {
this.loanScheduleAssembler.validateDisbursementDateWithMeetingDates(expectedDisbursementDate, calendar,
isSkipRepaymentOnFirstMonth, numberOfDays);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2847,8 +2847,8 @@ public GroupLoanAdditionalData mapRow(ResultSet rs, int rowNum) throws SQLExcept
.requestedValue(requestedValue).groupAuthorizedValue(groupAuthorizedValue)
.facilitatorProposedValue(facilitatorProposedValue).proposedFee(proposedFee)
.agencyAuthorizedAmount(agencyAuthorizedAmount).authorizedFee(authorizedFee).totalIncome(totalIncome)
.totalExpenditures(totalExpenditures).availableMonthly(availableMonthly).facValue(facValue).debtLevel(debtLevel).dateOfBirth(dateOfBirth)
.build();
.totalExpenditures(totalExpenditures).availableMonthly(availableMonthly).facValue(facValue).debtLevel(debtLevel)
.dateOfBirth(dateOfBirth).build();
return additionalGroupLoanData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,5 @@
<include file="parts/0114_FBR_440_pagare_libre_protesto_reporte.xml" relativeToChangelogFile="true"/>
<include file="parts/0115_FBR_490_Prestamo_complementario.xml" relativeToChangelogFile="true"/>
<include file="parts/0116_FBR_505_Reporte_de_Garantias_para_prestamos_.xml" relativeToChangelogFile="true"/>
<include file="parts/0117_FBR_506_Reporte_de_Cobranzas_y_Saldos_por_Financista.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
Loading
Loading