/**
 * Copyright (c) 2009 Penril Datability (SEA) Sdn Bhd All rights reserved.
 *
 * This software is copyrighted. Under the copyright laws, this software
 * may not be copied, in whole or in part, without prior written consent
 * of Penril Datability (SEA) Sdn Bhd or its assignees. This software is
 * provided under the terms of a license between Penril Datability (SEA)
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
 * license.
 */

package my.com.kfh.enterprise.services.ib104_fundtransfer.ftt;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

import my.com.kfh.enterprise.services.IBUtils;
import my.com.kfh.enterprise.services.IBUtilsOnlineAcc;
import my.com.kfh.enterprise.services.common.CommonConstants;
import my.com.kfh.enterprise.services.ib101_access.AccessConstants;
import my.com.kfh.enterprise.services.ib104_fundtransfer.constant.FTTConstants;
import my.com.kfh.enterprise.services.ib104_fundtransfer.others.IBStdDailyLimitBaseServices;
import my.com.kfh.enterprise.services.ib104_fundtransfer.thirdparty.IBFundTransferDBUtils;
import my.com.kfh.enterprise.services.ib104_fundtransfer.thirdparty.ThirdPartyTransferTags;
import my.com.kfh.enterprise.services.ib112_si.IBGenericSIServices;
import my.com.kfh.enterprise.services.ib112_si.SIConstants;
import my.com.kfh.enterprise.services.ib112_si.SI_PAYMENT_MODE;
import my.com.kfh.enterprise.services.ib116_online_acc.constant.OnlineAccConstants;
import my.com.kfh.error.exception.IBBusinessException;
import my.com.kfh.error.exception.IBGenericException;
import my.com.kfh.error.exception.IBServiceException;
import my.com.kfh.error.handler.CommonErrorCode;
import my.com.kfh.error.handler.IBErrorHandler;
import my.com.kfh.esb.response.ESBAccountEnquiryTC100Bean;
import my.com.kfh.esb.response.ESBAccountInfoDetailBean;
import my.com.kfh.esb.response.ESBCompanyProfileBean;
import my.com.kfh.esb.response.ESBFttTransferBean;
import my.com.kfh.integration.OnlineAccPromoBean;
import my.com.kfh.sms.services.SMSConstants;
import my.com.kfh.sms.services.SMSServices;
import my.com.kfh.web.utils.BVI_DateTime;
import my.com.kfh.web.utils.DataValidator;
import my.com.kfh.web.utils.DateTimeUtils;
import my.com.kfh.web.utils.FormatterUtils;
import my.com.kfh.web.utils.GSTUtils;
import my.com.kfh.web.utils.IBDynaBean;
import my.com.kfh.web.utils.IBLoadProperty;
import my.com.kfh.web.utils.IBLogWriter;
import my.com.kfh.web.utils.IBLogger;
import my.com.kfh.web.utils.IBOfacBlackList;
import my.com.kfh.web.utils.IBSessionObjects;
import my.com.kfh.web.utils.IBTimer;
import my.com.kfh.web.utils.ResourcesUtils;
import my.com.kfh.web.utils.constant.CurrencyCode;
import my.com.kfh.web.utils.constant.ESBConstants;
import my.com.kfh.web.utils.constant.ServiceInfo;
import my.com.kfh.web.utils.constant.TransactionType;

import com.broadvision.data.client.Content;
import com.broadvision.data.common.TableData;

/**
 * <pre>
 * PROGRAMMER: Jelson Low
 * CHANGE-NO:
 * TASK-NO:
 * DATE CREATED: Dec 15, 2008
 * TAG AS:
 * REASON(S):
 * MODIFICATION:
 * </pre>
 */

/**
 * This class will do back end process for FTT transfer results services.
 */
public class IBFttResultsServices extends IBGenericFttServices
{
	private static Class<IBFttResultsServices> c_oClass = IBFttResultsServices.class;

	/**
	 * @ Class constructor specifying session object.
	 *
	 * @param p_oIBSessionObjects Session object contains all information stored in HTTP session
	 */
	public IBFttResultsServices (IBSessionObjects m_oIBSessionObjects)
	{
		super (m_oIBSessionObjects);
	}

