Add Interest posting functionality for fd
Basic for rd schedule creation-1 Schedule creation for RD PrintPdf For FD Print RRMacs Demo FD Certificate Generation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
DROP TABLE IF EXISTS `m_saving_schedule`;
|
||||
CREATE TABLE `m_saving_schedule` (
|
||||
`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;
|
||||
+4
-2
@@ -59,7 +59,8 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
"interestCompoundedEveryPeriodType", "renewalAllowed", "preClosureAllowed", "preClosureInterestRate", "withdrawnonDate",
|
||||
"rejectedonDate", "closedonDate", "transactions", "permissions", "isInterestWithdrawable", "interestPaid",
|
||||
"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",
|
||||
"parentEntityId", "name", "fileName", "type", "size", "description"));
|
||||
@@ -101,7 +102,7 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
private static final Set<String> GUARANTOR_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("externalGuarantor", "existingClientId",
|
||||
"firstname", "lastname", "addressLine1", "addressLine2", "city", "state", "zip", "country", "mobileNumber", "housePhoneNumber",
|
||||
"comment", "dob"));
|
||||
|
||||
|
||||
private static final Set<String> SAVING_SCHEDULE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("periods", "cumulativeDepositDue"));
|
||||
|
||||
private final GoogleGsonSerializerHelper helper;
|
||||
@@ -296,4 +297,5 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, savingScheduleData);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -77,4 +77,5 @@ public interface PortfolioApiJsonSerializerService {
|
||||
|
||||
String serializeSavingScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingScheduleData savingScheduleData);
|
||||
|
||||
|
||||
}
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package org.mifosplatform.infrastructure.core.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,7 @@ public class EntityIdentifier {
|
||||
|
||||
public EntityIdentifier(final Long entityId) {
|
||||
this.entityId = entityId;
|
||||
this.changes = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
private EntityIdentifier(final Long entityId, final Long makerCheckerId, final Map<String, Object> changesOnly) {
|
||||
|
||||
+32
-28
@@ -143,37 +143,41 @@ public class SavingsAccountApiResource {
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
SavingAccountData account = this.savingAccountReadPlatformService.retrieveSavingsAccount(accountId);
|
||||
|
||||
return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account);
|
||||
}
|
||||
|
||||
SavingAccountData account = this.savingAccountReadPlatformService.retrieveSavingsAccount(accountId);
|
||||
|
||||
return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@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);
|
||||
|
||||
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);
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
@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);
|
||||
|
||||
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) {
|
||||
return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -56,4 +56,5 @@ public class CalculateSavingScheduleCommand {
|
||||
return this.tenure;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -231,7 +231,6 @@ public class SavingAccountCommand {
|
||||
public boolean isPartialDepositAllowedChanged() {
|
||||
return this.modifiedParameters.contains("isPartialDepositAllowed");
|
||||
}
|
||||
|
||||
public boolean isPayEveryChanged() {
|
||||
return this.modifiedParameters.contains("payEvery");
|
||||
}
|
||||
|
||||
+1
@@ -39,4 +39,5 @@ public class SavingSchedulePeriodData {
|
||||
return this.depositPaid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+4
-2
@@ -6,6 +6,8 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
||||
|
||||
public interface DepositScheduleDateGenerator {
|
||||
|
||||
|
||||
List<LocalDate> generate(LocalDate startDate, Integer paymentPeriods, Integer depositFrequency, PeriodFrequencyType depositFrequencyType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ import org.mifosplatform.portfolio.savingsdepositproduct.domain.TenureTypeEnum;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
|
||||
@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> {
|
||||
|
||||
@ManyToOne
|
||||
|
||||
+2
-1
@@ -62,4 +62,5 @@ public class SavingScheduleInstallments extends AbstractAuditableCustom<AppUser,
|
||||
public void updateAccount(SavingAccount account) {
|
||||
this.savingAccount = account;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,6 +4,6 @@ import org.mifosplatform.portfolio.savingsaccount.command.CalculateSavingSchedul
|
||||
import org.mifosplatform.portfolio.savingsaccount.data.SavingScheduleData;
|
||||
|
||||
public interface CalculateSavingSchedule {
|
||||
|
||||
SavingScheduleData calculateSavingSchedule(CalculateSavingScheduleCommand command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -45,4 +45,5 @@ public class DefaultDepositScheduleDateGenerator implements DepositScheduleDateG
|
||||
|
||||
return duePaymentPeriodDates;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -215,4 +215,5 @@ public class SavingAccountAssembler {
|
||||
List<DepositAccountStatus> allowedDepositStatuses = Arrays.asList(DepositAccountStatus.values());
|
||||
return new DepositLifecycleStateMachineImpl(allowedDepositStatuses);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -48,4 +48,5 @@ public class SavingScheduleGenerator {
|
||||
return new SavingScheduleData(currencyData, totalDeposit.getAmount(), periods);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+27
-2
@@ -1,5 +1,6 @@
|
||||
package org.mifosplatform.portfolio.savingsdepositaccount.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -18,6 +19,7 @@ import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
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.service.DepositAccountReadPlatformService;
|
||||
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.service.DepositProductReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -76,7 +79,9 @@ public class DepositAccountsApiResource {
|
||||
"interestCompoundedEvery", "interestCompoundingAllowed", "interestCompoundedEveryPeriodType", "renewalAllowed",
|
||||
"preClosureAllowed", "preClosureInterestRate", "withdrawnonDate", "rejectedonDate", "closedonDate", "transactions",
|
||||
"interestPaid", "isInterestWithdrawable", "availableInterestForWithdrawal", "availableWithdrawalAmount", "todaysDate",
|
||||
"isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType"));
|
||||
"isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType","printFDdetailsLocation", "availableInterest", "interestPostedAmount",
|
||||
"lastInterestPostedDate", "nextInterestPostedDate","fatherName","address","imageKey"));
|
||||
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@@ -258,7 +263,8 @@ public class DepositAccountsApiResource {
|
||||
|
||||
private boolean is(final String commandParam, final String commandValue) {
|
||||
return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("postinterest")
|
||||
@@ -270,4 +276,23 @@ public class DepositAccountsApiResource {
|
||||
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();
|
||||
}
|
||||
}
|
||||
+58
-6
@@ -65,11 +65,16 @@ public class DepositAccountData {
|
||||
private final boolean isLockinPeriodAllowed;
|
||||
private final Integer lockinPeriod;
|
||||
private final EnumOptionData lockinPeriodType;
|
||||
|
||||
|
||||
private final BigDecimal availableInterest;
|
||||
private final BigDecimal interestPostedAmount;
|
||||
private final LocalDate lastInterestPostedDate;
|
||||
private final LocalDate nextInterestPostedDate;
|
||||
private final BigDecimal interestPostedAmount;
|
||||
private final LocalDate lastInterestPostedDate;
|
||||
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,
|
||||
@@ -129,6 +134,12 @@ public class DepositAccountData {
|
||||
this.interestPostedAmount = BigDecimal.ZERO;
|
||||
this.lastInterestPostedDate = 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,
|
||||
@@ -181,6 +192,11 @@ public class DepositAccountData {
|
||||
this.interestPostedAmount = account.getInterestPostedAmount();
|
||||
this.lastInterestPostedDate = account.getLastInterestPostedDate();
|
||||
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,
|
||||
@@ -233,6 +249,10 @@ public class DepositAccountData {
|
||||
this.interestPostedAmount = account.getInterestPostedAmount();
|
||||
this.lastInterestPostedDate = account.getLastInterestPostedDate();
|
||||
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,
|
||||
@@ -245,7 +265,8 @@ public class DepositAccountData {
|
||||
final LocalDate rejectedonDate, final LocalDate closedonDate, final boolean isInterestWithdrawable,
|
||||
final BigDecimal interestPaid, final boolean interestCompoundingAllowed, final boolean isLockinPeriodAllowed,
|
||||
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.externalId = externalId;
|
||||
this.status = status;
|
||||
@@ -295,6 +316,11 @@ public class DepositAccountData {
|
||||
this.interestPostedAmount = interestPostedAmount;
|
||||
this.lastInterestPostedDate = lastInterestPostedDate;
|
||||
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,
|
||||
@@ -350,6 +376,11 @@ public class DepositAccountData {
|
||||
this.interestPostedAmount = BigDecimal.ZERO;
|
||||
this.lastInterestPostedDate = null;
|
||||
this.nextInterestPostedDate = null;
|
||||
|
||||
this.imageKey = null;
|
||||
this.printFDdetailsLocation = null;
|
||||
this.fatherName=null;
|
||||
this.address=null;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
@@ -524,7 +555,27 @@ public class DepositAccountData {
|
||||
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;
|
||||
|
||||
if (this.status != null) {
|
||||
@@ -582,4 +633,5 @@ public class DepositAccountData {
|
||||
return BigDecimal.valueOf(depsoitAmount.doubleValue() * days.doubleValue() * interestRateForOneDay.doubleValue());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -12,4 +12,5 @@ public class DepositAccountsForLookup {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-16
@@ -313,8 +313,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount();
|
||||
this.total = futureValueOnMaturity.getAmount();
|
||||
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(getDeposit(), getActualCommencementDate(),
|
||||
getAccuredInterest());
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(getDeposit(), getActualCommencementDate(), null);
|
||||
depositaccountTransaction.updateAccount(this);
|
||||
this.depositaccountTransactions.add(depositaccountTransaction);
|
||||
|
||||
@@ -559,9 +558,9 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
Money accuredInterestAfterMaturityToTillDate = fixedTermDepositInterestCalculator.calculateRemainInterest(getDeposit(), days,
|
||||
preClosureInterestRate);
|
||||
this.interestAccrued = this.interestAccrued.add(accuredInterestAfterMaturityToTillDate.getAmount());
|
||||
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), eventDate,
|
||||
getAccuredInterest());
|
||||
this.availableInterest = this.availableInterest.add(accuredInterestAfterMaturityToTillDate.getAmount());
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), eventDate,Money.of(currency, this.availableInterest),getDeposit().getAmount().add(this.availableInterest));
|
||||
//DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), eventDate, getAccuredInterest());
|
||||
depositaccountTransaction.updateAccount(this);
|
||||
this.depositaccountTransactions.add(depositaccountTransaction);
|
||||
|
||||
@@ -619,7 +618,8 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
@SuppressWarnings("unused")
|
||||
boolean statustest = 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);
|
||||
this.depositaccountTransactions.add(depositAccountTransaction);
|
||||
this.interstPaid = this.interstPaid.add(interest.getAmount());
|
||||
@@ -634,8 +634,9 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
DepositAccountStatus.fromInt(this.depositStatus));
|
||||
this.depositStatus = statusEnumForClose.getValue();
|
||||
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), new LocalDate(),
|
||||
Money.of(getDeposit().getCurrency(), getTotal()).minus(getDeposit()));
|
||||
//DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.withdraw(getDeposit(), new LocalDate(),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);
|
||||
this.depositaccountTransactions.add(depositaccountTransaction);
|
||||
|
||||
@@ -713,7 +714,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
if (lastInterestPostedDate.isBefore(getMaturityDate())) {
|
||||
if (nextInterestPostingDate.isAfter(getMaturityDate())) {
|
||||
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;
|
||||
if (noOfMonthsBeforeMaturity > 0) {
|
||||
|
||||
@@ -750,8 +751,8 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
}
|
||||
|
||||
// add transaction entry for each interest posting
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null,
|
||||
nextInterestPostingDate, futureValueOnMaturity.minus(deposit));
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate,futureValueOnMaturity.minus(deposit),deposit.getAmount().add(this.availableInterest));
|
||||
//DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate, futureValueOnMaturity.minus(deposit));
|
||||
|
||||
depositaccountTransaction.updateAccount(this);
|
||||
this.depositaccountTransactions.add(depositaccountTransaction);
|
||||
@@ -772,8 +773,8 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
this.nextInterestPostingDate = nextInterestPostingDate.plusMonths(this.interestCompoundedEvery).toDate();
|
||||
|
||||
// add transaction entry for each interest posting
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null,
|
||||
nextInterestPostingDate, futureValueOnMaturity.minus(deposit));
|
||||
// DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate, futureValueOnMaturity.minus(deposit));
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate,futureValueOnMaturity.minus(deposit),deposit.getAmount().add(this.availableInterest));
|
||||
depositaccountTransaction.updateAccount(this);
|
||||
this.depositaccountTransactions.add(depositaccountTransaction);
|
||||
}
|
||||
@@ -794,8 +795,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
this.nextInterestPostingDate = nextInterestPostingDate.plusMonths(this.interestCompoundedEvery).toDate();
|
||||
|
||||
// add transaction entry for each interest posting
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate,
|
||||
futureValueOnMaturity.minus(deposit));
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.postInterest(null, nextInterestPostingDate, futureValueOnMaturity.minus(deposit),deposit.getAmount().add(this.availableInterest));
|
||||
depositaccountTransaction.updateAccount(this);
|
||||
this.depositaccountTransactions.add(depositaccountTransaction);
|
||||
}
|
||||
@@ -831,5 +831,4 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
public BigDecimal getInterestPostedAmount() {
|
||||
return interestPostedAmount;
|
||||
}
|
||||
|
||||
}
|
||||
+21
-2
@@ -70,6 +70,14 @@ public class DepositAccountTransaction extends AbstractPersistable<Long> {
|
||||
this.interest = 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() {
|
||||
return dateOf;
|
||||
@@ -101,7 +109,7 @@ public class DepositAccountTransaction extends AbstractPersistable<Long> {
|
||||
: 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)
|
||||
: 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) {
|
||||
return new DepositAccountTransaction(DepositAccountTransactionType.INTEREST_POSTING, depositAmount == null ? new BigDecimal(0)
|
||||
: 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) {
|
||||
this.depositAccount = depositAccount;
|
||||
}
|
||||
|
||||
}
|
||||
+41
-37
@@ -7,51 +7,55 @@ public enum DepositAccountTransactionType {
|
||||
WITHDRAW(2, "depositTransactionType.withdraw"), //
|
||||
REVERSAL(3, "depositTransactionType.reversal"), INTEREST_POSTING(4, "depositTransactionType.interestPosting");
|
||||
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private DepositAccountTransactionType(final Integer value, final String code) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
this.value=value;
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DepositAccountTransactionType fromInt(final Integer transactionType) {
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static DepositAccountTransactionType fromInt(final Integer transactionType){
|
||||
|
||||
if (transactionType == null) {
|
||||
return DepositAccountTransactionType.INVALID;
|
||||
}
|
||||
|
||||
DepositAccountTransactionType depositTransactionType=null;
|
||||
switch (transactionType) {
|
||||
case 1:
|
||||
depositTransactionType=DepositAccountTransactionType.DEPOSIT;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
depositTransactionType=DepositAccountTransactionType.WITHDRAW;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
depositTransactionType=DepositAccountTransactionType.REVERSAL;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
depositTransactionType=DepositAccountTransactionType.INTEREST_POSTING;
|
||||
break;
|
||||
|
||||
default :
|
||||
depositTransactionType=DepositAccountTransactionType.INVALID;
|
||||
break;
|
||||
|
||||
if (transactionType == null) { return DepositAccountTransactionType.INVALID; }
|
||||
|
||||
DepositAccountTransactionType depositTransactionType = null;
|
||||
switch (transactionType) {
|
||||
case 1:
|
||||
depositTransactionType = DepositAccountTransactionType.DEPOSIT;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
depositTransactionType = DepositAccountTransactionType.WITHDRAW;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
depositTransactionType = DepositAccountTransactionType.REVERSAL;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
depositTransactionType = DepositAccountTransactionType.INTEREST_POSTING;
|
||||
break;
|
||||
|
||||
default:
|
||||
depositTransactionType = DepositAccountTransactionType.INVALID;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return depositTransactionType;
|
||||
}
|
||||
|
||||
return depositTransactionType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -334,4 +334,5 @@ public class DepositAccountAssembler {
|
||||
public void postInterest(DepositAccount account) {
|
||||
account.postInterestForDepositAccount(account, this.fixedTermDepositInterestCalculator);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -20,4 +20,5 @@ public interface DepositAccountReadPlatformService {
|
||||
BigDecimal retrieveAvailableInterestForWithdrawal(DepositAccountData account);
|
||||
|
||||
Collection<DepositAccountsForLookup> retrieveDepositAccountForLookup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+34
-37
@@ -132,23 +132,27 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
private static final class DepositAccountMapper implements RowMapper<DepositAccountData> {
|
||||
|
||||
public String schema() {
|
||||
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.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.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_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.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.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.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,"
|
||||
+ " 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 "
|
||||
+ " join m_client c on c.id = da.client_id " + " join m_product_deposit pd on pd.id = da.product_id";
|
||||
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.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.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_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.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.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.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.image_key as imageKey, "
|
||||
+ " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol, "
|
||||
+ " ecd.father_name as fatherName, ecd.client_address as clientAddress "
|
||||
+ " 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
|
||||
@@ -208,11 +212,14 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
Integer lockinPeriod = JdbcSupport.getInteger(rs, "lockinPeriod");
|
||||
Integer lockinPeriodTypeValue = JdbcSupport.getInteger(rs, "lockinPeriodType");
|
||||
EnumOptionData lockinPeriodType = SavingsDepositEnumerations.interestCompoundingPeriodType(lockinPeriodTypeValue);
|
||||
|
||||
|
||||
BigDecimal availableInterest = rs.getBigDecimal("availableInterest");
|
||||
BigDecimal interestPostedAmount = rs.getBigDecimal("interestPostedAmount");
|
||||
LocalDate lastInterestPostedDate = JdbcSupport.getLocalDate(rs, "lastInterestPostedDate");
|
||||
LocalDate nextInterestPostedDate = JdbcSupport.getLocalDate(rs, "nextInterestPostedDate");
|
||||
BigDecimal interestPostedAmount = rs.getBigDecimal("interestPostedAmount");
|
||||
LocalDate lastInterestPostedDate = JdbcSupport.getLocalDate(rs, "lastInterestPostedDate");
|
||||
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,
|
||||
depositAmount, interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, maturedOn,
|
||||
@@ -220,15 +227,15 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
interestCompoundedEvery, interestCompoundedEveryPeriodType, renewalAllowed, preClosureAllowed, preClosureInterestRate,
|
||||
withdrawnonDate, rejectedonDate, closedonDate, isInterestWithdrawable, interestPaid, interestCompoundingAllowed,
|
||||
isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, availableInterest, interestPostedAmount, lastInterestPostedDate,
|
||||
nextInterestPostedDate);
|
||||
nextInterestPostedDate,fatherName,address,imageKey);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DepositAccountTransactionMapper implements RowMapper<DepositAccountTransactionData> {
|
||||
|
||||
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 "
|
||||
+ " from m_deposit_account_transaction txn";
|
||||
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, "
|
||||
+ "txn.total as total from m_deposit_account_transaction txn";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,7 +248,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
LocalDate transactionDate = JdbcSupport.getLocalDate(rs, "transactionDate");
|
||||
BigDecimal transactionAmount = rs.getBigDecimal("transactionAmount");
|
||||
BigDecimal interestAmount = rs.getBigDecimal("interestAmount");
|
||||
BigDecimal total = transactionAmount.add(interestAmount);
|
||||
BigDecimal total = rs.getBigDecimal("total");
|
||||
|
||||
return new DepositAccountTransactionData(transactionId, accountId, transactionType, transactionDate, transactionAmount,
|
||||
interestAmount, total);
|
||||
@@ -255,18 +262,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
boolean undoApprovalAllowed = (depositAccountData.getStatus().getId().equals(300L));
|
||||
boolean renewelAllowed = false;
|
||||
if (depositAccountData.getMaturedOn() != null) {
|
||||
if (new LocalDate().isAfter(depositAccountData.getMaturedOn())/*
|
||||
* ||
|
||||
* depositAccountData
|
||||
* .
|
||||
* getMaturedOn
|
||||
* ().
|
||||
* isEqual
|
||||
* (
|
||||
* new
|
||||
* LocalDate
|
||||
* ())
|
||||
*/) {
|
||||
if (new LocalDate().isAfter(depositAccountData.getMaturedOn())/* || depositAccountData.getMaturedOn().isEqual(new LocalDate()) */) {
|
||||
renewelAllowed = depositAccountData.isRenewalAllowed();
|
||||
}
|
||||
}
|
||||
@@ -312,4 +308,5 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -27,6 +27,11 @@ public class DepositAccountTransactionEnumerations {
|
||||
optionData = new EnumOptionData(DepositAccountTransactionType.REVERSAL.getValue().longValue(),
|
||||
DepositAccountTransactionType.REVERSAL.getCode(), "Revarsal");
|
||||
break;
|
||||
|
||||
case INTEREST_POSTING:
|
||||
optionData=new EnumOptionData(DepositAccountTransactionType.INTEREST_POSTING.getValue().longValue(), DepositAccountTransactionType.INTEREST_POSTING.getCode(), "Interest posting");
|
||||
break;
|
||||
|
||||
default:
|
||||
optionData = new EnumOptionData(DepositAccountTransactionType.INVALID.getValue().longValue(),
|
||||
DepositAccountTransactionType.INVALID.getCode(), "Invalid Transaction");
|
||||
|
||||
+1
@@ -55,4 +55,5 @@ public interface DepositAccountWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
||||
EntityIdentifier postInterestToDepositAccount(Collection<DepositAccountsForLookup> accounts);
|
||||
|
||||
}
|
||||
+5
-5
@@ -333,9 +333,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
if (account == null || account.isDeleted()) { throw new DepositAccountNotFoundException(command.getAccountId()); }
|
||||
if (account.isInterestWithdrawable() && !account.isInterestCompoundingAllowed()) {
|
||||
|
||||
BigDecimal totalAvailableInterestForWithdrawal = getTotalWithdrawableInterestAvailable(account);
|
||||
BigDecimal interestPaid = account.getInterstPaid();
|
||||
BigDecimal remainInterestForWithdrawal = totalAvailableInterestForWithdrawal.subtract(interestPaid);
|
||||
// BigDecimal totalAvailableInterestForWithdrawal = getTotalWithdrawableInterestAvailable(account);
|
||||
// BigDecimal interestPaid = account.getInterstPaid();
|
||||
BigDecimal remainInterestForWithdrawal = account.getAvailableInterest(); //totalAvailableInterestForWithdrawal.subtract(interestPaid);
|
||||
|
||||
if (remainInterestForWithdrawal.doubleValue() > 0) {
|
||||
if (remainInterestForWithdrawal.doubleValue() >= command.getWithdrawInterest().doubleValue()
|
||||
@@ -357,13 +357,13 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
return new EntityIdentifier(account.getId());
|
||||
}
|
||||
|
||||
private BigDecimal getTotalWithdrawableInterestAvailable(DepositAccount account) {
|
||||
/* private BigDecimal getTotalWithdrawableInterestAvailable(DepositAccount account) {
|
||||
BigDecimal interstGettingForPeriod = BigDecimal.valueOf(account.getAccuredInterest().getAmount().doubleValue()
|
||||
/ new Double(account.getTenureInMonths()));
|
||||
Integer noOfMonthsforInterestCal = Months.monthsBetween(account.getActualCommencementDate(), new LocalDate()).getMonths();
|
||||
Integer noOfPeriods = noOfMonthsforInterestCal / account.getInterestCompoundedEvery();
|
||||
return interstGettingForPeriod.multiply(new BigDecimal(noOfPeriods));
|
||||
}
|
||||
}*/
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
|
||||
+73
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user