start of work for deposit accounts.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
CREATE TABLE `portfolio_deposit_account` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`product_id` bigint(20) NOT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`minimum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`maximum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`tenure_months` int(11) NOT NULL,
|
||||
`maturity_default_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_min_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_max_interest_rate` decimal(19,6) NOT NULL,
|
||||
`can_renew` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`can_pre_close` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `deposit_acc_external_id` (`external_id`),
|
||||
KEY `FKKW0000000000001` (`client_id`),
|
||||
KEY `FKKW0000000000002` (`product_id`),
|
||||
CONSTRAINT `FKKW0000000000001` FOREIGN KEY (`client_id`) REFERENCES `portfolio_client` (`id`),
|
||||
CONSTRAINT `FKKW0000000000002` FOREIGN KEY (`product_id`) REFERENCES `portfolio_product_deposit` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.SavingProductCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.SavingProductData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.savingproduct.service.SavingProductReadPlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.SavingProductWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/depositaccounts")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class DepositAccountsApiResource {
|
||||
|
||||
@Autowired
|
||||
private SavingProductReadPlatformService savingProductReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private SavingProductWritePlatformService savingProductWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createDepositAccount(final String jsonRequestBody){
|
||||
|
||||
final SavingProductCommand command=this.apiDataConversionService.convertJsonToSavingProductCommand(null, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier=this.savingProductWritePlatformService.createSavingProduct(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateSavingProduct(@PathParam("productId") final Long productId, final String jsonRequestBody){
|
||||
|
||||
SavingProductCommand command=this.apiDataConversionService.convertJsonToSavingProductCommand(productId, jsonRequestBody);
|
||||
EntityIdentifier entityIdentifier=this.savingProductWritePlatformService.updateSavingProduct(command);
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllSavingProducts(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
|
||||
"interestRate","currencyCode","digitsAfterDecimal"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<SavingProductData> products = this.savingProductReadPlatformService.retrieveAllSavingProducts();
|
||||
|
||||
return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, products.toArray(new SavingProductData[products.size()]));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveSavingProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
|
||||
"interestRate","currencyCode","digitsAfterDecimal"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
if (template) {
|
||||
responseParameters.addAll(Arrays.asList("currencyOptions"));
|
||||
}
|
||||
|
||||
SavingProductData savingProduct = this.savingProductReadPlatformService.retrieveSavingProduct(productId);
|
||||
|
||||
return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, savingProduct);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewSavingProductDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","interestRate","currencyCode","digitsAfterDecimal", "currencyOptions"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
SavingProductData savingProduct = this.savingProductReadPlatformService.retrieveNewSavingProductDetails();
|
||||
|
||||
return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, savingProduct);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response deleteProduct(@PathParam("productId") final Long productId) {
|
||||
|
||||
this.savingProductWritePlatformService.deleteSavingProduct(productId);
|
||||
|
||||
return Response.ok(new EntityIdentifier(productId)).build();
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Immutable command used when create/renewing deposit accounts
|
||||
*/
|
||||
public class DepositAccountCommand {
|
||||
|
||||
private final Long id;
|
||||
private final String externalId;
|
||||
|
||||
private final String currencyCode;
|
||||
private final Integer digitsAfterDecimal;
|
||||
private final BigDecimal maturityActualInterestRate;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
public DepositAccountCommand(final Set<String> modifiedParameters,
|
||||
final Long id,
|
||||
final String externalId,
|
||||
final String currencyCode,
|
||||
final Integer digitsAfterDecimal,
|
||||
final BigDecimal maturityActualInterestRate) {
|
||||
this.id = id;
|
||||
this.externalId = externalId;
|
||||
this.currencyCode = currencyCode;
|
||||
this.digitsAfterDecimal = digitsAfterDecimal;
|
||||
this.maturityActualInterestRate = maturityActualInterestRate;
|
||||
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
public Integer getDigitsAfterDecimal() {
|
||||
return digitsAfterDecimal;
|
||||
}
|
||||
|
||||
public BigDecimal getMaturityActualInterestRate() {
|
||||
return maturityActualInterestRate;
|
||||
}
|
||||
|
||||
public boolean isCurrencyCodeChanged() {
|
||||
return this.modifiedParameters.contains("currencyCode");
|
||||
}
|
||||
|
||||
public boolean isDigitsAfterDecimalChanged() {
|
||||
return this.modifiedParameters.contains("digitsAfterDecimal");
|
||||
}
|
||||
|
||||
public boolean isMaturityActualInterestRateChanged() {
|
||||
return this.modifiedParameters.contains("interestRate");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user