	/**
	 * <pre>
	 * To do tac verification if the value for requiredTac from service info bean is equals
	 * to true.
	 * Generate the transaction id number, date and time to display to the user.
	 * To get all necessary data from view beans.
	 * Check total transaction amount for FTT and compare the sum with maximum daily limit
	 * from table IB_FTT_TRANSFER.  If the total transaction amount is not exceed the maximum
	 * daily limit, proceed to process the FTT transfer by calling the ESB object.
	 * Calculate the FTT charges through the ESB object and get the charges response code and
	 * charges status. If the charges status is Unsuccessful, the FTT process will become Unsuccessful.
	 * Else, get the charges from account balance and charges reference number.
	 * Proceed to get the FTT response code and status from ESB object.
	 * If the status is Unsuccessful, roll back the FTT process but the charges is still remain.
	 * Else, get the new FTT from account balance, FTT reference number and total calculated FTT local amount.
	 * Set all the FTT transaction details to send a file to the bank and to generate the receipt.
	 * Insert the transaction details into table IB_RECEIPT_DETAILS.
	 * Log selected terms and condition and transaction details into table IB_TRANSACTION_HISTORY and
	 * also log the transaction details into table IB_FTT_TRANSFER.
	 * Reset the IBSession object for account enquiry so that the changes can be applied.
	 * </pre>
	 *
	 * @throws IBGenericException
	 */
	public void executeServices () throws IBGenericException
	{
		String m_sMethodName = "executeServices";
		IBTimer m_oTimer = IBLogger.logBSFNMethodEnteringMessage (c_oClass, m_sMethodName);

		String m_sTerms = null;
		String m_sTermsDeclaration = "";
		String m_sFttCountry = null;
		String m_sTransactionDesc = null;
		String otherPaymentDetails = "";
		String m_sToCurrencyCode = null;
		String m_sSpecialBankCode = null;
		String m_sFromAccIsoCurr = null;
		String m_sForeignAmount = null;
		String m_sLocalAmount = null;
		String m_sCurrencyServiceCharges = null;

		String m_sFromAccount = null;
		String m_sSenderName = null;
		String m_sSenderAddress1 = null;
		String m_sSenderAddress2 = null;
		String m_sSenderPostcode = null;
		String m_sSenderCountry = null;
		String m_sSenderContact = null;

		String m_sBeneficiaryName = null;
		String m_sBeneficiaryAddress1 = null;
		String m_sBeneficiaryAddress2 = null;
		String m_sBeneficiaryID = null;
		String m_sBeneficiaryContact = null;
		String m_sBeneficiaryCountry = null;
		String m_sBeneficiaryEmail = null;
		String m_sBeneficiaryBank = null;
		String m_sBeneficiaryAccountNo = null;
		String m_sBeneficiaryBranch = null;
		String m_sBeneficiaryCity = null;

		String m_sTrnxID = null;
		String m_sDate = null;
		String m_sTime = null;
		String m_sActualStatus = null;
		String m_sStatus = null;
		String m_sReason = null;
		String m_sBalance = null;
		String m_sPhoenixReference = null;
		StringBuffer m_sbDesc = new StringBuffer ();
		StringBuffer m_sFileContent  = null;

		String m_sChargesResponseCode = null;
		String m_sChargesErrorMessage = null;
		String m_sChargesFromAccBalance = null;
		String m_sChargesRefNo = null;
		String m_sResponseCode = null;
		boolean m_bFTTStatus = false;
		boolean m_bChargeStatus = false;
		String m_sDebitedLocalAmount = "";
		String m_sFrmAccCreateDate = null;

		TableData m_oTableData = null;
		double m_dTotalAmount = 0.0;
		String m_sMax = null;
		double m_dMax = 0.0;
		String m_sCharges = null;
		String m_sChargesDisplay = null;
		double m_dCharges = 0.0;
		double m_dCurrencyServiceCharges = 0.0;
		String m_sGSTCharges = null;
		String m_sGSTChargesDisplay = null;
		double m_dGSTCharges = 0.0;

		BVI_DateTime m_oDate = null;

		ESBFttTransferBean m_oESBFttTransferBean = null;

		IBDynaBean m_oViewBean = null;
		IBDynaBean m_oServiceInfoBean = null;
		IBDynaBean m_oTermsBean = null;
		String m_sTransactionType = TransactionType.FOREIGN_TELEGRAPHIC_TRANSFER;

		Date m_oEffectiveDate = null;
		String m_sEffectiveDate = null;
		boolean m_boSIIndicator = false;
		boolean m_boDeleteSIIndicator = false;
		String m_sPayFrequency = null;
		String m_sPaymentFrequencyDisplay = null;
		String m_sEffectiveDateDisplay = null;
		String m_sTerminationDate = null;
		String m_sTerminationDateDisplay = null;
		String m_sPaymentModeDisplay = null;
		String m_sPaymentMode = null;
		boolean m_boIsResultSuccessful = false;

		double m_dAvailableBal = 0.0;
		double m_dTransferAmount = 0.0;
		double m_dTotalTransferAmount = 0.0;
		boolean m_boIsFundSufficient = true;
		String m_sSIServiceCode = "";
		String m_sServiceCode = "";
		
		String staff = "";
		boolean m_bIsStaff = true;
		
		String m_sRimNo = "";
		Float m_fNonResLimit= new Float(0);;
		String residencyType = "";

		double m_dLocalAmt = 0.0;
		double m_dComThreshold = 0.0;
		double m_dChargesCom = 0.0;
		
		Content m_oServiceInfoContent = null;
		float nonResLimit = 0.0F;
		
		//#-- added by pixa 20121017 start 
		OnlineAccPromoBean onlineAccPromoBean = null;
    	String promotionCharges="0"; 
    	//#-- added by pixa 20121017 end --
    	
    	String m_sFromLocalIsoCurrency = CurrencyCode.MALAYSIA_RINGGIT; //defaulted to MYR
    	
		try
		{
			m_oDate = new BVI_DateTime ();
			m_sDate = DateTimeUtils.formatDayMonthYear (m_oDate);
			m_sTime = m_oDate.getTime ();
			m_sEffectiveDate = m_oDate.getSimpleDate ();
			m_oEffectiveDate = m_oDate.getJavaDate ();
			
			
			m_oViewBean = (IBDynaBean) getIBDynaBean ().get (FTTConstants.FTT_VIEW_BEAN);
			m_oServiceInfoBean = (IBDynaBean) m_oViewBean.get (ServiceInfo.SERVICE_INFO_BEAN);

			m_sRimNo = (String)getIBSessionObjects ().getHttpSessionAttrObject (AccessConstants.RIM_NO);
        	ESBCompanyProfileBean residencyByRim = getESBServices ().getProfileByAccRim(null, m_sRimNo);
        	residencyType = residencyByRim.getResidency();
        	
			if(m_oServiceInfoBean != null)
			{
				if (((Boolean) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_TAC_REQUIRED)).booleanValue ())
				{
					getIBAuthenticationServices ().userVerifyTac ((String) getIBDynaBean ().get (FTTConstants.FBEAN_TAC_VALUE),getIBSessionObjects().getIBSessionId());
				}
				m_sTransactionType = (String) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_SERVICE_NAME);
				m_sServiceCode = (String) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_SERVICE_CODE);
			}

			m_sTrnxID = IBUtils.getTransactionId (getIBSessionObjects ().getDataManager ());

			//To get Terms of Declaration
			m_sTerms = (String) getIBDynaBean ().get (FTTConstants.FBEAN_TERMS);
			m_oTermsBean = (IBDynaBean) m_oViewBean.get (FTTConstants.VBEAN_TERMS_BEAN);
			if(m_oTermsBean != null)
			{
				switch (Integer.valueOf (m_sTerms))
				{
					case 1:
						m_sTermsDeclaration = (String) m_oTermsBean.get (ServiceInfo.BEAN_ATT_MAIN_NOTE1);
						break;

					case 2:
						m_sTermsDeclaration = (String) m_oTermsBean.get (ServiceInfo.BEAN_ATT_MAIN_NOTE2);
						break;

					case 3:
						m_sTermsDeclaration = (String) m_oTermsBean.get (ServiceInfo.BEAN_ATT_MAIN_NOTE3);
						break;

					case 4:
						m_sTermsDeclaration = (String) m_oTermsBean.get (ServiceInfo.BEAN_ATT_MAIN_NOTE4);
						break;

					case 5:
						m_sTermsDeclaration = (String) m_oTermsBean.get (ServiceInfo.BEAN_ATT_MAIN_NOTE5);
						break;

					case 6:
						m_sTermsDeclaration = (String) m_oTermsBean.get (ServiceInfo.BEAN_ATT_MAIN_NOTE6);
						break;

					default:
						m_sTermsDeclaration = ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.term.others");
				}

			}


			m_sFttCountry = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_COUNTRY);
			m_sTransactionDesc = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_TRANS_DESCRIPTION_DISPLAY);
			otherPaymentDetails = (String) m_oViewBean.get(FTTConstants.OTHER_PAYMENT_DETAILS);
			m_sToCurrencyCode = (String) m_oViewBean.get (FTTConstants.VBEAN_CURRENCY);
			m_sSpecialBankCode = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_SPECIAL_CONDITION_NO_DISPLAY);
			m_sForeignAmount = (String) m_oViewBean.get (FTTConstants.VBEAN_FOREIGN_AMOUNT);
			m_sLocalAmount = (String) m_oViewBean.get (FTTConstants.VBEAN_LOCAL_AMOUNT);
			m_sCurrencyServiceCharges = (String) m_oViewBean.get (FTTConstants.VBEAN_CURRENCY_SERVICE_CHARGES);

			m_sFromAccount = (String) m_oViewBean.get (FTTConstants.VBEAN_FROM_ACCOUNT);
			m_sSenderName = (String) m_oViewBean.get(FTTConstants.SENDER_NAME);
			m_sSenderAddress1 = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_SENDER_ADD1_DISPLAY);
			m_sSenderAddress2 = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_SENDER_ADD2_DISPLAY);
			m_sSenderPostcode = (String) getIBDynaBean ().get (FTTConstants.FBEAN_SENDER_POSTCODE);
			m_sSenderCountry = (String) m_oViewBean.get (FTTConstants.VBEAN_SENDER_COUNTRY_DISPLAY);
			m_sSenderContact = (String) getIBDynaBean ().get (FTTConstants.FBEAN_SENDER_CONTACT);

			m_sBeneficiaryName = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_NAME_DISPLAY);
			m_sBeneficiaryAddress1 = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_ADD1_DISPLAY);
			m_sBeneficiaryAddress2 = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_ADD2_DISPLAY);
			m_sBeneficiaryID = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_ID_DISPLAY);
			m_sBeneficiaryContact = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_CONTACT_DISPLAY);
			m_sBeneficiaryCountry = (String) m_oViewBean.get (FTTConstants.VBEAN_BENEFICIARY_COUNTRY_DISPLAY);
			m_sBeneficiaryEmail = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_EMAIL_DISPLAY);
			m_sBeneficiaryBank = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_BANK_DISPLAY);
			m_sBeneficiaryAccountNo = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_ACCOUNT_NO);
			m_sBeneficiaryBranch = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_BRANCH_DISPLAY);
			m_sBeneficiaryCity = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_BENE_CITY_DISPLAY);
			m_sFromAccIsoCurr = (String) m_oViewBean.get (FTTConstants.VBEAN_FROM_CURRENCY);
			m_bIsStaff = (Boolean) m_oViewBean.get (FTTConstants.VBEAN_IS_STAFF_ACCOUNT);

