Merge remote-tracking branch 'madhukar/MIFOSX-43-Final'

This commit is contained in:
Madhukar
2012-12-08 01:04:57 +00:00
committed by Keith Woodlock
30 changed files with 363 additions and 144 deletions
@@ -1,3 +1,4 @@
DROP TABLE IF EXISTS `m_saving_schedule`; DROP TABLE IF EXISTS `m_saving_schedule`;
CREATE TABLE `m_saving_schedule` ( CREATE TABLE `m_saving_schedule` (
`id` bigint(20) NOT NULL AUTO_INCREMENT, `id` bigint(20) NOT NULL AUTO_INCREMENT,
@@ -0,0 +1,5 @@
ALTER TABLE `m_deposit_account`
ADD COLUMN `available_interest` decimal(19,6) DEFAULT '0.000000' AFTER `is_interest_withdrawable`,
ADD COLUMN `interest_posted_amount` decimal(19,6) DEFAULT '0.000000' AFTER `available_interest`,
ADD COLUMN `last_interest_posted_date` date DEFAULT NULL AFTER `interest_posted_amount`,
ADD COLUMN `next_interest_posting_date` date DEFAULT NULL AFTER `last_interest_posted_date`;
@@ -0,0 +1,19 @@
drop table if exists extra_client_details;
CREATE TABLE `extra_client_details` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`client_id` bigint(20) NOT NULL,
`client_dob` date DEFAULT NULL,
`client_address` varchar(60) DEFAULT NULL,
`father_name` varchar(40) DEFAULT NULL,
`nominee` varchar(40) DEFAULT NULL,
`nominee_relationship` varchar(40) DEFAULT NULL,
`nominee_address` varchar(60) DEFAULT NULL,
`crime_no` varchar(40) DEFAULT NULL,
`police_station` varchar(40) DEFAULT NULL,
`other_notes` text,
PRIMARY KEY (`id`),
UNIQUE KEY `client_id` (`client_id`),
KEY `FK_extra_client_details_1` (`client_id`),
CONSTRAINT `FK_extra_client_details` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -59,7 +59,8 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
"interestCompoundedEveryPeriodType", "renewalAllowed", "preClosureAllowed", "preClosureInterestRate", "withdrawnonDate", "interestCompoundedEveryPeriodType", "renewalAllowed", "preClosureAllowed", "preClosureInterestRate", "withdrawnonDate",
"rejectedonDate", "closedonDate", "transactions", "permissions", "isInterestWithdrawable", "interestPaid", "rejectedonDate", "closedonDate", "transactions", "permissions", "isInterestWithdrawable", "interestPaid",
"interestCompoundingAllowed", "availableInterestForWithdrawal", "availableWithdrawalAmount", "todaysDate", "interestCompoundingAllowed", "availableInterestForWithdrawal", "availableWithdrawalAmount", "todaysDate",
"isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType")); "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType", "printFDdetailsLocation","availableInterest", "interestPostedAmount",
"lastInterestPostedDate", "nextInterestPostedDate","fatherName","address","imageKey"));
private static final Set<String> DOCUMENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "parentEntityType", private static final Set<String> DOCUMENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "parentEntityType",
"parentEntityId", "name", "fileName", "type", "size", "description")); "parentEntityId", "name", "fileName", "type", "size", "description"));
@@ -296,4 +297,5 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
prettyPrint, responseParameters); prettyPrint, responseParameters);
return helper.serializedJsonFrom(gsonDeserializer, savingScheduleData); return helper.serializedJsonFrom(gsonDeserializer, savingScheduleData);
} }
} }
@@ -77,4 +77,5 @@ public interface PortfolioApiJsonSerializerService {
String serializeSavingScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingScheduleData savingScheduleData); String serializeSavingScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingScheduleData savingScheduleData);
} }
@@ -1,5 +1,6 @@
package org.mifosplatform.infrastructure.core.data; package org.mifosplatform.infrastructure.core.data;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
@@ -38,6 +39,7 @@ public class EntityIdentifier {
public EntityIdentifier(final Long entityId) { public EntityIdentifier(final Long entityId) {
this.entityId = entityId; this.entityId = entityId;
this.changes = new HashMap<String, Object>();
} }
private EntityIdentifier(final Long entityId, final Long makerCheckerId, final Map<String, Object> changesOnly) { private EntityIdentifier(final Long entityId, final Long makerCheckerId, final Map<String, Object> changesOnly) {
@@ -143,37 +143,41 @@ public class SavingsAccountApiResource {
if (responseParameters.isEmpty()) { if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters); responseParameters.addAll(typicalResponseParameters);
} }
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
SavingAccountData account = this.savingAccountReadPlatformService.retrieveSavingsAccount(accountId);
return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account); boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
}
@SuppressWarnings("unused") SavingAccountData account = this.savingAccountReadPlatformService.retrieveSavingsAccount(accountId);
@GET
@Path("template")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String retrieveNewDepositAccountDetails(@QueryParam("clientId") final Long clientId,
@QueryParam("productId") final Long productId, @Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(entityType); return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account);
}
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); @SuppressWarnings("unused")
if (responseParameters.isEmpty()) { @GET
responseParameters.addAll(typicalResponseParameters); @Path("template")
} @Consumes({MediaType.APPLICATION_JSON})
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); @Produces({MediaType.APPLICATION_JSON})
public String retrieveNewDepositAccountDetails(
@QueryParam("clientId") final Long clientId,
@QueryParam("productId") final Long productId,
@Context final UriInfo uriInfo) {
SavingAccountData account = null; context.authenticatedUser().validateHasReadPermission(entityType);
// this.savingAccountReadPlatformService.retrieveNewSavingsAccountDetails(clientId,
// productId);
return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
} if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters);
}
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
SavingAccountData account = null;
// this.savingAccountReadPlatformService.retrieveNewSavingsAccountDetails(clientId, productId);
return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account);
}
private boolean is(final String commandParam, final String commandValue) { private boolean is(final String commandParam, final String commandValue) {
return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue); return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue);
} }
} }
@@ -56,4 +56,5 @@ public class CalculateSavingScheduleCommand {
return this.tenure; return this.tenure;
} }
} }
@@ -231,7 +231,6 @@ public class SavingAccountCommand {
public boolean isPartialDepositAllowedChanged() { public boolean isPartialDepositAllowedChanged() {
return this.modifiedParameters.contains("isPartialDepositAllowed"); return this.modifiedParameters.contains("isPartialDepositAllowed");
} }
public boolean isPayEveryChanged() { public boolean isPayEveryChanged() {
return this.modifiedParameters.contains("payEvery"); return this.modifiedParameters.contains("payEvery");
} }
@@ -39,4 +39,5 @@ public class SavingSchedulePeriodData {
return this.depositPaid; return this.depositPaid;
} }
} }
@@ -8,4 +8,6 @@ import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
public interface DepositScheduleDateGenerator { public interface DepositScheduleDateGenerator {
List<LocalDate> generate(LocalDate startDate, Integer paymentPeriods, Integer depositFrequency, PeriodFrequencyType depositFrequencyType); List<LocalDate> generate(LocalDate startDate, Integer paymentPeriods, Integer depositFrequency, PeriodFrequencyType depositFrequencyType);
} }
@@ -37,7 +37,7 @@ import org.mifosplatform.portfolio.savingsdepositproduct.domain.TenureTypeEnum;
import org.mifosplatform.useradministration.domain.AppUser; import org.mifosplatform.useradministration.domain.AppUser;
@Entity @Entity
@Table(name = "m_saving_account", uniqueConstraints = @UniqueConstraint(name = "saving_acc_external_id", columnNames = { "external_id" })) @Table(name = "m_saving_account", uniqueConstraints = @UniqueConstraint(name="saving_acc_external_id", columnNames = { "external_id" }))
public class SavingAccount extends AbstractAuditableCustom<AppUser, Long> { public class SavingAccount extends AbstractAuditableCustom<AppUser, Long> {
@ManyToOne @ManyToOne
@@ -63,3 +63,4 @@ public class SavingScheduleInstallments extends AbstractAuditableCustom<AppUser,
this.savingAccount = account; this.savingAccount = account;
} }
} }
@@ -4,6 +4,6 @@ import org.mifosplatform.portfolio.savingsaccount.command.CalculateSavingSchedul
import org.mifosplatform.portfolio.savingsaccount.data.SavingScheduleData; import org.mifosplatform.portfolio.savingsaccount.data.SavingScheduleData;
public interface CalculateSavingSchedule { public interface CalculateSavingSchedule {
SavingScheduleData calculateSavingSchedule(CalculateSavingScheduleCommand command); SavingScheduleData calculateSavingSchedule(CalculateSavingScheduleCommand command);
} }
@@ -45,4 +45,5 @@ public class DefaultDepositScheduleDateGenerator implements DepositScheduleDateG
return duePaymentPeriodDates; return duePaymentPeriodDates;
} }
} }
@@ -215,4 +215,5 @@ public class SavingAccountAssembler {
List<DepositAccountStatus> allowedDepositStatuses = Arrays.asList(DepositAccountStatus.values()); List<DepositAccountStatus> allowedDepositStatuses = Arrays.asList(DepositAccountStatus.values());
return new DepositLifecycleStateMachineImpl(allowedDepositStatuses); return new DepositLifecycleStateMachineImpl(allowedDepositStatuses);
} }
} }
@@ -48,4 +48,5 @@ public class SavingScheduleGenerator {
return new SavingScheduleData(currencyData, totalDeposit.getAmount(), periods); return new SavingScheduleData(currencyData, totalDeposit.getAmount(), periods);
} }
} }
@@ -1,5 +1,6 @@
package org.mifosplatform.portfolio.savingsdepositaccount.api; package org.mifosplatform.portfolio.savingsdepositaccount.api;
import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@@ -18,6 +19,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@@ -41,6 +43,7 @@ import org.mifosplatform.portfolio.savingsdepositaccount.data.DepositAccountsFor
import org.mifosplatform.portfolio.savingsdepositaccount.data.DepositPermissionData; import org.mifosplatform.portfolio.savingsdepositaccount.data.DepositPermissionData;
import org.mifosplatform.portfolio.savingsdepositaccount.service.DepositAccountReadPlatformService; import org.mifosplatform.portfolio.savingsdepositaccount.service.DepositAccountReadPlatformService;
import org.mifosplatform.portfolio.savingsdepositaccount.service.DepositAccountWritePlatformService; import org.mifosplatform.portfolio.savingsdepositaccount.service.DepositAccountWritePlatformService;
import org.mifosplatform.portfolio.savingsdepositaccount.service.GeneratePDF;
import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductLookup; import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductLookup;
import org.mifosplatform.portfolio.savingsdepositproduct.service.DepositProductReadPlatformService; import org.mifosplatform.portfolio.savingsdepositproduct.service.DepositProductReadPlatformService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -76,7 +79,9 @@ public class DepositAccountsApiResource {
"interestCompoundedEvery", "interestCompoundingAllowed", "interestCompoundedEveryPeriodType", "renewalAllowed", "interestCompoundedEvery", "interestCompoundingAllowed", "interestCompoundedEveryPeriodType", "renewalAllowed",
"preClosureAllowed", "preClosureInterestRate", "withdrawnonDate", "rejectedonDate", "closedonDate", "transactions", "preClosureAllowed", "preClosureInterestRate", "withdrawnonDate", "rejectedonDate", "closedonDate", "transactions",
"interestPaid", "isInterestWithdrawable", "availableInterestForWithdrawal", "availableWithdrawalAmount", "todaysDate", "interestPaid", "isInterestWithdrawable", "availableInterestForWithdrawal", "availableWithdrawalAmount", "todaysDate",
"isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType")); "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType","printFDdetailsLocation", "availableInterest", "interestPostedAmount",
"lastInterestPostedDate", "nextInterestPostedDate","fatherName","address","imageKey"));
@POST @POST
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@@ -260,6 +265,7 @@ public class DepositAccountsApiResource {
return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue); return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue);
} }
@POST @POST
@Path("postinterest") @Path("postinterest")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@@ -270,4 +276,23 @@ public class DepositAccountsApiResource {
return Response.ok().entity(entityIdentifier).build(); return Response.ok().entity(entityIdentifier).build();
} }
@GET
@Path("{accountId}/print")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Response printDepositAccount(@PathParam("accountId") final Long accountId, @Context final UriInfo uriInfo) {
DepositAccountData account = this.depositAccountReadPlatformService.retrieveDepositAccount(accountId);
String printFileName=null;
if (account != null)
printFileName = new GeneratePDF(account).generatePDF();
account.setPrintFDdetailsLocation(printFileName);
File file = new File(printFileName);
ResponseBuilder response = Response.ok(file);
response.header("Content-Disposition", "attachment; filename=\""+ printFileName + "\"");
response.header("Content-Type", "applicatio/pdf");
return response.build();
}
} }
@@ -67,9 +67,14 @@ public class DepositAccountData {
private final EnumOptionData lockinPeriodType; private final EnumOptionData lockinPeriodType;
private final BigDecimal availableInterest; private final BigDecimal availableInterest;
private final BigDecimal interestPostedAmount; private final BigDecimal interestPostedAmount;
private final LocalDate lastInterestPostedDate; private final LocalDate lastInterestPostedDate;
private final LocalDate nextInterestPostedDate; private final LocalDate nextInterestPostedDate;
private final String imageKey;
private String printFDdetailsLocation;
private final String fatherName;
private final String address;
/* /*
* used when returning account template data but only a clientId is passed, * used when returning account template data but only a clientId is passed,
@@ -129,6 +134,12 @@ public class DepositAccountData {
this.interestPostedAmount = BigDecimal.ZERO; this.interestPostedAmount = BigDecimal.ZERO;
this.lastInterestPostedDate = null; this.lastInterestPostedDate = null;
this.nextInterestPostedDate = null; this.nextInterestPostedDate = null;
this.imageKey = null;
this.printFDdetailsLocation = null;
this.fatherName = null;
this.address = null;
} }
public DepositAccountData(final DepositAccountData account, final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions, public DepositAccountData(final DepositAccountData account, final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions,
@@ -181,6 +192,11 @@ public class DepositAccountData {
this.interestPostedAmount = account.getInterestPostedAmount(); this.interestPostedAmount = account.getInterestPostedAmount();
this.lastInterestPostedDate = account.getLastInterestPostedDate(); this.lastInterestPostedDate = account.getLastInterestPostedDate();
this.nextInterestPostedDate = account.getNextInterestPostedDate(); this.nextInterestPostedDate = account.getNextInterestPostedDate();
this.imageKey = account.getImageKey();
this.printFDdetailsLocation = account.getPrintFDdetailsLocation();
this.fatherName=account.getFatherName();
this.address=account.getAddress();
} }
public DepositAccountData(final DepositAccountData account, final DepositPermissionData permissions, public DepositAccountData(final DepositAccountData account, final DepositPermissionData permissions,
@@ -233,6 +249,10 @@ public class DepositAccountData {
this.interestPostedAmount = account.getInterestPostedAmount(); this.interestPostedAmount = account.getInterestPostedAmount();
this.lastInterestPostedDate = account.getLastInterestPostedDate(); this.lastInterestPostedDate = account.getLastInterestPostedDate();
this.nextInterestPostedDate = account.getNextInterestPostedDate(); this.nextInterestPostedDate = account.getNextInterestPostedDate();
this.imageKey = account.getImageKey();
this.printFDdetailsLocation = account.getPrintFDdetailsLocation();
this.fatherName=account.getFatherName();
this.address=account.getAddress();
} }
public DepositAccountData(final Long id, final String externalId, final EnumOptionData status, final Long clientId, public DepositAccountData(final Long id, final String externalId, final EnumOptionData status, final Long clientId,
@@ -245,7 +265,8 @@ public class DepositAccountData {
final LocalDate rejectedonDate, final LocalDate closedonDate, final boolean isInterestWithdrawable, final LocalDate rejectedonDate, final LocalDate closedonDate, final boolean isInterestWithdrawable,
final BigDecimal interestPaid, final boolean interestCompoundingAllowed, final boolean isLockinPeriodAllowed, final BigDecimal interestPaid, final boolean interestCompoundingAllowed, final boolean isLockinPeriodAllowed,
final Integer lockinPeriod, final EnumOptionData lockinPeriodType, final BigDecimal availableInterest, final Integer lockinPeriod, final EnumOptionData lockinPeriodType, final BigDecimal availableInterest,
final BigDecimal interestPostedAmount, final LocalDate lastInterestPostedDate, final LocalDate nextInterestPostedDate) { final BigDecimal interestPostedAmount, final LocalDate lastInterestPostedDate, final LocalDate nextInterestPostedDate,
final String fatherName, final String address, final String imageKey) {
this.id = id; this.id = id;
this.externalId = externalId; this.externalId = externalId;
this.status = status; this.status = status;
@@ -295,6 +316,11 @@ public class DepositAccountData {
this.interestPostedAmount = interestPostedAmount; this.interestPostedAmount = interestPostedAmount;
this.lastInterestPostedDate = lastInterestPostedDate; this.lastInterestPostedDate = lastInterestPostedDate;
this.nextInterestPostedDate = nextInterestPostedDate; this.nextInterestPostedDate = nextInterestPostedDate;
this.imageKey = imageKey;
this.fatherName = fatherName;
this.address = address;
this.printFDdetailsLocation = null;
} }
public DepositAccountData(final Long clientId, final String clientName, final Long productId, final String productName, public DepositAccountData(final Long clientId, final String clientName, final Long productId, final String productName,
@@ -350,6 +376,11 @@ public class DepositAccountData {
this.interestPostedAmount = BigDecimal.ZERO; this.interestPostedAmount = BigDecimal.ZERO;
this.lastInterestPostedDate = null; this.lastInterestPostedDate = null;
this.nextInterestPostedDate = null; this.nextInterestPostedDate = null;
this.imageKey = null;
this.printFDdetailsLocation = null;
this.fatherName=null;
this.address=null;
} }
public Long getId() { public Long getId() {
@@ -524,7 +555,27 @@ public class DepositAccountData {
return this.nextInterestPostedDate; return this.nextInterestPostedDate;
} }
private BigDecimal determineAvailableInterestForWithdrawal(final DepositAccountData account) { public String getPrintFDdetailsLocation() {
return this.printFDdetailsLocation;
}
public void setPrintFDdetailsLocation(String printFDdetailsLocation) {
this.printFDdetailsLocation = printFDdetailsLocation;
}
public String getImageKey() {
return this.imageKey;
}
public String getFatherName() {
return this.fatherName;
}
public String getAddress() {
return this.address;
}
private BigDecimal determineAvailableInterestForWithdrawal(final DepositAccountData account) {
BigDecimal availableInterestForWithdrawal = BigDecimal.ZERO; BigDecimal availableInterestForWithdrawal = BigDecimal.ZERO;
if (this.status != null) { if (this.status != null) {
@@ -582,4 +633,5 @@ public class DepositAccountData {
return BigDecimal.valueOf(depsoitAmount.doubleValue() * days.doubleValue() * interestRateForOneDay.doubleValue()); return BigDecimal.valueOf(depsoitAmount.doubleValue() * days.doubleValue() * interestRateForOneDay.doubleValue());
} }
} }
@@ -13,3 +13,4 @@ public class DepositAccountsForLookup {
} }
} }
@@ -313,8 +313,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount(); this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount();
this.total = futureValueOnMaturity.getAmount(); this.total = futureValueOnMaturity.getAmount();
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(getDeposit(), getActualCommencementDate(), DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(getDeposit(), getActualCommencementDate(), null);
getAccuredInterest());
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction); this.depositaccountTransactions.add(depositaccountTransaction);
@@ -559,9 +558,9 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
Money accuredInterestAfterMaturityToTillDate = fixedTermDepositInterestCalculator.calculateRemainInterest(getDeposit(), days, Money accuredInterestAfterMaturityToTillDate = fixedTermDepositInterestCalculator.calculateRemainInterest(getDeposit(), days,
preClosureInterestRate); preClosureInterestRate);
this.interestAccrued = this.interestAccrued.add(accuredInterestAfterMaturityToTillDate.getAmount()); this.interestAccrued = this.interestAccrued.add(accuredInterestAfterMaturityToTillDate.getAmount());
this.availableInterest = this.availableInterest.add(accuredInterestAfterMaturityToTillDate.getAmount());
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), eventDate, DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), eventDate,Money.of(currency, this.availableInterest),getDeposit().getAmount().add(this.availableInterest));
getAccuredInterest()); //DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), eventDate, getAccuredInterest());
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction); this.depositaccountTransactions.add(depositaccountTransaction);
@@ -619,7 +618,8 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
@SuppressWarnings("unused") @SuppressWarnings("unused")
boolean statustest = isActive(); boolean statustest = isActive();
if (isActive()) { if (isActive()) {
DepositAccountTransaction depositAccountTransaction = DepositAccountTransaction.withdraw(null, new LocalDate(), interest); //DepositAccountTransaction depositAccountTransaction = DepositAccountTransaction.withdraw(null, new LocalDate(), interest);
DepositAccountTransaction depositAccountTransaction = DepositAccountTransaction.withdraw(null, new LocalDate(), interest,getDeposit().getAmount().add(this.availableInterest).subtract(interest.getAmount()));
depositAccountTransaction.updateAccount(this); depositAccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositAccountTransaction); this.depositaccountTransactions.add(depositAccountTransaction);
this.interstPaid = this.interstPaid.add(interest.getAmount()); this.interstPaid = this.interstPaid.add(interest.getAmount());
@@ -634,8 +634,9 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
DepositAccountStatus.fromInt(this.depositStatus)); DepositAccountStatus.fromInt(this.depositStatus));
this.depositStatus = statusEnumForClose.getValue(); this.depositStatus = statusEnumForClose.getValue();
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), new LocalDate(), //DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), new LocalDate(),Money.of(getDeposit().getCurrency(), getTotal()).minus(getDeposit()));
Money.of(getDeposit().getCurrency(), getTotal()).minus(getDeposit())); DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), new LocalDate(),Money.of(getDeposit().getCurrency(), getTotal()).minus(getDeposit()),
getDeposit().plus(Money.of(getDeposit().getCurrency(), getTotal()).minus(getDeposit())).getAmount());
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction); this.depositaccountTransactions.add(depositaccountTransaction);
@@ -713,7 +714,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
if (lastInterestPostedDate.isBefore(getMaturityDate())) { if (lastInterestPostedDate.isBefore(getMaturityDate())) {
if (nextInterestPostingDate.isAfter(getMaturityDate())) { if (nextInterestPostingDate.isAfter(getMaturityDate())) {
Integer noofRemainMonthsAfterMaturity = Months.monthsBetween(getMaturityDate(), nextInterestPostingDate).getMonths(); Integer noofRemainMonthsAfterMaturity = Months.monthsBetween(getMaturityDate(), nextInterestPostingDate).getMonths();
Integer noOfMonthsBeforeMaturity = Months.monthsBetween(lastInterestPostedDate, getMaturityDate()).getMonths(); Integer noOfMonthsBeforeMaturity = Months.monthsBetween(lastInterestPostedDate, getMaturityDate().plusDays(1)).getMonths();
Money futureValueOnMaturity = null; Money futureValueOnMaturity = null;
if (noOfMonthsBeforeMaturity > 0) { if (noOfMonthsBeforeMaturity > 0) {
@@ -750,8 +751,8 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
} }
// add transaction entry for each interest posting // add transaction entry for each interest posting
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate,futureValueOnMaturity.minus(deposit),deposit.getAmount().add(this.availableInterest));
nextInterestPostingDate, futureValueOnMaturity.minus(deposit)); //DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate, futureValueOnMaturity.minus(deposit));
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction); this.depositaccountTransactions.add(depositaccountTransaction);
@@ -772,8 +773,8 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.nextInterestPostingDate = nextInterestPostingDate.plusMonths(this.interestCompoundedEvery).toDate(); this.nextInterestPostingDate = nextInterestPostingDate.plusMonths(this.interestCompoundedEvery).toDate();
// add transaction entry for each interest posting // add transaction entry for each interest posting
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, // DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate, futureValueOnMaturity.minus(deposit));
nextInterestPostingDate, futureValueOnMaturity.minus(deposit)); DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate,futureValueOnMaturity.minus(deposit),deposit.getAmount().add(this.availableInterest));
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction); this.depositaccountTransactions.add(depositaccountTransaction);
} }
@@ -794,8 +795,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.nextInterestPostingDate = nextInterestPostingDate.plusMonths(this.interestCompoundedEvery).toDate(); this.nextInterestPostingDate = nextInterestPostingDate.plusMonths(this.interestCompoundedEvery).toDate();
// add transaction entry for each interest posting // add transaction entry for each interest posting
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate, DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate, futureValueOnMaturity.minus(deposit),deposit.getAmount().add(this.availableInterest));
futureValueOnMaturity.minus(deposit));
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction); this.depositaccountTransactions.add(depositaccountTransaction);
} }
@@ -831,5 +831,4 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
public BigDecimal getInterestPostedAmount() { public BigDecimal getInterestPostedAmount() {
return interestPostedAmount; return interestPostedAmount;
} }
} }
@@ -71,6 +71,14 @@ public class DepositAccountTransaction extends AbstractPersistable<Long> {
this.total = amount.doubleValue() == 0 ? new BigDecimal(0) : amount.add(interest); this.total = amount.doubleValue() == 0 ? new BigDecimal(0) : amount.add(interest);
} }
private DepositAccountTransaction(DepositAccountTransactionType type, final BigDecimal amount, final LocalDate date, final BigDecimal interest, final BigDecimal total) {
this.typeOf = type;
this.amount = amount;
this.dateOf = date.toDateMidnight().toDate();
this.interest = interest;
this.total = total;
}
public Date getDateOf() { public Date getDateOf() {
return dateOf; return dateOf;
} }
@@ -101,7 +109,7 @@ public class DepositAccountTransaction extends AbstractPersistable<Long> {
: interest.getAmount()); : interest.getAmount());
} }
public static DepositAccountTransaction withdraw(Money amount, LocalDate paymentDate, Money interest) { /* public static DepositAccountTransaction withdraw(Money amount, LocalDate paymentDate, Money interest) {
return new DepositAccountTransaction(DepositAccountTransactionType.WITHDRAW, amount == null ? new BigDecimal(0) return new DepositAccountTransaction(DepositAccountTransactionType.WITHDRAW, amount == null ? new BigDecimal(0)
: amount.getAmount(), paymentDate, interest == null ? new BigDecimal(0) : interest.getAmount()); : amount.getAmount(), paymentDate, interest == null ? new BigDecimal(0) : interest.getAmount());
} }
@@ -109,9 +117,20 @@ public class DepositAccountTransaction extends AbstractPersistable<Long> {
public static DepositAccountTransaction postInterest(Money depositAmount, LocalDate paymentDate, Money interest) { public static DepositAccountTransaction postInterest(Money depositAmount, LocalDate paymentDate, Money interest) {
return new DepositAccountTransaction(DepositAccountTransactionType.INTEREST_POSTING, depositAmount == null ? new BigDecimal(0) return new DepositAccountTransaction(DepositAccountTransactionType.INTEREST_POSTING, depositAmount == null ? new BigDecimal(0)
: depositAmount.getAmount(), paymentDate, interest == null ? new BigDecimal(0) : interest.getAmount()); : depositAmount.getAmount(), paymentDate, interest == null ? new BigDecimal(0) : interest.getAmount());
} }*/
public static DepositAccountTransaction withdraw(Money amount, LocalDate paymentDate, Money interest, BigDecimal total) {
return new DepositAccountTransaction(DepositAccountTransactionType.WITHDRAW, amount == null ? new BigDecimal(0) : amount.getAmount(), paymentDate, interest==null ? new BigDecimal(0) : interest.getAmount(),total);
}
public static DepositAccountTransaction postInterest(Money depositAmount, LocalDate paymentDate, Money interest, BigDecimal total) {
return new DepositAccountTransaction(DepositAccountTransactionType.INTEREST_POSTING, depositAmount == null ? new BigDecimal(0) : depositAmount.getAmount(), paymentDate, interest==null ? new BigDecimal(0) : interest.getAmount(),total);
}
public void updateAccount(DepositAccount depositAccount) { public void updateAccount(DepositAccount depositAccount) {
this.depositAccount = depositAccount; this.depositAccount = depositAccount;
} }
} }
@@ -7,51 +7,55 @@ public enum DepositAccountTransactionType {
WITHDRAW(2, "depositTransactionType.withdraw"), // WITHDRAW(2, "depositTransactionType.withdraw"), //
REVERSAL(3, "depositTransactionType.reversal"), INTEREST_POSTING(4, "depositTransactionType.interestPosting"); REVERSAL(3, "depositTransactionType.reversal"), INTEREST_POSTING(4, "depositTransactionType.interestPosting");
private final Integer value; private final Integer value;
private final String code; private final String code;
private DepositAccountTransactionType(final Integer value, final String code) { private DepositAccountTransactionType(final Integer value, final String code) {
this.value = value;
this.code = code;
}
public Integer getValue() { this.value=value;
return value; this.code=code;
} }
public String getCode() { public Integer getValue() {
return code; return value;
} }
public static DepositAccountTransactionType fromInt(final Integer transactionType) { public String getCode() {
return code;
}
if (transactionType == null) { return DepositAccountTransactionType.INVALID; } public static DepositAccountTransactionType fromInt(final Integer transactionType){
DepositAccountTransactionType depositTransactionType = null; if (transactionType == null) {
switch (transactionType) { return DepositAccountTransactionType.INVALID;
case 1: }
depositTransactionType = DepositAccountTransactionType.DEPOSIT;
break;
case 2: DepositAccountTransactionType depositTransactionType=null;
depositTransactionType = DepositAccountTransactionType.WITHDRAW; switch (transactionType) {
break; case 1:
depositTransactionType=DepositAccountTransactionType.DEPOSIT;
break;
case 3: case 2:
depositTransactionType = DepositAccountTransactionType.REVERSAL; depositTransactionType=DepositAccountTransactionType.WITHDRAW;
break; break;
case 4: case 3:
depositTransactionType = DepositAccountTransactionType.INTEREST_POSTING; depositTransactionType=DepositAccountTransactionType.REVERSAL;
break; break;
default: case 4:
depositTransactionType = DepositAccountTransactionType.INVALID; depositTransactionType=DepositAccountTransactionType.INTEREST_POSTING;
break; break;
} default :
depositTransactionType=DepositAccountTransactionType.INVALID;
break;
return depositTransactionType; }
return depositTransactionType;
} }
} }
@@ -334,4 +334,5 @@ public class DepositAccountAssembler {
public void postInterest(DepositAccount account) { public void postInterest(DepositAccount account) {
account.postInterestForDepositAccount(account, this.fixedTermDepositInterestCalculator); account.postInterestForDepositAccount(account, this.fixedTermDepositInterestCalculator);
} }
} }
@@ -21,3 +21,4 @@ public interface DepositAccountReadPlatformService {
Collection<DepositAccountsForLookup> retrieveDepositAccountForLookup(); Collection<DepositAccountsForLookup> retrieveDepositAccountForLookup();
} }
@@ -133,22 +133,26 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
public String schema() { public String schema() {
return "da.id as id, da.external_id as externalId, da.client_id as clientId, da.product_id as productId, " return "da.id as id, da.external_id as externalId, da.client_id as clientId, da.product_id as productId, "
+ " da.currency_code as currencyCode, da.currency_digits as currencyDigits, " + " da.currency_code as currencyCode, da.currency_digits as currencyDigits, "
+ " da.deposit_amount as depositAmount, da.status_enum as statusId, " + " da.deposit_amount as depositAmount, da.status_enum as statusId, "
+ " da.maturity_nominal_interest_rate as interestRate, da.tenure_months as termInMonths, da.projected_commencement_date as projectedCommencementDate," + " da.maturity_nominal_interest_rate as interestRate, da.tenure_months as termInMonths, da.projected_commencement_date as projectedCommencementDate,"
+ " da.actual_commencement_date as actualCommencementDate, da.matures_on_date as maturedOn," + " da.actual_commencement_date as actualCommencementDate, da.matures_on_date as maturedOn,"
+ " da.projected_interest_accrued_on_maturity as projectedInterestAccrued, da.actual_interest_accrued as actualInterestAccrued, " + " da.projected_interest_accrued_on_maturity as projectedInterestAccrued, da.actual_interest_accrued as actualInterestAccrued, "
+ " da.projected_total_maturity_amount as projectedMaturityAmount, da.actual_total_amount as actualMaturityAmount, " + " da.projected_total_maturity_amount as projectedMaturityAmount, da.actual_total_amount as actualMaturityAmount, "
+ " da.interest_compounded_every as interestCompoundedEvery, da.interest_compounded_every_period_enum as interestCompoundedEveryPeriodType, " + " da.interest_compounded_every as interestCompoundedEvery, da.interest_compounded_every_period_enum as interestCompoundedEveryPeriodType, "
+ " da.is_renewal_allowed as renewalAllowed, da.is_preclosure_allowed as preClosureAllowed, da.pre_closure_interest_rate as preClosureInterestRate, " + " da.is_renewal_allowed as renewalAllowed, da.is_preclosure_allowed as preClosureAllowed, da.pre_closure_interest_rate as preClosureInterestRate, "
+ " da.withdrawnon_date as withdrawnonDate, da.rejectedon_date as rejectedonDate, da.closedon_date as closedonDate, " + " da.withdrawnon_date as withdrawnonDate, da.rejectedon_date as rejectedonDate, da.closedon_date as closedonDate, "
+ " da.interest_paid as interestPaid, da.is_interest_withdrawable as isInterestWithdrawable, da.is_compounding_interest_allowed as interestCompoundingAllowed, " + " da.interest_paid as interestPaid, da.is_interest_withdrawable as isInterestWithdrawable, da.is_compounding_interest_allowed as interestCompoundingAllowed, "
+ " da.is_lock_in_period_allowed as isLockinPeriodAllowed, da.lock_in_period as lockinPeriod, da.lock_in_period_type lockinPeriodType, " + " da.is_lock_in_period_allowed as isLockinPeriodAllowed, da.lock_in_period as lockinPeriod, da.lock_in_period_type lockinPeriodType, "
+ " da.available_interest as availableInterest, da.interest_posted_amount as interestPostedAmount, da.last_interest_posted_date as lastInterestPostedDate, da.next_interest_posting_date as nextInterestPostedDate," + " da.available_interest as availableInterest, da.interest_posted_amount as interestPostedAmount, da.last_interest_posted_date as lastInterestPostedDate, da.next_interest_posting_date as nextInterestPostedDate,"
+ " c.firstname as firstname, c.lastname as lastname, pd.name as productName," + " c.firstname as firstname, c.lastname as lastname, pd.name as productName, c.image_key as imageKey, "
+ " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol " + " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol, "
+ " from m_deposit_account da " + " join m_currency curr on curr.code = da.currency_code " + " ecd.father_name as fatherName, ecd.client_address as clientAddress "
+ " join m_client c on c.id = da.client_id " + " join m_product_deposit pd on pd.id = da.product_id"; + " from m_deposit_account da "
+ " join m_currency curr on curr.code = da.currency_code "
+ " join m_client c on c.id = da.client_id "
+ " join m_product_deposit pd on pd.id = da.product_id"
+ " left join extra_client_details ecd on da.client_id = ecd.client_id ";
} }
@Override @Override
@@ -210,9 +214,12 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
EnumOptionData lockinPeriodType = SavingsDepositEnumerations.interestCompoundingPeriodType(lockinPeriodTypeValue); EnumOptionData lockinPeriodType = SavingsDepositEnumerations.interestCompoundingPeriodType(lockinPeriodTypeValue);
BigDecimal availableInterest = rs.getBigDecimal("availableInterest"); BigDecimal availableInterest = rs.getBigDecimal("availableInterest");
BigDecimal interestPostedAmount = rs.getBigDecimal("interestPostedAmount"); BigDecimal interestPostedAmount = rs.getBigDecimal("interestPostedAmount");
LocalDate lastInterestPostedDate = JdbcSupport.getLocalDate(rs, "lastInterestPostedDate"); LocalDate lastInterestPostedDate = JdbcSupport.getLocalDate(rs, "lastInterestPostedDate");
LocalDate nextInterestPostedDate = JdbcSupport.getLocalDate(rs, "nextInterestPostedDate"); LocalDate nextInterestPostedDate = JdbcSupport.getLocalDate(rs, "nextInterestPostedDate");
String imageKey = rs.getString("imageKey");
String fatherName = rs.getString("fatherName");
String address = rs.getString("clientAddress");
return new DepositAccountData(id, externalId, status, clientId, clientName, productId, productName, currencyData, return new DepositAccountData(id, externalId, status, clientId, clientName, productId, productName, currencyData,
depositAmount, interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, maturedOn, depositAmount, interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, maturedOn,
@@ -220,15 +227,15 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
interestCompoundedEvery, interestCompoundedEveryPeriodType, renewalAllowed, preClosureAllowed, preClosureInterestRate, interestCompoundedEvery, interestCompoundedEveryPeriodType, renewalAllowed, preClosureAllowed, preClosureInterestRate,
withdrawnonDate, rejectedonDate, closedonDate, isInterestWithdrawable, interestPaid, interestCompoundingAllowed, withdrawnonDate, rejectedonDate, closedonDate, isInterestWithdrawable, interestPaid, interestCompoundingAllowed,
isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, availableInterest, interestPostedAmount, lastInterestPostedDate, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, availableInterest, interestPostedAmount, lastInterestPostedDate,
nextInterestPostedDate); nextInterestPostedDate,fatherName,address,imageKey);
} }
} }
private static final class DepositAccountTransactionMapper implements RowMapper<DepositAccountTransactionData> { private static final class DepositAccountTransactionMapper implements RowMapper<DepositAccountTransactionData> {
public String schema() { public String schema() {
return " txn.id as transactionId, txn.deposit_account_id as accountId, txn.transaction_type_enum as transactionType, txn.transaction_date as transactionDate, txn.amount as transactionAmount, txn.interest as interestAmount " return " txn.id as transactionId, txn.deposit_account_id as accountId, txn.transaction_type_enum as transactionType, txn.transaction_date as transactionDate, txn.amount as transactionAmount, txn.interest as interestAmount, "
+ " from m_deposit_account_transaction txn"; + "txn.total as total from m_deposit_account_transaction txn";
} }
@Override @Override
@@ -241,7 +248,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
LocalDate transactionDate = JdbcSupport.getLocalDate(rs, "transactionDate"); LocalDate transactionDate = JdbcSupport.getLocalDate(rs, "transactionDate");
BigDecimal transactionAmount = rs.getBigDecimal("transactionAmount"); BigDecimal transactionAmount = rs.getBigDecimal("transactionAmount");
BigDecimal interestAmount = rs.getBigDecimal("interestAmount"); BigDecimal interestAmount = rs.getBigDecimal("interestAmount");
BigDecimal total = transactionAmount.add(interestAmount); BigDecimal total = rs.getBigDecimal("total");
return new DepositAccountTransactionData(transactionId, accountId, transactionType, transactionDate, transactionAmount, return new DepositAccountTransactionData(transactionId, accountId, transactionType, transactionDate, transactionAmount,
interestAmount, total); interestAmount, total);
@@ -255,18 +262,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
boolean undoApprovalAllowed = (depositAccountData.getStatus().getId().equals(300L)); boolean undoApprovalAllowed = (depositAccountData.getStatus().getId().equals(300L));
boolean renewelAllowed = false; boolean renewelAllowed = false;
if (depositAccountData.getMaturedOn() != null) { if (depositAccountData.getMaturedOn() != null) {
if (new LocalDate().isAfter(depositAccountData.getMaturedOn())/* if (new LocalDate().isAfter(depositAccountData.getMaturedOn())/* || depositAccountData.getMaturedOn().isEqual(new LocalDate()) */) {
* ||
* depositAccountData
* .
* getMaturedOn
* ().
* isEqual
* (
* new
* LocalDate
* ())
*/) {
renewelAllowed = depositAccountData.isRenewalAllowed(); renewelAllowed = depositAccountData.isRenewalAllowed();
} }
} }
@@ -312,4 +308,5 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
} }
} }
} }
@@ -27,6 +27,11 @@ public class DepositAccountTransactionEnumerations {
optionData = new EnumOptionData(DepositAccountTransactionType.REVERSAL.getValue().longValue(), optionData = new EnumOptionData(DepositAccountTransactionType.REVERSAL.getValue().longValue(),
DepositAccountTransactionType.REVERSAL.getCode(), "Revarsal"); DepositAccountTransactionType.REVERSAL.getCode(), "Revarsal");
break; break;
case INTEREST_POSTING:
optionData=new EnumOptionData(DepositAccountTransactionType.INTEREST_POSTING.getValue().longValue(), DepositAccountTransactionType.INTEREST_POSTING.getCode(), "Interest posting");
break;
default: default:
optionData = new EnumOptionData(DepositAccountTransactionType.INVALID.getValue().longValue(), optionData = new EnumOptionData(DepositAccountTransactionType.INVALID.getValue().longValue(),
DepositAccountTransactionType.INVALID.getCode(), "Invalid Transaction"); DepositAccountTransactionType.INVALID.getCode(), "Invalid Transaction");
@@ -55,4 +55,5 @@ public interface DepositAccountWritePlatformService {
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER')")
EntityIdentifier postInterestToDepositAccount(Collection<DepositAccountsForLookup> accounts); EntityIdentifier postInterestToDepositAccount(Collection<DepositAccountsForLookup> accounts);
} }
@@ -333,9 +333,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
if (account == null || account.isDeleted()) { throw new DepositAccountNotFoundException(command.getAccountId()); } if (account == null || account.isDeleted()) { throw new DepositAccountNotFoundException(command.getAccountId()); }
if (account.isInterestWithdrawable() && !account.isInterestCompoundingAllowed()) { if (account.isInterestWithdrawable() && !account.isInterestCompoundingAllowed()) {
BigDecimal totalAvailableInterestForWithdrawal = getTotalWithdrawableInterestAvailable(account); // BigDecimal totalAvailableInterestForWithdrawal = getTotalWithdrawableInterestAvailable(account);
BigDecimal interestPaid = account.getInterstPaid(); // BigDecimal interestPaid = account.getInterstPaid();
BigDecimal remainInterestForWithdrawal = totalAvailableInterestForWithdrawal.subtract(interestPaid); BigDecimal remainInterestForWithdrawal = account.getAvailableInterest(); //totalAvailableInterestForWithdrawal.subtract(interestPaid);
if (remainInterestForWithdrawal.doubleValue() > 0) { if (remainInterestForWithdrawal.doubleValue() > 0) {
if (remainInterestForWithdrawal.doubleValue() >= command.getWithdrawInterest().doubleValue() if (remainInterestForWithdrawal.doubleValue() >= command.getWithdrawInterest().doubleValue()
@@ -357,13 +357,13 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
return new EntityIdentifier(account.getId()); return new EntityIdentifier(account.getId());
} }
private BigDecimal getTotalWithdrawableInterestAvailable(DepositAccount account) { /* private BigDecimal getTotalWithdrawableInterestAvailable(DepositAccount account) {
BigDecimal interstGettingForPeriod = BigDecimal.valueOf(account.getAccuredInterest().getAmount().doubleValue() BigDecimal interstGettingForPeriod = BigDecimal.valueOf(account.getAccuredInterest().getAmount().doubleValue()
/ new Double(account.getTenureInMonths())); / new Double(account.getTenureInMonths()));
Integer noOfMonthsforInterestCal = Months.monthsBetween(account.getActualCommencementDate(), new LocalDate()).getMonths(); Integer noOfMonthsforInterestCal = Months.monthsBetween(account.getActualCommencementDate(), new LocalDate()).getMonths();
Integer noOfPeriods = noOfMonthsforInterestCal / account.getInterestCompoundedEvery(); Integer noOfPeriods = noOfMonthsforInterestCal / account.getInterestCompoundedEvery();
return interstGettingForPeriod.multiply(new BigDecimal(noOfPeriods)); return interstGettingForPeriod.multiply(new BigDecimal(noOfPeriods));
} }*/
@Transactional @Transactional
@Override @Override
@@ -0,0 +1,73 @@
package org.mifosplatform.portfolio.savingsdepositaccount.service;
import java.io.File;
import java.io.FileOutputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import org.mifosplatform.infrastructure.core.service.FileUtils;
import org.mifosplatform.portfolio.savingsdepositaccount.data.DepositAccountData;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.CMYKColor;
import com.lowagie.text.pdf.PdfWriter;
public class GeneratePDF {
private final DepositAccountData account;
public GeneratePDF(DepositAccountData account) {
this.account = account;
}
public String generatePDF() {
String fileLocation = FileUtils.MIFOSX_BASE_DIR + File.separator+ "Print_FD_Details";
/** Recursively create the directory if it does not exist **/
if (!new File(fileLocation).isDirectory()) {
new File(fileLocation).mkdirs();
}
String printFDdetailsLocation = fileLocation + File.separator + account.getId() + ".pdf";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMMM-yyyy");
DecimalFormat decimalFormat = new DecimalFormat("#.##");
try {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(printFDdetailsLocation));
document.open();
Paragraph paragraph = new Paragraph("FIXED DEPOSIT CERTIFICATE ", FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new CMYKColor(0, 255, 0, 0)));
paragraph.setAlignment(Element.ALIGN_CENTER);
paragraph.setSpacingAfter(30);
document.add(paragraph);
Image img = Image.getInstance(account.getImageKey());
img.scaleAbsolute(70, 80);
img.setAbsolutePosition(450, 670);
document.add(img);
Font font = FontFactory.getFont(FontFactory.COURIER, 10);
document.add(new Paragraph("Extenal id: "+ account.getExternalId(), font));
document.add(new Paragraph("Created date: "+ dateFormat.format(account.getActualCommencementDate().toDate()), font));
document.add(new Paragraph("Mature date: " + dateFormat.format(account.getMaturedOn().toDate()), font));
document.add(new Paragraph("Client name: " + account.getClientName(), font));
document.add(new Paragraph("Amount: " + decimalFormat.format(account.getDeposit()), font));
document.add(new Paragraph("FD interest rate: " + decimalFormat.format(account.getMaturityInterestRate()), font));
document.add(new Paragraph("Preclosure interest rate: " + decimalFormat.format(account.getPreClosureInterestRate()), font));
document.add(new Paragraph("Tenure: " + account.getTenureInMonths(), font));
document.add(new Paragraph("Maturity Amount: " + decimalFormat.format(account.getActualMaturityAmount()), font));
document.close();
} catch (Exception e) {
e.printStackTrace();
}
return printFDdetailsLocation;
}
}