/**
 * 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.math.BigDecimal;
import java.util.List;
import java.util.Map;

import my.com.kfh.enterprise.services.IBUtils;
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.others.IBTransferLimitConstant;
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.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.ESBCompanyProfileBean;
import my.com.kfh.hibernate.tables.IBGSTContent;
import my.com.kfh.hibernate.utils.HibernateUtils;
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.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.IBLogger;
import my.com.kfh.web.utils.IBSessionObjects;
import my.com.kfh.web.utils.IBTimer;
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 com.broadvision.data.client.Content;

/**
 * <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 confirm services.
 */
public class IBFttConfirmServices extends IBGenericFttServices
{
	private static Class c_oClass = IBFttConfirmServices.class;

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

	/**
	 * <pre>
	 * To calculate the foreign currency to transfer by multiply the amount entered by the user
	 * to the current forex rate for the selected country.
	 * If the user select favourite beneficiary, get the beneficiary account details from table
	 * IB_REGISTERED_IMT.
	 * Check the min and max limit for FTT transfer from service info bean.
	 * If the user key in amount less than the minimum limit or more than the maximum limit,
	 * throw a Business exception and get the error message to display to the user.
	 * Set all the required data into view beans.
	 * </pre>
	 *
	 * @throws IBGenericException
	 */
	public void executeServices () throws IBGenericException
	{
		String m_sMethodName = "executeServices";
		IBTimer m_oTimer = IBLogger.logBSFNMethodEnteringMessage (c_oClass, m_sMethodName);

		String m_sCurrency = null;
		String m_sCurrencyRate = null;
		String m_sCurrencyServiceCharges = null;
		StringBuffer m_sbDisplayRate = new StringBuffer ();

		String m_sSenderCountry = null;

		String m_sBeneficiaryCountry = null;

		String m_sTransDescription = null;
		String otherPaymentDetails = "";
		String m_sBeneficiaryBankCode = null;
		String m_sBeneficiaryBank = null;
		String m_sBeneficiaryCity = null;
		String m_sSenderAdd1 = null;
		String m_sSenderAdd2 = null;
		String m_sBeneficiaryName = null;

		String m_sBeneficiaryBranch = null;
		String m_sBeneficiaryEmail = null;
		String m_sBeneficiaryID = null;
		String m_sBeneficiaryContact = null;
		String m_sBeneficiaryAdd1 = null;
		String m_sBeneficiaryAdd2 = null;

		String m_sForeignAmount = null;
		String m_sLocalAmount = null;
		String m_sForeignAmountDisplay = null;
		String m_sLocalAmountDisplay = null;
		String m_sFromAccount = null;

		String m_sMax = null;
		String m_sMin = null;
		double m_dMax = 0.0;
		double m_dMin = 0.0;
		double m_dLocalAmount = 0.0;

		BigDecimal m_bdForeignAmount = null;
		BigDecimal m_bdLocalAmount = null;

		boolean m_bConvertForeign = false;

		List m_oCurrencyList = null;

		IBDynaBean m_oCurrencyBean = null;
		IBDynaBean m_oFromAccountBean = null;
		IBDynaBean m_oViewBean = null;
		IBDynaBean m_oServiceInfoBean = null;

		String m_sPaymentMode = null;
		String m_sSIServiceCode = "";
		
		String m_sRimNo = "";
		String residencyType = "";
		BVI_DateTime m_oDate = null;
		m_oDate = new BVI_DateTime ();
		
		Content m_oServiceInfoContent = null;
		String m_fNonResLimit = null;
		float nonResLimit = 0;

		try
		{
			m_oViewBean = (IBDynaBean) getIBDynaBean ().get (FTTConstants.FTT_VIEW_BEAN);

			//Bank code validation
			//verifySpecialCode();

			//Currency details
			m_oCurrencyList = (List) m_oViewBean.get (FTTConstants.VBEAN_CURRENCY_LIST);

			m_oCurrencyBean = (IBDynaBean) m_oCurrencyList.get (Integer.parseInt
					((String) getIBDynaBean ().get (FTTConstants.FBEAN_CURRENCY_INDEX)));
			m_sCurrency = (String) m_oCurrencyBean.get (FTTConstants.VBEAN_CURRENCY_CODE);
			m_oViewBean.set (FTTConstants.VBEAN_CURRENCY, m_sCurrency);
			m_oViewBean.set (FTTConstants.VBEAN_CURRENCY_DISPLAY, ((String)m_oCurrencyBean.get (FTTConstants.VBEAN_CURRENCY_DESC)).toUpperCase ());
			m_sCurrencyRate = (String) m_oCurrencyBean.get (FTTConstants.VBEAN_CURRENCY_SELL);
			m_sCurrencyServiceCharges = (String) m_oCurrencyBean.get (FTTConstants.VBEAN_CURRENCY_SERVICE_CHARGES);
			//From Account
			Map m_oFromAccountsMap = (Map)m_oViewBean.get (FTTConstants.VBEAN_FROM_ACCOUNT_MAP);
			m_sFromAccount = (String) getIBDynaBean ().get (FTTConstants.FBEAN_FROM_ACCOUNT_INDEX);
			m_oFromAccountBean = (IBDynaBean) m_oFromAccountsMap.get (m_sFromAccount);
			m_oViewBean.set (FTTConstants.VBEAN_FROM_ACCOUNT, m_oFromAccountBean.get (CommonConstants.ACCOUNT_NO));
			m_oViewBean.set (FTTConstants.VBEAN_FROM_ACCOUNT_DISPLAY,
					m_oFromAccountBean.get (CommonConstants.ACCOUNT_NO)+" "+m_oFromAccountBean.get (CommonConstants.ACCOUNT_NICKNAME));
			m_oViewBean.set (FTTConstants.VBEAN_FROM_CURRENCY, m_oFromAccountBean.get (CommonConstants.ISO_CURRENCY));
			m_sBeneficiaryName = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_NAME);

			//sender country
			m_sSenderCountry = (String) getIBDynaBean ().get (FTTConstants.FBEAN_SENDER_COUNTRY_INDEX);

			m_oViewBean.set (FTTConstants.VBEAN_SENDER_COUNTRY_DISPLAY, m_sSenderCountry.toUpperCase ());

			if (!((Boolean) m_oViewBean.get (FTTConstants.VBEAN_IS_FAVOURITE)).booleanValue ())
			{
				m_sBeneficiaryCountry = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_COUNTRY_INDEX);
				if(DataValidator.isEmptyString (m_sBeneficiaryCountry))
				{
					m_sBeneficiaryCountry = "-";
				}

				m_oViewBean.set (FTTConstants.VBEAN_BENEFICIARY_COUNTRY_DISPLAY, m_sBeneficiaryCountry.toUpperCase ());

			}
			//Calculate foreign amount
			m_sForeignAmount = (String) getIBDynaBean ().get (FTTConstants.FBEAN_FOREIGN_AMOUNT);