//			m_sFrmAccCreateDate = m_oESBFttTransferBean.getFttFromAccountCreateDate();

			m_sPaymentMode = (String)getIBDynaBean ().get (SIConstants.PAY_MODE);
			m_sPaymentModeDisplay = (String)m_oViewBean.get (SIConstants.PAY_MODE_DISPLAY);
			m_sEffectiveDateDisplay = (String)m_oViewBean.get (SIConstants.EFFECTIVE_DATE_DISPLAY);

			if (!SI_PAYMENT_MODE.PAY_NOW.getCode ().equals (m_sPaymentMode))
			{
				m_boSIIndicator = true;
				m_sTransactionType = IBGenericSIServices.getSITransType (m_sTransactionType, m_sPaymentMode);

				m_sEffectiveDate = (String)m_oViewBean.get (SIConstants.EFFECTIVE_DATE_FORMAT);
				BVI_DateTime m_oIBEffectiveDate = new BVI_DateTime (m_sEffectiveDate);
				m_oEffectiveDate = m_oIBEffectiveDate.getJavaDate ();

				if (SI_PAYMENT_MODE.RECURRING_PAYMENT.getCode ().equals (m_sPaymentMode))
				{
					m_sPayFrequency = (String)getIBDynaBean ().get (SIConstants.PAY_FREQUENCY);
					m_sPaymentFrequencyDisplay = (String)m_oViewBean.get (SIConstants.PAY_FREQUENCY_DISPLAY);
					m_sTerminationDate = (String) m_oViewBean.get (SIConstants.TERMINATION_DATE_FORMAT);
					m_sTerminationDateDisplay = (String)m_oViewBean.get (SIConstants.TERMINATION_DATE_DISPLAY);
				}
			}

			m_sbDesc.append ("TT Transfer to ");
			m_sbDesc.append (m_sBeneficiaryName);
			if(!DataValidator.isEmptyString ((String)getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_ID)))
			{
				m_sbDesc.append (" - ");
				m_sbDesc.append (m_sBeneficiaryID);
			}
					
			if(!m_bIsStaff)
			{
				m_sCharges = (String) m_oViewBean.get (FTTConstants.VBEAN_CHARGES);
				m_dCharges = Double.parseDouble(m_sCharges);
				m_sGSTCharges = (String) m_oViewBean.get (FTTConstants.VBEAN_GST_CHARGES);
				m_dGSTCharges = Double.parseDouble(m_sGSTCharges);
				
				//#-- added by pixa 20121017 start --remember to include import at top
	        	onlineAccPromoBean = IBUtilsOnlineAcc.getChargesIfIsOnlineAccount(this,m_sFromAccount, OnlineAccConstants.FTT);
	        	if(onlineAccPromoBean !=null){
	        		promotionCharges = onlineAccPromoBean.getPromotionCharges();
	        		m_dCharges = Double.valueOf (promotionCharges);
	        	}
	        	//#-- added by pixa 20121017 end --
			}
			
			m_sChargesDisplay = (String) m_oViewBean.get (FTTConstants.VBEAN_CHARGES_DISPLAY);
			m_sGSTChargesDisplay = (String) m_oViewBean.get (FTTConstants.VBEAN_GST_CHARGES_DISPLAY);

			/*
             * check blacklisted beneficiary name
             */
            if (IBFundTransferDBUtils.isNameBlacklisted (this, m_sBeneficiaryName))
			{
            	m_boIsResultSuccessful = false;
            	m_sActualStatus = IBOfacBlackList.BLACK_LISTED;

            	m_sStatus = ResourcesUtils.getUnsuccessful ();
            	m_sReason = ResourcesUtils.getBusinessExceptionErrorMessage (IBBusinessException.FTT_FUND_TRANSFER, FTTConstants.ERR_BLACKLISTED_BENE_NAME);
			}
            else
            {
            	if(residencyType.equalsIgnoreCase(FTTConstants.NON_RESIDENT_TYPE))
				{
					m_oServiceInfoContent = IBGenericSIServices.getServiceInfoContent (ServiceInfo.FUND_TRANSFER_STANDARD_DAILY_LIMIT_NON_RES);
					nonResLimit = Float.valueOf(DataValidator.isEmptyString ((String) m_oServiceInfoContent.getStringValue (ServiceInfo.TABLE_ATT_MAX_LIMIT)) ? "0" : 
	    				(String) m_oServiceInfoContent.getStringValue (ServiceInfo.TABLE_ATT_MAX_LIMIT)).floatValue();
				}
				if (SI_PAYMENT_MODE.PAY_NOW.getCode ().equals (m_sPaymentMode))
				{
					//check max limit from service info bean(BVMC)
					m_sMax = (String) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_MAX_LIMIT);
					m_dMax = Double.parseDouble (DataValidator.isEmptyString (m_sMax)?"0.0":m_sMax);
					
					if(residencyType.equalsIgnoreCase(FTTConstants.NON_RESIDENT_TYPE))
					{
						if(m_dMax > nonResLimit)
						{
							m_dMax = nonResLimit;
						}
					}

					//check daily limit
					m_oTableData = getTotalFTTAmount (this);
					if (m_oTableData != null && m_oTableData.size () > 0)
					{
						m_dTotalAmount = (Double)m_oTableData.getDoubleValue (0, "TOTAL_AMT");
					}

					m_dTotalAmount = m_dTotalAmount + Double.parseDouble (DataValidator.isEmptyString (m_sLocalAmount)? "0.0" : m_sLocalAmount);
						  
					Map m_oDailyLimitReturnMap = IBStdDailyLimitBaseServices.checkFttDailyLimit(this ,m_sEffectiveDate,
							m_sLocalAmount, residencyType , false , false);
					
					if ((!((Boolean) m_oDailyLimitReturnMap.get (ThirdPartyTransferTags.STATUS)).booleanValue ()))
	 	            {
	 	            	m_boIsResultSuccessful = false;
	  
	 	            	m_sStatus = ResourcesUtils.getUnsuccessful ();
	 	            	m_sReason = ResourcesUtils.getApplicationResourceMessage ("error.transaction.max.amount",
	 	                		new String [] { FormatterUtils.formatMoneyDisplay ((String) m_oDailyLimitReturnMap.get (ThirdPartyTransferTags.MAX_LIMIT),
	 	                				null, true) });	
	 	            }
		            else if(m_dTotalAmount > m_dMax)
					{
						m_sStatus = ResourcesUtils.getUnsuccessful ();
						m_sReason = ResourcesUtils.getApplicationResourceMessage ("error.transaction.max.amount",
		                		new String [] { FormatterUtils.formatMoneyDisplay (String.valueOf (m_dMax), null, true)});
					}
					else
					{
						ESBAccountEnquiryTC100Bean m_oTCEnquiryBean = getESBServices ().getAccountDetailsTC100 (m_sFromAccount);
						if (!DataValidator.isEmptyString (m_oTCEnquiryBean.getAvailable_Bal ()))
						{
							m_dAvailableBal = Double.parseDouble (m_oTCEnquiryBean.getAvailable_Bal ());
						}

						m_dTransferAmount = Double.parseDouble (m_sLocalAmount);
						m_dTotalTransferAmount = m_dTransferAmount + m_dCharges + m_dGSTCharges;

						if(m_dAvailableBal < m_dTotalTransferAmount)
						{
							m_boIsFundSufficient = false;
							m_boIsResultSuccessful = false;
							m_sStatus = ResourcesUtils.getUnsuccessful ();
							m_sReason = ResourcesUtils.getApplicationResourceMessage (SIConstants.RESOURCES_INSUFFICIENT_FUND);
						}

						if (m_boIsFundSufficient)
						{
							if(m_bIsStaff)
							{
								//process FTT transfer through phoenix
								m_oESBFttTransferBean = getESBServices ().foreignFundTransferWithoutCharges (m_sFromAccount, m_sToCurrencyCode,
									m_sForeignAmount, ESBConstants.FUND_TRANSFER_FTT, null, m_sSenderName, m_sBeneficiaryName, m_sTransactionDesc, otherPaymentDetails);
							}
							else
							{
								//process FTT transfer through phoenix
								m_oESBFttTransferBean = getESBServices ().foreignFundTransfer (m_sFromAccount, m_sToCurrencyCode,
										m_sForeignAmount, m_sCharges, m_sGSTCharges, ESBConstants.FUND_TRANSFER_FTT, null, ESBConstants.FTT_CHARGES, ESBConstants.FTT_GST_CHARGES,  m_sSenderName, m_sBeneficiaryName, m_sTransactionDesc, otherPaymentDetails);
								
							}
							
							//calculate charges through phoenix
							if(!"".equalsIgnoreCase( m_oESBFttTransferBean.getChargesResponseCode ()))
							{
								if(ESBConstants.IB_SUCCESS_RC.equals(m_oESBFttTransferBean.getChargesResponseCode ()))
								{
									m_sChargesFromAccBalance = m_oESBFttTransferBean.getChargesFromAccountBalance ();
									m_sChargesRefNo = m_oESBFttTransferBean.getChargesReferenceNo ();
									
								}
								else //FTT charges failed, display charges error message and response code
								{
									m_sStatus = ResourcesUtils.getUnsuccessful ();
									m_sChargesErrorMessage = m_oESBFttTransferBean.getChargesErrorMessage ();
									m_sReason = m_sChargesErrorMessage;
								}
							}
							
							m_sChargesResponseCode = m_oESBFttTransferBean.getChargesResponseCode ();
							m_bChargeStatus = m_oESBFttTransferBean.getChargesStatus ();


								//get FTT response code from Phoenix
								m_sResponseCode = m_oESBFttTransferBean.getFttResponseCode ();
								m_bFTTStatus = m_oESBFttTransferBean.getFttStatus ();
								if (ESBConstants.IB_SUCCESS_RC.equalsIgnoreCase (m_sResponseCode))
								{
									m_sStatus = ResourcesUtils.getAccepted ();
									m_boIsResultSuccessful = true;
									m_sBalance = m_oESBFttTransferBean.getFttFromAccountBalance ();
									m_sPhoenixReference = m_oESBFttTransferBean.getFttReferenceNo ();
									m_sDebitedLocalAmount = m_oESBFttTransferBean.getFttLocalAmount ();

									if(!DataValidator.isEmptyString (m_sPhoenixReference))
									{
										String m_sRefNoLabel = ResourcesUtils.getApplicationResourceMessage ("general.reference.number.short"); //(Ref No : )
										m_sbDesc.append ("<br>").append ("(").append (m_sRefNoLabel).append (":").append (m_sPhoenixReference).append (")");
									}

									m_sFileContent  = new StringBuffer ();
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.terms")).append (" : ").append (m_sTermsDeclaration).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.country")).append (" : ").append (m_sFttCountry).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.description")).append (" : ").append (m_sTransactionDesc).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.other.payment.details")).append (" : ").append (otherPaymentDetails).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.currency")).append (" : ").append (m_sToCurrencyCode).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.foreign.amount")).append (" : ").append (m_sForeignAmount).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("general.fromAccount")).append (" : ").append (m_sFromAccount).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.sender.name")).append (" : ").append (m_sSenderName).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.sender.address1")).append (" : ").append (m_sSenderAddress1).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.sender.address2")).append (" : ").append (m_sSenderAddress2).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.sender.postcode")).append (" : ").append (m_sSenderPostcode).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.sender.country")).append (" : ").append (m_sSenderCountry).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.sender.contact")).append (" : ").append (m_sSenderContact).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryName")).append (" : ").append (m_sBeneficiaryName).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryAddress1")).append (" : ").append (m_sBeneficiaryAddress1).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryAddress2")).append (" : ").append (m_sBeneficiaryAddress2).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryCountry")).append (" : ").append (m_sBeneficiaryCountry).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryID")).append (" : ").append (m_sBeneficiaryID).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryContact")).append (" : ").append (m_sBeneficiaryContact).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryEmail")).append (" : ").append (m_sBeneficiaryEmail).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryBank")).append (" : ").append (m_sBeneficiaryBank).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiary.bank.code.swift")).append (" : ").append (m_sSpecialBankCode).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryAccountNo")).append (" : ").append (m_sBeneficiaryAccountNo).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryBranch")).append (" : ").append (m_sBeneficiaryBranch).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryCity")).append (" : ").append (m_sBeneficiaryCity).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("general.reference.number")).append (" : ").append (FormatterUtils.formatTransID (m_sTrnxID)).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("general.reference")).append (" : ").append (m_sPhoenixReference).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("general.transaction.date")).append (" : ").append (m_sDate).append ("\n");
									m_sFileContent.append (ResourcesUtils.getApplicationResourceMessage ("general.transaction.time")).append (" : ").append (m_sTime);

									//send email to beneficiary
									String m_sEmail = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_EMAIL);
									if (!DataValidator.isEmptyString (m_sEmail))
				                    {
				                    	/*
				                    	 * email transfer notification to recipient
				                    	 */
										String m_sSubject = ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.subject");
				                    	String m_sCustomerName = getIBSessionObjects ().getVisitor ().getStringValue (AccessConstants.VISITOR_LAST_NAME);

				                    	StringBuffer m_sbEmailMsg = new StringBuffer ();
				                    	m_sbEmailMsg.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.greetCustomer", new String [] {m_sSubject, m_sBeneficiaryName} ));
				                    	m_sbEmailMsg.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.note1",
				                    			new String [] {m_sCustomerName, m_sDate.concat (" ").concat (m_sTime) } ));

				                    	IBLogWriter m_oTableCreater = new IBLogWriter();
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("S", ResourcesUtils.getApplicationResourceMessage ("general.status"), m_sStatus, null, null)).append("\n");
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("C", ResourcesUtils.getApplicationResourceMessage ("general.amount"), (String) m_oViewBean.get (FTTConstants.VBEAN_FOREIGN_AMOUNT_DISPLAY), null, null)).append("\n");
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("C", ResourcesUtils.getApplicationResourceMessage ("general.reference.number"), FormatterUtils.formatTransID (m_sTrnxID), null, null)).append("\n");
				                    	if(!DataValidator.isEmptyString (m_sPhoenixReference))
				        				{
				                    		m_sbEmailMsg.append (m_oTableCreater.RowCreater ("C", ResourcesUtils.getApplicationResourceMessage ("general.reference"), m_sPhoenixReference, null, null)).append("\n");
				        				}
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("C", ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.description"),
				                    			DataValidator.isEmptyString (m_sTransactionDesc) ? "-" : m_sTransactionDesc, null, null)).append("\n");
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("C", ResourcesUtils.getApplicationResourceMessage ("ib104.other.payment.details"),
				                    			DataValidator.isEmptyString (otherPaymentDetails) ? "-" : otherPaymentDetails, null, null)).append("\n");
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("C", ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.country"), m_sBeneficiaryCountry, null, null)).append("\n");
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("C", ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.bankname"), m_sBeneficiaryBank, null, null)).append("\n");
				                    	m_sbEmailMsg.append (m_oTableCreater.RowCreater ("E", ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.bankcity"), m_sBeneficiaryCity, null, null)).append("\n");

				                    	m_sbEmailMsg.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.note2"));
				                    	m_sbEmailMsg.append (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.bene.email.disclaimer"));

				                    	IBUtils.sendEmail (this, null, m_sEmail, m_sSubject, m_sbEmailMsg.toString (), m_sStatus, null);
				                    }
								}
								else//FTT failed, display ftt error message and response code
								{
									m_sBalance = m_sChargesFromAccBalance;
									m_sStatus = ResourcesUtils.getUnsuccessful ();
									m_sReason = m_oESBFttTransferBean.getFttErrorMessage ();
								}
							
							m_sFrmAccCreateDate = m_oESBFttTransferBean.getFttFromAccountCreateDate();
						}
					}
				}
				// SI
				else
				{
					String m_sTransType = (String)m_oViewBean.get (FTTConstants.VBEAN_TRANS_TYPE);
					if((FTTConstants.TRANSTYPE_OPEN).equalsIgnoreCase (m_sTransType))
					{
						m_sSIServiceCode = ServiceInfo.SI_FTT_OPEN_LIMIT;
					}
					else if((FTTConstants.TRANSTYPE_REGISTERED).equalsIgnoreCase (m_sTransType))
					{
						m_sSIServiceCode = ServiceInfo.SI_FTT_REG_LIMIT;
					}
					
					Map m_oDailyLimitReturnMap = IBStdDailyLimitBaseServices.checkFttDailyLimit(this ,m_sEffectiveDate,
							m_sLocalAmount, residencyType , false , true);
					
					m_sServiceCode = m_sSIServiceCode;
					// Had do checking at IBFttConfirmServices
					Map m_oSILimitMap = IBGenericSIServices.verifySIDailyLimitByServiceCode (this, getIBDynaBean (), getIBSessionObjects (),
							m_sSIServiceCode, m_sLocalAmount, m_sEffectiveDate, false , residencyType , nonResLimit);
					
					if ((!((Boolean) m_oDailyLimitReturnMap.get (ThirdPartyTransferTags.STATUS)).booleanValue ()))
	 	            {
	 	            	m_boIsResultSuccessful = false;
	  
	 	            	m_sStatus = ResourcesUtils.getUnsuccessful ();
	 	            	m_sReason = ResourcesUtils.getApplicationResourceMessage ("error.transaction.max.amount",
	 	                		new String [] { FormatterUtils.formatMoneyDisplay ((String) m_oDailyLimitReturnMap.get (ThirdPartyTransferTags.MAX_LIMIT),
	 	                				null, true) });
	 	            }
					else if (!((Boolean) m_oSILimitMap.get (SIConstants.TRANS_STATUS)).booleanValue ())
			        {
						m_boIsResultSuccessful = false;
						m_sStatus = ResourcesUtils.getUnsuccessful ();
						m_sReason = ResourcesUtils.getBusinessExceptionErrorMessage (IBBusinessException.SI,
			            		SIConstants.ERR_BANK_MAX_LIMIT,
			            		new String [] { FormatterUtils.formatMoneyDisplay ( (String)m_oSILimitMap.get (SIConstants.MAX_LIMIT),
			            				m_sFromAccIsoCurr, true) });
			        }
					else
			    	{
						m_boIsResultSuccessful = true;
						m_sStatus = ResourcesUtils.getAccepted ();
			    	}
				}
            }


			//Print receipt
			if(m_boIsResultSuccessful)
			{
				Map<String, String> m_oReceiptDetails = new LinkedHashMap <String, String> ();
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("receipt.transaction.type"), m_sTransactionType);
				m_oReceiptDetails.put(ResourcesUtils.getApplicationResourceMessage("ib104.transfer.ftt.sender.name"), m_sSenderName);
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryName"), m_sBeneficiaryName);
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.status"), m_sStatus);
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.beneficiaryAccountNo"), m_sBeneficiaryAccountNo);
				m_oReceiptDetails.put(ResourcesUtils.getApplicationResourceMessage("ib104.transfer.ftt.description"), m_sTransactionDesc);
				m_oReceiptDetails.put(ResourcesUtils.getApplicationResourceMessage("ib104.other.payment.details"), otherPaymentDetails);
