diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 79759e830..940af8220 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -918,6 +918,22 @@ + + + holidays/{holidayId} + + Retrieve a Holiday + Update a Holiday + Delete a Holiday + + + + holidays/{holidayId}?command=activate + Activate a Holiday + + + + Working days @@ -9187,7 +9203,7 @@ GET https://DomainName/api/v1/holidays?officeId=1 -   +  

Create a Holiday

@@ -9196,7 +9212,7 @@ GET https://DomainName/api/v1/holidays?officeId=1
Mandatory Fields
- name, fromDate, toDate, repaymentsRescheduledTo, offices + name, description, fromDate, toDate, repaymentsRescheduledTo, offices
@@ -9210,6 +9226,7 @@ Content-Type: application/json Request Body: { "name": "Good Friday", +"description": "Good Friday", "dateFormat": "dd MMMM yyyy", "locale": "en", "fromDate": "25 October 2013", @@ -9224,6 +9241,125 @@ Request Body: { "resourceId": 1 +} + +
+ + +   +
+
+

Activate a Holiday

+

Always Holidays are created in pending state. This API allows to activate a holiday.

+

Only the active holidays are considered for rescheduling the loan repayment.

+
+
+ +POST https://DomainName/api/v1/holidays/{holidayId}?command=activate + + +POST holidays +Content-Type: application/json +Request Body: +{ +} + + +{ +"resourceId": 1 +} + +
+
+ +   +
+
+

Retrieve a Holiday

+

Example Requests:

+
holidays/1
+
+
+
+ +GET https://DomainName/api/v1/holidays/{holidayId} + + +{ + "id": 1, + "name": "Good Friday", + "fromDate": [ + 2013, + 10, + 25 + ], + "toDate": [ + 2013, + 10, + 25 + ], + "repaymentsRescheduledTo": [ + 2013, + 10, + 26 + ] +} + +
+
+ +   +
+
+

Update a Holiday

+

If a holiday is in pending state (created and not activated) then all fields are allowed to modify. Once holidays become active only name and descriptions are allowed to modify.

+
+
+ +PUT https://DomainName/api/v1/holidays/{holidayId} + + +PUT holidays/1 +Content-Type: application/json +Request Body: +{ + name:"Independence day", + description: "Holiday for Independence day celebration" +} + + +{ + "resourceId": 1, + "changes": { + "name": "Independence day", + "description": "Holiday for Independence day celebration" + } +} + +
+
+ +   +
+
+

Delete a Holiday

+

This API allows to delete a holiday. This is a soft delete the deleted holiday status is marked as deleted.

+
+
+ +DELETE https://DomainName/api/v1/holidays/{holidayId} + + +DELETE holidays/1 +Content-Type: application/json +Request Body: +{ +} + + +{ + "resourceId": 1 }
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayData.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayData.java index f31f6f9a5..f6f648326 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayData.java @@ -9,6 +9,8 @@ public class HolidayData { @SuppressWarnings("unused") private final String name; @SuppressWarnings("unused") + private final String description; + @SuppressWarnings("unused") private final LocalDate fromDate; @SuppressWarnings("unused") private final LocalDate toDate; @@ -17,10 +19,11 @@ public class HolidayData { @SuppressWarnings("unused") private final Long officeId; - public HolidayData(final Long id, final String name, final LocalDate fromDate, final LocalDate toDate, + public HolidayData(final Long id, final String name, final String description, final LocalDate fromDate, final LocalDate toDate, final LocalDate repaymentsRescheduledTo) { this.id = id; this.name = name; + this.description = description; this.fromDate = fromDate; this.toDate = toDate; this.repaymentsRescheduledTo = repaymentsRescheduledTo; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java index 0867c7350..395a3228e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java @@ -38,7 +38,7 @@ public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformServic public HolidayMapper() { final StringBuilder sqlBuilder = new StringBuilder(200); - sqlBuilder.append("h.id as id, h.name as name, h.from_date as fromDate, h.to_date as toDate, "); + sqlBuilder.append("h.id as id, h.name as name, h.description as description, h.from_date as fromDate, h.to_date as toDate, "); sqlBuilder.append("h.repayments_rescheduled_to as repaymentsScheduleTO "); sqlBuilder.append("from m_holiday h "); this.schema = sqlBuilder.toString(); @@ -52,11 +52,12 @@ public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformServic public HolidayData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { final Long id = rs.getLong("id"); final String name = rs.getString("name"); + final String description = rs.getString("description"); final LocalDate fromDate = JdbcSupport.getLocalDate(rs, "fromDate"); final LocalDate toDate = JdbcSupport.getLocalDate(rs, "toDate"); final LocalDate repaymentsScheduleTO = JdbcSupport.getLocalDate(rs, "repaymentsScheduleTO"); - return new HolidayData(id, name, fromDate, toDate, repaymentsScheduleTO); + return new HolidayData(id, name, description, fromDate, toDate, repaymentsScheduleTO); } } @@ -104,7 +105,7 @@ public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformServic try { final HolidayMapper rm = new HolidayMapper(); - final String sql = rm.schema() + " where h.id = ?"; + final String sql = " select " + rm.schema() + " where h.id = ?"; return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { holidayId }); } catch (final EmptyResultDataAccessException e) {