diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index cd3fce57e..833aa2445 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -1035,6 +1035,46 @@ Update a Code Value Delete a Code Value + + Audits + audits + + List Audits + + + + + + audits/{auditId} + + Retrieve an Audit Entry + + + + + Makercheckers + makercheckers + + List Maker Checker Entries + + + + + + makercheckers/{auditId} + + + + Delete Maker Checker Entry + + + + makercheckers/{auditId}?command=approve + Approve Maker Checker Entry + + + + @@ -7010,18 +7050,277 @@ Content-Type: application/json - -   + +  
-

Funds

-

Simple implementation of funds. At present funds can - optionally be associated with a Loan.

-

This information can then be used to produce reports on - loans/loan amounts drawn from a fund.

+

Audits

+

+

+   +
+
+

List Audits

+

+

Example Requests:

+
audits
+
+
+ +GET https://DomainName/api/v1/audits + + +[ + { + "id": 671, + "actionName": "PERMISSIONS", + "entityName": "ROLE", + "resourceId": 6, + "maker": "keithwoodlock", + "madeOnDate": 1365014262000, + "processingResult": "processed" + }, + { + "id": 670, + "actionName": "CREATE", + "entityName": "CLIENTNOTE", + "resourceId": 287, + "maker": "keithwoodlock", + "madeOnDate": 1365014204000, + "processingResult": "awaiting.approval", + "officeName": "my office", + "clientName": "gg ggg" + }, + { + "id": 668, + "actionName": "UPDATE", + "entityName": "PERMISSION", + "maker": "keithwoodlock", + "madeOnDate": 1365014186000, + "processingResult": "processed" + }, + { + "id": 667, + "actionName": "CREATE", + "entityName": "CLIENTNOTE", + "resourceId": 286, + "maker": "keithwoodlock", + "madeOnDate": 1365014169000, + "processingResult": "processed", + "officeName": "my office name", + "clientName": "gg ggg" + }, + { + "id": 666, + "actionName": "CREATE", + "entityName": "CLIENT", + "resourceId": 363, + "maker": "keithwoodlock", + "madeOnDate": 1365012843000, + "processingResult": "awaiting.approval", + "officeName": "my office name" + }, + { + "id": 657, + "actionName": "CREATE", + "entityName": "CLIENT", + "resourceId": 362, + "maker": "ii", + "madeOnDate": 1364953928000, + "checker": "ii", + "checkedOnDate": 1365010060000, + "processingResult": "processed", + "officeName": "my office name", + "clientName": "gg ggg" + }, + { + "id": 645, + "actionName": "CREATE", + "entityName": "LOAN", + "resourceId": 373, + "maker": "keithwoodlock", + "madeOnDate": 1364860260000, + "checker": "keithwoodlock", + "checkedOnDate": 1364861222000, + "processingResult": "processed", + "officeName": "another office", + "clientName": "another client", + "loanAccountNo": "000000373" + },... + ] + +
+
+ + +   +
+
+

Audit Search Template

+

This is a convenience resource. It can be useful when + building an Audit Search UI. "appUsers" are data scoped to + the office/branch the requestor is associated with. +

+

Example Requests:

+
audits/searchtemplate
+
audits/searchtemplate?fields=actionNames
+
+
+ +GET https://DomainName/api/v1/audits/searchtemplate + + +{ + "appUsers": [ + { + "id": 30, + "username": "user 1" + }, + { + "id": 28, + "username": "user 2" + }, + { + "id": 35, + "username": "user 3" + },... + ], + "actionNames": [ + "CREATE", + "DELETE", + "UPDATE", + "ACTIVATE", + "ADJUST", + "APPROVALUNDO", + "APPROVE", + "APPROVEINPAST", + "BULKREASSIGN", + "CALCULATEINTEREST", + "CLOSE", + "CLOSEASRESCHEDULED", + "CREATEHISTORIC", + "DEPOSIT", + "DEREGISTER", + "DISBURSALUNDO", + "DISBURSE", + "DISBURSEINPAST", + "INTEREST", + "PERMISSIONS", + "REGISTER", + "REJECT",... + ], + "entityNames": [ + "CALENDAR", + "CENTER", + "CHARGE", + "CLIENT", + "CLIENTIDENTIFIER", + "CLIENTIMAGE", + "CLIENTNOTE", + "CODE", + "CODEVALUE", + "COLLATERAL", + "CONFIGURATION", + "CURRENCY", + "DATATABLE", + "DEPOSITACCOUNT", + "DEPOSITNOTE", + "DEPOSITPRODUCT", + "DOCUMENT", + "FUND", + "GLACCOUNT", + "GLCLOSURE", + "GROUP", + "GROUPNOTE",... + ], + "processingResults": [ + { + "id": 0, + "processingResult": "invalid" + }, + { + "id": 1, + "processingResult": "processed" + }, + { + "id": 2, + "processingResult": "awaiting.approval" + }, + { + "id": 3, + "processingResult": "rejected" + } + ] +} + +
+
+ + + + +   +
+
+