//				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.local.amount"), (String) m_oViewBean.get (FTTConstants.VBEAN_LOCAL_AMOUNT_DISPLAY));
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.foreign.amount"), (String) m_oViewBean.get (FTTConstants.VBEAN_FOREIGN_AMOUNT_DISPLAY));
				if(!"-".equals(m_sChargesDisplay)){
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("ib104.transfer.ftt.charges"), m_sChargesDisplay);
				}
				if(!"-".equals(m_sGSTChargesDisplay)){
					m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.gst.charges"), m_sGSTChargesDisplay);
				}

				if (!DataValidator.isEmptyString (m_sPaymentModeDisplay))
				{
					m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("ib112.si.payment.mode"), m_sPaymentModeDisplay);
				}
				if (!DataValidator.isEmptyString (m_sPaymentFrequencyDisplay))
				{
					m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.payment.frequency"), m_sPaymentFrequencyDisplay);
				}
				if (!DataValidator.isEmptyString (m_sEffectiveDateDisplay))
				{
					m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.start.date"), m_sEffectiveDateDisplay);
				}
				if (!DataValidator.isEmptyString (m_sTerminationDateDisplay))
				{
					m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.terminate.date"), m_sTerminationDateDisplay);
				}

				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.reference.number"), FormatterUtils.formatTransID (m_sTrnxID));
				if(!DataValidator.isEmptyString (m_sPhoenixReference))
				{
					m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.reference"), m_sPhoenixReference );
				}
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.transaction.date"), m_sDate );
				m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.transaction.time"), m_sTime);

				//Add KFH GST Account No
				if(!"-".equals(m_sGSTChargesDisplay))
					m_oReceiptDetails.put (ResourcesUtils.getApplicationResourceMessage ("general.gst.id.no"), IBLoadProperty.getValue("gst.id.no") );
				
				//Insert into table IB_RECEIPT_DETAILS
				IBUtils.loopIntoReceiptDetails (this, m_oReceiptDetails, m_oDate.getSimpleDate (), m_sTrnxID);

				m_oViewBean.set (CommonConstants.RECEIPT_MAP, m_oReceiptDetails);

				String m_sReceiptLink = IBUtils.getReceiptLink (FTTConstants.FBEAN_FTT_FORM, FTTConstants.FTT_VIEW_BEAN);
				m_oViewBean.set (CommonConstants.RECEIPT_LINK, m_sReceiptLink);
			}


			m_oViewBean.set (FTTConstants.VBEAN_TERMS_DECLARATION, m_sTermsDeclaration);
			m_oViewBean.set (FTTConstants.VBEAN_STATUS, m_sStatus);
			m_oViewBean.set (FTTConstants.VBEAN_REASON, m_sReason);
			m_oViewBean.set (FTTConstants.VBEAN_REFERENCE_NO, FormatterUtils.formatTransID (m_sTrnxID));
			m_oViewBean.set (FTTConstants.VBEAN_FROM_ACCOUNT_BALANCE,
					FormatterUtils.formatMoneyDisplay (m_sBalance, null, true));
			m_oViewBean.set (FTTConstants.VBEAN_TRANSACTION_DATE, m_sDate);
			m_oViewBean.set (FTTConstants.VBEAN_TRANSACTION_TIME, m_sTime);
			m_oViewBean.set (FTTConstants.VBEAN_PHX_REFERENCE_NO, m_sPhoenixReference);

			m_oViewBean.set (FTTConstants.VBEAN_BOFTTSTATUS, (Boolean)m_bFTTStatus);
			m_oViewBean.set (FTTConstants.VBEAN_BOCHARGESTATUS, (Boolean)m_bChargeStatus);
			m_oViewBean.set (FTTConstants.VBEAN_CHARGES, String.valueOf (m_dCharges));
			m_oViewBean.set (FTTConstants.VBEAN_CHARGES_DISPLAY, m_sChargesDisplay);

			m_oViewBean.set (FTTConstants.VBEAN_DEBITED_AMT, DataValidator.isEmptyString (m_sDebitedLocalAmount) ? m_sLocalAmount : m_sDebitedLocalAmount);
			m_oViewBean.set (FTTConstants.VBEAN_DEBITED_AMT_DISPLAY, FormatterUtils.formatMoneyDisplay (m_sDebitedLocalAmount, null, true));

			//Log Accept FTT Terms and Condition
			StringBuffer m_oTermsDescription = new StringBuffer();
			m_oTermsDescription.append (FTTConstants.ACCEPT_TERMS_CONDITION).append (" - ").append ("Term : "+m_sTerms);