			m_bConvertForeign = true;
			m_bdForeignAmount = new BigDecimal (m_sForeignAmount);
			m_bdLocalAmount = m_bdForeignAmount.multiply (new BigDecimal (m_sCurrencyRate)).setScale(3, BigDecimal.ROUND_UP);
			m_sForeignAmount = m_bdForeignAmount.toString ();
			m_sLocalAmount = m_bdLocalAmount.toString ();

			m_sForeignAmountDisplay = FormatterUtils.formatMoneyDisplay (m_sForeignAmount,
					                (String) m_oCurrencyBean.get (FTTConstants.VBEAN_CURRENCY_CODE), true);

			m_sLocalAmountDisplay = FormatterUtils.formatMoneyDisplay (m_sLocalAmount, null, true);//by default it's in RM

			//Check max and min limit from service info bean
			m_oServiceInfoBean = (IBDynaBean)m_oViewBean.get (ServiceInfo.SERVICE_INFO_BEAN);

			//Pixakarft Bank Negara Changes 30th Mar 2013 start
			if (((Boolean) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_TAC_REQUIRED)).booleanValue ())
			{
				IBDynaBean m_oSMSViewBean = (IBDynaBean) getIBSessionObjects().getHttpSessionAttrObject(CommonConstants.SMS_VIEW_BEAN);
				m_oSMSViewBean.set(CommonConstants.AMOUNT, m_sLocalAmountDisplay);
				if(!DataValidator.isEmptyString(m_sBeneficiaryName)){
					m_oSMSViewBean.set(CommonConstants.BENE_NAME, m_sBeneficiaryName.length()>18?m_sBeneficiaryName.substring(0, 18):m_sBeneficiaryName);
				}
				m_oSMSViewBean.set(CommonConstants.BENE_NAME, m_sBeneficiaryName);
				getIBSessionObjects().setHttpSessionAttrObject(CommonConstants.SMS_VIEW_BEAN, m_oSMSViewBean);
			}
			//Pixakarft Bank Negara Changes 30th Mar 2013 start
			
			m_sPaymentMode = (String)getIBDynaBean ().get (SIConstants.PAY_MODE);
			if (SI_PAYMENT_MODE.PAY_NOW.getCode ().equals (m_sPaymentMode))
			{
				m_sMax = (String) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_MAX_LIMIT);
				m_sMin = (String) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_MIN_LIMIT);
			}
			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;
				}
				IBDynaBean m_oSIServiceInfoBean = IBUtils.getServiceInfoBean (m_sSIServiceCode, getIBDynaBean (), getIBSessionObjects (), false);
				if (m_oSIServiceInfoBean != null)
				{
					m_sMax = (String) m_oSIServiceInfoBean.get (ServiceInfo.BEAN_ATT_MAX_LIMIT);
					m_sMin = (String) m_oSIServiceInfoBean.get (ServiceInfo.BEAN_ATT_MIN_LIMIT);
				}
			}
			
			if(IBTransferLimitConstant.NON_RESIDENT_TYPE.equalsIgnoreCase(residencyType))
    		{
				m_oServiceInfoContent = IBGenericSIServices.getServiceInfoContent (ServiceInfo.FUND_TRANSFER_FTT_LIMIT_NON_RES);
				m_fNonResLimit = DataValidator.isEmptyString ((String) m_oServiceInfoContent.getStringValue (ServiceInfo.TABLE_ATT_MAX_LIMIT)) ? "0" : 
    				(String) m_oServiceInfoContent.getStringValue (ServiceInfo.TABLE_ATT_MAX_LIMIT);
                
                if(Float.valueOf(m_sMax) > Float.valueOf(m_fNonResLimit))
                {
                	m_sMax = m_fNonResLimit;
                }
    		}
			
			m_sRimNo = (String)getIBSessionObjects ().getHttpSessionAttrObject (AccessConstants.RIM_NO);
        	ESBCompanyProfileBean residencyByRim = getESBServices ().getProfileByAccRim(null, m_sRimNo);
        	residencyType = residencyByRim.getResidency();
        	
			m_dMax = Double.parseDouble (DataValidator.isEmptyString (m_sMax)?"0.0":m_sMax);
			m_dMin = Double.parseDouble (DataValidator.isEmptyString (m_sMin)?"0.0":m_sMin);

			m_dLocalAmount = Double.parseDouble (DataValidator.isEmptyString(m_sLocalAmount)?"0.0":m_sLocalAmount);

			//local amount < min
			if(m_dLocalAmount < m_dMin)
			{
				throw IBErrorHandler.createBusinessException (IBBusinessException.FTT_FUND_TRANSFER, "1",
						new  String[] {m_sLocalAmountDisplay + "(" + m_sForeignAmountDisplay +")",
						FormatterUtils.formatMoneyDisplay (String.valueOf (m_dMin), null, true)});
			}

			//local amount > max
			
			Map m_oDailyLimitReturnMap = IBStdDailyLimitBaseServices.checkFttDailyLimitConfirm(this, m_sLocalAmount, residencyType);
			if ((!((Boolean) m_oDailyLimitReturnMap.get (ThirdPartyTransferTags.STATUS)).booleanValue ()))
	        {
	            	throw IBErrorHandler.createBusinessException (IBBusinessException.FTT_FUND_TRANSFER, "2",
							new  String[] {m_sLocalAmountDisplay + "(" + m_sForeignAmountDisplay +")",
							FormatterUtils.formatMoneyDisplay ((String) m_oDailyLimitReturnMap.get (ThirdPartyTransferTags.MAX_LIMIT), null, true)});
	        }
			
			if(m_dLocalAmount > m_dMax)
			{
				throw IBErrorHandler.createBusinessException (IBBusinessException.FTT_FUND_TRANSFER, "2",
						new  String[] {m_sLocalAmountDisplay + "(" + m_sForeignAmountDisplay +")",
						FormatterUtils.formatMoneyDisplay (String.valueOf (m_dMax), null, true)});
			}

			m_sbDisplayRate.append (m_sCurrency).append ("1=").append (CurrencyCode.MALAYSIA_RINGGIT3).append (m_sCurrencyRate);

			m_oViewBean.set (FTTConstants.VBEAN_CURRENCY_RATE_DISPLAY, m_sbDisplayRate.toString ());
			m_oViewBean.set (FTTConstants.VBEAN_CONVERT_FOREIGN, m_bConvertForeign);
			m_oViewBean.set (FTTConstants.VBEAN_FOREIGN_AMOUNT, m_sForeignAmount);
			m_oViewBean.set (FTTConstants.VBEAN_FOREIGN_AMOUNT_DISPLAY, m_sForeignAmountDisplay);
			m_oViewBean.set (FTTConstants.VBEAN_LOCAL_AMOUNT, m_sLocalAmount);
			m_oViewBean.set (FTTConstants.VBEAN_LOCAL_AMOUNT_DISPLAY, m_sLocalAmountDisplay);
			m_oViewBean.set (FTTConstants.VBEAN_FOREX_RATE, m_sCurrencyRate);
			m_oViewBean.set (FTTConstants.VBEAN_CURRENCY_SERVICE_CHARGES, m_sCurrencyServiceCharges);

			//GST implementation
			String m_sCharges = "0.00";
			double m_dCharges = 0.0;
			String m_sGSTCharges = "0.00";
			String staff = getESBServices().getInquiryStaffByAcctNo(m_sFromAccount).getStatus();
			String m_sFttCountry = (String) m_oViewBean.get (FTTConstants.VBEAN_FTT_COUNTRY);
			boolean m_bIsStaff = false;
			String gstChargesWithoutRounding = "";
			
			if(ESBConstants.ACC_NONSTAFF.equalsIgnoreCase(staff))
			{
				m_sCharges = (String) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_CHARGES);
				m_bIsStaff = false;
				

				//find the ftt charges according to the certain foreign country
				if(!DataValidator.isEmptyString (m_sFttCountry) && !DataValidator.isEmptyString (m_sCurrency))
				{
					Double m_dCurrencyServiceCharges = Double.valueOf (m_sCurrencyServiceCharges);
					if( m_dCurrencyServiceCharges > 0.0)
					{
						m_dCharges = m_dCurrencyServiceCharges;
					}

				}
				
				double m_dLocalAmt = Double.parseDouble(m_sLocalAmount);
				
				IBLoadProperty.load("ibconfig");
				double m_dComThreshold = Double.parseDouble (IBLoadProperty.getValue("ftt.commision.threshold"));
				
				double m_dChargesCom = Double.parseDouble (IBLoadProperty.getValue("ftt.charges.commission"));

				if(m_dLocalAmt > m_dComThreshold)
				{
					m_dCharges = m_dCharges - m_dChargesCom;
				}
				IBGSTContent gstContent = HibernateUtils.getGstContentByChargesCode(IBLoadProperty.getValue(GSTUtils.FTT_CHARGES_CODE));
				if(gstContent!=null){
				String gstChargesRate = IBUtils.getGSTRate(this, IBLoadProperty.getValue(GSTUtils.FTT_CHARGES_CODE));
				m_sGSTCharges = GSTUtils.gstAmount2Dec(m_sCharges, gstChargesRate);
				gstChargesWithoutRounding = GSTUtils.gstCalcCharges(m_sCharges, gstChargesRate);
				}			
			}else{
				m_bIsStaff = true;
			}
			
			m_oViewBean.set (FTTConstants.VBEAN_CHARGES, m_sCharges);
			m_oViewBean.set (FTTConstants.VBEAN_CHARGES_DISPLAY, DataValidator.isEmptyString(m_sCharges)?"-":FormatterUtils.formatMoneyDisplay (m_sCharges, null, true));
			m_oViewBean.set (FTTConstants.VBEAN_GST_CHARGES, m_sGSTCharges);
			m_oViewBean.set (FTTConstants.VBEAN_GST_CHARGES_DISPLAY, DataValidator.isEmptyString(m_sGSTCharges)? "-":(m_sGSTCharges.equals("0.00")||m_sGSTCharges.equals("0.0")||m_sGSTCharges.equals("0")?"-":FormatterUtils.formatMoneyDisplay (m_sGSTCharges, null, true)));
			m_oViewBean.set (FTTConstants.VBEAN_IS_STAFF_ACCOUNT, m_bIsStaff);
			m_oViewBean.set (FTTConstants.GST_CHARGES_WITHOUT_ROUNDING, gstChargesWithoutRounding);

			//Change all fields to upper case
			m_sTransDescription = (String) getIBDynaBean ().get (FTTConstants.FBEAN_TRNX_DESC);
			otherPaymentDetails = (String) getIBDynaBean().get(FTTConstants.OTHER_PAYMENT_DETAILS);
			m_sBeneficiaryBank = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_BANK);
			m_sBeneficiaryCity = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_CITY);
			m_sSenderAdd1 = (String) getIBDynaBean ().get (FTTConstants.FBEAN_SENDER_ADDRESS1);
			m_sSenderAdd2 = (String) getIBDynaBean ().get (FTTConstants.FBEAN_SENDER_ADDRESS2);

			//IBLOgger!!, create file,
			m_oViewBean.set (FTTConstants.VBEAN_FTT_TRANS_DESCRIPTION_DISPLAY, m_sTransDescription);
			m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_BANK_DISPLAY, m_sBeneficiaryBank.toUpperCase ());
			m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_CITY_DISPLAY, m_sBeneficiaryCity.toUpperCase ());
			m_oViewBean.set (FTTConstants.VBEAN_FTT_SENDER_ADD1_DISPLAY, m_sSenderAdd1.toUpperCase ());
			m_oViewBean.set (FTTConstants.VBEAN_FTT_SENDER_ADD2_DISPLAY, m_sSenderAdd2.toUpperCase ());
			m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_NAME_DISPLAY, m_sBeneficiaryName.toUpperCase ());
			m_oViewBean.set(FTTConstants.OTHER_PAYMENT_DETAILS, otherPaymentDetails);

			//Not required field is empty, display '-'
			m_sBeneficiaryBankCode = (String) getIBDynaBean ().get (FTTConstants.FBEAN_CURR_CONDITION_NO);
			m_sBeneficiaryBranch = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_BRANCH);
			m_sBeneficiaryID = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_ID);
			m_sBeneficiaryContact = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_CONTACT);
			m_sBeneficiaryAdd1 = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_ADDRESS1);
			m_sBeneficiaryAdd2 = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_ADDRESS2);
			m_sBeneficiaryEmail = (String) getIBDynaBean ().get (FTTConstants.FBEAN_BENEFICIARY_EMAIL);

			if (m_oServiceInfoBean != null && ((Boolean)m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_FUTURE_TRANSACTION_FLAG)).booleanValue ())
			{
				IBGenericSIServices m_oGenericSIServices = new IBGenericSIServices (getIBSessionObjects ());
				m_oGenericSIServices.setIBDynaBean (getIBDynaBean ());
				m_oGenericSIServices.confirmSIInput (m_oViewBean);
			}

			if(DataValidator.isEmptyString (m_sBeneficiaryBankCode))
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_SPECIAL_CONDITION_NO_DISPLAY, "-");
			}
			else
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_SPECIAL_CONDITION_NO_DISPLAY, m_sBeneficiaryBankCode.toUpperCase ());
			}

			if(DataValidator.isEmptyString (m_sBeneficiaryBranch))
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_BRANCH_DISPLAY, "-");
			}
			else
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_BRANCH_DISPLAY, m_sBeneficiaryBranch.toUpperCase ());
			}

			if(DataValidator.isEmptyString (m_sBeneficiaryID))
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_ID_DISPLAY, "-");
			}
			else
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_ID_DISPLAY, m_sBeneficiaryID.toUpperCase ());
			}

			if(DataValidator.isEmptyString (m_sBeneficiaryContact))
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_CONTACT_DISPLAY, "-");
			}
			else
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_CONTACT_DISPLAY, m_sBeneficiaryContact);
			}

			if(DataValidator.isEmptyString (m_sBeneficiaryAdd1))
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_ADD1_DISPLAY, "-");
			}
			else
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_ADD1_DISPLAY, m_sBeneficiaryAdd1.toUpperCase ());
			}

			if(DataValidator.isEmptyString (m_sBeneficiaryAdd2))
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_ADD2_DISPLAY, "-");
			}
			else
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_ADD2_DISPLAY, m_sBeneficiaryAdd2.toUpperCase ());
			}

			if(DataValidator.isEmptyString (m_sBeneficiaryEmail))
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_EMAIL_DISPLAY, "-");
			}
			else
			{
				m_oViewBean.set (FTTConstants.VBEAN_FTT_BENE_EMAIL_DISPLAY, m_sBeneficiaryEmail);
			}
			
			// SMS Notification START
			m_oViewBean = SMSServices.setupConfirmViewBean(this, m_sForeignAmount, m_sCurrency, getIBDynaBean(), m_oViewBean, m_oServiceInfoBean);
			// SMS Notification END
		}
		catch (Exception e)
		{
			e.printStackTrace();
			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);
	}


	/**
	 * To validate the length of the special code provide by certain bank for a certain foreign country.
	 *
	 * @throws IBGenericException
	 */