Maker Checker Search Template

+

This is a convenience resource. It can be useful when + building a Checker Inbox UI. "appUsers" are data scoped to + the office/branch the requestor is associated with. + "actionNames" and "entityNames" returned are those that the + requestor has Checker approval permissions for. +

+

Example Requests:

+
makercheckers/searchtemplate
+
makercheckers/searchtemplate?fields=entityNames
+
+
+ +GET https://DomainName/api/v1/audits/searchtemplate + + +{ + "appUsers": [ + { + "id": 30, + "username": "user 1" + }, + { + "id": 28, + "username": "user 2" + }, + { + "id": 35, + "username": "user 3" + },... + ], + "actionNames": [ + "CREATE", + "DELETE", + "UPDATE", + "ACTIVATE", + "ADJUST", + "APPROVALUNDO", + "APPROVE",... + ], + "entityNames": [ + "CALENDAR", + "CENTER", + "CHARGE", + "CLIENT", + "CLIENTIDENTIFIER",... + ] +} + +
+
+ +  
@@ -12686,6 +12985,46 @@ GET https://DomainName/api/v1/search?query=000000111 Update a Code Value Delete a Code Value + + Audits + audits + + List Audits + + + + + + audits/{auditId} + + Retrieve an Audit Entry + + + + + Makercheckers + makercheckers + + List Maker Checker Entries + + + + + + makercheckers/{auditId} + + + + Delete Maker Checker Entry + + + + makercheckers/{auditId}?command=approve + Approve Maker Checker Entry + + + + Funds funds diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java index f76d226a6..d2b99c5eb 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java @@ -39,10 +39,12 @@ import org.springframework.stereotype.Component; public class AuditsApiResource { private final Set RESPONSE_DATA_PARAMETERS = new HashSet( - Arrays.asList("id", "actionName", "entityName", "resourceId", "subresourceId", - "maker", "madeOnDate", "checker", "checkedOnDate", "processingResult", - "commandAsJson", "officeName", "groupLevelName", "groupName", "clientName", "loanAccountNo", "savingsAccountNo")); - + Arrays.asList("id", "actionName", "entityName", "resourceId", + "subresourceId", "maker", "madeOnDate", "checker", + "checkedOnDate", "processingResult", "commandAsJson", + "officeName", "groupLevelName", "groupName", "clientName", + "loanAccountNo", "savingsAccountNo")); + private final String resourceNameForPermissions = "AUDIT"; private final PlatformSecurityContext context; @@ -79,14 +81,21 @@ public class AuditsApiResource { @QueryParam("checkerId") final Long checkerId, @QueryParam("checkerDateTimeFrom") final String checkerDateTimeFrom, @QueryParam("checkerDateTimeTo") final String checkerDateTimeTo, - @QueryParam("processingResult") final Integer processingResult) { + @QueryParam("processingResult") final Integer processingResult, + @QueryParam("officeId") final Integer officeId, + @QueryParam("groupId") final Integer groupId, + @QueryParam("clientId") final Integer clientId, + @QueryParam("loanid") final Integer loanId, + @QueryParam("savingsAccountId") final Integer savingsAccountId) { context.authenticatedUser().validateHasReadPermission( resourceNameForPermissions); final String extraCriteria = getExtraCriteria(actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo, - checkerId, checkerDateTimeFrom, checkerDateTimeTo, processingResult); + checkerId, checkerDateTimeFrom, checkerDateTimeTo, + processingResult, officeId, groupId, clientId, loanId, + savingsAccountId); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper .process(uriInfo.getQueryParameters()); @@ -133,7 +142,8 @@ public class AuditsApiResource { .retrieveSearchTemplate("audit"); final Set RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE = new HashSet( - Arrays.asList("appUsers", "actionNames", "entityNames", "processingResults")); + Arrays.asList("appUsers", "actionNames", "entityNames", + "processingResults")); return this.toApiJsonSerializerSearchTemplate.serialize(settings, auditSearchData, RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE); @@ -143,7 +153,10 @@ public class AuditsApiResource { final String entityName, final Long resourceId, final Long makerId, final String makerDateTimeFrom, final String makerDateTimeTo, final Long checkerId, final String checkerDateTimeFrom, - final String checkerDateTimeTo, final Integer processingResult) { + final String checkerDateTimeTo, final Integer processingResult, + final Integer officeId, final Integer groupId, + final Integer clientId, final Integer loanId, + final Integer savingsAccountId) { String extraCriteria = ""; @@ -183,9 +196,30 @@ public class AuditsApiResource { } if (processingResult != null) { - extraCriteria += " and aud.processing_result_enum = " + processingResult; + extraCriteria += " and aud.processing_result_enum = " + + processingResult; } - + + if (officeId != null) { + extraCriteria += " and aud.office_id = " + officeId; + } + + if (groupId != null) { + extraCriteria += " and aud.group_id = " + groupId; + } + + if (clientId != null) { + extraCriteria += " and aud.client_id = " + clientId; + } + + if (loanId != null) { + extraCriteria += " and aud.loan_id = " + loanId; + } + + if (savingsAccountId != null) { + extraCriteria += " and aud.savings_account_id = " + savingsAccountId; + } + if (StringUtils.isNotBlank(extraCriteria)) { extraCriteria = extraCriteria.substring(4); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/MakercheckersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/MakercheckersApiResource.java index 593d3e186..ea56aa620 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/MakercheckersApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/MakercheckersApiResource.java @@ -87,13 +87,19 @@ public class MakercheckersApiResource { @QueryParam("resourceId") final Long resourceId, @QueryParam("makerId") final Long makerId, @QueryParam("makerDateTimeFrom") final String makerDateTimeFrom, - @QueryParam("makerDateTimeTo") final String makerDateTimeTo) { + @QueryParam("makerDateTimeTo") final String makerDateTimeTo, + @QueryParam("officeId") final Integer officeId, + @QueryParam("groupId") final Integer groupId, + @QueryParam("clientId") final Integer clientId, + @QueryParam("loanid") final Integer loanId, + @QueryParam("savingsAccountId") final Integer savingsAccountId) { context.authenticatedUser().validateHasReadPermission( resourceNameForPermissions); final String extraCriteria = getExtraCriteria(actionName, entityName, - resourceId, makerId, makerDateTimeFrom, makerDateTimeTo); + resourceId, makerId, makerDateTimeFrom, makerDateTimeTo, + officeId, groupId, clientId, loanId, savingsAccountId); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper .process(uriInfo.getQueryParameters()); @@ -129,16 +135,16 @@ public class MakercheckersApiResource { } @POST - @Path("{commandId}") + @Path("{auditId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String approveMakerCheckerEntry( - @PathParam("commandId") final Long commandId, + @PathParam("auditId") final Long auditId, @QueryParam("command") final String commandParam) { CommandProcessingResult result = null; if (is(commandParam, "approve")) { - result = this.writePlatformService.approveEntry(commandId); + result = this.writePlatformService.approveEntry(auditId); } else { throw new UnrecognizedQueryParamException("command", commandParam); } @@ -152,13 +158,13 @@ public class MakercheckersApiResource { } @DELETE - @Path("{commandId}") + @Path("{auditId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String deleteMakerCheckerEntry( - @PathParam("commandId") final Long commandId) { + @PathParam("auditId") final Long auditId) { - final Long id = this.writePlatformService.deleteEntry(commandId); + final Long id = this.writePlatformService.deleteEntry(auditId); return this.toApiJsonSerializer.serialize(CommandProcessingResult .commandOnlyResult(id)); @@ -166,7 +172,10 @@ public class MakercheckersApiResource { private String getExtraCriteria(final String actionName, final String entityName, final Long resourceId, final Long makerId, - final String makerDateTimeFrom, final String makerDateTimeTo) { + final String makerDateTimeFrom, final String makerDateTimeTo, + final Integer officeId, final Integer groupId, + final Integer clientId, final Integer loanId, + final Integer savingsAccountId) { String extraCriteria = ""; @@ -194,6 +203,27 @@ public class MakercheckersApiResource { + ApiParameterHelper.sqlEncodeString(makerDateTimeTo); } + if (officeId != null) { + extraCriteria += " and aud.office_id = " + officeId; + } + + if (groupId != null) { + extraCriteria += " and aud.group_id = " + groupId; + } + + if (clientId != null) { + extraCriteria += " and aud.client_id = " + clientId; + } + + if (loanId != null) { + extraCriteria += " and aud.loan_id = " + loanId; + } + + if (savingsAccountId != null) { + extraCriteria += " and aud.savings_account_id = " + + savingsAccountId; + } + if (StringUtils.isNotBlank(extraCriteria)) { extraCriteria = extraCriteria.substring(4); }