//			IBLogger.logInetTranHistory (this,
//					IBUtils.getTransactionId (getIBSessionObjects ().getDataManager ()), m_sTransactionType,
//					m_sFromAccount, m_sBeneficiaryAccountNo,
//					"0.00",  m_oTermsDescription.toString () , ResourcesUtils.getSuccessful (),
//					"", getIBSessionObjects ().getRemoteIPAddress (), "",
//					false, "", getIBSessionObjects ().getIBSessionId ());

			String gstAbsorbedAmount = (String) m_oViewBean.get(FTTConstants.GST_CHARGES_WITHOUT_ROUNDING);
			String gstAbsorbed = null;
			if(!DataValidator.isEmptyString(gstAbsorbedAmount))
				gstAbsorbed = GSTUtils.isGSTAmountAbsorbed(gstAbsorbedAmount);


			//TODO amount to be defaulted to RM?? local amount = m_sDebitedLocalAmount
			IBLogger.logInetTranHistory (
					this,
					m_sTrnxID,
					m_sTransactionType,
					m_sFromAccount,
					m_sFromAccIsoCurr,
					m_sBeneficiaryAccountNo,
					m_sToCurrencyCode,
					m_sForeignAmount,
					m_sbDesc.toString (),
					m_sStatus,
					"",
					"",
					m_sEffectiveDate,
					getIBSessionObjects ().getRemoteIPAddress (), "",
					true,
					m_sPhoenixReference,
					"",
					"",
					"",
					getIBSessionObjects ().getIBSessionId (),
					"",
					m_sChargesRefNo,
					"",
					m_sFrmAccCreateDate,
					null,
					m_sReason,
					m_sPaymentMode,
					m_sPayFrequency,
					m_sTerminationDate,
					// Penril: Additional fields for GST report
					String.valueOf (m_dCharges),
					m_sGSTCharges,
					gstAbsorbed,
					gstAbsorbedAmount,
					getIBSessionObjects().getGSTGLAccount(),
					m_sBeneficiaryName,
					m_sBeneficiaryBank,
					m_sChargesRefNo,
					String.valueOf(getIBSessionObjects().getVisitor().getId()),
					m_bIsStaff == true?"Staff":"NonStaff"
					// End Penril: Additional fields for GST report
					);

			IBLogger.logFTTActivity (
					this,
					getIBDynaBean (),
					m_sTrnxID,
					m_sTransactionType,
					m_oDate,
					getIBSessionObjects ().getRemoteIPAddress (),
					m_oEffectiveDate,
					m_sChargesRefNo,//p_sPhxChargesRefNo
					"",//p_sPhxChargesRevertRefNo
					String.valueOf (m_dCharges),//p_sCharges
					m_sFileContent,
					m_sFrmAccCreateDate,
					m_boSIIndicator,
					m_sActualStatus,
					m_sServiceCode,
					m_sSenderName,
					otherPaymentDetails,
					m_sGSTCharges);

			if (m_boSIIndicator && m_boIsResultSuccessful)
			{
				IBLogger.logSIDetail (
						this,
						m_sTrnxID,
						m_sTrnxID,
						SIConstants.TRANSCODE_FTT_TRANSFER,
						m_sTransactionType,
						m_sPaymentMode,
						m_sPayFrequency,
						m_sEffectiveDate,
						m_sTerminationDate,
						m_sSIServiceCode,
						m_boDeleteSIIndicator
						);
			}

			getIBSessionObjects ().setAccountEnquiryBean (null);
			
