diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java index 66c89e8f59c..d3571272b30 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java @@ -359,7 +359,7 @@ public String revertJournalEntry(final List journalEntries, String @Override public String revertProvisioningJournalEntries(final LocalDate reversalTransactionDate, final Long entityId, final Integer entityType) { List journalEntries = this.glJournalEntryRepository.findProvisioningJournalEntriesByEntityId(entityId, entityType); - final String reversalTransactionId = journalEntries.get(0).getTransactionId(); + final String reversalTransactionId = !journalEntries.isEmpty() ? journalEntries.get(0).getTransactionId() : null; for (final JournalEntry journalEntry : journalEntries) { JournalEntry reversalJournalEntry; String reversalComment = "Reversal entry for Journal Entry with Entry Id :" + journalEntry.getId() + " and transaction Id " diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java index be26e39fcb7..6617fad6008 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java @@ -81,9 +81,9 @@ public class PrequalificationReadPlatformServiceImpl implements Prequalification @Autowired public PrequalificationReadPlatformServiceImpl(final PlatformSecurityContext context, final PaginationHelper paginationHelper, - final DatabaseSpecificSQLGenerator sqlGenerator, final ColumnValidator columnValidator, - final CodeValueReadPlatformService codeValueReadPlatformService, final JdbcTemplate jdbcTemplate, - GenericDataService genericDataService) { + final DatabaseSpecificSQLGenerator sqlGenerator, final ColumnValidator columnValidator, + final CodeValueReadPlatformService codeValueReadPlatformService, final JdbcTemplate jdbcTemplate, + GenericDataService genericDataService) { this.context = context; this.codeValueReadPlatformService = codeValueReadPlatformService; this.jdbcTemplate = jdbcTemplate; @@ -413,244 +413,244 @@ private static final class PrequalificationsGroupMapper implements RowMapper 0 THEN 'Reproceso'\s - ELSE 'Nuevo'\s - END AS processQuality, - concat(mu.firstname, ' ', mu.lastname) as statusChangedBy, - coalesce(ma.name,individualOffice.agency_name) AS agencyName, - ma.id AS agencyId, - cg.display_name AS groupName, - g.group_name AS newGroupName, - g.group_id AS groupId, - pc.display_name AS centerName, - pc.id AS centerId, - lp.id AS productId, - fa.id AS facilitatorId, - concat(fa.firstname, ' ', fa.lastname) AS facilitatorName, - lp.name AS productName, - au.firstname, - au.lastname, - validations.greenValidCount AS greenValidationCount, - validations.yellowValidCount AS yellowValidationCount, - validations.orangeValidCount AS orangeValidationCount, - validations.redValidCount AS redValidationCount - FROM - m_prequalification_group g - INNER JOIN m_appuser au ON - au.id = g.added_by - INNER JOIN m_product_loan lp ON - g.product_id = lp.id - LEFT JOIN ( - SELECT - mpgm.group_id AS prequalification_id, - SUM(mpgm.requested_amount) total_requested_amount, - SUM(mpgm.approved_amount) total_approved_amount - FROM m_prequalification_group_members mpgm - GROUP BY mpgm.group_id - ) prequalification_numbers ON prequalification_numbers.prequalification_id = g.id - - LEFT JOIN( - select DISTINCT mc.office_id, ms.agency_id,mag.name as agency_name, mpgm.group_id, ms.linked_office_id as supervision_office - from m_prequalification_group_members mpgm - INNER JOIN m_client mc on mc.dpi = mpgm.dpi - INNER JOIN m_group_client mgc on mgc.client_id = mc.id - INNER JOIN m_group mg on mg.id = mgc.group_id - INNER JOIN m_group center on center.id = mg.parent_id - INNER JOIN m_portfolio mp on mp.id = center.portfolio_id - INNER JOIN m_supervision ms on ms.id = mp.supervision_id - INNER JOIN m_agency mag on mag.id = ms.agency_id - ) individualOffice ON individualOffice.group_id = g.id - - LEFT JOIN m_agency ma ON - g.agency_id = ma.id - LEFT JOIN( - select agency_id, linked_office_id from m_supervision GROUP BY agency_id - ) supv ON supv.agency_id = ma.id - LEFT JOIN m_office mo on mo.id = supv.linked_office_id - LEFT JOIN m_office moind on moind.id = individualOffice.supervision_office - LEFT JOIN ( - SELECT\s - mcvr.prequalification_id, - COUNT(CASE WHEN mcvr.validation_color_enum = 1 THEN 1 END) AS greenValidCount, - COUNT(CASE WHEN mcvr.validation_color_enum = 2 THEN 1 END) AS yellowValidCount, - COUNT(CASE WHEN mcvr.validation_color_enum = 3 THEN 1 END) AS orangeValidCount, - COUNT(CASE WHEN mcvr.validation_color_enum = 4 THEN 1 END) AS redValidCount - FROM\s - m_checklist_validation_result mcvr - GROUP BY\s - mcvr.prequalification_id - ) validations ON validations.prequalification_id = g.id - LEFT JOIN ( - SELECT\s - prequalification_id,\s - to_status,\s - from_status,\s - sub_status,\s - comments,\s - assigned_to,\s - updatedby_id,\s - MAX(date_created) AS date_created - FROM\s - m_prequalification_status_log\s - GROUP BY\s - prequalification_id - ) sl ON sl.prequalification_id = g.id AND sl.to_status=g.status\s - LEFT JOIN ( - SELECT\s - count(*) as reprocess_count,\s - prequalification_id,\s - to_status - FROM\s - m_prequalification_status_log\s - GROUP BY\s - prequalification_id, to_status - ) mpsl ON mpsl.prequalification_id = g.id AND mpsl.to_status=g.status - LEFT JOIN m_group cg ON - cg.id = g.group_id - LEFT JOIN m_group linkedGroup ON - linkedGroup.prequalification_id = g.id - LEFT JOIN m_group pc ON - pc.id = g.center_id - LEFT JOIN m_appuser assigned ON assigned.id = sl.assigned_to - LEFT JOIN m_appuser mu ON - mu.id = sl.updatedby_id - LEFT JOIN m_appuser fa ON - fa.id = g.facilitator + g.prequalification_number AS prequalificationNumber, + g.status,linkedGroup.id as linkedGroupId, + g.prequalification_duration as prequalilficationTimespan, + g.comments, + g.created_at, + g.prequalification_type_enum as prequalificationType, + sl.from_status as previousStatus, + sl.sub_status as substatus, + sl.comments as latestComments, + assigned.username as assignedUser, + concat(assigned.firstname, ' ', assigned.lastname) as assignedUserName, + sl.date_created as statusChangedOn, + prequalification_numbers.total_requested_amount as totalRequestedAmount, + prequalification_numbers.total_approved_amount totalApprovedAmount, + (case when g.previous_prequalification is not null THEN 'Recredito' ELSE 'Nuevo' END) as processType, + (case when (select count(*) from m_prequalification_status_log where prequalification_id = g.id and to_status = g.status )>0 THEN 'Reproceso' ELSE 'Nuevo' END) as processQuality, + concat(mu.firstname, ' ', mu.lastname) as statusChangedBy, + coalesce(ma.name,individualOffice.agency_name) AS agencyName, + ma.id AS agencyId, + cg.display_name AS groupName, + g.group_name AS newGroupName, + g.group_id AS groupId, + pc.display_name AS centerName, + pc.id AS centerId, + lp.id AS productId, + fa.id AS facilitatorId, + concat(fa.firstname, ' ', fa.lastname) AS facilitatorName, + lp.name AS productName, + au.firstname, + au.lastname, + greenValidation.validCount AS greenValidationCount, + yellowValidation.validCount AS yellowValidationCount, + orangeValidation.validCount AS orangeValidationCount, + redValidation.validCount AS redValidationCount + FROM + m_prequalification_group g + INNER JOIN m_appuser au ON + au.id = g.added_by + INNER JOIN m_product_loan lp ON + g.product_id = lp.id + LEFT JOIN ( + SELECT + mpgm.group_id AS prequalification_id, + SUM(mpgm.requested_amount) total_requested_amount, + SUM(mpgm.approved_amount) total_approved_amount + FROM m_prequalification_group_members mpgm + GROUP BY mpgm.group_id + ) prequalification_numbers ON prequalification_numbers.prequalification_id = g.id + \s + LEFT JOIN( + select DISTINCT mc.office_id, ms.agency_id,mag.name as agency_name, mpgm.group_id, ms.linked_office_id as supervision_office + from m_prequalification_group_members mpgm + INNER JOIN m_client mc on mc.dpi = mpgm.dpi + INNER JOIN m_group_client mgc on mgc.client_id = mc.id + INNER JOIN m_group mg on mg.id = mgc.group_id + INNER JOIN m_group center on center.id = mg.parent_id + INNER JOIN m_portfolio mp on mp.id = center.portfolio_id + INNER JOIN m_supervision ms on ms.id = mp.supervision_id + INNER JOIN m_agency mag on mag.id = ms.agency_id + ) individualOffice ON individualOffice.group_id = g.id + LEFT JOIN m_agency ma ON + g.agency_id = ma.id + LEFT JOIN( + select agency_id, linked_office_id from m_supervision GROUP BY agency_id + ) supv ON supv.agency_id = ma.id + LEFT JOIN m_office mo on mo.id = supv.linked_office_id + LEFT JOIN m_office moind on moind.id = individualOffice.supervision_office + LEFT JOIN + ( + SELECT p.id AS groupid, + COUNT(mcvr.id) AS validCount + FROM m_checklist_validation_result mcvr + INNER JOIN m_prequalification_group p ON mcvr.prequalification_id = p.id and mcvr.validation_color_enum = 1 + GROUP BY p.id + ) greenValidation ON greenValidation.groupid = g.id + LEFT JOIN + ( + SELECT p.id AS groupid, + COUNT(mcvr.id) AS validCount + FROM m_checklist_validation_result mcvr + INNER JOIN m_prequalification_group p ON mcvr.prequalification_id = p.id and mcvr.validation_color_enum = 2 + GROUP BY p.id + ) yellowValidation ON yellowValidation.groupid = g.id + LEFT JOIN + ( + SELECT p.id AS groupid, + COUNT(mcvr.id) AS validCount + FROM m_checklist_validation_result mcvr + INNER JOIN m_prequalification_group p ON mcvr.prequalification_id = p.id and mcvr.validation_color_enum = 3 + GROUP BY p.id + ) orangeValidation ON orangeValidation.groupid = g.id + LEFT JOIN + ( + SELECT p.id AS groupid, + COUNT(mcvr.id) AS validCount + FROM m_checklist_validation_result mcvr + INNER JOIN m_prequalification_group p ON mcvr.prequalification_id = p.id and mcvr.validation_color_enum = 4 + GROUP BY p.id + ) redValidation ON redValidation.groupid = g.id + LEFT JOIN m_group cg ON + cg.id = g.group_id + LEFT JOIN m_group linkedGroup ON + linkedGroup.prequalification_id = g.id + LEFT JOIN m_group pc ON + pc.id = g.center_id + LEFT JOIN m_prequalification_status_log sl ON + sl.prequalification_id = g.id AND sl.to_status=g.status + AND sl.id = + (SELECT MAX(id) + FROM m_prequalification_status_log WHERE prequalification_id = g.id AND sl.to_status=g.status ) + LEFT JOIN m_appuser assigned ON assigned.id = sl.assigned_to + LEFT JOIN m_appuser mu ON + mu.id = sl.updatedby_id + LEFT JOIN m_appuser fa ON + fa.id = g.facilitator """; this.grpSchema = """ - DISTINCT g.id AS id, - g.prequalification_number AS prequalificationNumber, - g.status, - linkedGroup.id AS linkedGroupId, - g.prequalification_duration AS prequalilficationTimespan, - g.comments, - g.created_at, - g.prequalification_type_enum AS prequalificationType, - sl.from_status AS previousStatus, - sl.sub_status AS substatus, - sl.comments AS latestComments, - assigned.username AS assignedUser, - CONCAT(assigned.firstname, ' ', assigned.lastname) AS assignedUserName, - sl.date_created AS statusChangedOn, - prequalification_numbers.total_requested_amount AS totalRequestedAmount, - prequalification_numbers.total_approved_amount AS totalApprovedAmount, - CASE - WHEN g.previous_prequalification IS NOT NULL THEN 'Recredito' - ELSE 'Nuevo' - END AS processType, - CASE - WHEN mpsl.reprocess_count > 0 THEN 'Reproceso' - ELSE 'Nuevo' - END AS processQuality, - CONCAT(mu.firstname, ' ', mu.lastname) AS statusChangedBy, - ma.name AS agencyName, - ma.id AS agencyId, - cg.display_name AS groupName, - g.group_name AS newGroupName, - g.group_id AS groupId, - pc.display_name AS centerName, - pc.id AS centerId, - lp.id AS productId, - fa.id AS facilitatorId, - CONCAT(fa.firstname, ' ', fa.lastname) AS facilitatorName, - lp.name AS productName, - au.firstname, - au.lastname, - greenValidCount AS greenValidationCount, - yellowValidCount AS yellowValidationCount, - orangeValidCount AS orangeValidationCount, - redValidCount AS redValidationCount + DISTINCT g.id AS id, + g.prequalification_number AS prequalificationNumber, + g.status,linkedGroup.id as linkedGroupId, + g.prequalification_duration as prequalilficationTimespan, + g.comments, + g.created_at, + g.prequalification_type_enum as prequalificationType, + sl.from_status as previousStatus, + sl.sub_status as substatus, + sl.comments as latestComments, + assigned.username as assignedUser, + concat(assigned.firstname, ' ', assigned.lastname) as assignedUserName, + sl.date_created as statusChangedOn, + prequalification_numbers.total_requested_amount as totalRequestedAmount, + prequalification_numbers.total_approved_amount totalApprovedAmount, + CASE + WHEN g.previous_prequalification IS NOT NULL THEN 'Recredito' + ELSE 'Nuevo' + END AS processType, + CASE + WHEN mpsl.reprocess_count > 0 THEN 'Reproceso' + ELSE 'Nuevo' + END AS processQuality, + CONCAT(mu.firstname, ' ', mu.lastname) AS statusChangedBy, + ma.name AS agencyName, + ma.id AS agencyId, + cg.display_name AS groupName, + g.group_name AS newGroupName, + g.group_id AS groupId, + pc.display_name AS centerName, + pc.id AS centerId, + lp.id AS productId, + fa.id AS facilitatorId, + concat(fa.firstname, ' ', fa.lastname) AS facilitatorName, + lp.name AS productName, + au.firstname, + au.lastname, + greenValidCount AS greenValidationCount, + yellowValidCount AS yellowValidationCount, + orangeValidCount AS orangeValidationCount, + redValidCount AS redValidationCount + FROM + m_prequalification_group g + INNER JOIN m_appuser au ON + au.id = g.added_by + INNER JOIN m_product_loan lp ON + g.product_id = lp.id + LEFT JOIN ( + SELECT + mpgm.group_id AS prequalification_id, + SUM(mpgm.requested_amount) AS total_requested_amount, + SUM(mpgm.approved_amount) AS total_approved_amount + FROM m_prequalification_group_members mpgm + GROUP BY mpgm.group_id + ) prequalification_numbers ON prequalification_numbers.prequalification_id = g.id + LEFT JOIN m_agency ma ON g.agency_id = ma.id + LEFT JOIN m_office groupOffice ON ma.linked_office_id = groupOffice.parent_id + LEFT JOIN m_office mogrp ON mogrp.id = groupOffice.id + LEFT JOIN ( + SELECT + mcvr.prequalification_id, + COUNT( + CASE + WHEN mcvr.validation_color_enum = 1 THEN 1 + END + ) AS greenValidCount, + COUNT( + CASE + WHEN mcvr.validation_color_enum = 2 THEN 1 + END + ) AS yellowValidCount, + COUNT( + CASE + WHEN mcvr.validation_color_enum = 3 THEN 1 + END + ) AS orangeValidCount, + COUNT( + CASE + WHEN mcvr.validation_color_enum = 4 THEN 1 + END + ) AS redValidCount + FROM m_checklist_validation_result mcvr + GROUP BY + mcvr.prequalification_id + ) validations ON validations.prequalification_id = g.id + LEFT JOIN m_group cg ON + cg.id = g.group_id + LEFT JOIN m_group linkedGroup ON + linkedGroup.prequalification_id = g.id + LEFT JOIN m_group pc ON + pc.id = g.center_id + LEFT JOIN ( + SELECT + prequalification_id, + to_status, + from_status, + sub_status, + comments, + assigned_to, + updatedby_id, + MAX(date_created) AS date_created FROM - m_prequalification_group g - INNER JOIN - m_appuser au ON au.id = g.added_by - INNER JOIN - m_product_loan lp ON g.product_id = lp.id - LEFT JOIN ( - SELECT - mpgm.group_id AS prequalification_id, - SUM(mpgm.requested_amount) AS total_requested_amount, - SUM(mpgm.approved_amount) AS total_approved_amount - FROM - m_prequalification_group_members mpgm - GROUP BY - mpgm.group_id - ) prequalification_numbers ON prequalification_numbers.prequalification_id = g.id - LEFT JOIN - m_agency ma ON g.agency_id = ma.id - LEFT JOIN - m_office groupOffice ON ma.linked_office_id = groupOffice.parent_id - LEFT JOIN - m_office mogrp ON mogrp.id = groupOffice.id - LEFT JOIN ( - SELECT - mcvr.prequalification_id, - COUNT(CASE WHEN mcvr.validation_color_enum = 1 THEN 1 END) AS greenValidCount, - COUNT(CASE WHEN mcvr.validation_color_enum = 2 THEN 1 END) AS yellowValidCount, - COUNT(CASE WHEN mcvr.validation_color_enum = 3 THEN 1 END) AS orangeValidCount, - COUNT(CASE WHEN mcvr.validation_color_enum = 4 THEN 1 END) AS redValidCount - FROM - m_checklist_validation_result mcvr - GROUP BY - mcvr.prequalification_id - ) validations ON validations.prequalification_id = g.id - LEFT JOIN - m_group cg ON cg.id = g.group_id - LEFT JOIN - m_group linkedGroup ON linkedGroup.prequalification_id = g.id - LEFT JOIN - m_group pc ON pc.id = g.center_id - LEFT JOIN ( - SELECT - prequalification_id, - to_status, - from_status, - sub_status, - comments, - assigned_to, - updatedby_id, - MAX(date_created) AS date_created - FROM - m_prequalification_status_log - GROUP BY - prequalification_id - ) sl ON sl.prequalification_id = g.id AND sl.to_status=g.status - LEFT JOIN ( - SELECT - count(*) as reprocess_count, - prequalification_id, - to_status - FROM - m_prequalification_status_log - GROUP BY - prequalification_id, to_status - ) mpsl ON mpsl.prequalification_id = g.id AND mpsl.to_status=g.status - LEFT JOIN - m_appuser assigned ON assigned.id = sl.assigned_to - LEFT JOIN - m_appuser mu ON mu.id = sl.updatedby_id - LEFT JOIN - m_appuser fa ON fa.id = g.facilitator + m_prequalification_status_log + GROUP BY + prequalification_id + ) sl ON sl.prequalification_id = g.id + AND sl.to_status = g.status + LEFT JOIN ( + SELECT + count(*) as reprocess_count, + prequalification_id, + to_status + FROM m_prequalification_status_log GROUP BY prequalification_id, to_status ) + mpsl ON mpsl.prequalification_id = g.id + AND mpsl.to_status = g.status + LEFT JOIN m_appuser assigned ON assigned.id = sl.assigned_to + LEFT JOIN m_appuser mu ON + mu.id = sl.updatedby_id + LEFT JOIN m_appuser fa ON + fa.id = g.facilitator """; }