Академический Документы
Профессиональный Документы
Культура Документы
services;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.Date;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.evolvus.account.bean.AccountTypeBean;
import com.evolvus.account.bean.MasterAccountBean;
import com.evolvus.account.business.IAccountBusiness;
import com.evolvus.collateralManagement.bean.CollateralBean;
import com.evolvus.common.bean.AuthenticationBean;
import com.evolvus.common.bean.CommonBean;
import com.evolvus.common.bean.DefinitionBean;
import com.evolvus.common.bean.StatusBean;
import com.evolvus.common.business.INumberGenerationBusiness;
import com.evolvus.common.exception.BaseException;
import com.evolvus.common.exception.ServiceException;
import com.evolvus.common.holiday.bean.HolidayBean;
import com.evolvus.common.holiday.business.IHolidayBusiness;
import com.evolvus.common.model.TaAcct;
import com.evolvus.common.model.TaAcctEntries;
import com.evolvus.common.model.TaDocumentMaster;
import com.evolvus.common.model.TaEntity;
import com.evolvus.common.model.TaTxnType;
import com.evolvus.common.model.TaUser;
import com.evolvus.common.util.AMSDateUtil;
import com.evolvus.common.util.Constants;
import com.evolvus.common.util.DateFormat;
import com.evolvus.common.util.ErrorCodeConstants;
import com.evolvus.documentmanagement.bean.DocumentBean;
import com.evolvus.documentmanagement.business.IDocumentBusiness;
import com.evolvus.entity.bean.EntityBean;
import com.evolvus.ibl.account.business.IMantleAccountBusiness;
import com.evolvus.ibl.bean.AcctEntriesBean;
import com.evolvus.ibl.bean.referral.RSABean;
import com.evolvus.ibl.bean.referral.ReferralEntriesBean;
import com.evolvus.ibl.bean.transaction.BaseTransactionBean;
import com.evolvus.ibl.business.IBLAccountEntriesBusiness;
import com.evolvus.ibl.customer.business.ICustomerBusiness;
import com.evolvus.ibl.product.business.MantleProductBusiness;
import com.evolvus.ibl.referral.business.ReferralBusiness;
import com.evolvus.ibl.util.ConstructAcctEntriesList;
import com.evolvus.ibl.util.HexString;
import com.evolvus.ibl.util.IBLConstants;
import com.evolvus.ibl.workflow.bean.MantleWorkFlowBean;
import com.evolvus.ibl.workflow.business.MantleWorkFlowBusiness;
import com.evolvus.loan.bean.LoanBean;
import com.evolvus.loan.bean.LoanRepaymentCycleBean;
import com.evolvus.loan.bean.LoanScheduleBean;
import com.evolvus.loanManagement.bean.LoanDisbursementBean;
import com.evolvus.loanManagement.bean.LoanRepaymentBean;
import com.evolvus.loanManagement.bean.LoanRepaymentStructureBean;
import com.evolvus.loanManagement.bean.LoanWriteoffBean;
import com.evolvus.loanManagement.business.IMantleLoanBusiness;
import com.evolvus.microbeans.definition.business.IDefinitionBusiness;
import com.evolvus.narration.business.INarrationBusiness;
import com.evolvus.numbergeneration.business.IGenericNumberGenerationBusiness;
import com.evolvus.numbergenration.constant.NumberGenConstant;
import com.evolvus.product.bean.ProductBean;
import com.evolvus.product.business.ProductBusiness;
import com.evolvus.product.interest.bean.InterestBean;
import com.evolvus.product.interest.business.InterestBusiness;
import com.evolvus.product.util.ILoanErrorCode;
import com.evolvus.product.util.IProductConstants;
import com.evolvus.transactioncontroller.bean.ResponseBean;
import com.evolvus.transactioncontroller.business.ITransactionBusiness;
import com.evolvus.transactioncontroller.exception.TransactionFailureException;
import com.evolvus.user.bean.CustomerBean;
import com.evolvus.user.bean.UserBean;
import com.evolvus.user.business.CustomerBusiness;
import com.evolvus.user.business.IUserBusiness;
import com.evolvus.workflow.bean.WorkflowBean;
import com.evolvus.workflow.business.IWorkflowBaseBusiness;
/**
* @param holidayBusiness the holidayBusiness to set
*/
public void setHolidayBusiness(IHolidayBusiness holidayBusiness) {
this.holidayBusiness = holidayBusiness;
}
/**
* @param narrationBusiness the narrationBusiness to set
*/
public void setNarrationBusiness(INarrationBusiness narrationBusiness) {
this.narrationBusiness = narrationBusiness;
}
/**
* Method : findLoanDisburseDetailsByLoanApplicationNumber Purpose 1. find
all the loan details
*
* @param loanApplicationNumber
* @return LoanDisbursementBean
*/
public LoanDisbursementBean
findLoanDisburseDetailsByLoanApplicationNumber(
String loanApplicationNumber,AuthenticationBean
authenticationBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
String acctType = "";
List<DefinitionBean> paymentModeList = null;
List<DefinitionBean> swifthChargeList = null;
List<DefinitionBean> definitionBeanList = null;
List<DefinitionBean> chargeBeanList = null;
LoanDisbursementBean loanDisbursementBean = new
LoanDisbursementBean();
loanDisbursementBean.setReferralIdentificationNumber(loanBean.getReferralIdentificati
onNumber());
loanDisbursementBean.setRefStatus(loanBean.getReferralStatus());
String accountType=
mantleProductBusiness.findProductAttributeByProductIdAndAttribute(loanBean.getProd
uctId(), IProductConstants.ACCOUNT_TYPE);
TaAcct taAcct = this.mantleLoanBusiness
.findLoanAcctByLoanApplicationNumber(loanApplication
Number,
accountType);
paymentModeList = this.definitionBusiness
.loadDefinitionList(Constants.DEFINITION_TYPE_PAY
MENT_MODE);
swifthChargeList = this.definitionBusiness
.loadDefinitionList(Constants.DEFINITION_TYPE_SWIF
TH_CHARGE);
loanDisbursementBean.setCustomerNum(loanBean.getCustomerNumber());
loanDisbursementBean.setProductName(loanBean.getProductName());
loanDisbursementBean.setCustomerName(loanBean.getCustomerName());
loanDisbursementBean.setLoanApplcationNum(loanBean
.getLoanApplicationNumber());
loanDisbursementBean.setLoanAmount(loanBean.getLoanAmount());
if(loanBean
.getLoanSanctionAmount()!=null){
loanDisbursementBean.setLoanSanctionAmount(loanBean
.getLoanSanctionAmount().toString());
}
if(loanBean.getLoanDisburseAmount()!=null){
loanDisbursementBean.setAmtDisbursed(loanBean.getLoanDisburseAmount()
.toString());
}
if ((loanBean.getLoanSanctionAmount().subtract(loanBean
.getLoanDisburseAmount())).compareTo(BigDecimal.ZER
O) == 0) {
throw new
ServiceException(ILoanErrorCode.LOAN_IS_DISBURSED);
}
loanDisbursementBean.setAmtDisburse(loanBean.getLoanSanctionAmount()
.subtract(loanBean.getLoanDisburseAmount()).toString());
loanDisbursementBean.setCustEntityName(loanBean.getEntityName());
loanDisbursementBean.setRepaymentFrequency(loanBean
.getRepaymentFrequency());
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanDisbursementBean;
}
/**
* Method : insertLoanDisburseMentAcctEntries Purpose : to insert
LoanDisburseMent
* @param loanDisbursementBean
* @return loanDisbursementBean
*
*/
public LoanDisbursementBean insertLoanDisburseMentAcctEntries(
LoanDisbursementBean loanDisbursementBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
TaAcctEntries[] taAcctEntries = null;
TaAcctEntries[] responseTaAcctEntries = null;
ArrayList<TaAcctEntries> taAcctEntrieslist = null;
ResponseBean responseBean = new ResponseBean();
ArrayList accountEntriesList = null;
String crAcctNum =
"0003879100356";//loanDisbursementBean.getProductLoanAccount();
List<TaAcctEntries[]> responseList = new ArrayList<TaAcctEntries[]>();
BaseTransactionBean baseTransactionBean = (BaseTransactionBean)
loanDisbursementBean;
ConstructAcctEntriesList constructAcctEntriesList = new
ConstructAcctEntriesList();
HashMap<String, String> macroValueMap = new HashMap<String,
String>();
Date businessDate =
loanDisbursementBean.getAuthenticationBean().getBusinessDate();
String userName =
loanDisbursementBean.getAuthenticationBean().getLoggedInUserName();
macroValueMap.put(NumberGenConstant.MACRO_LOAN_DISBURSEMENT,Constan
ts.LOAN_DISBURSEMENT);
macroValueMap.put(NumberGenConstant.MACRO_CUSTOMER_ID,
loanDisbursementBean.getCustomerId());
macroValueMap.put(NumberGenConstant.MACRO_CUSTOMER_NAME,
loanDisbursementBean.getCustomerName());
macroValueMap.put(NumberGenConstant.MACRO_LOAN_APP_NUM,
loanDisbursementBean.getLoanApplcationNum());
String narration = narrationBusiness.generateNarrtion(
macroValueMap,
Constants.TXN_TYPE_LOAN_DISBURSEMENT,
userName, businessDate);
taAcctEntrieslist = this.hydrateAccountEntries(loanDisbursementBean
.getAuthenticationBean(),
loanDisbursementBean.getAccountNum(),
crAcctNum, new BigDecimal(loanDisbursementBean
.getAmtDisburse()),Constants.TXN_TYPE_
LOAN_DISBURSEMENT, Constants.CONSTANTS_DEBIT,narration);
if (taAcctEntrieslist != null && taAcctEntrieslist.size() > 0) {
try {
constructAcctEntriesList
.generateTransactionServiceList(taAcctEntri
eslist);
taAcctEntries = new
TaAcctEntries[taAcctEntrieslist.size()];
//responseTaAcctEntries = transactionBusiness
.equationTransactionController(taAcctEntries);
} catch (TransactionFailureException e) {
e.printStackTrace();
responseList.add(taAcctEntries);
responseBean.setErrorMessage(e.getMessageKey());
responseBean.setTransactionStatus(false);
responseBean.setSeqNo(e.getMessageKey());
throw new ServiceException(e.getMessageKey());
} catch (BaseException e) {
responseList.add(taAcctEntries);
responseBean.setErrorMessage(e.getMessageKey());
responseBean.setTransactionStatus(false);
responseBean.setSeqNo(e.getMessageKey());
throw new ServiceException(e.getMessageKey());
} catch (Exception e) {
// TODO: handle exception
responseList.add(taAcctEntries);
responseBean.setErrorMessage(e.getMessage());
responseBean.setTransactionStatus(false);
responseBean.setSeqNo(e.getMessage());
throw new ServiceException(e.getMessage());
}
for (int i = 0; i < taAcctEntrieslist.size(); i++) {
TaAcctEntries tAcctEntries = (TaAcctEntries)
taAcctEntrieslist
.get(i);
if (tAcctEntries.getEntrySeq() == 1)
baseTransactionBean.setHdrAmount(String
.valueOf(tAcctEntries.getTxnAmoun
t()));
}
for (int i = 0; i < taAcctEntrieslist.size(); i++) {
TaAcctEntries tAcctEntries = (TaAcctEntries)
taAcctEntrieslist
.get(i);
if (tAcctEntries.getCashAccount() ==
IBLConstants.CASH_ACCOUNT_FALSE) {
baseTransactionBean.setTxnReferenceNumber(tAcctEntries
.getTxnNumber());
}
}
baseTransactionBean.setSuperUserId(loanDisbursementBean
.getAuthenticationBean().getLoggedInUserId());
/*accountEntriesList = this.accountEntriesBusiness
.saveAccountEntriesList(taAcctEntrieslist,
Constants.CONSTANTS_CREDIT,
loanDisbursementBean
.getAuthenticationBea
n().getBusinessDate(),
"", "", loanDisbursementBean
.getAuthenticationBea
n()
.getLoggedInUserEnti
tyId(),
Constants.TXN_TYPE_LOAN_DISBURSEMENT, "",
baseTransactionBean);*/
accountEntriesList = accountEntriesBusiness
.saveAccountEntriesList(taAcctEntrieslist,
IBLConstants.CONSTANTS_DEBIT,
loanDisbursementBean
.getAuthenticationBean().getBusinessDate(),
IBLConstants.EMPTY,
null, loanDisbursementBean
.getAuthenticationBean()
.getLoggedInUserEntityId(),
Constants.TXN_TYPE_LOAN_DISBURSEMENT,
null,
baseTransactionBean);
}
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanDisbursementBean;
}
/**
* Method : hydrateAccountEntries Purpose : to hydrateAccountEntries
* @param authenticationBean
* @param creditAcctNum
* @param debitAcctNum
* @param txnAmount
* @param txnName
* @return ArrayList<TaAcctEntries>
*
*/
public ArrayList<TaAcctEntries> hydrateAccountEntries(
AuthenticationBean authenticationBean, String debitAcctNum,
String creditAcctNum, BigDecimal txnAmount, String
txnName,String DebitCreditFlag,String narration) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
ArrayList<TaAcctEntries> taAcctEntrieslist = new
ArrayList<TaAcctEntries>();
DateFormat dateFormat = new DateFormat();
TaAcct taAcct = new TaAcct();
TaAcctEntries crAcctEntries = new TaAcctEntries();
TaAcctEntries drAcctEntries = new TaAcctEntries();
taAcct.setAcctNum(creditAcctNum);
crAcctEntries.setEntrySeq(2);
crAcctEntries.setCurrency("INR");
crAcctEntries.setTaAcct(taAcct);
crAcctEntries.setTxnValueDate(authenticationBean.getBusinessDate());
crAcctEntries.setAccountNumber1(crAcctEntries.getTaAcct().getAcctNum()
.substring(0, 4));
crAcctEntries.setAccountNumber2(crAcctEntries.getTaAcct().getAcctNum()
.substring(4, 10));
crAcctEntries.setAccountNumber3(crAcctEntries.getTaAcct().getAcctNum()
.substring(10, 13));
String currentDateObj = dateFormat.convertToFormatDateRef(
authenticationBean.getBusinessDate().toString(),
Constants.DATE_FORMAT);
crAcctEntries.setValueFromDate(authenticationBean.getCenturyIndicator()
+ currentDateObj);
crAcctEntries.setBranchMnemonic(authenticationBean
.getLoggedInUserEntityName());
taEntity.setEntityName(authenticationBean.getLoggedInUserEntityName());
taEntity.setEntityId(authenticationBean.getLoggedInUserEntityId());
crAcctEntries.setTaEntity(taEntity);
crAcctEntries.setTaUser(taUser);
crAcctEntries.setDebitCreditFlag(Constants.CONSTANTS_CREDIT);
crAcctEntries.setCashAccount(IBLConstants.CASH_ACCOUNT_FALSE);
crAcctEntries.setHostReferenceKey("");
crAcctEntries.setBusinessDate(authenticationBean.getBusinessDate());
crAcctEntries.setHostTxnStatus(IBLConstants.HOST_STATUS_PENDING);
crAcctEntries.setTxnName(txnName);
crAcctEntries.setTxnNarration(narration);
crAcctEntries.setTxnAmount(txnAmount);
TaTxnType crtaTxnType = new TaTxnType();
crtaTxnType.setTxnTypeCode(txnName);
crAcctEntries.setTaTxnType(crtaTxnType);
taAcctEntrieslist.add(crAcctEntries);
drAcctEntries.setEntrySeq(1);
TaAcct taAcctDr = new TaAcct();
taAcctDr.setAcctNum(debitAcctNum);
drAcctEntries.setTxnNarration("");
drAcctEntries.setCurrency("INR");
drAcctEntries.setTaAcct(taAcctDr);
drAcctEntries.setTxnValueDate(authenticationBean.getBusinessDate());
drAcctEntries.setAccountNumber1(drAcctEntries.getTaAcct().getAcctNum()
.substring(0, 4));
drAcctEntries.setAccountNumber2(drAcctEntries.getTaAcct().getAcctNum()
.substring(4, 10));
drAcctEntries.setAccountNumber3(drAcctEntries.getTaAcct().getAcctNum()
.substring(10, 13));
currentDateObj =
dateFormat.convertToFormatDateRef(authenticationBean
.getBusinessDate().toString(),
Constants.DATE_FORMAT);
drAcctEntries.setValueFromDate(authenticationBean.getCenturyIndicator()
+ currentDateObj);
drAcctEntries.setBranchMnemonic(authenticationBean
.getLoggedInUserEntityName());
drAcctEntries.setHostReferenceKey("");
taEntity = new TaEntity();
taUser = new TaUser();
taUser.setUserId(authenticationBean.getLoggedInUserId());
taEntity.setEntityName(authenticationBean.getLoggedInUserEntityName());
taEntity.setEntityId(authenticationBean.getLoggedInUserEntityId());
drAcctEntries.setTaEntity(taEntity);
drAcctEntries.setTaUser(taUser);
drAcctEntries.setDebitCreditFlag(DebitCreditFlag);
drAcctEntries.setCashAccount(IBLConstants.CASH_ACCOUNT_FALSE);
drAcctEntries.setCashAccount(IBLConstants.CASH_ACCOUNT_FALSE);
drAcctEntries.setBusinessDate(authenticationBean.getBusinessDate());
drAcctEntries.setHostTxnStatus(IBLConstants.HOST_STATUS_PENDING);
drAcctEntries.setTxnName(txnName);
drAcctEntries.setTxnAmount(txnAmount);
TaTxnType drtaTxnType = new TaTxnType();
drtaTxnType.setTxnTypeCode(txnName);
drAcctEntries.setTaTxnType(drtaTxnType);
taAcctEntrieslist.add(drAcctEntries);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return taAcctEntrieslist;
}
/**
* Method : insertLoanDisbursementRSA Purpose : to Loan Disburse
* @param LoanDisbursementBean
* @return LoanDisbursementBean
*
*/
public LoanDisbursementBean
insertLoanDisbursementRSA(LoanDisbursementBean loanDisbursementBean){
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
boolean referralStatus = false;
HashMap<String, String> macroValueMap = new HashMap<String,
String>();
Date businessDate =
loanDisbursementBean.getAuthenticationBean().getBusinessDate();
String userName =
loanDisbursementBean.getAuthenticationBean().getLoggedInUserName();
macroValueMap.put(NumberGenConstant.MACRO_LOAN_DISBURSEMENT,Constan
ts.LOAN_DISBURSEMENT);
macroValueMap.put(NumberGenConstant.MACRO_CUSTOMER_ID,
loanDisbursementBean.getCustomerNum());
macroValueMap.put(NumberGenConstant.MACRO_CUSTOMER_NAME,
loanDisbursementBean.getCustomerName());
macroValueMap.put(NumberGenConstant.MACRO_LOAN_APP_NUM,
loanDisbursementBean.getLoanApplcationNum());
String narration = narrationBusiness.generateNarrtion(
macroValueMap,
Constants.TXN_TYPE_LOAN_DISBURSED,
userName, businessDate);
ArrayList<TaAcctEntries> acctEntrieslist =
hydrateAccountEntries(loanDisbursementBean.getAuthenticationBean(),loanDisburseme
ntBean.getAccountNum(),
"0003879100356",new
BigDecimal(loanDisbursementBean.getAmtDisburse()),
Constants.TXN_TYPE_LOAN_DISBURSED,Constants.CONSTANTS_DEBIT,narratio
n);
loanDisbursementBean.setCreditDebitFlag(Constants.CONSTANTS_DEBIT);
loanDisbursementBean.setEntriesList(acctEntrieslist);
loanDisbursementBean.setValueDate(loanDisbursementBean.getAuthenticationBean().ge
tStrBusinessDate());
loanDisbursementBean.setHdrAmount(loanDisbursementBean.getAmtDisburse().toStrin
g());
loanDisbursementBean.setHdrAvailableFund("0.00");
loanDisbursementBean.setTxnReferenceNumber("");
loanDisbursementBean.setReferralIdentificationNumber("-1");
loanDisbursementBean.setTxnName(Constants.TXN_TYPE_LOAN_DISBURSED);
if(loanDisbursementBean.getPaymentModeOption()>0){
DefinitionBean paymentMode= null;
paymentMode =
this.definitionBusiness.loadDefinition(loanDisbursementBean.getPaymentModeOption())
;
int index = 0;
loanDisbursementBean.setPayMode(paymentMode.getDefinitionCode());
if(paymentMode.getDefinitionCode().equalsIgnoreCase(Constants.PAYMENT_MODE_
SWIFT))
index=1;
else
if(paymentMode.getDefinitionCode().equalsIgnoreCase(Constants.PAYMENT_MODE_
DRAFT))
index=0;
else
if(paymentMode.getDefinitionCode().equalsIgnoreCase(Constants.PAYMENT_MODE_
ACCOUNT))
index = 2;
loanDisbursementBean.setModBankName(loanDisbursementBean.getModeBankName()
[index]);
loanDisbursementBean.setModAcctName(loanDisbursementBean.getModeAcctName()
[index]);
loanDisbursementBean.setModAcctNum(loanDisbursementBean.getModeAcctNum()
[index]);
loanDisbursementBean.setModBranchName(loanDisbursementBean.getModeBranchNa
me()[index]);
if(loanDisbursementBean.getSwiftChargeId()==0){
loanDisbursementBean.setSwiftAddres("");
loanDisbursementBean.setSwiftChargeCode("");
}
}
loanDisbursementBean.setCurrencyId(Integer.valueOf(loanDisbursementBean.getAuthen
ticationBean().getLocalCurrency()));
BaseTransactionBean baseTransactionBean =
this.insertTransactions(loanDisbursementBean);
/*ReferralEntriesBean referralEntriesBean=
baseTransactionBean.getRsaBean().getRsaEntriesId();
referralEntriesBean.getRsaBean().getRsaEntriesId();*/
LoanBean loanBean
= new LoanBean();
loanBean.setLoanApplcationNum(loanDisbursementBean.getLoanApplcationNum());
loanBean.setRsaEntryId(baseTransactionBean.getRsaBean().getRsaEntriesId());
mantleLoanBusiness.updateLoanWithRSA(loanBean);
/*if(!referralStatus)
this.mantleLoanBusiness.serviceLoanDisbursement(loanDisbursementBean);*/
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanDisbursementBean;
}
/**
* Method : serviceLoanDisbursement Purpose : to Loan Disburse
* @param LoanDisbursementBean
* @return LoanDisbursementBean
*
*/
public LoanDisbursementBean serviceLoanDisbursement(
LoanDisbursementBean loanDisbursementBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
this.insertLoanDisburseMentAcctEntries(loanDisbursementBean);
List<HolidayBean> holidayBeanList = holidayBusiness
.findHolidayByCurrencyId(Integer.parseInt(loanDisbursementBean.getAu
thenticationBean().getLocalCurrency()));
loanDisbursementBean.setHolidayBeanList(holidayBeanList);
this.mantleLoanBusiness.serviceLoanDisbursement(loanDisbursementBean);
this.referralBusiness.findAndUpdateRsaEntriesToCompleteTransaction(loanDisburseme
ntBean.getReferralIdentificationNumber());
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanDisbursementBean;
}
/**
* Method : searchLoanApplicationNumber Purpose : to search the loan
application number
* @param loanBean
* @return List<LoanBean>
*
*/
public List<LoanBean> searchLoanApplicationNumber(LoanBean loanBean) {
if (logger.isDebugEnabled())
logger.debug("START");
/**
* Method : searchLoanDisbuseHistoryDetails Purpose : to search the loan
application number
* @param loanBean
* @return List<LoanBean>
*
*/
public List<LoanBean> searchLoanDisbuseHistoryDetails(LoanBean loanBean) {
if (logger.isDebugEnabled())
logger.debug("START");
/**
* Method : findCustomerCategory
* Purpose: to find the customer category from the definition.
* @return : LoanBean
* @param : customerCategory
*/
if (logger.isTraceEnabled())
logger.trace(" END");
return loanBean;
}
/**
* Method:findProductAttributesByProductId
* Purpose: to find the product attributed for loan based on the product id
* @return :ProductBean
* @param
:productId,businnessDaeStrfindProductAndCustomerAttributesforLoan
*/
customerBean.setDateOfBirth(customerBean.getCustomerDOB());*/
// CustomerBean customerBean =
mantleCustomerBusiness.findCustomerByCustomerNumber(String.valueOf(loanBean.ge
tCustomerNum()));
CustomerBean customerBean =
mantleCustomerBusiness.findCustomerByCustomerNumber(customerNumber);
if(customerBean.getCustomerDOB()!=null &&
customerBean.getCustomerDOB().length()>0){
try {
int age =
AMSDateUtil.retrieveAgeByDate(DateFormat.parseDate(customerBean.getCustomerDO
B(), Constants.DATE_PATTERN));
customerBean.setAge(age);
loanBean.setAge(String.valueOf(age));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
loanBean.setCustomerBean(customerBean);
}
if (logger.isTraceEnabled())
logger.trace(" END");
return loanBean;
}
/**
* Method: insertSaveLoanApplication
* Purpose: to insert the loan application detials
* @return LoanBean
* @param LoanBean
*/
public LoanBean insertSaveLoanApplication(LoanBean loanBean) {
if (logger.isTraceEnabled())
logger.trace(" START");
if(loanBean.getLoanApplicationNumber()==null ||
loanBean.getLoanApplicationNumber().length()<=0){
HashMap<String, String> macroValueMap = new
HashMap<String, String>();
macroValueMap.put(NumberGenConstant.MACRO_PRODUCT_CODE,""+loanBean.ge
tProductCode());
String loanApplicationNumber =
this.genericNumberGenerationBusiness.
generatingRefNum(macroValueMap,
NumberGenConstant.REF_LOAN_APPLICATION_NUMBER,
loanBean.getAuthenticationBean().getLoggedInUserName(),loanBean.getAuthentication
Bean().getBusinessDate());
loanBean.setLoanApplicationNumber(loanApplicationNumber)
;
}
CustomerBean WalkInCustomerBean = null;
if(loanBean.getWalkInCustomerBean()!=null){
WalkInCustomerBean = loanBean.getWalkInCustomerBean();
WalkInCustomerBean =
mantleCustomerBusiness.insertWalkInCustomerForLoan(WalkInCustomerBean);
loanBean.setWalkInCustomerBean(WalkInCustomerBean);
}
if(loanBean.getCustomerNumber()!=null &&
loanBean.getCustomerNumber().length()>0){
CustomerBean customerBean =
mantleCustomerBusiness.findCustomerByCustomerNumber(loanBean.getCustomerNum
ber());
if(customerBean!=null){
if(customerBean.getCustomerDOB()!=null &&
customerBean.getCustomerDOB().length()>0){
try {
int age =
AMSDateUtil.retrieveAgeByDate(DateFormat.parseDate(customerBean.getCustomerDO
B(), Constants.DATE_PATTERN));
customerBean.setAge(age);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
loanBean.setCustomerBean(customerBean);
}
}
//List<TaDocumentMaster> documentList =
documentBusiness.insertDocument(loanBean.getDocumentBeanList(),
"PROJECT_DOC", loanBean.getAuthenticationBean().getLoggedInUserRoleId();
if(loanBean.getDocumentBeanList()!=null){
List<TaDocumentMaster> documentList =
documentBusiness.insertDocument(loanBean.getDocumentBeanList(),
loanBean.getDocCode(), loanBean.getAuthenticationBean().getLoggedInUserRoleId(),
loanBean.getAuthenticationBean().getBusinessDate(),
loanBean.getAuthenticationBean().getLoggedInUserId());
List<Integer> integerList =
this.constructIntegerFromTaDocumentMaster(documentList);
List<DocumentBean> documentBeanSaveList =
documentBusiness.findDoumentMasterListByDocumentIdListAndloginUsername(intege
rList, loanBean.getAuthenticationBean().getLoggedInUserName());
loanBean.setDocumentBeanSaveList(documentBeanSaveList);
this.insertLoanDocument(loanBeanObject.getLoanId(),integerList,loanBean);
}
if (logger.isTraceEnabled())
logger.trace(" END");
return loanBeanObject;
}
private void insertLoanDocument(int loanId, List<Integer> integerList,LoanBean
loanBean) {
mantleLoanBusiness.insertLoanDocument(loanId,integerList,loanBean);
}
/**
* Method:constructIntegerFromTaDocumentMaster
* Purpose:
* @return
* @param List<Integer>
*
*/
private List<Integer>
constructIntegerFromTaDocumentMaster( List<TaDocumentMaster>
documentMasterList){
List<Integer> taDocumentMasterList = new ArrayList<Integer>();
if(documentMasterList!=null && documentMasterList.size()>0){
for (TaDocumentMaster taDocumentMaster :
documentMasterList) {
Integer integer = new
Integer(taDocumentMaster.getDocumentId());
taDocumentMasterList.add(integer);
}
}
return taDocumentMasterList;
}
/**
* Method : findLoanScheduleListWithoutDates
* Purpose 1.finding the schedule list by passing required loan application details
* @param LoanBean
* @return LoanBean
*/
public ArrayList<LoanRepaymentCycleBean>
findLoanScheduleListWithoutDates(
LoanBean reqBean) {
if (logger.isTraceEnabled())
logger
.debug("
LoanManager::findLoanScheduleListWithoutDates::START");
Float discreationValue = null ;
if(reqBean.getInterestRate()!=null && reqBean.getInterestRate().trim().length()>0){
discreationValue = Float.parseFloat(reqBean.getInterestRate());
}
String dscrtnVlue = discreationValue.toString();
int recurrence = reqBean.getRecurrance();
int installment = Integer.parseInt(reqBean.getInstallment());
BigDecimal loanAmount =new BigDecimal(reqBean.getLoanAmount());
this.definitionBusiness.loadDefinition(Integer.valueOf(reqBean.getRepaymentFrequency
Id()));
reqBean.setFrequencyCode(defBean.getDefinitionCode());
}
if ((Constants.WEEKLY).equals(reqBean.getFrequencyCode())) {
int periodicity = recurrence * 7;
loanScheduleBean.setPeriodicity(periodicity);
} else if ((Constants.MONTHLY).equals(reqBean.getFrequencyCode()))
{
int periodicity = recurrence * 30;
loanScheduleBean.setPeriodicity(periodicity);
}else if
((Constants.HALF_YEARLY).equals(reqBean.getFrequencyCode())) {
int periodicity = recurrence * 30;
loanScheduleBean.setPeriodicity(periodicity);
}
else if ((Constants.QUATERLY).equals(reqBean.getFrequencyCode())) {
int periodicity = recurrence * 180;
loanScheduleBean.setPeriodicity(periodicity);
}
else if ((Constants.YEARLY).equals(reqBean.getFrequencyCode())) {
int periodicity = recurrence * 365;
loanScheduleBean.setPeriodicity(periodicity);
}
else if ((Constants.DAILY).equals(reqBean.getFrequencyCode())) {
int periodicity = recurrence * 1;
loanScheduleBean.setPeriodicity(periodicity);
}
loanScheduleBean.setLoanAmount(loanAmount);
loanScheduleBean.setNumberOfInstalments(installment);
interestType =
Constants.INTEREST_TYPE_DECLAINING_WITH_EQUATED_PRINCIPAL;
//if the interest type is flat inerest
if (interestType
.equalsIgnoreCase(Constants.INTEREST_TYPE_FLAT_I
NTEREST)) {
if (reqBean.getInterestDeductedAtDisbursement() != null
&&
reqBean.getInterestDeductedAtDisbursement().trim()
.length() > 0
&& reqBean.getInterestDeductedAtDisbursement()
.equalsIgnoreCase(Constants.YES))
{
loanScheduleList =
generateLSForFIntrIntrDeductAtDisbWithoutDate(
interestRates, loanScheduleBean);
} else {
loanScheduleList =
generateLSForFIWithoutDate(interestRates,
loanScheduleBean);
}
}
//if the interest type is declining interest
else if (interestType
.equalsIgnoreCase(Constants.INTEREST_TYPE_DECLAI
NING_INTEREST)) {
loanScheduleList = this.generateLSForDBWithoutMeetingDate(
interestRates, loanScheduleBean);
}
//if the interest type is declining interest with equated principle
else if (interestType
.equalsIgnoreCase(Constants.INTEREST_TYPE_DECLAI
NING_WITH_EQUATED_PRINCIPAL)) {
loanScheduleList =
this.generateLSForDBEPWithoutMeetingDate(
interestRates, loanScheduleBean);
}
if (logger.isTraceEnabled())
logger.debug("
LoanManager::findLoanScheduleListWithoutDates::END");
return loanScheduleList;
}
/**
* Method : generateLSForDBWithoutMeetingDate
* Purpose 1.
* @param actualInterestRate
* @param loanScheduleBean
* @return ArrayList<LoanRepaymentCycleBean>
*/
private ArrayList<LoanRepaymentCycleBean>
generateLSForDBWithoutMeetingDate(
BigDecimal actualInterestRate, LoanScheduleBean
loanScheduleBean) {
if (logger.isTraceEnabled())
logger
.debug("
LoanManager::generateLSForDBWithoutMeetingDate::END");
BigDecimal loanAmount = loanScheduleBean.getLoanAmount();
BigDecimal numberOfDays = new BigDecimal(loanScheduleBean
.getPeriodicity()); // Input
BigDecimal interestDurationInYrs = numberOfDays.divide(new
BigDecimal(
360), 5, 2);
int noOfInstallments = loanScheduleBean.getNumberOfInstalments();
BigDecimal interestRateAtPeriod = actualInterestRate
.multiply(interestDurationInYrs);
BigDecimal EMIAmount = new BigDecimal(0);
BigDecimal interestAmount = new BigDecimal(0);
BigDecimal principalAmount = new BigDecimal(0);
BigDecimal one = new BigDecimal(1);
ArrayList<LoanRepaymentCycleBean> loanScheduleDtlList = new
ArrayList<LoanRepaymentCycleBean>();
MathContext mc1 = new MathContext(5);
int noOfInstallmentstoPrint = noOfInstallments;
for (int i = 0; i < noOfInstallments; i++) {
/**
* Method : diminishingEquatedPrincipal
* Purpose 1.
* @param principalOutstanding
* @param loanAmount
* @param rateOfInterest
* @param terms
* @param interestRateAtPeriod
* @return ArrayList<LoanRepaymentCycleBean>
*/
public LoanRepaymentCycleBean diminishingEquatedPrincipal(
BigDecimal principalOutstanding, BigDecimal loanAmount,
BigDecimal rateOfInterest, int terms,
BigDecimal interestRateAtPeriod) {
if (logger.isTraceEnabled())
logger.debug("
LoanManager::diminishingEquatedPrincipal::START");
LoanRepaymentCycleBean loanRepaymentCycleBean = new
LoanRepaymentCycleBean();
BigDecimal principal = loanAmount.divide(new BigDecimal(terms), 5);
BigDecimal interest = principalOutstanding.multiply(
interestRateAtPeriod).multiply(rateOfInterest);
String pos = principalOutstanding.toString();
String irp = interestRateAtPeriod.toString();
String rtOfIntrst = rateOfInterest.toString();
BigDecimal EMI = interest.add(principal);
loanRepaymentCycleBean.setEmiAmount(EMI);
loanRepaymentCycleBean.setInterestAmount(interest);
String intAmt = interest.toString();
loanRepaymentCycleBean.setPrincipalAmount(principal);
if (logger.isTraceEnabled())
logger.debug("
LoanManager::diminishingEquatedPrincipal::END");
return loanRepaymentCycleBean;
}
/**
* Method : generateLSForDBEPWithoutMeetingDate
* Purpose 1.
* @param actualInterestRate
* @param loanScheduleBean
* @return ArrayList<LoanRepaymentCycleBean>
*/
private ArrayList<LoanRepaymentCycleBean>
generateLSForDBEPWithoutMeetingDate(
BigDecimal interestRates, LoanScheduleBean loanScheduleBean)
{
if (logger.isTraceEnabled())
logger
.debug("
LoanManager::generateLSForDBEPWithoutMeetingDate::END");
ArrayList<LoanRepaymentCycleBean> loanRepaymentCycleBeanList =
new ArrayList<LoanRepaymentCycleBean>();
// Principle amount = loanAmount
BigDecimal loanAmount = loanScheduleBean.getLoanAmount();
BigDecimal numberOfDays = new BigDecimal(loanScheduleBean
.getPeriodicity()); // Input
BigDecimal interestRateAtPeriod = numberOfDays.divide(new
BigDecimal(
360), 8, 2);
int noOfInstallments = loanScheduleBean.getNumberOfInstalments();
BigDecimal principalOutStanding = loanAmount;
for (int i = 0, j = 1; i < noOfInstallments; i++, j++) {
LoanRepaymentCycleBean loanRepaymentCycleBean =
diminishingEquatedPrincipal(
principalOutStanding, loanAmount, interestRates,
noOfInstallments, interestRateAtPeriod);
principalOutStanding = principalOutStanding
.subtract(loanRepaymentCycleBean.getPrincipalAm
ount());
loanRepaymentCycleBean.setInstalmentNumber(j);
loanRepaymentCycleBeanList.add(loanRepaymentCycleBean);
}
if (logger.isTraceEnabled())
logger
.debug("
LoanManager::generateLSForDBEPWithoutMeetingDate::END");
return loanRepaymentCycleBeanList;
}
/**
* Method : generateLSForFIWithoutDate
* Purpose 1.
* @param actualInterestRate
* @param loanScheduleBean
* @return ArrayList<LoanRepaymentCycleBean>
*/
private ArrayList<LoanRepaymentCycleBean> generateLSForFIWithoutDate(
BigDecimal actualInterestRate, LoanScheduleBean
loanScheduleBean) {
if (logger.isTraceEnabled())
logger.trace("LoanManager :: generateLSForFIWithoutDate ::
START");
BigDecimal loanAmount = loanScheduleBean.getLoanAmount();
int periodicityValue = loanScheduleBean.getPeriodicity();
BigDecimal interestRateAtPeriod = new BigDecimal(periodicityValue)
.divide(new BigDecimal(360), 5, 2);
interestRateAtPeriod = interestRateAtPeriod
.multiply(actualInterestRate);
BigDecimal formula = (loanAmount.multiply(interestRateAtPeriod))
.multiply(new BigDecimal(loanScheduleBean
.getNumberOfInstalments()));
BigDecimal totalLoanAmount = loanAmount.add(formula);
BigDecimal principal = totalLoanAmount.divide(new BigDecimal(
loanScheduleBean.getNumberOfInstalments()), 5, 2);
principal = principal.setScale(5, RoundingMode.HALF_UP);
BigDecimal interestRate = totalLoanAmount.subtract(loanAmount);
interestRate = interestRate.divide(new BigDecimal(loanScheduleBean
.getNumberOfInstalments()));
principal = principal.subtract(interestRate);
ArrayList<LoanRepaymentCycleBean> loanRepaymentCycleList = new
ArrayList<LoanRepaymentCycleBean>();
for (int index = 0; index < loanScheduleBean.getNumberOfInstalments();
index++) {
LoanRepaymentCycleBean loanRepaymentCycleBean = new
LoanRepaymentCycleBean();
loanRepaymentCycleBean.setInstalmentNumber(index + 1);
loanRepaymentCycleBean.setInterestAmount(interestRate);
loanRepaymentCycleBean.setPrincipalAmount(principal);
loanRepaymentCycleBean.setEmiAmount(interestRate.add(principal));
loanRepaymentCycleList.add(loanRepaymentCycleBean);
}
if (logger.isTraceEnabled())
logger.trace("LoanManager :: generateLSForFIWithoutDate ::
END");
return loanRepaymentCycleList;
}
/**
* Method : generateLSForFIntrIntrDeductAtDisbWithoutDate
* Purpose 1.
* @param actualInterestRate
* @param loanScheduleBean
* @return ArrayList<LoanRepaymentCycleBean>
*/
private ArrayList<LoanRepaymentCycleBean>
generateLSForFIntrIntrDeductAtDisbWithoutDate(
BigDecimal actualInterestRate, LoanScheduleBean
loanScheduleBean) {
if (logger.isTraceEnabled())
logger
.trace("LoanManager ::
generateLSForFIntrIntrDeductAtDisbWithoutDate :: END");
BigDecimal loanAmount = loanScheduleBean.getLoanAmount();
int periodicityValue = loanScheduleBean.getPeriodicity();
BigDecimal interestRateAtPeriod = new BigDecimal(periodicityValue)
.divide(new BigDecimal(360), 5, 2);
interestRateAtPeriod = interestRateAtPeriod
.multiply(actualInterestRate);
BigDecimal totalLoanAmount = loanAmount.add((loanAmount
.multiply(interestRateAtPeriod)).multiply(new
BigDecimal(
loanScheduleBean.getNumberOfInstalments())));
BigDecimal principal = loanAmount.divide(new BigDecimal(
loanScheduleBean.getNumberOfInstalments()), 5, 2);
principal = principal.setScale(5, RoundingMode.HALF_UP);
BigDecimal interestRate = totalLoanAmount.subtract(loanAmount);
ArrayList<LoanRepaymentCycleBean> loanRepaymentCycleList = new
ArrayList<LoanRepaymentCycleBean>();
for (int index = 0; index <=
loanScheduleBean.getNumberOfInstalments(); index++) {
LoanRepaymentCycleBean loanRepaymentCycleBean = new
LoanRepaymentCycleBean();
loanRepaymentCycleBean.setInstalmentNumber(index);
if (index != 0) {
loanRepaymentCycleBean.setPrincipalAmount(principal);
loanRepaymentCycleBean.setInterestAmount(new
BigDecimal(0));
loanRepaymentCycleBean.setEmiAmount(principal);
} else if (index == 0) {
loanRepaymentCycleBean.setInterestAmount(interestRate);
loanRepaymentCycleBean.setPrincipalAmount(new
BigDecimal(0));
loanRepaymentCycleBean.setEmiAmount(interestRate);
}
loanRepaymentCycleList.add(loanRepaymentCycleBean);
}
if (logger.isTraceEnabled())
logger
.trace("LoanManager ::
generateLSForFIntrIntrDeductAtDisbWithoutDate :: END");
return loanRepaymentCycleList;
}
// add by sanjeev
/**
* Method: findStatusForModuleName Purpose:this method used for find the
status
*
* @param String
* @return List<StatusBean>
* @author SanjeevG
*/
public List<StatusBean> findStatusForModuleName(String moduleName) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
List<StatusBean> statusBeans = this.mantleLoanBusiness
.findStatusForModuleName(moduleName);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return statusBeans;
}
/**
* Method: findLoanDetails Purpose:To load the loan details search
* @param loanBean
* @return List<LoanBean>
* @author SanjeevG
*/
public List<LoanBean> findLoanDetails(LoanBean loanBean){
if (logger.isTraceEnabled())
logger
.trace("LoanManager ::
findStatusForModuleName :: START");
List<LoanBean> loanBeans =
this.mantleLoanBusiness.findLoanDetails(loanBean);
if (logger.isTraceEnabled())
logger.trace("LoanManager :: findStatusForModuleName ::
END");
return loanBeans;
}
/**
* Method: viewManageLoan Purpose:this method use To fetch all detail for
manage loan
*
* @param LoanBean
* @return LoanBean
* @author SanjeevG
*/
public LoanBean viewManageLoan(LoanBean loanBean) {
if (logger.isTraceEnabled())
logger.trace("LoanManager :: viewManageLoan :: START");
loanBean = this.mantleLoanBusiness.viewManageLoan(loanBean);
loanBean.setCollateralBeanSavedList(loanBean.getCollateralBeanList());
//String docCode
=mantleProductBusiness.findDocGroupCodeByProductId(loanBean.getProductId());
//loanBean.setDocCode(docCode);
WorkflowBean workFlowBean = this.workflowBaseBusiness
.findNextAvailableTaskByStatusId(loanBean.getTaskFlow
StatusId());
List<WorkflowBean> workStatusList = this.workflowBaseBusiness
.findNextAvailableTaskStatusByStatusId(loanBean
.getTaskFlowStatusId());
if(workStatusList!=null && workStatusList.size()>0){
loanBean.setStatusList(workStatusList);
}
if (workFlowBean != null) {
loanBean.setTaskName(workFlowBean.getTaskName());
loanBean.setCurrentStatusId(workFlowBean.getTaskId());
loanBean.setTaskClassName(workFlowBean.getClassName());
workFlowBean=
workflowBaseBusiness.findTaskDetailByTaskId(workFlowBean);
loanBean.setWorkFlowUser(workFlowBean.getWorkFlowUser());
}
ProductBean productBean =
mantleProductBusiness.findProductAttributeForLoanForProductId(loanBean.getProductI
d(), loanBean.getAuthenticationBean().getBusinessDate(),"");
//
productBean.getCollateralBeanList().removeAll(loanBean.getCollateralBeanSavedList())
;
if(productBean.getCollateralBeanList()!=null &&
productBean.getCollateralBeanList().size()>0){
productBean.setCollateralBeanList( constructCollateralList(loanBean.getCollateralBea
nSavedList(),productBean.getCollateralBeanList()));
}
// loanBean.setCollateralBeanList(productBean.getCollateralBeanList());
loanBean.setInterestHolidayId(productBean.getInterestHolidayId());
loanBean.setRepaymentHolidayId(productBean.getRepaymentHolidayId());
loanBean.setAge(productBean.getAge());
loanBean.setHolidayCode(productBean.getHolidayCode());
loanBean.setMinAge(productBean.getMinAge());
loanBean.setMaxAge(productBean.getMaxAge());
loanBean.setProductBean(productBean);
List<DocumentBean> documentBeanList =
mantleLoanBusiness.findDocGroupByProductIdAndActivitySubType(loanBean.getProd
uctId(),"CREATE_LOAN");
List<DocumentBean> constructedDocumentBeanList =
this.constructDocTypeFileType(documentBeanList);
productBean.setDocumentBeanList(constructedDocumentBeanList);
// List<DocumentBean> documentBeanList =
this.constructDocTypeFileType(productBean.getDocumentBeanList());
// productBean.setDocumentBeanList(documentBeanList);
// loanBean.setCollateralBeanList(productBean.getCollateralList());
loanBean.setInterestFrequencyList(productBean.getInterestBeanList());
loanBean.setPaymentFrequency(productBean.getPaymentFrequency());
loanBean.setInterestBeanList(productBean.getInterestFrequency());
if(loanBean.getCustomerNum()!=null &&
loanBean.getCustomerNum().length()>0){
CustomerBean customerBean =
customerBusiness.findCustomerDataByCustomerNumber(loanBean.getCustomerNum());
loanBean.setCustomerBean(customerBean);
try {
int age =
AMSDateUtil.retrieveAgeByDate(DateFormat.parseDate(customerBean.getCustomerDO
B(), Constants.DATE_PATTERN));
customerBean.setAge(age);
loanBean.setAge(String.valueOf(age));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
List<Integer> documentsIdlist =
this.mantleLoanBusiness.findDocumentIdsByLoanId(loanBean.getLoanId());
if(documentsIdlist!=null && documentsIdlist.size()>0){
List<DocumentBean>
documentBeanlist=this.documentBusiness.findDoumentMasterListByDocumentIdListAn
dloginUsername(documentsIdlist,loanBean.getAuthenticationBean().getLoggedInUserNa
me());
if(documentBeanlist!=null && documentBeanlist.size()>0){
List<DocumentBean> documentBeanSavedList =
this.constructDocTypeFileType(documentBeanlist);
loanBean.setDocumentBeanSaveList(documentBeanSavedList);
}
}
if (logger.isTraceEnabled())
logger
.trace("LoanManager :: viewManageLoan :: END");
return loanBean;
}
/**
* Method: updateManageLoan Purpose:this method uuse to update the manage
loan
*
* @param LoanBean
* @return LoanBean
* @author SanjeevG
*/
@SuppressWarnings("unchecked")
public LoanBean updateManageLoan(LoanBean loanBean) {
if (logger.isTraceEnabled())
logger.trace("LoanManager :: updateManageLoan :: START");
loanBean.setCurrentStatusCode(Constants.LOAN_VERIFICATION);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(
Constants.LOAN_APPROVED)){
HashMap<String, String> macroValueMap = new
HashMap<String, String>();
Date businessDate =
loanBean.getAuthenticationBean().getBusinessDate();
String entityMnemonic =
loanBean.getAuthenticationBean().getLoggedInUserEntityName();
String userName =
loanBean.getAuthenticationBean().getLoggedInUserName();
int loggedInEntityId =
loanBean.getAuthenticationBean().getLoggedInUserEntityId();
MasterAccountBean masterAccountBean = new
MasterAccountBean();
String accountType =
mantleProductBusiness.findProductAttributeByProductIdAndAttribute(loanBean.getProd
uctId(), IProductConstants.ACCOUNT_TYPE);
if(accountType!=null && accountType.length()>0){
AccountTypeBean accountTypeBean =
accountBusiness.findAccountTypeByAcctTypeCode(accountType);
if(accountTypeBean!=null){
masterAccountBean.setAcctTypeId(accountTypeBean.getAcctTypeId());
}
}
macroValueMap.put(NumberGenConstant.MACRO_BRANCH_CODE,entityMnemonic
);
macroValueMap.put(NumberGenConstant.MACRO_BRANCH_CODE,String.valueOf(
masterAccountBean.getAcctTypeId()));
String loanAccountNumber =
this.genericNumberGenerationBusiness.
generatingRefNum(macroValueMap,
NumberGenConstant.REF_LOAN_ACCOUNT_NUMBER, userName,businessDate );
String customerNumber =
this.genericNumberGenerationBusiness.
generatingRefNum(macroValueMap,
NumberGenConstant.CUSTOMER_NUMBER, userName,businessDate );
loanBean.setCustomerNumber(customerNumber);
loanBean.setLoanAccountNumber(loanAccountNumber);
masterAccountBean.setAccountNumber(loanAccountNumber);
masterAccountBean.setAccountName("Loan Account");
masterAccountBean.setEntityId(loanBean.getAuthenticationBean().getLoggedInUserEnti
tyId());
MasterAccountBean accountBean =
mantleAccountBusiness.insertLoanAccount(masterAccountBean,
loanBean.getAuthenticationBean().getLoggedInUserId());
loanBean.setAccountId(
accountBean.getAccountId());
loanBean.setAcctNum(loanAccountNumber);
loanBean.setLoanSanctionDate(loanBean.getAuthenticationBean().getStrBusinessDate())
;
}
loanBean = this.mantleLoanBusiness.updateManageLoan(loanBean);
//if(loanBean.getDocumentBeanList()!=null){
List<DocumentBean> previousDocList =
this.mantleLoanBusiness.findDocumenListByLoanId(loanBean.getLoanId());
if(previousDocList!=null&&previousDocList.size()>0){
List<Integer>
matchedList=this.settingPreviousDocIdPresentList(previousDocList,
loanBean.getDocumentBeanList());
this.mantleLoanBusiness.updateTaLoanDocumentMap(loanBean.getLoanId(),
matchedList);
}
List<Integer> integerList = new ArrayList<Integer>();
if(loanBean.getDocumentBeanList()!=null &&
loanBean.getDocumentBeanList().size()>0){
List<TaDocumentMaster> documentList =
documentBusiness.insertDocument(loanBean.getDocumentBeanList(),
loanBean.getDocCode(), loanBean.getAuthenticationBean().getLoggedInUserRoleId(),
loanBean.getAuthenticationBean().getBusinessDate(),
loanBean.getAuthenticationBean().getLoggedInUserId());
integerList =
this.constructIntegerFromTaDocumentMaster(documentList);
}
this.insertLoanDocument(loanBean.getLoanId(),integerList,loanBean);
if(previousDocList!=null && previousDocList.size()>0){
for (DocumentBean documentBean : previousDocList) {
Integer integers = new
Integer(documentBean.getPreviousDocumentId());
integerList.add(integers);
}
}
List<DocumentBean> documentBeanSaveList =
documentBusiness.findDoumentMasterListByDocumentIdListAndloginUsername(intege
rList, loanBean.getAuthenticationBean().getLoggedInUserName());
loanBean.setDocumentBeanSaveList(documentBeanSaveList);
//}
if (logger.isTraceEnabled())
logger.trace("LoanManager :: updateManageLoan :: END");
return loanBean;
if(preBean.getDocTypeCode().equalsIgnoreCase(savebean.getDocTypeCode())){
savebean.setPreviousDocumentId(preBean.getPreviousDocumentId());
matchedList.add(preBean.getPreviousDocumentId());
break;
}
}
}
}
return matchedList;
}
/**
*Method: createClaimApplicationTask
*
* @param claimBean
* @return
* @see
com.evolvus.gravity.workflow.service.IGravityWorkflowManager#createClaimApplicati
onTask(com.evolvus.gravity.claim.bean.ClaimBean)
* @author SanjeevG
*/
public MantleWorkFlowBean createLoanApplicationTask(LoanBean loanBean) {
String taskName = loanBean.getTaskName();
MantleWorkFlowBean mantleWorkFlowBean = new
MantleWorkFlowBean();
mantleWorkFlowBean.setTaskName(taskName);
if (entityId > 0) {
if (workflowBean.getRoleId() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("Role Assigned for Task '"
+
workflowBean.getTaskName() + "' is "
+
workflowBean.getRoleName());
}
List<UserBean> usersList = userBusiness
.findUserListByEntityId(entityId);
if (usersList != null && usersList.size() > 0) {
for (Object o : usersList) {
if (o instanceof UserBean) {
UserBean userBean =
(UserBean) o;
if
(userBean.getRoleName().equalsIgnoreCase(
roleForTask))
{
usersListForTaskAssignment.add(userBean);
}
}
}
}
if (loanBean.getAuthenticationBean() != null) {
workflowBean.setAssignedDate(loanBean
.getAuthenticationBean().get
StrBusinessDate());
}
if(loanBean.getAuthenticationBean() != null)
{
String assginedDate =
DateFormat.formatDate(loanBean.getAuthenticationBean().getBusinessDate(), "yyyy-
MM-dd");
workflowBean.setAssignedDate(assginedDate);
}
workflowBean.setUsersTasksList(usersListForTaskAssignment);
workflowBean.setCurrentStatusCode(loanBean.getCurrentStatusCode());
workflowBean =
mantleWorkFlowBusiness.saveTaskDetails(workflowBean);
mantleWorkFlowBean.setTaskDetailsId(workflowBean.getTaskDetailsId());
mantleWorkFlowBean.setLoanId(String.valueOf(loanBean.getLoanId()));
//updateLoanTaskDetails(loanBean.getLoan
Id(), workflowBean.getTaskDetailsId());
mantleWorkFlowBean =
mantleWorkFlowBusiness.saveTaskAdditionalDetails(mantleWorkFlowBean);
}
}
//}
status = true;
}
catch(Exception ex)
{
ex.printStackTrace();
status = false;
}
return mantleWorkFlowBean;
}
/**
* Method: findProductDetails Purpose:Find the product details
* @return List<ProductBean>
* @author SanjeevG
*/
public List<ProductBean> findProductDetails(){
if (logger.isTraceEnabled())
logger
.trace("LoanManager :: viewManageLoan :: START");
List<ProductBean> productBeans =
this.mantleLoanBusiness.findProductDetails();
if (logger.isTraceEnabled())
logger
.trace("LoanManager :: viewManageLoan :: END");
return productBeans;
}
public LoanWriteoffBean findLoanWriteOffDetailsByLoanApplicationNumber(
LoanWriteoffBean loanWriteoffBean) {
if (logger.isTraceEnabled())
logger.trace(" START");
LoanWriteoffBean loanBean = this.mantleLoanBusiness
.findLoanWriteOffDetailsByLoanApplicationNumber(loan
WriteoffBean);
String accountType=
mantleProductBusiness.findProductAttributeByProductIdAndAttribute(loanBean.getProd
uctId(), IProductConstants.ACCOUNT_TYPE);
loanBean.setAcctNum(taAcct.getAcctNum());
loanBean.setCustomerNumber(loanBean.getCustomerNumber());
loanBean.setProductName(loanBean.getProductName());
loanBean.setCustomerName(loanBean.getCustomerName());
loanBean.setLoanApplicationNumber(loanBean.getLoanApplicationNumber());
if (logger.isDebugEnabled())
{
logger.debug("End");
}
return loanBean;
}
this.referralBusiness.findAndUpdateRsaEntriesToCompleteTransaction(loanBean.getRef
erralIdentificationNumber());
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
macroValueMap.put(NumberGenConstant.MACRO_LOAN_WRITE_OFF,Constants.L
OAN_WRITE_OFF);
macroValueMap.put(NumberGenConstant.MACRO_CUSTOMER_ID,
loanBean.getCustomerNumber());
macroValueMap.put(NumberGenConstant.MACRO_CUSTOMER_NAME,
loanBean.getCustomerName());
macroValueMap.put(NumberGenConstant.MACRO_LOAN_APP_NUM,
loanBean.getLoanApplicationNumber());
String narration = narrationBusiness.generateNarrtion(
macroValueMap,
Constants.TXN_TYPE_LOAN_WRITEOFF,
userName, businessDate);
ArrayList<TaAcctEntries> acctEntrieslist =
hydrateAccountEntries(loanBean.getAuthenticationBean(),
loanBean.getLoanAccountNumber(),"0003879100356",loanBean.getLoanWriteOffAmou
nt(),
Constants.TXN_TYPE_LOAN_WRITEOFF,Constants.CONSTANTS_DEBIT,narration)
;
loanBean.setCreditDebitFlag(Constants.CONSTANTS_DEBIT);
loanBean.setEntriesList(acctEntrieslist);
loanBean.setValueDate(loanBean.getAuthenticationBean().getStrBusinessDate());
loanBean.setHdrAmount(loanBean.getLoanWriteOffAmount().toString());
loanBean.setHdrAvailableFund("0.00");
loanBean.setTxnReferenceNumber("");
loanBean.setReferralIdentificationNumber("-1");
loanBean.setTxnName(Constants.TXN_TYPE_LOAN_WRITEOFF);
loanBean.setLocalCurrency(loanBean.getLocalCurrency());
BaseTransactionBean baseTransactionBean =
(BaseTransactionBean)loanBean;
baseTransactionBean.setCurrencyId(Integer.valueOf(loanBean.getAuthenticationBean().
getLocalCurrency()));
BaseTransactionBean transactionBean =
this.insertTransactions(baseTransactionBean);
referralStatus =transactionBean.isReferralStatus();
if(!referralStatus)
this.mantleLoanBusiness.insertLoanWriteOffDetails(loanBean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
/**
* Call Equation business logic to pass one or more ASI's then save in local
* database using the teller system business logic
*/
public BaseTransactionBean insertTransactions(BaseTransactionBean
baseTransactionBean) {
if (logger.isTraceEnabled())
logger.trace("TransferManager :: insertTransfer :: START");
ReferralEntriesBean referralEntriesBean=referralBusiness
.validateTransactionMaster(baseTransactionBean);
referralList = referralEntriesBean.getRsaBean().getReferralList();
baseTransactionBean.setRequestString(baseTransactionBean.getRequestString());
baseTransactionBean.setRsaBean(referralEntriesBean.getRsaBean());
ArrayList<TaAcctEntries> accArrayList =
baseTransactionBean.getEntriesList();
// eq3
TaAcctEntries[] responseTaAcctEntries =
transactionBusiness
.equationTransactionController(taAcctEntrie
s);
responseList.add(responseTaAcctEntries);
responseBean.setAcctEntries(responseList);
responseBean.setTransactionStatus(true);
responseList.add(taAcctEntries);
responseBean.setErrorMessage(e.getMessageKey());
responseBean.setTransactionStatus(false);
responseBean.setSeqNo(e.getMessageKey());
throw new ServiceException(e.getMessageKey());
} catch (BaseException e) {
responseList.add(taAcctEntries);
responseBean.setErrorMessage(e.getMessageKey());
responseBean.setTransactionStatus(false);
responseBean.setSeqNo(e.getMessageKey());
throw new ServiceException(e.getMessageKey());
} catch (Exception e) {
// TODO: handle exception
responseList.add(taAcctEntries);
responseBean.setErrorMessage(e.getMessage());
responseBean.setTransactionStatus(false);
responseBean.setSeqNo(e.getMessage());
throw new ServiceException(e.getMessage());
}
for (int i = 0; i < accArrayList.size(); i++) {
TaAcctEntries tAcctEntries = (TaAcctEntries) accArrayList
.get(i);
if (tAcctEntries.getEntrySeq() == 1)
baseTransactionBean.setHdrAmount(String
.valueOf(tAcctEntries.getTxnAmoun
t()));
}
for (int i = 0; i < accArrayList.size(); i++) {
TaAcctEntries tAcctEntries = (TaAcctEntries) accArrayList
.get(i);
if (tAcctEntries.getCashAccount() ==
IBLConstants.CASH_ACCOUNT_FALSE) {
baseTransactionBean.setTxnReferenceNumber(tAcctEntries
.getTxnNumber());
}
}
if (responseBean.isTransactionStatus() == true) {
// baseTransactionBean.setEntriesList(accArrayList);
baseTransactionBean =
generateString(baseTransactionBean);
if (!
baseTransactionBean.getReferralIdentificationNumber()
.equals("-1")) {
RSABean rsaBean = new RSABean();
rsaBean.setCompletedStatus("C");
rsaBean.setStatus("A");
rsaBean.setReferralIdentificationNumber(baseTransactionBean
.getReferralIdentificationNumber());
rsaBean =
referralBusiness.txnConfirmation(rsaBean);
baseTransactionBean.setSuperUserId(rsaBean
.getSupervisorId());
}
baseTransactionBean.getCreditDebitFlag(), baseTransactionBean
.getAuthentica
tionBean()
.getBusinessD
ate(), "",
baseTransactionBean.getRequestString(),
baseTransactionBean.getAuthenticationBean()
.getLoggedIn
UserEntityId(),
baseTransactionBean.getTxnName(), baseTransactionBean
.getReferralId
entificationNumber(),
baseTransactionBean);
baseTransactionBean.setEntriesList(accountEntriesList);
baseTransactionBean.setReferralStatus(false);
} else {
throw new ServiceException(
"The transaction is not able to commit :"
+
responseBean.getErrorMessage());
}
referralStatus = true;
} else {
baseTransactionBean.setReferralList(referralList);
baseTransactionBean.setReferralStatus(true);
}
/**
* Generates a request string in Hex String format which includes complete
* information of the transaction performed
*/
private BaseTransactionBean generateString(
BaseTransactionBean baseTransactionBean) {
// TODO Auto-generated method stub
byte[] requestData = baseTransactionBean.pack();
String packedData = HexString.bufferToHex(requestData);
baseTransactionBean.setRequestString(packedData);
return baseTransactionBean;
}
/**
* Method: findLoanDetailsByTaskDetailId
* Purpose: to find the loan details by task detail id
* @return LoanBean
* @param LoanBean
*/
public LoanBean findLoanDetailsByTaskDetailId(LoanBean loanBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
MantleWorkFlowBean mantleWorkFlowBean =
mantleWorkFlowBusiness.findTaskAdditionalDetailsByTaskDetailsId(loanBean.getTask
DetailsId());
loanBean.setCurrentStatusCode(mantleWorkFlowBean.getCurrentStatusCode());
loanBean.setLoanApplicationNumber(mantleWorkFlowBean.getLoanApplicationNumbe
r());
loanBean = this.findLoanByLoanId(loanBean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
/**
* Method: findLoanRepaymentDetailsByLoanApplicationNumber
* Purpose: to find repayment Details by loan application Number
* @return loanApplcationNum
* @param loanRepaymentBean
*/
public LoanRepaymentStructureBean
findLoanRepaymentStructureDetailsByLoanApplicationNumber(String
loanApplcationNum,AuthenticationBean authenticationBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
String acctType = "";
List<DefinitionBean> repaymentModeList = null;
List<DefinitionBean> sorceOptionList = null;
List<DefinitionBean> sourceModeList = null;
List<DefinitionBean> repaymentStructureList = null;
ArrayList<LoanRepaymentCycleBean> loanRepaymentCycleBeanlist =
null;
LoanRepaymentStructureBean loanRepaymentBean = new
LoanRepaymentStructureBean();
LoanBean loanBean =
this.mantleLoanBusiness.findLoanByLoanApplicationNumber(loanApplcationNum,auth
enticationBean);
loanRepaymentCycleBeanlist =
this.findLoanScheduleListWithoutDates(loanBean);
String accountType=
mantleProductBusiness.findProductAttributeByProductIdAndAttribute(loanBean.getProd
uctId(), IProductConstants.ACCOUNT_TYPE);
TaAcct taAcct =
this.mantleLoanBusiness.findLoanAcctByLoanApplicationNumber(loanApplcationNum,
accountType);
sourceModeList =
this.definitionBusiness.loadDefinitionList(Constants.DEFINITION_TYPE_SOURCE_O
PTION);
repaymentStructureList =
this.definitionBusiness.loadDefinitionList(Constants.DEFINITION_TYPE_REPAYMEN
T_MODE);
loanRepaymentBean.setCustomerNum(loanBean.getCustomerNumber());
loanRepaymentBean.setProductName(loanBean.getProductName());
loanRepaymentBean.setCustomerName(loanBean.getCustomerName());
loanRepaymentBean.setLoanApplcationNum(loanBean.getLoanApplicationNumber());
loanRepaymentBean.setLoanAmount(loanBean.getLoanAmount());
if(loanBean.getLoanSanctionAmount()!=null){
loanRepaymentBean.setLoanSanctionAmount(loanBean.getLoanSanctionAmount().toStr
ing());
}
if(loanBean.getLoanDisburseAmount()!=null){
loanRepaymentBean.setAmtDisbursed(loanBean.getLoanDisburseAmount().toString());
}
if(loanBean.getLoanSanctionAmount()!=null &&
loanBean.getLoanDisburseAmount()!=null){
loanRepaymentBean.setAmtDisburse(loanBean.getLoanSanctionAmount().subtract(loan
Bean.getLoanDisburseAmount()).toString());
}
if(loanBean.getLoanDisburseAmount()!=null &&
loanBean.getLoanSanctionAmount()!=null && loanBean.getLoanDisburseAmount()!
=null){
loanRepaymentBean.setTotalDisbursementAmt(loanBean.getLoanDisburseAmount().add
(loanBean.getLoanSanctionAmount().subtract(loanBean.getLoanDisburseAmount())).toS
tring());
}
loanRepaymentBean.setCustEntityName(loanBean.getEntityName());
loanRepaymentBean.setRepaymentFrequency(loanBean.getRepaymentFrequency());
loanRepaymentBean.setNoInstallments(loanBean.getNumberOfInstallment());
if(loanRepaymentCycleBeanlist!=null &&
loanRepaymentCycleBeanlist.size()>0){
LoanRepaymentCycleBean loanRepaymentCycleBean =
loanRepaymentCycleBeanlist.get(0);
loanRepaymentBean.setPrincipleRepaymentAmt(DateFormat.formatNumber(
loanRepaymentCycleBean.getPrincipalAmount(),
2));
loanRepaymentBean.setInterestRepaymentAmt(DateFormat.formatNumber(
loanRepaymentCycleBean.getInterestAmount(),
2));
loanRepaymentBean.setTotalRepaymentAmt(DateFormat.formatNumber(loanRepaymen
tCycleBean.getPrincipalAmount().add(loanRepaymentCycleBean.getInterestAmount()),
2).toString());
}
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanRepaymentBean;
}
/**
* Method : insertloanRepaymentMode Purpose 1. insert the loan repayment
mode details
*
* @param loanRepaymentBean
* @return loanRepaymentBean
*/
public LoanRepaymentStructureBean
insertloanRepaymentMode(LoanRepaymentStructureBean loanRepaymentBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
loanRepaymentBean =
this.mantleLoanBusiness.insertloanRepaymentMode(loanRepaymentBean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanRepaymentBean;
}
/**
* Method : getCustomerNameByCustomerNumber Purpose 1. to find the introducer
name by introducer's number
* @param String introducerNumber
* @return introducerName
*
*/
public String getCustomerNameByCustomerNumber(String introducer) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
CustomerBean customerBean =
customerBusiness.findCustomer(introducer);
String introducerName = customerBean.getCustomerName();
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return introducerName;
}
if(collateralBean.getCollateralId()==actualBean.getCollateralId()){
secondCollateralBeanList.remove(actualBean);
}
}
}
}
for(CollateralBean actualBean : secondCollateralBeanList){
completeCollateralBeanList.add(actualBean);
}
}
if(completeCollateralBeanList!=null &&
completeCollateralBeanList.size()>0){
for(CollateralBean collateralBean : completeCollateralBeanList){
if(collateralBean.getCollateralValue()!=null
&&collateralBean.getCollateralValue().trim().length()>0){
collateralBean.setCollateralValue(DateFormat.formatNumber(new
BigDecimal(collateralBean.getCollateralValue()), 2));
}
}
}
return completeCollateralBeanList;
}
/**
* Method : findDefinitionListForGender Purpose 1. To find the gender
* @return LoanBean
* @author SanjeevG
*/
public LoanBean findDefinitionListForGender() {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
LoanBean loanBean =
this.mantleLoanBusiness.findDefinitionListForGender();
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
/**
* Method : findProductDetailsByProductType Purpose 1. To find the product
based on the product type
* @return List<ProductBean>
* @author Rajesh
*/
public List<ProductBean> findProductDetailsByProductType(String
productType,
String strBusinessDate) {
// TODO Auto-generated method stub
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
List<ProductBean> productList = mantleProductBusiness
.findProductByProductTypeCode(productType, strBusinessDate);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return productList;
}
/**
* Method:generateLoanSchedule
* Purpose: To generate loan schedule based
* @return LoanScheduleBean
* @param LoanScheduleBean
*/
public LoanScheduleBean generateLoanSchedule(
LoanScheduleBean loanScheduleBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
loanScheduleBean=
mantleLoanBusiness.generateLoanSchedule(loanScheduleBean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanScheduleBean;
}
/**
* Method: viewLoanByLoanId Purpose:this method use To fetch all
detail for manage loan
*
* @param LoanBean
* @return LoanBean
* @author Rajesh
*/
public LoanBean findLoanByLoanId(LoanBean loanBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
//the below line is called to get the loan details on the basis of loan
id.
loanBean =
this.mantleLoanBusiness.viewManageLoan(loanBean);
loanBean =
this.findProductAttributeForViewLoanByProductId(loanBean);
if(loanBean.getCustomerNum()!=null &&
loanBean.getCustomerNum().length()>0){
// CustomerBean customerBean =
customerBusiness.findCustomerDataByCustomerNumber(loanBean.getCustomerNum());
CustomerBean customerBean =
mantleCustomerBusiness.findCustomerByCustomerNumber(String.valueOf(loanBean.ge
tCustomerNum()));
loanBean.setCustomerBean(customerBean);
if(customerBean.getCustomerDOB()!=null &&
customerBean.getCustomerDOB().length()>0){
try {
int age =
AMSDateUtil.retrieveAgeByDate(DateFormat.parseDate(customerBean.getCustomerDO
B(), Constants.DATE_PATTERN));
customerBean.setAge(age);
loanBean.setAge(String.valueOf(age));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
loanBean = this.findDocumentIdsByLoanId(loanBean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
loanBean.setDocumentBeanSaveList(documentBeanSavedList);
}
}
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
loanBean.setInterestHolidayId(productBean.getInterestHolidayId());
loanBean.setRepaymentHolidayId(productBean.getRepaymentHolidayId());
loanBean.setAge(productBean.getAge());
loanBean.setHolidayCode(productBean.getHolidayCode());
loanBean.setMinAge(productBean.getMinAge());
loanBean.setMaxAge(productBean.getMaxAge());
loanBean.setProductBean(productBean);
loanBean.setInterestFrequencyList(productBean.getInterestBeanList());
loanBean.setPaymentFrequency(productBean.getPaymentFrequency());
loanBean.setInterestBeanList(productBean.getInterestFrequency());
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
loanBean.setCollateralBeanList(constructCollateralList(loanBean.getCollateralBeanList()
,collateralBeanList));
}else{
loanBean.setCollateralBeanList(collateralBeanList);
}
}
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
if(walkInCustomerBean.getCustomerTypeCode().equalsIgnoreCase("Individual")){
definitionBean =
this.findInitialForIndividual();
}else
if(walkInCustomerBean.getCustomerTypeCode().equalsIgnoreCase("Non Individual")){
definitionBean =
this.findInitialForNonIndividual();
}
if(definitionBean!=null){
loanBean.setDefinitionBean(definitionBean);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
/**
* Method: updateLoanByCustomer
* Purpose: This method use for to update the customer
* @param LoanBean
* @return LoanBean
* @author Rajesh
*/
public LoanBean updateLoanByCustomer(LoanBean loanBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
String customerNumber = "";
if(loanBean.getNextTaskStatusCode()!=null &&
loanBean.getNextTaskStatusCode().length()>0){
MantleWorkFlowBean mantleFlowBean =
this.mantleWorkFlowBusiness.updateTaTaskDetailsByLoanIdAndStatusMasterId(loanB
ean.getLoanId(), loanBean.getTaskStatusMasterId());
// need to check next task avaialable.
if
(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.LOAN_VERIFICATI
ON)) {
loanBean.setTaskName(Constants.LOAN_VARI_FICATION);
loanBean.setCurrentStatusCode(Constants.LOAN_VERIFICATION);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.PENDING_VERIFIC
ATION)){
loanBean.setTaskName(Constants.PENDING_VERIFICATION);
loanBean.setCurrentStatusCode(Constants.PENDING_VERIFICATION);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.LOAN_SANCTION
_APP)){
loanBean.setTaskName("loan_sanction");
loanBean.setCurrentStatusCode(Constants.LOAN_SANCTION_APP);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.PARTIAL_LOAN_R
EJECTION)){
loanBean.setTaskName(Constants.PARTIAL_LOAN_REJECTION);
loanBean.setCurrentStatusCode(Constants.PARTIAL_LOAN_REJECTION);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.COMPLETE_LOAN
_REJECTION)){
loanBean.setTaskName(Constants.COMPLETE_LOAN_REJECTION);
loanBean.setCurrentStatusCode(Constants.COMPLETE_LOAN_REJECTION);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.RE_VERIFICATION
)){
loanBean.setTaskName(Constants.RE_VERIFICATION);
loanBean.setCurrentStatusCode(Constants.RE_VERIFICATION);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.LOAN_REJECTED)
){
loanBean.setTaskName(Constants.LOAN_REJECTED);
loanBean.setCurrentStatusCode(Constants.LOAN_REJECTED);
this.createLoanApplicationTask(loanBean);
}
if(loanBean.getNextTaskStatusCode().equalsIgnoreCase(Constants.LOAN_APPROVED
)){
loanBean.setCurrentStatusCode(Constants.LOANAPPROVED);
HashMap<String, String> macroValueMap
= new HashMap<String, String>();
Date businessDate =
loanBean.getAuthenticationBean().getBusinessDate();
String entityMnemonic =
loanBean.getAuthenticationBean().getLoggedInUserEntityName();
String userName =
loanBean.getAuthenticationBean().getLoggedInUserName();
int loggedInEntityId =
loanBean.getAuthenticationBean().getLoggedInUserEntityId();
macroValueMap.put(NumberGenConstant.MACRO_BRANCH_CODE,entityMnemonic
);
String accountType =
mantleProductBusiness.findProductAttributeByProductIdAndAttribute(loanBean.getProd
uctId(), IProductConstants.ACCOUNT_TYPE);
MasterAccountBean masterAccountBean =
new MasterAccountBean();
if(accountType!=null &&
accountType.length()>0){
AccountTypeBean accountTypeBean
= accountBusiness.findAccountTypeByAcctTypeCode(accountType);
if(accountTypeBean!=null){
masterAccountBean.setAcctTypeId(accountTypeBean.getAcctTypeId());
}
}
macroValueMap.put(NumberGenConstant.MACRO_BRANCH_CODE,String.valueOf(
masterAccountBean.getAcctTypeId()));
String loanAccountNumber =
this.genericNumberGenerationBusiness.
generatingRefNum(macroValueMap,
NumberGenConstant.REF_LOAN_ACCOUNT_NUMBER, userName,businessDate );
loanBean.setLoanAccountNumber(loanAccountNumber);
masterAccountBean.setAccountNumber(loanAccountNumber);
masterAccountBean.setAccountName("Loan Account");
masterAccountBean.setEntityId(loanBean.getAuthenticationBean().getLoggedInUserEnti
tyId());
MasterAccountBean accountBean =
mantleAccountBusiness.insertLoanAccount(masterAccountBean,
loanBean.getAuthenticationBean().getLoggedInUserId());
loanBean.setAccountId(
accountBean.getAccountId());
loanBean.setAcctNum(loanAccountNumber);
loanBean.setLoanSanctionDate(loanBean.getAuthenticationBean().getStrBusinessDate())
;
// customerNumber =
loanBean.getAcctNum();
HashMap<String, String> macroValue =
new HashMap<String, String>();
macroValueMap.put(NumberGenConstant.MACRO_PRODUCT_CODE,""+loanBean.ge
tProductCode());
customerNumber =
this.genericNumberGenerationBusiness.
generatingRefNum(macroValueMap,
NumberGenConstant.CUSTOMER_NUMBER,
loanBean.getAuthenticationBean().getLoggedInUserName(),loanBean.getAuthentication
Bean().getBusinessDate());
}
}
CustomerBean customerBean = null;
if(loanBean.getWalkInCustomerBean()!=null){
customerBean =
loanBean.getWalkInCustomerBean();
customerBean =
mantleCustomerBusiness.updateWalkInCustomerForLoan(customerBean);
loanBean.setCustomerBean(customerBean);
}
loanBean.setCustomerNumber(customerNumber);
loanBean =
this.mantleLoanBusiness.updateManageLoan(loanBean);
List<DocumentBean> previousDocList =
this.mantleLoanBusiness.findDocumenListByLoanId(loanBean.getLoanId());
if(previousDocList!=null&&previousDocList.size()>0){
List<Integer>
matchedList=this.settingPreviousDocIdPresentList(previousDocList,
loanBean.getDocumentBeanList());
this.mantleLoanBusiness.updateTaLoanDocumentMap(loanBean.getLoanId(),
matchedList);
}
List<Integer> integerList = new ArrayList<Integer>();
if(loanBean.getDocumentBeanList()!=null &&
loanBean.getDocumentBeanList().size()>0){
List<TaDocumentMaster> documentList =
documentBusiness.insertDocument(loanBean.getDocumentBeanList(),
loanBean.getDocCode(), loanBean.getAuthenticationBean().getLoggedInUserRoleId(),
loanBean.getAuthenticationBean().getBusinessDate(),
loanBean.getAuthenticationBean().getLoggedInUserId());
integerList =
this.constructIntegerFromTaDocumentMaster(documentList);
}
this.insertLoanDocument(loanBean.getLoanId(),integerList,loanBean);
if(previousDocList!=null && previousDocList.size()>0){
for (DocumentBean documentBean :
previousDocList) {
Integer integers = new
Integer(documentBean.getPreviousDocumentId());
integerList.add(integers);
}
}
List<DocumentBean> documentBeanSaveList =
documentBusiness.findDoumentMasterListByDocumentIdListAndloginUsername(intege
rList, loanBean.getAuthenticationBean().getLoggedInUserName());
loanBean.setDocumentBeanSaveList(documentBeanSaveList);
loanBean = this.findLoanByLoanId(loanBean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
loanBean.setTaskClassName(workFlowBean.getClassName());
workFlowBean=
workflowBaseBusiness.findTaskDetailByTaskId(workFlowBean);
loanBean.setWorkFlowUser(workFlowBean.getWorkFlowUser());
}
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanBean;
}
/**
* Method : findSearchDetailsForLoanRepayment
* Purpose : to search the loan application number
* @param loanBean
* @return List<LoanBean>
* @author sanjeevg
*/
public List<LoanBean> findSearchDetailsForLoanRepayment(LoanBean
loanBean) {
if (logger.isDebugEnabled())
logger.debug("START");
public LoanRepaymentBean
findLoanMovmentByLoanApplicationNumber(LoanRepaymentBean
loanRepaymentBean) {
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
loanRepaymentBean =
mantleLoanBusiness.findLoanRepayDetailByLoanApplicationNumber(loanRepaymentB
ean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanRepaymentBean;
}
public LoanBean findCollateralAndDocuments(LoanBean loanBean) {if
(logger.isTraceEnabled())
logger.trace("LoanManager :: editLoanByLoanBean :: START");
//the below line is called to get the loan details on the basis of loan
id.
loanBean = this.findLoanByLoanId(loanBean);
loanBean = this.findCollateralsForLoan(loanBean);
if (logger.isTraceEnabled())
logger
.trace("LoanManager ::
editLoanByLoanBean :: END");
return loanBean;
}
public LoanDisbursementBean
serviceLoanRejection(LoanDisbursementBean loanDisbursementBean) {
// TODO Auto-generated method stub
if (logger.isDebugEnabled()) {
logger.debug("Start");
}
String txnRefNumber = null;
RSABean rsaBean = loanDisbursementBean.getRsaBean();
if(rsaBean.isGenerateTxnNumber())
txnRefNumber =
numberGenerationBusiness.getNextTransactionReferenceNumber(rsaBean.getAuthentica
tionBean().getLoggedInUserId(), rsaBean.getAuthenticationBean().getBusinessDate(),
rsaBean.getAuthenticationBean().getLoggedInUserEntityId());
rsaBean.setTransactionReferenceNumber(txnRefNumber);
rsaBean = referralBusiness.txnConfirmation(rsaBean);
loanDisbursementBean.setRsaBean(rsaBean);
LoanBean loanBean = new LoanBean();
loanBean.setAuthenticationBean(loanDisbursementBean.getAuthenticationBean());
loanBean.setLoanApplicationNumber(loanDisbursementBean.getLoanApplcationNum())
;
loanBean.setLoanApplcationNum(loanDisbursementBean.getLoanApplcationNum());
loanBean.setNextTaskStatusCode(Constants.LOAN_REJECTED);
loanBean =
this.mantleLoanBusiness.updateManageLoan(loanBean);
if (logger.isDebugEnabled()) {
logger.debug("End");
}
return loanDisbursementBean;
}
/**
* Method: findLoanDetails Purpose:To load the loan details search
* @param loanBean
* @return List<LoanBean>
* @author SanjeevG
*/
/*public List<LoanBean> findLoanDetails(LoanBean loanBean){
if (logger.isTraceEnabled())
logger
.trace("LoanManager ::
findStatusForModuleName :: START");
List<LoanBean> loanBeans =
this.mantleLoanBusiness.findLoanDetails(loanBean);
if (logger.isTraceEnabled())
logger.trace("LoanManager :: findStatusForModuleName ::
END");
return loanBeans;
}
*/
/**
* Method : findSearchDetailsForManualRepayment
* Purpose : to search the loan application number,Account
Number,CustomerId,Customer Name
* @param loanBean
* @return List<LoanBean>
* @author sanjeevg
*/
public List<LoanBean>
findSearchDetailsForManualRepayment(LoanBean loanBean) {
if (logger.isDebugEnabled())
logger.debug("START");
loanRepaymentBean.setLoanAccountNumber(loanBeans.getAcctNum());
loanRepaymentBean =
mantleLoanBusiness.findDemandRaiseAndSatisfydDetailsForLoanRepay(loanRepaymen
tBean);
if (logger.isDebugEnabled())
logger.debug("END");
return loanRepaymentBean;
}
/**
* Method : findDebitAccountNumberForTransferAcct
* Purpose :
* @param loanRepaymentBean
* @return LoanRepaymentBean
* @author sanjeevg
*/
public LoanRepaymentBean
findDebitAccountNumberForTransferAcct(LoanRepaymentBean loanRepaymentBean){
if (logger.isDebugEnabled())
logger.debug("START");
loanRepaymentBean =
mantleLoanBusiness.findDebitAccountNumberForTransferAcct(loanRepaymentBean);
if (logger.isDebugEnabled())
logger.debug("END");
return loanRepaymentBean;
}
/**
* Method : findDebitAccountNumberForTransferAcct
* Purpose :
* @param loanRepaymentBean
* @return LoanRepaymentBean
* @author sanjeevg
*/
public LoanRepaymentBean
findUnReconcilAccountEntriesForSuspenceAcct(LoanRepaymentBean
loanRepaymentBean){
if (logger.isDebugEnabled())
logger.debug("START");
loanRepaymentBean =
mantleLoanBusiness.findUnReconcilAccountEntriesForSuspenceAcct(loanRepaymentBe
an);
if (logger.isDebugEnabled())
logger.debug("END");
return loanRepaymentBean;
}
/**
* Method : insertManualLoanRepaymentDetails
* Purpose :
* @param loanRepaymentBean
* @return LoanRepaymentBean
* @author sanjeevg
*/
public LoanRepaymentBean
insertManualLoanRepaymentDetails(LoanRepaymentBean loanRepaymentBean){
String businessDate =
loanRepaymentBean.getAuthenticationBean().getBusinessDate().toString();
String cashSuspense = null;
String pdcSuspence = null;
String ecsSuspence = null;
String hostAcctNumber = null;
LoanRepaymentBean repaymentBean = new
LoanRepaymentBean();
List<AcctEntriesBean> acctEntriesBeanList = null;
String hostNumber = Constants.EMPTY;
Date txnDate = Date.valueOf(businessDate);
Float totalTxnValue = 0.0f;
LoanBean loanBeans =
mantleLoanBusiness.findLoanAccountByLoanAccountNumber(loanRepaymentBean
.getAccountNumber());
InterestBean interestBean =
mantleLoanBusiness.findInterestbyAccontNumber(loanRepaymentBean
.getAccountNumber());
if(loanRepaymentBean.getModeType().equalsIgnoreCase("SA")){
acctEntriesBeanList = accountEntriesBusiness
.findAccountingEntriesByReconNumberAndTxnDa
te(loanRepaymentBean
.getAccountNumber(),
businessDate);
totalTxnValue = totalTxnValue
+
Float.valueOf(acctEntriesBean.getTxnAmount()
.toString());
}
}
repaymentBean.setModeType(loanRepaymentBean.getModeType());
}else{
throw new
ServiceException(ErrorCodeConstants.HOST_ACCT_NUM_NOT_SUSPENCE_ACCT)
;
}
}
String interestAccount = mantleProductBusiness
.findProductAttributeByProductIdAndAttribute(loa
nBeans.getProductId(),
IProductConstants.INTEREST_ACCOUNT);
String centuryIndicator =
loanRepaymentBean.getAuthenticationBean().getCenturyIndicator();
if(loanRepaymentBean.getModeType().equalsIgnoreCase("AT")){
totalTxnValue
=Float.valueOf(loanRepaymentBean.getTransferAcctRepayAmt());
hostNumber =
loanRepaymentBean.getTranferAccountNum();
repaymentBean.setModeType(loanRepaymentBean.getModeType());
}else
if(loanRepaymentBean.getModeType().equalsIgnoreCase("OA")){
totalTxnValue
=Float.valueOf(loanRepaymentBean.getOtherAccountRepayAmt());
hostNumber =
loanRepaymentBean.getOtherAccountNum();
repaymentBean.setModeType(loanRepaymentBean.getModeType());
}
repaymentBean.setProductId(loanBeans.getProductId());
repaymentBean.setLoanMasterId(loanBeans.getLoanMasterId());
repaymentBean.setTotalTxnAmount(new
BigDecimal(totalTxnValue));
repaymentBean.setSuspenceAccountnumber(hostNumber);
repaymentBean.setPrincipalAcctNumber(loanRepaymentBean
.getAccountNumber());
repaymentBean.setInterestAcctNumber(/*"0110C43250050"*/interestAccount);
repaymentBean.setTxnDate(txnDate);
//repaymentBean.setTaAccountEntries(taAcctEntries);
repaymentBean.setEntityBeanListForSequenceList(entityBeanListForSequenceList);
repaymentBean.setJobCode(Constants.MANUAL_REPAYMENT);
repaymentBean.setEntityId(loanRepaymentBean.getAuthenticationBean().getLoggedInU
serEntityId());
repaymentBean.setEntityName(loanRepaymentBean.getAuthenticationBean().getLogged
InUserEntityName());
repaymentBean.setUserId(loanRepaymentBean.getAuthenticationBean().getLoggedInUs
erId());
repaymentBean.setUserName(loanRepaymentBean.getAuthenticationBean().getLoggedI
nUserName());
repaymentBean.setNarration(Constants.MANUAL_REPAY/*narration*/);
repaymentBean.setCenturyIndicator(centuryIndicator);
DateFormat dateFormat = new DateFormat();
String valueDate = dateFormat.convertToFormatDateRef(
businessDate, Constants.DATE_FORMAT);
repaymentBean.setValueDate(valueDate);
repaymentBean.setLoanAccountNumber(loanRepaymentBean
.getAccountNumber());
repaymentBean.setNoOfInstalment(/*"4"*/loanBeans.getNoInstallments());
repaymentBean.setInterestRate(/*"9"*/interestBean.getBaseRate());
repaymentBean.setInterestFrequecy(loanBeans.getInterestFrequency());
repaymentBean.setRepaymentFrequecy(loanBeans.getRepaymentFrequency());
repaymentBean.setScheduleDate(businessDate);
ArrayList<TaAcctEntries> hyderateAcctEntriesList =
(ArrayList<TaAcctEntries>) commonBean
.getHyderateAccountEntriesList();
* if(!
commonBean.getTxnName().equals(IBLConstants.INTEREST_POSTING_JOB)){
* try {
* TaAcctEntries[]
* responseTaAcctEntries =
* transactionBusiness
* .equationTransactionController(taAcctEntriesOne);
* responseList.add(responseTaAcctEntries);
* responseBean.setAcctEntries(responseList);
* responseBean.setTransactionStatus(true); }
* catch
* (TransactionFailureException
* e) {
* responseList.add(taAcctEntriesOne);
* responseBean.setErrorMessage(e.getMessageKey());
* responseBean.setTransactionStatus(false);
* responseBean.setSeqNo(e.getMessageKey());
* throw new
* ServiceException(e.getMessageKey()); }
* catch
* (BaseException e) {
* responseList.add(taAcctEntriesOne);
* responseBean.setErrorMessage(e.getMessageKey());
* responseBean.setTransactionStatus(false);
* responseBean.setSeqNo(e.getMessageKey());
* throw new
* ServiceException(e.getMessageKey()); }
* catch (Exception
* e) { // TODO:
* handle exception
* responseList.add(taAcctEntriesOne);
* responseBean.setErrorMessage(e.getMessage());
* responseBean.setTransactionStatus(false);
* responseBean.setSeqNo(e.getMessage());
* throw new
* ServiceException(e.getMessage()); } }
*/
// if (responseBean == null ||
responseBean.isTransactionStatus()) {
ArrayList<TaAcctEntries> accountEntriesList =
accountEntriesBusiness
.saveAccountEntriesList(hyderateAc
ctEntriesList,
IBLConstants.CONSTANTS_DEBIT, repaymentBean
.getTx
nDate(), IBLConstants.EMPTY,
null,
repaymentBean.getEntityId(),
repaymentBean.getJobCode(), null,
commonBean);
//}
if(commonBean.getRemainAmt()>0){
IProductConstants.NO_OF_PREPAYMENT);
String prePaymentCharge =
/*"5";*/mantleProductBusiness
.findProductAttributeByProductIdAndAttrib
ute(loanBeans.getProductId(),
IProductConstants.PREPAYMENT_CHARGE);
String excessPrePayCharge =
/*"2";*/mantleProductBusiness
.findProductAttributeByProductIdAndAttrib
ute(loanBeans.getProductId(),
IProductConstants.EXCESS_PREPAYMENT_CHARGE);
repaymentBean.setNoOfPrepayment(noOfPrepayment);
repaymentBean.setPrePaymentCharge(prePaymentCharge);
repaymentBean.setExcessPrePayCharge(excessPrePayCharge);
// loan prepayment EOD
repaymentBean.setPrePaymentAmt(commonBean.getRemainAmt());
repaymentBean =
this.mantleLoanBusiness.insertPrePaymentDetails(repaymentBean);
rsaBean.setTxnTypeCode(CRUDActionConstants.REPAYMENT_JOB);
rsaBean.setTranaction_Amount(repaymentBean.getExtraOutstandingAmount());
byte[] requestData =
aInwardClearingBean.pack();
String packedData =
HexString.bufferToHex(requestData);
rsaBean.setRequestString(packedData);
rsaBean =
this.referralBusiness.insertRSAEntriesDetails(rsaBean);
List<ReferralEntriesBean>
referralEntriesBeanList = new ArrayList<ReferralEntriesBean>();
ReferralEntriesBean
refrralEntrieBean = new ReferralEntriesBean();
refrralEntrieBean.setReferralCode("XYZ");
referralEntriesBeanList.add(refrralEntrieBean);
referralEntriesBeanList =
this.referralBusiness.insertReferralEntriesDetails(referralEntriesBeanList,rsaBean);*/
}
return loanRepaymentBean;
}