//			 SMS Notification START
			String m_sCustomerSMSMessage = "-";
			String m_sBeneficiarySMSMessage = "-";

//			String m_sCustomerAmount = SMSServices.formatAmountValue(m_sLocalAmount, m_sFromAccIsoCurr);
			/*
			 * for FTT sender's SMS msg, need to display the actual debited amount, not the estimated local amount.
			 */
			String m_sCustomerAmount = FormatterUtils.formatMoneyDisplay (m_sDebitedLocalAmount, null, true);
//			String m_sBeneficiaryAmount = SMSServices.formatAmountValue(m_sForeignAmount, m_sToCurrencyCode);

			String m_sTransactionTypeForSMSMessage = ResourcesUtils.getApplicationResourceMessage(SMSConstants.RESOURCE_SMS_TEXT_MESSAGE_SERVICE_FOREIGN);

			m_sCustomerSMSMessage = SMSServices.generateCustomerSMSMessage(
					m_sTransactionTypeForSMSMessage,
					m_sCustomerAmount, 
					m_sBeneficiaryName.length()>18?m_sBeneficiaryName.substring(0, 18):m_sBeneficiaryName,
					m_sStatus, 
					new Date(),
					FormatterUtils.formatMoneyDisplay (m_sBalance, m_sFromLocalIsoCurrency, true));
			
			SMSServices.sendCustomerSMS(this, 
					m_oViewBean, 
					m_sFromAccount, 
					m_sStatus, 
					getIBDynaBean().get(SIConstants.PAY_MODE).toString(), 
					m_sTransactionType, 
					m_sTrnxID,
					m_sLocalAmount, 
					getIBSessionObjects().getVisitor().getId(), 
					m_sCustomerSMSMessage, 
					m_oDate,
					SMSConstants.DEBIT_IB_TYPE);
			
			m_sBeneficiarySMSMessage = SMSServices.generateBeneficiaryOtherSMSMessage(
					m_oViewBean,
					m_sTransactionTypeForSMSMessage,
					m_sBeneficiaryAccountNo,
					m_sCustomerAmount,
					m_oDate);
			
			SMSServices.sendBeneficiarySMS(this, 
					getIBDynaBean(),
					m_oViewBean, 
					m_sFromAccount, 
					m_sStatus, 
					getIBDynaBean().get(SIConstants.PAY_MODE).toString(), 
					m_sTransactionType, 
					m_sTrnxID, 
					getIBSessionObjects().getVisitor().getId(), 
					m_sBeneficiarySMSMessage, 
					m_oDate,
					"");
	
			ESBAccountEnquiryTC100Bean m_oTCEnquiryBean = getESBServices ().getAccountDetailsTC100 (m_sFromAccount);
			
			m_oViewBean.set (FTTConstants.VBEAN_FROM_ACCOUNT_BALANCE,
					FormatterUtils.formatMoneyDisplay (m_oTCEnquiryBean.getAvailable_Bal(), null, true));
			
			// UAT START
			m_oViewBean.set(SMSConstants.VBEAN_SMS_UAT_IS_BENE_SMS_SENT, SMSServices.isSMSLogged(this, m_oViewBean.get(SMSConstants.VBEAN_SMS_BENE_MOBILE_NO).toString(), SMSConstants.SMS_NOTIFICATION_TYPE, m_oDate.getDateDDMMMYYYYHMS()));
			m_oViewBean.set(SMSConstants.VBEAN_SMS_UAT_IS_CUSTOMER_SMS_SENT, SMSServices.isSMSLogged(this, m_oViewBean.get(SMSConstants.VBEAN_SMS_CUSTOMER_MOBILE_NO).toString(), SMSConstants.SMS_NOTIFICATION_TYPE, m_oDate.getDateDDMMMYYYYHMS()));
			m_oViewBean.set(SMSConstants.VBEAN_SMS_UAT_BENE_SMS_MESSAGE, m_sBeneficiarySMSMessage);
			m_oViewBean.set(SMSConstants.VBEAN_SMS_UAT_CUSTOMER_SMS_MESSAGE, m_sCustomerSMSMessage);
			// UAT END
		
			// SMS Notification END
		}
		catch (Exception e)
		{
			m_sStatus = ResourcesUtils.getUnsuccessful ();
			if (e instanceof IBGenericException)
			{
				throw (IBGenericException) e;
			}
			throw IBErrorHandler.createServiceException(
					IBServiceException.GENERAL_SERVICE_ERROR, true,
					new String[] {CommonErrorCode.GENERIC_CODE, "", "", "", IBErrorHandler.generateErrorMessage(e)}, c_oClass);
		}

		IBLogger.logBSFNMethodLeavingMessage (c_oClass, m_sMethodName, m_oTimer);
	}
	
	public ESBAccountInfoDetailBean retrieveAcctInfoDetail(String p_sAcctNo)throws IBGenericException
	{
		ESBAccountInfoDetailBean m_oESBAcctInfoDetails = null;
		
		try 
		{
			m_oESBAcctInfoDetails = getESBServices ().getAccountInfoDetail(p_sAcctNo);
		} 
		catch (IBGenericException e) 
		{
			if (e instanceof IBGenericException)
			{
				throw (IBGenericException) e;
			}
			throw IBErrorHandler.createServiceException(
					IBServiceException.GENERAL_SERVICE_ERROR, true,
					new String[] {CommonErrorCode.GENERIC_CODE, "", "", "", IBErrorHandler.generateErrorMessage(e)}, c_oClass);
		}
		
		return m_oESBAcctInfoDetails;
		
	}
}
