Skip to content

Commit

Permalink
Merge pull request #1337 from fiterlatam/fix/FSF-80-QA
Browse files Browse the repository at this point in the history
fix/FSF-80-QA
  • Loading branch information
BrianMuhimbura authored Dec 4, 2024
2 parents 1f4efb4 + 531cf57 commit 7ed3078
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ private void updateOrganizationRunningBalance(LocalDate entityDate) {
final String organizationRunningBalanceQuery = """
SELECT
je.organization_running_balance AS runningBalance,
je.account_id AS accountId
je.account_id AS accountId
FROM
acc_gl_journal_entry je
INNER JOIN ( SELECT max( id ) AS id FROM acc_gl_journal_entry WHERE entry_date < ? GROUP BY account_id, entry_date ) je2 ON je2.id = je.id
INNER JOIN ( SELECT max( entry_date ) AS entrydt FROM acc_gl_journal_entry WHERE entry_date < ? GROUP BY account_id ) je3 ON je.entry_date = je3.entrydt
INNER JOIN ( SELECT max( id ) AS id FROM acc_gl_journal_entry WHERE entry_date < ? GROUP BY account_id, entry_date ) je2 ON je2.id = je.id
INNER JOIN ( SELECT max( entry_date ) AS entrydt FROM acc_gl_journal_entry WHERE entry_date < ? GROUP BY account_id ) je3 ON je.entry_date = je3.entrydt
GROUP BY
je.id
je.id
ORDER BY
je.entry_date DESC LIMIT 10000;
""";
Expand All @@ -131,13 +131,13 @@ INNER JOIN ( SELECT max( entry_date ) AS entrydt FROM acc_gl_journal_entry WHERE
SELECT
je.office_running_balance AS runningBalance,
je.account_id AS accountId,
je.office_id AS officeId
je.office_id AS officeId
FROM
acc_gl_journal_entry je
INNER JOIN ( SELECT max( id ) AS id FROM acc_gl_journal_entry WHERE entry_date < ? GROUP BY office_id, account_id, entry_date ) je2 ON je2.id = je.id
INNER JOIN ( SELECT max( entry_date ) AS entrydt FROM acc_gl_journal_entry WHERE entry_date < ? GROUP BY office_id, account_id ) je3 ON je.entry_date = je3.entrydt
INNER JOIN ( SELECT max( entry_date ) AS entrydt FROM acc_gl_journal_entry WHERE entry_date < ? GROUP BY office_id, account_id ) je3 ON je.entry_date = je3.entrydt
GROUP BY
je.id
je.id
ORDER BY
je.entry_date DESC LIMIT 10000;
""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.serialization.GoogleGsonSerializerHelper;
import org.apache.fineract.portfolio.collateral.data.CollateralData;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.data.DisbursementData;
import org.apache.fineract.portfolio.loanaccount.data.LoanAccountData;
import org.apache.fineract.portfolio.loanaccount.data.LoanApprovalData;
import org.apache.fineract.portfolio.loanaccount.data.LoanChargeData;
import org.apache.fineract.portfolio.loanaccount.data.LoanCollateralManagementData;
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionData;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
import org.apache.fineract.portfolio.loanaccount.exception.InvalidAmountOfCollateralQuantity;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
Expand Down Expand Up @@ -350,17 +349,7 @@ private LoanAccountData readLoan(Row row, String locale, String dateFormat) {
}
}

List<LoanCollateralManagementData> loanCollateralManagementData = new ArrayList<>();

if (collateralId != null) {
if (ImportHandlerUtils.readAsDouble(LoanConstants.LOAN_COLLATERAL_QUANTITY, row) != null) {
loanCollateralManagementData.add(new LoanCollateralManagementData(collateralId,
BigDecimal.valueOf(ImportHandlerUtils.readAsDouble(LoanConstants.LOAN_COLLATERAL_QUANTITY, row)), null, null,
null));
} else {
throw new InvalidAmountOfCollateralQuantity(null);
}
}
List<CollateralData> loanCollateralManagementData = new ArrayList<>();

statuses.add(status);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ private static final class CollateralMapper implements RowMapper<CollateralData>

private final StringBuilder sqlBuilder = new StringBuilder(
"lc.id as id, lc.description as description, lc.value as value, cv.id as typeId, cv.code_value as typeName, oc.code as currencyCode, ")
.append(" oc.name as currencyName,oc.decimal_places as currencyDecimalPlaces, oc.currency_multiplesof as inMultiplesOf, oc.display_symbol as currencyDisplaySymbol, oc.internationalized_name_code as currencyNameCode")
.append(" oc.name as currencyName,oc.decimal_places as currencyDecimalPlaces, oc.currency_multiplesof as inMultiplesOf, "
+ "oc.display_symbol as currencyDisplaySymbol, oc.internationalized_name_code as currencyNameCode, "
+ "oc.int_code as intCode")
.append(" FROM m_loan_collateral lc") //
.append(" JOIN m_code_value cv on lc.type_cv_id = cv.id")//
.append(" JOIN m_loan loan on lc.loan_id = loan.id")//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
import org.apache.fineract.portfolio.client.data.EconomicSectorData;
import org.apache.fineract.portfolio.client.service.ClientReadPlatformService;
import org.apache.fineract.portfolio.client.service.EconomicActivityReadPlatformService;
import org.apache.fineract.portfolio.collateralmanagement.data.LoanCollateralResponseData;
import org.apache.fineract.portfolio.collateralmanagement.service.LoanCollateralManagementReadPlatformService;
import org.apache.fineract.portfolio.collateral.data.CollateralData;
import org.apache.fineract.portfolio.collateral.service.CollateralReadPlatformService;
import org.apache.fineract.portfolio.cupo.data.CupoData;
import org.apache.fineract.portfolio.cupo.domain.CupoStatus;
import org.apache.fineract.portfolio.cupo.service.CupoReadService;
Expand All @@ -131,7 +131,6 @@
import org.apache.fineract.portfolio.loanaccount.data.LoanAccountData;
import org.apache.fineract.portfolio.loanaccount.data.LoanApprovalData;
import org.apache.fineract.portfolio.loanaccount.data.LoanChargeData;
import org.apache.fineract.portfolio.loanaccount.data.LoanCollateralManagementData;
import org.apache.fineract.portfolio.loanaccount.data.LoanTermVariationsData;
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionData;
import org.apache.fineract.portfolio.loanaccount.data.PaidInAdvanceData;
Expand Down Expand Up @@ -284,7 +283,7 @@ public class LoansApiResource {
private final ConfigurationDomainService configurationDomainService;
private final DefaultToApiJsonSerializer<GlimRepaymentTemplate> glimTemplateToApiJsonSerializer;
private final GLIMAccountInfoReadPlatformService glimAccountInfoReadPlatformService;
private final LoanCollateralManagementReadPlatformService loanCollateralManagementReadPlatformService;
private final CollateralReadPlatformService collateralReadPlatformService;
private final CupoReadService cupoReadService;
private final AppUserReadPlatformService appUserReadPlatformService;
private final AgencyReadPlatformServiceImpl agencyReadPlatformService;
Expand Down Expand Up @@ -316,9 +315,8 @@ public LoansApiResource(final PlatformSecurityContext context, final LoanReadPla
final ConfigurationDomainService configurationDomainService,
final DefaultToApiJsonSerializer<GlimRepaymentTemplate> glimTemplateToApiJsonSerializer,
final GLIMAccountInfoReadPlatformService glimAccountInfoReadPlatformService,
final LoanCollateralManagementReadPlatformService loanCollateralManagementReadPlatformService,
final CupoReadService cupoReadService, AppUserReadPlatformService appUserReadPlatformService,
EconomicActivityReadPlatformService economicActivityReadPlatformService,
final CollateralReadPlatformService collateralReadPlatformService, final CupoReadService cupoReadService,
AppUserReadPlatformService appUserReadPlatformService, EconomicActivityReadPlatformService economicActivityReadPlatformService,
AgencyReadPlatformServiceImpl agencyReadPlatformService, CenterReadPlatformServiceImpl centerReadPlatformService) {
this.context = context;
this.loanReadPlatformService = loanReadPlatformService;
Expand Down Expand Up @@ -350,7 +348,7 @@ public LoansApiResource(final PlatformSecurityContext context, final LoanReadPla
this.configurationDomainService = configurationDomainService;
this.glimTemplateToApiJsonSerializer = glimTemplateToApiJsonSerializer;
this.glimAccountInfoReadPlatformService = glimAccountInfoReadPlatformService;
this.loanCollateralManagementReadPlatformService = loanCollateralManagementReadPlatformService;
this.collateralReadPlatformService = collateralReadPlatformService;
this.cupoReadService = cupoReadService;
this.clientReadPlatformService = clientReadPlatformService;
this.ageLimitValidationJsonSerializer = ageLimitValidationJsonSerializer;
Expand Down Expand Up @@ -715,8 +713,7 @@ public String retrieveLoan(@PathParam("loanId") @Parameter(description = "loanId
CupoData linkedCupo = this.accountAssociationsReadPlatformService.retrieveLinkedCupo(loanId);
Collection<DisbursementData> disbursementData = null;
Collection<LoanTermVariationsData> emiAmountVariations = null;
Collection<LoanCollateralResponseData> loanCollateralManagements = null;
Collection<LoanCollateralManagementData> loanCollateralManagementData = new ArrayList<>();
Collection<CollateralData> collateralData = null;
CollectionData collectionData = CollectionData.template();

final Set<String> mandatoryResponseParameters = new HashSet<>();
Expand Down Expand Up @@ -803,13 +800,8 @@ public String retrieveLoan(@PathParam("loanId") @Parameter(description = "loanId

if (associationParameters.contains(DataTableApiConstant.collateralAssociateParamName)) {
mandatoryResponseParameters.add(DataTableApiConstant.collateralAssociateParamName);
loanCollateralManagements = this.loanCollateralManagementReadPlatformService.getLoanCollateralResponseDataList(loanId);
for (LoanCollateralResponseData loanCollateralManagement : loanCollateralManagements) {
loanCollateralManagementData.add(loanCollateralManagement.toCommand());
}
if (CollectionUtils.isEmpty(loanCollateralManagements)) {
loanCollateralManagements = null;
}
collateralData = this.collateralReadPlatformService.retrieveCollaterals(loanId);

}

if (associationParameters.contains(DataTableApiConstant.meetingAssociateParamName)) {
Expand Down Expand Up @@ -941,13 +933,12 @@ public String retrieveLoan(@PathParam("loanId") @Parameter(description = "loanId
}

final LoanAccountData loanAccount = LoanAccountData.associationsAndTemplate(loanBasicDetails, repaymentSchedule, loanRepayments,
charges, loanCollateralManagementData, guarantors, meeting, productOptions, loanTermFrequencyTypeOptions,
repaymentFrequencyTypeOptions, repaymentFrequencyNthDayTypeOptions, repaymentFrequencyDayOfWeekTypeOptions,
repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions,
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers, loanPurposeOptions,
loanCollateralOptions, calendarOptions, notes, accountLinkingOptions, linkedAccount, disbursementData, emiAmountVariations,
overdueCharges, paidInAdvanceTemplate, interestRatesPeriods, clientActiveLoanOptions, rates, isRatesEnabled,
collectionData);
charges, collateralData, guarantors, meeting, productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
repaymentFrequencyNthDayTypeOptions, repaymentFrequencyDayOfWeekTypeOptions, repaymentStrategyOptions,
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers, loanPurposeOptions, loanCollateralOptions, calendarOptions,
notes, accountLinkingOptions, linkedAccount, disbursementData, emiAmountVariations, overdueCharges, paidInAdvanceTemplate,
interestRatesPeriods, clientActiveLoanOptions, rates, isRatesEnabled, collectionData);
loanAccount.setLinkedCupo(linkedCupo);
loanAccount.setCupoLinkingOptions(cupoLinkingOptions);
loanAccount.setPrequalificationId(prequalificationId);
Expand Down
Loading

0 comments on commit 7ed3078

Please sign in to comment.