//	private void verifySpecialCode() throws IBGenericException
//	{
//		String m_sMethodName = "verifySpecialCode";
//		IBTimer m_oTimer = IBLogger.logBSFNMethodEnteringMessage (c_oClass, m_sMethodName);
//
//		String m_sSpecialConditionType = null;
//		String m_sCodeMaxLength = null;
//		int m_iSpecialCodeLength = 0;
//		int m_iMaxInputLength = 0;
//
//		List m_alCountryList = null;
//		IBDynaBean m_oCountryBean = null;
//		IBDynaBean m_oViewBean = null;
//
//		try
//		{
//			m_oViewBean = (IBDynaBean) getIBDynaBean ().get (FTTConstants.FTT_VIEW_BEAN);
//
//			m_alCountryList = (List) m_oViewBean.get (FTTConstants.VBEAN_COUNTRY_LIST);
//			m_oCountryBean = (IBDynaBean) m_alCountryList.get (Integer.parseInt
//					((String) getIBDynaBean ().get (FTTConstants.FBEAN_FTT_COUNTRY_INDEX)));
//			m_sSpecialConditionType = (String) m_oCountryBean.get (FTTConstants.VBEAN_CONDITION_TYPE);
//
//			if(!DataValidator.isEmptyString (m_sSpecialConditionType) && !FTTConstants.noSpecialCondition (m_sSpecialConditionType))
//			{
//				m_iSpecialCodeLength = ((String) getIBDynaBean ().get (FTTConstants.FBEAN_CURR_CONDITION_NO)).length ();
//
//				m_sCodeMaxLength = (String) m_oViewBean.get (FTTConstants.VBEAN_CODE_MAX_LENGTH);
//				m_iMaxInputLength = Integer.parseInt (m_sCodeMaxLength);
//				if (m_iSpecialCodeLength < m_iMaxInputLength)
//				{
//					throw IBErrorHandler.createBusinessException (
//							IBBusinessException.FTT_FUND_TRANSFER, "4",
//							new String[] {m_sSpecialConditionType, m_sCodeMaxLength});
//				}
//			}
//		}
//		catch (Exception 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);
//		}
//		IBLogger.logBSFNMethodLeavingMessage (c_oClass, m_sMethodName, m_oTimer);
//
//	}

}
