Skip to content

Commit

Permalink
Merge pull request #1054 from fiterlatam/fix/FBR-712
Browse files Browse the repository at this point in the history
pagare report charges
  • Loading branch information
BrianMuhimbura authored Aug 22, 2024
2 parents 7621cbe + b74c934 commit 9d339b9
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 193 deletions.
Binary file modified fineract-provider/pentahoReports/Pagare Libre Protesto Grupal.prpt
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GlJournalEntryInvalidReason;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryRuntimeException;
import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType;
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMapping;
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMappingRepository;
Expand Down Expand Up @@ -588,36 +587,35 @@ private void createJournalEntriesForSavings(final Office office, final String cu
}

// Check for duplicate debit and credit account
/*if (debitAccount.getId().equals(creditAccount.getId())) {
StringBuffer sb = new StringBuffer();
sb.append("Incorrect Gl Account detected \n");
sb.append("Savings Product Id: " + savingsProductId).append("\n");
sb.append("Debit Account Id: " + debitAccount.getId()).append("\n");
sb.append("Debit Account Name: " + debitAccount.getName()).append("\n");
sb.append("Credit Account Id: " + creditAccount.getId()).append("\n");
sb.append("Credit Account Name: " + creditAccount.getName()).append("\n");
sb.append("accountTypeToDebitId: " + accountTypeToDebitId).append("\n");
sb.append("accountTypeToCreditId: " + accountTypeToCreditId).append("\n");
sb.append("paymentTypeId: " + paymentTypeId).append("\n");
sb.append("savingsReferenceGlAccountId: " + savingsReferenceGlAccountId).append("\n");
sb.append("transactionId: " + transactionId).append("\n");
sb.append("transactionDate: " + transactionDate).append("\n");
sb.append("amount: " + amount).append("\n");
sb.append("transactionDate: " + transactionDate).append("\n");
sb.append("isDebitAccountOrganziationAccount?: " + isOrganizationAccount(accountTypeToDebitId)).append("\n");
sb.append("isCreditAccountOrganziationAccount?: " + isOrganizationAccount(accountTypeToCreditId)).append("\n");
sb.append("transactionDate: " + transactionDate).append("\n");
sb.append("Execute below query to validate the Debit gl account \n");
sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId +" and mapping.product_type =2 " +
"and mapping.financial_account_type="+accountTypeToDebitId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
sb.append("Execute below query to validate the Credit gl account \n");
sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId +" and mapping.product_type =2 " +
"and mapping.financial_account_type="+accountTypeToCreditId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
log.error(sb.toString());
throw new JournalEntryRuntimeException("error.msg.journal.entry.save.operation.failed", "Invalid GL Account detected for debit entry");
}*/
/*
* if (debitAccount.getId().equals(creditAccount.getId())) {
*
* StringBuffer sb = new StringBuffer(); sb.append("Incorrect Gl Account detected \n");
* sb.append("Savings Product Id: " + savingsProductId).append("\n"); sb.append("Debit Account Id: " +
* debitAccount.getId()).append("\n"); sb.append("Debit Account Name: " + debitAccount.getName()).append("\n");
* sb.append("Credit Account Id: " + creditAccount.getId()).append("\n"); sb.append("Credit Account Name: " +
* creditAccount.getName()).append("\n"); sb.append("accountTypeToDebitId: " +
* accountTypeToDebitId).append("\n"); sb.append("accountTypeToCreditId: " +
* accountTypeToCreditId).append("\n"); sb.append("paymentTypeId: " + paymentTypeId).append("\n");
* sb.append("savingsReferenceGlAccountId: " + savingsReferenceGlAccountId).append("\n");
* sb.append("transactionId: " + transactionId).append("\n"); sb.append("transactionDate: " +
* transactionDate).append("\n"); sb.append("amount: " + amount).append("\n"); sb.append("transactionDate: " +
* transactionDate).append("\n"); sb.append("isDebitAccountOrganziationAccount?: " +
* isOrganizationAccount(accountTypeToDebitId)).append("\n"); sb.append("isCreditAccountOrganziationAccount?: "
* + isOrganizationAccount(accountTypeToCreditId)).append("\n"); sb.append("transactionDate: " +
* transactionDate).append("\n"); sb.append("Execute below query to validate the Debit gl account \n");
* sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId
* +" and mapping.product_type =2 " + "and mapping.financial_account_type="
* +accountTypeToDebitId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
* sb.append("Execute below query to validate the Credit gl account \n");
* sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId
* +" and mapping.product_type =2 " + "and mapping.financial_account_type="
* +accountTypeToCreditId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
*
* log.error(sb.toString()); throw new
* JournalEntryRuntimeException("error.msg.journal.entry.save.operation.failed",
* "Invalid GL Account detected for debit entry"); }
*/
//
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount);
Expand All @@ -633,36 +631,35 @@ private void createJournalEntriesForSavings(final Office office, final String cu
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);

