fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [1/2] incubator-fineract git commit: FINERACT-330 : No error message is getting displayed in productive collection sheet if meeting is not attached to center/group
Date Wed, 22 Mar 2017 06:13:48 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop 7f9591ce9 -> e444aca44


FINERACT-330 : No error message is getting displayed in productive collection sheet if meeting
is not attached to center/group


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/d6e70134
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/d6e70134
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/d6e70134

Branch: refs/heads/develop
Commit: d6e70134107c65d627ae27b9e59f4f0ec886850d
Parents: 8cc560c
Author: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Authored: Fri Mar 17 15:53:39 2017 +0530
Committer: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Committed: Fri Mar 17 15:53:39 2017 +0530

----------------------------------------------------------------------
 .../service/CenterReadPlatformServiceImpl.java  | 28 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/d6e70134/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
index ca8aa1b..625d1d6 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
@@ -40,8 +40,8 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData;
 import org.apache.fineract.infrastructure.core.data.PaginationParameters;
 import org.apache.fineract.infrastructure.core.data.PaginationParametersDataValidator;
 import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
+import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
 import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
 import org.apache.fineract.infrastructure.core.service.Page;
 import org.apache.fineract.infrastructure.core.service.PaginationHelper;
 import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
@@ -549,9 +549,12 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
         validateForGenerateCollectionSheet(staffId);
         LocalDate localDate = new LocalDate(meetingDate);
         final CenterCalendarDataMapper centerCalendarMapper = new CenterCalendarDataMapper();
+        String passeddate = formatter.print(localDate);
+        if (!isCentersHavingMeetingFrequencyBasedOnOfficeIdAndMeetingDate(officeId, passeddate,
staffId)) { throw new GeneralPlatformDomainRuleException(
+                "error.msg.collection.sheet.can.not.be.selected.meeting.date.not.attached.to.any.center",
+                "Collection sheet can not be generated without meeting date " + passeddate
+ " attached to any center ", passeddate); }
         String sql = centerCalendarMapper.schema();
         Collection<CenterData> centerDataArray = null;
-        String passeddate = formatter.print(localDate);
         if (staffId != null) {
             sql += " and g.staff_id=? ";
             sql += "and lrs.duedate<='" + passeddate + "' and l.loan_type_enum=3";
@@ -600,6 +603,27 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
         return staffCenterDataArray;
     }
 
+    @SuppressWarnings("deprecation")
+    private boolean isCentersHavingMeetingFrequencyBasedOnOfficeIdAndMeetingDate(final Long
officeId, final String passeddate,
+            final Long staffId) {
+        final StringBuilder sb = new StringBuilder(100);
+        sb.append("SELECT COUNT(*) ");
+        sb.append("FROM m_calendar c ");
+        sb.append("JOIN m_calendar_instance ci ON ci.calendar_id=c.id AND ci.entity_type_enum=4
");
+        sb.append("JOIN m_group ce ON ce.id = ci.entity_id ");
+        sb.append("JOIN m_group g ON g.parent_id = ce.id ");
+        sb.append("WHERE c.start_date = ? AND g.office_id= ? ");
+        int i = 0;
+        if (staffId != null) {
+            sb.append(" AND g.staff_id = ? ");
+            i = this.jdbcTemplate.queryForInt(sb.toString(), new Object[] { passeddate, officeId,
staffId });
+        } else {
+            i = this.jdbcTemplate.queryForInt(sb.toString(), new Object[] { passeddate, officeId
});
+        }
+        if (i > 0) { return true; }
+        return false;
+    }
+
     public void validateForGenerateCollectionSheet(final Long staffId) {
         final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
 


Mime
View raw message