diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 7102c41b4..781539785 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -470,6 +470,22 @@ + + Loan Charges + loans/{loanId}/charges + Add a Loan Charge + + + + + + + loans/{loanId}/charges/{loanChargeId} + + Retrieve a Loan Charge + Modify a Loan Charge + Delete a Loan Charge + Loan Guarantors loans/{loanId}/guarantors @@ -1529,7 +1545,7 @@ function executeAjaxRequest(url, verbType, jsonData, basicAuthKey, successFuncti Error Message returned when attempting to create an Office without passing any parameters { "developerMessage": "The request was invalid. This typically will happen due to validation errors which are provided.", -"developerDocLink": "https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes", +"developerDocLink": "https://github.com/openMF/mifosx/wiki/HTTP-API-Error-codes", "httpStatusCode": "400", "defaultUserMessage": "Validation errors exist.", "userMessageGlobalisationCode": "validation.msg.validation.errors.exist", @@ -4260,255 +4276,7 @@ Request Body: - -   -
-
-

Loan Charges

-

Loan charges can be fees or penalities. They can be defined using the charges api and associated with loan products.

-

- - - - - - - - - - - - - - - - - - - - - - -
Field Descriptions
chargeId
The id of the charge definition.
amount
The flat amount or percenatge amount of the charge. (depending on its type)
dueDate
The date the loan charge is due for collection. Relevant for charges defined as specified due date.
-
-
- -   -
-
-

Retrieve Loan Charge Template

-

This is a convenience resource. It can be useful when - building maintenance user interface screens for client - applications. The template data returned consists of any or all - of: -

-

-

Example Request:

-
loans/1/charges/template
-
-
- -GET https://DomainName/api/v1/loans/{loanId}/charges/template - - -{ - { - "amountPaid": 0, - "amountWaived": 0, - "amountWrittenOff": 0, - "chargeOptions": [ - { - "id": 1, - "name": "Bank Fee (per installment)", - "active": true, - "penalty": false, - "currency": { - "code": "UGX", - "name": "Uganda Shilling", - "decimalPlaces": 2, - "displaySymbol": "USh", - "nameCode": "currency.UGX", - "displayLabel": "Uganda Shilling (USh)" - }, - "amount": 1500, - "chargeTimeType": { - "id": 2, - "code": "chargeTimeType.specifiedDueDate", - "value": "Specified due date" - }, - "chargeAppliesTo": { - "id": 1, - "code": "chargeAppliesTo.loan", - "value": "Loan" - }, - "chargeCalculationType": { - "id": 1, - "code": "chargeCalculationType.flat", - "value": "Flat" - } - } - ], - "penalty": false -} -} - -
-
- -   -
-
-

Create a Loan Charge

- - - - - - - -
Mandatory Fields
chargeId, amount, dueDate (depending on chargeTimeType of charge definition)
-
-
- -POST https://DomainName/api/v1//loans/{loanId}/charges - - -POST /loans/1/charges -Content-Type: application/json -Request Body: -{ - "locale": "en", - "dateFormat": "dd MMMM yyyy", - "chargeId": 1, - "amount": "333", - "dueDate": "21 November 2011" -} - - -{ - "officeId": 1, - "clientId": 1, - "loanId": 1, - "resourceId": 14 -} - -
-
- -   -
-
-

Update a Loan Charge

-
-
- -PUT https://DomainName/api/v1//loans/{loanId}/charges/{loanChargeId} - - -PUT /loans/1/charges/14 -Content-Type: application/json -Request Body: -{ - "locale": "en", - "amount": "650" -} - - -{ - "officeId": 1, - "clientId": 1, - "loanId": 1, - "resourceId": 14, - "changes": { - "amount": 650, - "locale": "en" - } -} - -
-
- -   -
-
-

Delete a Loan Charge

-
-
- -DELETE https://DomainName/api/v1//loans/{loanId}/charges/{loanChargeId} - - -DELETE /loans/1/charges/14 -Content-Type: application/json - - -{ - "officeId": 1, - "clientId": 1, - "loanId": 1, - "resourceId": 14 -} - -
-
- -   -
-
-

Retrieve a Loan Charge

-
-
- -GET https://DomainName/api/v1//loans/{loanId}/charges/{loanChargeId} - - -GET /loans/1/charges/1 -Content-Type: application/json - - -{ - "id": 14, - "chargeId": 1, - "name": "Bank Fee (per installment)", - "chargeTimeType": { - "id": 2, - "code": "chargeTimeType.specifiedDueDate", - "value": "Specified due date" - }, - "dueDate": [ - 2011, - 11, - 21 - ], - "chargeCalculationType": { - "id": 1, - "code": "chargeCalculationType.flat", - "value": "Flat" - }, - "percentage": 0, - "amountPercentageAppliedTo": 0, - "currency": { - "code": "UGX", - "name": "Uganda Shilling", - "decimalPlaces": 2, - "displaySymbol": "USh", - "nameCode": "currency.UGX", - "displayLabel": "Uganda Shilling (USh)" - }, - "amount": 650, - "amountPaid": 0, - "amountWaived": 0, - "amountWrittenOff": 0, - "amountOutstanding": 650, - "amountOrPercentage": 650, - "penalty": false -} - -
-
+  
@@ -5116,6 +4884,431 @@ No Request Body:
+ +   +
+
+

Loan Charges

+

Its typical for MFIs to add extra costs for their loan products. They + can be either Fees or Penalties.

+

Loan Charges are instances of Charges and + represent either fees and penalties for loan products. Refer Charges + for documentation of the various properties of a charge, Only additional properties ( + specific to the context of a Charge being associated with a Loan) are + described here

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field Descriptions
amountPaid
The Total amount which has been paid for this Charge +
amountWaived
The Total amount that has been waived for this Charge +
amountWrittenOff
Total amount written off from this Charge +
amountOutstanding
The Total outstanding amount for this Charge +
+
+
+ +   +
+
+

List Loan Charges

+

Example Requests:

+
loans/1/charges
+
+
+
loans/1/charges?fields=name,amountOrPercentage
+
+
+ +GET https://DomainName/api/v1/loans/{loanId}/charges + + +[ + { + "id": 1, + "chargeId": 1, + "name": "Loan Processing fee", + "chargeTimeType": { + "id": 1, + "code": "chargeTimeType.disbursement", + "value": "Disbursement" + }, + "chargeCalculationType": { + "id": 1, + "code": "chargeCalculationType.flat", + "value": "Flat" + }, + "percentage": 0, + "amountPercentageAppliedTo": 0, + "currency": { + "code": "USD", + "name": "US Dollar", + "decimalPlaces": 2, + "displaySymbol": "$", + "nameCode": "currency.USD", + "displayLabel": "US Dollar ($)" + }, + "amount": 100, + "amountPaid": 0, + "amountWaived": 0, + "amountWrittenOff": 0, + "amountOutstanding": 100, + "amountOrPercentage": 100, + "penalty": false + }, + { + "id": 7, + "chargeId": 2, + "name": "Collection Fee", + "chargeTimeType": { + "id": 2, + "code": "chargeTimeType.specifiedDueDate", + "value": "Specified due date" + }, + "dueDate": [ + 2013, + 3, + 29 + ], + "chargeCalculationType": { + "id": 1, + "code": "chargeCalculationType.flat", + "value": "Flat" + }, + "percentage": 0, + "amountPercentageAppliedTo": 0, + "currency": { + "code": "USD", + "name": "US Dollar", + "decimalPlaces": 2, + "displaySymbol": "$", + "nameCode": "currency.USD", + "displayLabel": "US Dollar ($)" + }, + "amount": 100, + "amountPaid": 0, + "amountWaived": 0, + "amountWrittenOff": 0, + "amountOutstanding": 100, + "amountOrPercentage": 100, + "penalty": false + } +] + +
+
+ +   +
+
+

Retrieve Loan Charges Template

+

This is a convenience resource. It can be useful when + building maintenance user interface screens for client + applications. The template data returned consists of any or all + of: +

+

+

Example Request:

+
loans/1/charges/template
+
+
+ +GET https://DomainName/api/v1/loans/{loanId}/charges/template + + +{ + "amountPaid": 0, + "amountWaived": 0, + "amountWrittenOff": 0, + "chargeOptions": [ + { + "id": 2, + "name": "Collection Fee", + "active": true, + "penalty": false, + "currency": { + "code": "USD", + "name": "US Dollar", + "decimalPlaces": 2, + "displaySymbol": "$", + "nameCode": "currency.USD", + "displayLabel": "US Dollar ($)" + }, + "amount": 100, + "chargeTimeType": { + "id": 2, + "code": "chargeTimeType.specifiedDueDate", + "value": "Specified due date" + }, + "chargeAppliesTo": { + "id": 1, + "code": "chargeAppliesTo.loan", + "value": "Loan" + }, + "chargeCalculationType": { + "id": 1, + "code": "chargeCalculationType.flat", + "value": "Flat" + } + }, + { + "id": 3, + "name": "Late payment penalty", + "active": true, + "penalty": true, + "currency": { + "code": "USD", + "name": "US Dollar", + "decimalPlaces": 2, + "displaySymbol": "$", + "nameCode": "currency.USD", + "displayLabel": "US Dollar ($)" + }, + "amount": 1, + "chargeTimeType": { + "id": 2, + "code": "chargeTimeType.specifiedDueDate", + "value": "Specified due date" + }, + "chargeAppliesTo": { + "id": 1, + "code": "chargeAppliesTo.loan", + "value": "Loan" + }, + "chargeCalculationType": { + "id": 1, + "code": "chargeCalculationType.flat", + "value": "Flat" + } + }, + { + "id": 1, + "name": "Loan Processing fee", + "active": true, + "penalty": false, + "currency": { + "code": "USD", + "name": "US Dollar", + "decimalPlaces": 2, + "displaySymbol": "$", + "nameCode": "currency.USD", + "displayLabel": "US Dollar ($)" + }, + "amount": 100, + "chargeTimeType": { + "id": 1, + "code": "chargeTimeType.disbursement", + "value": "Disbursement" + }, + "chargeAppliesTo": { + "id": 1, + "code": "chargeAppliesTo.loan", + "value": "Loan" + }, + "chargeCalculationType": { + "id": 1, + "code": "chargeCalculationType.flat", + "value": "Flat" + } + } + ], + "penalty": false +} + +
+
+ +   +
+
+

Retrieve a Loan Charge

+

Example Requests:

+
/loans/1/charges/1
+
+
+
/loans/1/charges/1?fields=name,amountOrPercentage
+
+
+ +GET https://DomainName/api/v1/loans/{loanId}/charges/{chargeId} + + +{ + "id": 1, + "chargeId": 1, + "name": "Loan Processing fee", + "chargeTimeType": { + "id": 1, + "code": "chargeTimeType.disbursement", + "value": "Disbursement" + }, + "chargeCalculationType": { + "id": 1, + "code": "chargeCalculationType.flat", + "value": "Flat" + }, + "percentage": 0, + "amountPercentageAppliedTo": 0, + "currency": { + "code": "USD", + "name": "US Dollar", + "decimalPlaces": 2, + "displaySymbol": "$", + "nameCode": "currency.USD", + "displayLabel": "US Dollar ($)" + }, + "amount": 100, + "amountPaid": 0, + "amountWaived": 0, + "amountWrittenOff": 0, + "amountOutstanding": 100, + "amountOrPercentage": 100, + "penalty": false +} +
+
+ +   +
+
+

Create a Loan Charge

+ + + + + + + +
Mandatory Fields + for Loan Charges
chargeId, amount, dueDate
+
+
+ +POST https://DomainName/api/v1/loans/{loanId}/charges + + +POST /loans/1/charges +Content-Type: application/json +Request Body: +{ + "chargeId": "2", + "locale": "en", + "amount": "100", + "dateFormat": "dd MMMM yyyy", + "dueDate": "29 April 2013" +} + + +{ + "officeId": 1, + "clientId": 1, + "loanId": 1, + "resourceId": 31 +} + +
+
+ +   +
+
+

Update a Loan Charge

+

Currently Loan Charges may be updated only if the Loan + is not yet approved +

+
+
+ +PUT https://DomainName/api/v1/loans/{loanId}/charges/{chargeId} + + +PUT loans/1/charges/12 +Content-Type: application/json +Request Body: +{ + "dateFormat": "dd MMMM yyyy", + "locale": "en", + "amount": "60", + "dueDate": "27 March 2013" +} + + +{ + "officeId": 1, + "clientId": 1, + "loanId": 1, + "resourceId": 6, + "changes": { + "dueDate": "27 March 2013", + "dateFormat": "dd MMMM yyyy", + "locale": "en", + "amount": 60.0 + } +} + +
+
+ +   +
+
+

Delete a Loan Charge

+

+ Note:Currently, A Loan Charge may only be removed from Loans that are not + yet approved. +

+
+
+ +DELETE https://DomainName/api/v1/loans/{loanId}/charges/{chargeId} + + +DELETE loans/1/charges/2 +Content-Type: application/json +No Request Body: + + +{ + "officeId": 1, + "clientId": 1, + "loanId": 1, + "resourceId": 2 +} + +
+
+  
@@ -6808,7 +7001,7 @@ Request Body:

Staff

Allows you to model staff members. At present the key role - of signifigance is whether this staff member is a loan officer or + of significance is whether this staff member is a loan officer or not.

@@ -6925,21 +7118,156 @@ Request Body: - +  

Charges

- Its typical for MFIs to add extra costs to their financial - products. There are typically Fees or Penalites. + Its typical for MFIs to add extra costs for their financial + products. There are typically Fees or Penalties.

-

Charges is what we use to model both fees and penalities. +

Charges is what we use to model both fees and penalties. For now charges can only be associated with loan products / loans.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field Descriptions
name
Name associated with this charge.
active
Boolean flag determines if the Charge is currently active.
penalty
Boolean flag determines if the Charge is a penalty.
currency
Details of the currency associated with this charge. + Refer Charges Template for additional details
amount
Field holds the details of the actual amount to be collected + in the case of "Flat Charges" or the percentage amount to be collected in + case of "Percentage Amount Charges". Refer Charges Template + for details of the Available Charge Types
chargeTimeType
The time at which the charge becomes Due. + Refer Charges Template for additional details
chargeAppliesTo
The Entity for which the charge can be applied (Loans etc). + Refer Charges Template for additional details
chargeCalculationType
Rules for calculating the amount for a particular Charge. + Refer Charges Template for additional details
-   +   +
+
+

Retrieve Charges Details Template

+

This is a convenience resource. It can be useful when + building maintenance user interface screens for client + applications. The template data returned consists of any or all + of: +

+

+

Example Request:

+
charges/template
+
+
+ +GET https://DomainName/api/v1/charges/template + + +{ + "active": false, + "penalty": false, + "currencyOptions": + [ + { + "code": "USD", + "name": "US Dollar", + "decimalPlaces": 2, + "displaySymbol": "$", + "nameCode": "currency.USD", + "displayLabel": "US Dollar ($)" + } + ], + "chargeCalculationTypeOptions": + [ + { + "id": 1, + "code": "chargeCalculationType.flat", + "value": "Flat" + }, + { + "id": 2, + "code": "chargeCalculationType.percent.of.amount", + "value": "% Amount" + } + ], + "chargeAppliesToOptions": + [ + { + "id": 1, + "code": "chargeAppliesTo.loan", + "value": "Loan" + } + ], + "chargeTimeTypeOptions": + [ + { + "id": 1, + "code": "chargeTimeType.disbursement", + "value": "Disbursement" + }, + { + "id": 2, + "code": "chargeTimeType.specifiedDueDate", + "value": "Specified due date" + } + ] +} + +
+
+ +  

Create/Define a Charge

@@ -6965,7 +7293,32 @@ Request Body: "active": true } - { "resourceId": 1 } + +{ + "resourceId": 1 +} + + +POST charges +Content-Type: application/json +Request Body: +{ + "locale": "en", + "name": "Default Penalty", + "amount": "2", + "currencyCode": "USD", + "chargeAppliesTo": "1", + "chargeTimeType": "2", + "chargeCalculationType": "2", + "active": "true", + "penalty": "true" +} + + +{ + "resourceId": 4 +} +
@@ -7118,8 +7471,8 @@ Content-Type: application/json

Savings Product:

-

An MFIs savings product offerings are modelled using this API.

-

When creating savings accounts, the details from the savings product are used to autofill details of savings account.

+

An MFIs savings product offerings are modeled using this API.

+

When creating savings accounts, the details from the savings product are used to auto fill details of savings account.

@@ -7130,7 +7483,7 @@ Content-Type: application/json - + @@ -7724,7 +8077,7 @@ Request Body:

Arguments

associations
-
optional, Either 'all' or a comma separated list of savings 'associations' (itemised below).
+
optional, Either 'all' or a comma separated list of savings 'associations' (itemized below).

Associations are just extra pieces of data that you might or might not want to retrieve.

'all': Gets data related to all associations e.g. ?associations=all.
'transactions': Gets data related to transactions on the account e.g. ?associations=transactions
@@ -7813,7 +8166,7 @@ No Request Body:

Delete a Savings Account

-

At present we support hard delete of savings account but this is likely to change to a savings account closure or de-activation process/command.

+

At present we support hard delete of savings account but this is likely to change to a savings account closure or De-activation process/command.

DELETE https://Domain Name/api/v1/savingsaccounts/{accountsId} @@ -7959,7 +8312,7 @@ No Request Body: 'plugged-in' table. The API checks for permission and for 'data scoping' (only data within the users' office hierarchy can be managed by the user).

-

The Mifos X Reference App uses a JQuery plugin called +

The Mifos X Reference App uses a JQuery plug-in called stretchydatatables (which in turn uses this datatables resource) to provide a pretty flexible CRUD (Create, Read, Update, Delete) User Interface.

@@ -9927,7 +10280,7 @@ No Request Body { "developerMessage": "Invalid authentication details were passed in api request.", - "developerDocLink": "https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes", + "developerDocLink": "https://github.com/openMF/mifosx/wiki/HTTP-API-Error-codes", "httpStatusCode": "401", "defaultUserMessage": "Unauthenticated. Please login.", "userMessageGlobalisationCode": "error.msg.not.authenticated", @@ -11720,7 +12073,7 @@ Content-Type: application/json
- + diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java index ee4fb02a9..a0734d319 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java @@ -77,6 +77,19 @@ public class LoanChargesApiResource { return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue); } + @GET + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String retrieveAllLoanCharges(@PathParam("loanId") final Long loanId, @Context final UriInfo uriInfo) { + + context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions); + + final Collection loanCharges = this.loanChargeReadPlatformService.retrieveLoanCharges(loanId); + + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return this.toApiJsonSerializer.serialize(settings, loanCharges, RESPONSE_DATA_PARAMETERS); + } + @GET @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @@ -94,10 +107,10 @@ public class LoanChargesApiResource { } @GET - @Path("{loanChargeId}") + @Path("{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("loanChargeId") final Long loanChargeId, + public String retrieveLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId, @Context final UriInfo uriInfo) { context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions); @@ -121,10 +134,10 @@ public class LoanChargesApiResource { } @PUT - @Path("{loanChargeId}") + @Path("{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("loanChargeId") final Long loanChargeId, + public String updateLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId, final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanCharge(loanId, loanChargeId)
Field Descriptions
A description of the product offering.
currencyCode
Three letter ISO code reprsenting currency.
Three letter ISO code representing currency.
digitsAfterDecimal
Override the currency default value for digitsAfterDecimal.
Loan Charges loans/{loanId}/chargesAdd a loan chargeAdd a Loan Charge