// Check for duplicate debit and credit account
/*if (debitAccount.getId().equals(creditAccount.getId())) {
StringBuffer sb = new StringBuffer();
sb.append("Incorrect Gl Account detected \n");
sb.append("Savings Product Id: " + savingsProductId).append("\n");
sb.append("Debit Account Id: " + debitAccount.getId()).append("\n");
sb.append("Debit Account Name: " + debitAccount.getName()).append("\n");
sb.append("Credit Account Id: " + creditAccount.getId()).append("\n");
sb.append("Credit Account Name: " + creditAccount.getName()).append("\n");
sb.append("glAccountId of Bank Account: " + glAccountId).append("\n");
sb.append("accountTypeToDebitId: " + accountTypeToDebitId).append("\n");
sb.append("accountTypeToCreditId: " + accountTypeToCreditId).append("\n");
sb.append("paymentTypeId: " + paymentTypeId).append("\n");
sb.append("transactionId: " + transactionId).append("\n");
sb.append("transactionDate: " + transactionDate).append("\n");
sb.append("amount: " + amount).append("\n");
sb.append("transactionDate: " + transactionDate).append("\n");
sb.append("isDebitAccountOrganziationAccount?: " + isOrganizationAccount(accountTypeToDebitId)).append("\n");
sb.append("isCreditAccountOrganziationAccount?: " + isOrganizationAccount(accountTypeToCreditId)).append("\n");
sb.append("transactionDate: " + transactionDate).append("\n");
sb.append("Execute below query to validate the Debit gl account only if glAccountId param is null \n");
sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId +" and mapping.product_type =2 " +
"and mapping.financial_account_type="+accountTypeToDebitId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
sb.append("Execute below query to validate the Credit gl account \n");
sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId +" and mapping.product_type =2 " +
"and mapping.financial_account_type="+accountTypeToCreditId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
log.error(sb.toString());
throw new JournalEntryRuntimeException("error.msg.journal.entry.save.operation.failed", "Invalid GL Account detected for debit entry");
}*/
/*
* if (debitAccount.getId().equals(creditAccount.getId())) {
*
* StringBuffer sb = new StringBuffer(); sb.append("Incorrect Gl Account detected \n");
* sb.append("Savings Product Id: " + savingsProductId).append("\n"); sb.append("Debit Account Id: " +
* debitAccount.getId()).append("\n"); sb.append("Debit Account Name: " + debitAccount.getName()).append("\n");
* sb.append("Credit Account Id: " + creditAccount.getId()).append("\n"); sb.append("Credit Account Name: " +
* creditAccount.getName()).append("\n"); sb.append("glAccountId of Bank Account: " + glAccountId).append("\n");
* sb.append("accountTypeToDebitId: " + accountTypeToDebitId).append("\n"); sb.append("accountTypeToCreditId: "
* + accountTypeToCreditId).append("\n"); sb.append("paymentTypeId: " + paymentTypeId).append("\n");
* sb.append("transactionId: " + transactionId).append("\n"); sb.append("transactionDate: " +
* transactionDate).append("\n"); sb.append("amount: " + amount).append("\n"); sb.append("transactionDate: " +
* transactionDate).append("\n"); sb.append("isDebitAccountOrganziationAccount?: " +
* isOrganizationAccount(accountTypeToDebitId)).append("\n"); sb.append("isCreditAccountOrganziationAccount?: "
* + isOrganizationAccount(accountTypeToCreditId)).append("\n"); sb.append("transactionDate: " +
* transactionDate).append("\n");
* sb.append("Execute below query to validate the Debit gl account only if glAccountId param is null \n");
* sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId
* +" and mapping.product_type =2 " + "and mapping.financial_account_type="
* +accountTypeToDebitId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
* sb.append("Execute below query to validate the Credit gl account \n");
* sb.append("select * from acc_product_mapping mapping where mapping.product_id ="+savingsProductId
* +" and mapping.product_type =2 " + "and mapping.financial_account_type="
* +accountTypeToCreditId+" and mapping.payment_Type is NULL and mapping.charge_id is NULL \n");
*
* log.error(sb.toString()); throw new
* JournalEntryRuntimeException("error.msg.journal.entry.save.operation.failed",
* "Invalid GL Account detected for debit entry"); }
*/

createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static SearchParameters forPrequalification(final String displayName, fin

return new SearchParameters(searchText, null, null, displayName, null, null, null, status, offset, maxLimitAllowed, orderBy,
sortOrder, staffId, accountNo, loanId, savingsId, null, false, null, type, null, null, null, groupingType,
portfolioCenterId,agencyId);
portfolioCenterId, agencyId);
}

public static SearchParameters forBankCheques(final Long agencyId, final String chequeNo, final String bankAccNo, final Long batchId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public String retrieveAllBlacklistItems(@Context final UriInfo uriInfo,

String clientName = queryParameters.getFirst("clientName");
SearchParameters searchParameters = SearchParameters.forPrequalification(clientName, status, offset, limit, orderBy, sortOrder,
type, searchText, groupingType, portfolioCenterId,null);
type, searchText, groupingType, portfolioCenterId, null);
final Page<MemberPrequalificationData> memberData = this.prequalificationReadPlatformService.retrieveAllMembers(searchParameters);

final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(queryParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ public LoanAdditionalData mapFromJson(final JsonElement jsonElement, String date
dateLocale);
loanAdditionalData.setDateOpened(dateOpened);

LocalDate fechaInicioNegocio = dateOpened!=null?dateOpened.toLocalDate(): DateUtils.getBusinessLocalDate();
LocalDate fechaInicioNegocio = dateOpened != null ? dateOpened.toLocalDate() : DateUtils.getBusinessLocalDate();
loanAdditionalData.setFecha_inicio_negocio(fechaInicioNegocio);

final LocalDate fechaFin = this.fromApiJsonHelper.extractLocalDateNamed("fecha_fin", jsonElement, dateFormat, dateLocale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public PrequalificationChecklistData retrieveHardPolicyValidationResults(final L
dpi = validationResult.getDpi();
memberRow.addAll(List.of(memberId, clientName, dpi));
}
if (!memberColumnHeaders.contains(policy.getDescription())){
if (!memberColumnHeaders.contains(policy.getDescription())) {
memberColumnHeaders.add(policy.getDescription());
}
memberRow.add(validationColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,17 @@ public ClientData mapRow(@NotNull ResultSet rs, int rowNum) throws SQLException
final String gender = rs.getString("gender");
final String clientArea = rs.getString("clientArea");
final String clientCategorization = rs.getString("clientCategorization");
String recreditCategorization = isTopup?"RECREDITO" : "NUEVO";
String recreditCategorization = isTopup ? "RECREDITO" : "NUEVO";
final String loanCycleCompleted = rs.getString("loanCycleCompleted");
if (!StringUtils.isBlank(loanCycleCompleted)){
if (!StringUtils.isBlank(loanCycleCompleted)) {
recreditCategorization = StringUtils.equalsIgnoreCase(loanCycleCompleted, "fromAnotherGroup") ? "RECREDITO" : "NUEVO";
}

return ClientData.builder().clientId(clientId).prequalificationId(prequalificationId).clientArea(clientArea)
.clientCategorization(clientCategorization).recreditCategorization(recreditCategorization).prequalificationMemberId(prequalificationMemberId).name(name)
.dateOfBirth(dateOfBirth).dpi(dpi).requestedAmount(requestedAmount).gender(gender).workWithPuente(workWithPuente)
.president(president).buroCheckStatus(buroCheckStatus).agencyBuroStatus(agencyBuroStatus).isLoanTopup(isTopup)
.loanCycle(loanCycle).build();
.clientCategorization(clientCategorization).recreditCategorization(recreditCategorization)
.prequalificationMemberId(prequalificationMemberId).name(name).dateOfBirth(dateOfBirth).dpi(dpi)
.requestedAmount(requestedAmount).gender(gender).workWithPuente(workWithPuente).president(president)
.buroCheckStatus(buroCheckStatus).agencyBuroStatus(agencyBuroStatus).isLoanTopup(isTopup).loanCycle(loanCycle).build();
}
}

Expand Down Expand Up @@ -369,6 +369,7 @@ private CheckValidationColor runCheck1() {

/**
* Recurring customer categorization
*
* @param clientData
*/
private CheckValidationColor runCheck2(ClientData clientData) {
Expand Down Expand Up @@ -645,7 +646,7 @@ private CheckValidationColor runCheck8(final GroupData groupData) {
reportParams.put("${prequalificationId}", prequalificationId);
reportParams.put("${loanProductId}", productId);
reportParams.put("${clientArea}", clientArea);
String categorization = groupData.getPreviousPrequalification()!=null?"RECREDITO":"NUEVO";
String categorization = groupData.getPreviousPrequalification() != null ? "RECREDITO" : "NUEVO";
reportParams.put("${categorization}", categorization);
reportParams.put("${disparityRatio}", disparityRatio);
final GenericResultsetData result = this.readReportingService.retrieveGenericResultset(reportName, "report", reportParams, false);
Expand All @@ -663,7 +664,7 @@ private CheckValidationColor runCheck9(final GroupData groupData) {
LocalDate sixMonthsAgo = businessLocalDate.minus(6, ChronoUnit.MONTHS);
final String numberOfMemberSQL = """
SELECT COUNT(mlag.loan_id) totalCount
FROM m_loan ml
FROM m_loan ml
LEFT JOIN m_loan_additionals_group mlag ON mlag.loan_id = ml.id
LEFT JOIN m_code_value mcv ON mcv.id = mlag.business_experience
WHERE mcv.code_value = '<6m' AND ml.prequalification_id = ?
Expand Down Expand Up @@ -1018,7 +1019,7 @@ private CheckValidationColor runCheck25(final ClientData clientData) {
final LoanAdditionProperties loanAdditionProperties = loanAdditionPropertiesList.get(0);
LocalDate businessStartDate = loanAdditionProperties.getFecha_inicio_negocio();
LocalDate currentDate = DateUtils.getLocalDateOfTenant();
Double monthsBetween = Double.valueOf(ChronoUnit.MONTHS.between(businessStartDate,currentDate));
Double monthsBetween = Double.valueOf(ChronoUnit.MONTHS.between(businessStartDate, currentDate));
DecimalFormat f = new DecimalFormat("##.0");

yearsInBusiness = f.format(Double.valueOf(monthsBetween / 12));
Expand Down Expand Up @@ -1217,8 +1218,8 @@ SELECT COUNT(ml.id) AS totalCount
final Map<String, String> reportParams = new HashMap<>();
BigDecimal membersPercentage = BigDecimal.valueOf(100L);
if (numberOfMembers != null && numberOfMembers < Long.valueOf(totalMembers)) {
membersPercentage = BigDecimal.valueOf(100L)
.multiply(BigDecimal.valueOf(numberOfMembers).divide(BigDecimal.valueOf(totalMembers),2, MoneyHelper.getRoundingMode()));
membersPercentage = BigDecimal.valueOf(100L).multiply(
BigDecimal.valueOf(numberOfMembers).divide(BigDecimal.valueOf(totalMembers), 2, MoneyHelper.getRoundingMode()));
}
reportParams.put("${membersPercentage}", String.valueOf(membersPercentage));
final GenericResultsetData result = this.readReportingService.retrieveGenericResultset(reportName, "report", reportParams, false);
Expand Down
Loading

0 comments on commit 9d339b9

Please sign in to comment.