Exemple #1
0
        public Account createNewBusinessAccount(string userNBR, string ctryCD, string langCD)
        {
            try
            {
                var newAcct  = new Account();
                var ctryCrcy = new CountryCurrency();
                //get Account currency
                string crcyCD = ctryCrcy.getCurrencyByCountry(ctryCD);
                if (string.IsNullOrWhiteSpace(crcyCD))
                {
                    throw new Exception();
                }

                //add the date and to avoid duplicate value of ACCT_NBR before updating
                int    dtSecond      = DateTime.Now.Second;
                int    dtMillisecond = DateTime.Now.Millisecond;
                string acctNbr       = string.Concat(ctryCD, "00000", dtSecond, dtMillisecond);

                //get Account Culture Info
                string acctCulInfo = ctryCrcy.getCultureInfoByCountryAndLanguage(ctryCD, langCD);
                if (string.IsNullOrWhiteSpace(acctCulInfo))
                {
                    throw new Exception();
                }

                newAcct.ACCT_TCD       = "2";
                newAcct.CRCY_CD        = crcyCD;
                newAcct.ACCT_SCD       = "01";
                newAcct.ACCT_NBR       = acctNbr;
                newAcct.ACCT_NAME      = "Compte Courant Affaire";
                newAcct.ACCT_BAL       = 0.0m;
                newAcct.ACCT_CLTR_INFO = acctCulInfo;
                newAcct.LGC_DEL_IND    = "0";
                newAcct.USR_NBR        = userNBR;
                newAcct.ACCT_CDT       = DateTime.Now;
                return(newAcct);
            }
            catch
            {
                return(null);
            }
        }
Exemple #2
0
        public Account createNewBusinessUserAccount(int bn, string busAgcyNbr, string userNBR, string ctryCD, string langCD)
        {
            try
            {
                var newAcct  = new Account();
                var ctryCrcy = new CountryCurrency();
                //get Account currency
                string crcyCD = ctryCrcy.getCurrencyByCountry(ctryCD);
                if (string.IsNullOrWhiteSpace(crcyCD))
                {
                    throw new Exception();
                }

                //generate client account number
                var busAgcyList = db.TBUS_AGCY.Where(x => x.BN == bn && x.BUS_AGCY_NBR == busAgcyNbr).ToList();
                if (busAgcyList.Count() == 0)
                {
                    return(null);
                }
                var busAgcy = busAgcyList[0];

                //find agency account
                var busAcct = db.TACCT.Find(busAgcy.BUS_AGCY_ACCT_ID);
                if (busAcct == null)
                {
                    return(null);
                }

                int currentLength = db.TBUS_USR.Where(x => x.BN == bn && x.BUS_AGCY_NBR == busAgcyNbr).Count();
                if (busAgcyList.Count() == 0)
                {
                    return(null);
                }

                string acctNbr = busAcct.ACCT_NBR + CommonLibrary.generateStringCode(3, currentLength);
                if (string.IsNullOrWhiteSpace(acctNbr) || acctNbr.Length != 20)
                {
                    throw new Exception();
                }

                //get Account Culture Info
                string acctCulInfo = ctryCrcy.getCultureInfoByCountryAndLanguage(ctryCD, langCD);
                if (string.IsNullOrWhiteSpace(acctCulInfo))
                {
                    throw new Exception();
                }

                newAcct.ACCT_TCD       = "2";
                newAcct.CRCY_CD        = crcyCD;
                newAcct.ACCT_SCD       = "01";
                newAcct.ACCT_NBR       = acctNbr;
                newAcct.ACCT_NAME      = "Compte Courant Affaire";
                newAcct.ACCT_BAL       = 0.0m;
                newAcct.ACCT_CLTR_INFO = acctCulInfo;
                newAcct.LGC_DEL_IND    = "0";
                newAcct.USR_NBR        = userNBR;
                newAcct.ACCT_CDT       = DateTime.Now;
                return(newAcct);
            }
            catch
            {
                return(null);
            }
        }
Exemple #3
0
        public Account createNewClientAccount(string usrNbr, string ctryCD, string crcyCD, string langCD, string clientTCD)
        {
            var newAcct      = new Account();
            var ctryCrcy     = new CountryCurrency();
            var newAcctIdent = new AccountIdentity();

            try
            {
                var acctIdent = newAcctIdent.generateLastPartAccountNumber();
                if ((clientTCD != "1" && clientTCD != "3") || acctIdent == null)
                {
                    return(null);
                }

                //get param
                string acctNbr         = null;
                string ACCT_TCD        = null;
                string ACCT_NAME       = null;
                string acctCrcyCD      = null;
                string acctCulInfo     = null;
                string lastPartAcctNbr = Convert.ToString(acctIdent.ACCT_ID);

                if (clientTCD == "1")
                {
                    ACCT_TCD = "1";
                    //currentLength = db.TACCT.Where(x => x.ACCT_TCD == ACCT_TCD && x.ACCT_NBR.StartsWith(ctryCD)).ToList().Count();
                    acctNbr   = ctryCD + "C" + lastPartAcctNbr;
                    ACCT_NAME = "Compte Courant Particulier";

                    acctCrcyCD  = ctryCrcy.getCurrencyByCountry(ctryCD);
                    acctCulInfo = ctryCrcy.getCultureInfoByCountryAndLanguage(ctryCD, langCD);
                }

                if (clientTCD == "3")
                {
                    ACCT_TCD = "3";
                    //currentLength = db.TACCT.Where(x => x.ACCT_TCD == ACCT_TCD && x.ACCT_NBR.StartsWith(ctryCD)).ToList().Count();
                    acctNbr   = ctryCD + "X" + lastPartAcctNbr;
                    ACCT_NAME = "Compte Carte Particulier";

                    acctCrcyCD  = crcyCD;
                    acctCulInfo = ctryCrcy.getCultureInfoByCurrencyCD(crcyCD, langCD);
                }

                if (string.IsNullOrWhiteSpace(acctNbr) || acctNbr.Length != 12 ||
                    string.IsNullOrWhiteSpace(acctCrcyCD) || string.IsNullOrWhiteSpace(acctCulInfo))
                {
                    throw new Exception();
                }

                newAcct.ACCT_TCD       = ACCT_TCD;
                newAcct.CRCY_CD        = acctCrcyCD;
                newAcct.ACCT_SCD       = "01";
                newAcct.ACCT_NBR       = acctNbr;
                newAcct.ACCT_NAME      = ACCT_NAME;
                newAcct.ACCT_BAL       = 0.0m;
                newAcct.ACCT_CLTR_INFO = acctCulInfo;
                newAcct.LGC_DEL_IND    = "0";
                newAcct.USR_NBR        = usrNbr;
                newAcct.ACCT_CDT       = DateTime.Now;
                return(newAcct);
            }
            catch
            {
                return(null);
            }
        }
Exemple #4
0
        public TransactionFeeViewModel getTransactionFee(int FROM_SRVC_ID, int TO_SRVC_ID,
                                                         string FROM_CTRY_CD, string TO_CTRY_CD,
                                                         string FROM_CRCY_CD, string TO_CRCY_CD,
                                                         decimal TRANS_AMT, decimal crcyXchgPercent,
                                                         string SEND_RCPT_CD, string SRVC_TCD,
                                                         string CLT_ON_CLT_BHLF_TCD)
        {
            try
            {
                var     model          = new TransactionFeeViewModel();
                var     crcyXchgRt     = new CurrencyExchangeRate();
                decimal adjustXchgRate = 0.0m;
                decimal fromXchgRt     = 1.0m;
                string  formatString   = CommonLibrary.getExchangeRateDecimalPartByCurrencyCD(FROM_CRCY_CD);

                if (FROM_CTRY_CD != TO_CTRY_CD) // DIFFRENT COUNTRIES
                {
                    decimal FROM_TRANS_AMT = 0.0M;
                    decimal TO_TRANS_AMT   = 0.0M;
                    if (FROM_CRCY_CD != TO_CRCY_CD) // DIFFRENT CURRENCIES
                    {
                        //GET the crcy exchange rate
                        decimal xchgRate = crcyXchgRt.getExchangeRateByCurrency(FROM_CRCY_CD, TO_CRCY_CD);
                        if (xchgRate == 0.0m)
                        {
                            model.ERROR_TXT = CommonLibrary.displayGenericErrorMessage();
                            return(model);
                        }

                        //GET THE ADJUSTMENT CURRENCY PERCENT RATE
                        if (crcyXchgPercent == 0.0m)
                        {
                            FROM_TRANS_AMT = TRANS_AMT;
                            if (SEND_RCPT_CD == "2")
                            {
                                FROM_TRANS_AMT = TRANS_AMT / xchgRate;
                            }

                            //this first query is to get the approximative sent amount, to get the adjustment
                            var transFeeObj = getTransactionFee(FROM_TRANS_AMT, FROM_SRVC_ID, TO_SRVC_ID,
                                                                FROM_CTRY_CD, TO_CTRY_CD, FROM_CRCY_CD, TO_CRCY_CD);
                            if (transFeeObj != null)
                            {
                                var crcyXchgPercentObj     = new CurrencyExchangePercent();
                                var getCcrcyXchgPercentObj = crcyXchgPercentObj.getCurrencyExchangePercentByID(transFeeObj.CRCY_XCHG_PRCNT_ID);
                                if (crcyXchgPercentObj != null)
                                {
                                    crcyXchgPercent = getCcrcyXchgPercentObj.IVSTR_CRCY_XCHG_PRCNT_RT;
                                }
                                else
                                {
                                    crcyXchgPercent = 0.980m;
                                }
                            }
                        }

                        //adjust the currency exchange rate
                        adjustXchgRate = xchgRate;
                        if (xchgRate == 1.0m)
                        {
                            adjustXchgRate = xchgRate;
                        }
                        else if (crcyXchgPercent != 0.0m)
                        {
                            adjustXchgRate = xchgRate * crcyXchgPercent;
                        }

                        if (SEND_RCPT_CD == "1")
                        {
                            FROM_TRANS_AMT = TRANS_AMT;
                            TO_TRANS_AMT   = TRANS_AMT * adjustXchgRate;
                        }
                        if (SEND_RCPT_CD == "2")
                        {
                            FROM_TRANS_AMT = TRANS_AMT / adjustXchgRate;
                            TO_TRANS_AMT   = TRANS_AMT;
                        }
                    }
                    else
                    {
                        adjustXchgRate = 1.0m;
                        FROM_TRANS_AMT = TRANS_AMT;
                        TO_TRANS_AMT   = TRANS_AMT;
                    }

                    model.FROM_TRANS_AMT = FROM_TRANS_AMT;
                    model.TO_TRANS_AMT   = TO_TRANS_AMT;

                    // calculate transaction fee
                    var transFeeObj1 = getTransactionFee(model.FROM_TRANS_AMT, FROM_SRVC_ID, TO_SRVC_ID,
                                                         FROM_CTRY_CD, TO_CTRY_CD, FROM_CRCY_CD, TO_CRCY_CD);
                    if (transFeeObj1 == null)
                    {
                        model.ERROR_TXT = "Il se peut que le type de transaction que vous effectuez n'est pas encore autorisé par PayKap. Contactez nous si vous croyez être une erreur.";
                        return(model);
                    }

                    if (transFeeObj1.TRANS_FEE_TCD == "1")
                    {
                        model.FEE_AMT = transFeeObj1.IVSTR_FIX_FEE_AMT;
                    }
                    else
                    {
                        model.FEE_AMT = transFeeObj1.IVSTR_PRCNT_FEE_RT * model.FROM_TRANS_AMT;
                    }

                    model.CRCY_XCHG_RT_IND = true;
                    model.CRCY_XCHG_RT_TXT = fromXchgRt.ToString("N2") + " " + FROM_CRCY_CD + " = " + adjustXchgRate.ToString(formatString) + " " + TO_CRCY_CD;
                    model.CRCY_XCHG_RT     = adjustXchgRate;
                    model.ADJUST_XCHG_RT   = crcyXchgPercent;
                }
                else // SAME COUNTRIES
                {
                    if (FROM_CRCY_CD != TO_CRCY_CD) // DIFFRENT CURRENCIES
                    {
                        model.ERROR_TXT = "Les devises des transactions intra nationales ne peuvent pas être differentes";
                        return(model);
                    }

                    //when the fromCtry and toCtry are the same contries,
                    //the fee comes from the BusinessFee class, the class name will be updating in the future
                    var     newBusFee = new BusinessFee();
                    decimal getBusFee;
                    if (FROM_CTRY_CD == TO_CTRY_CD)
                    {
                        //if it is the same country but the transaction on behalf of the client, apply fee
                        if (CLT_ON_CLT_BHLF_TCD == "1")
                        {
                            getBusFee = 0.0m;
                        }
                        else
                        {
                            //getBusFee IS 0.0 because PayKap does not apply the transFee when it is the same country online.

                            //getBusFee = newBusFee.getClientFeeAmount(TRANS_AMT, FROM_CTRY_CD, FROM_CRCY_CD, SRVC_TCD);

                            //if (getBusFee == 0.0m)
                            //{
                            //    model.ERROR_TXT = "Il se peut que le type de transaction que vous effectuez n'est pas encore autorisé par PayKap. Contactez nous si vous croyez être une erreur.";
                            //    return model;
                            //}
                            //decimal getBehalfFeeAmt = getBusFee * 1.3m;
                            //getBusFee = CommonLibrary.roundAmountToCeiling(getBehalfFeeAmt);
                            getBusFee = 0.0m;
                        }
                    }
                    else
                    {
                        getBusFee = newBusFee.getClientFeeAmount(TRANS_AMT, FROM_CTRY_CD, FROM_CRCY_CD, SRVC_TCD);

                        if (getBusFee == 0.0m)
                        {
                            model.ERROR_TXT = "Il se peut que le type de transaction que vous effectuez n'est pas encore autorisé par PayKap. Contactez nous si vous croyez être une erreur.";
                            return(model);
                        }
                    }

                    model.FEE_AMT          = getBusFee;
                    model.CRCY_XCHG_RT_IND = false;
                    model.CRCY_XCHG_RT_TXT = "";
                    model.CRCY_XCHG_RT     = 0.0M;
                    model.ADJUST_XCHG_RT   = crcyXchgPercent;
                    model.FROM_TRANS_AMT   = TRANS_AMT;
                    model.TO_TRANS_AMT     = TRANS_AMT;
                }

                if (CLT_ON_CLT_BHLF_TCD == "1")
                {
                    model.TOT_TO_PAY_AMT = model.FROM_TRANS_AMT + model.FEE_AMT;
                }
                else
                {
                    decimal getBehalfFeeAmt = model.FEE_AMT * 1.3m;
                    model.FEE_AMT        = CommonLibrary.roundAmountToCeiling(getBehalfFeeAmt);
                    model.TOT_TO_PAY_AMT = model.FROM_TRANS_AMT + model.FEE_AMT;
                }

                var    newObjCultureInfo = new CountryCurrency();
                string cultureInfo       = newObjCultureInfo.getCultureInfoByCurrencyCD(FROM_CRCY_CD, "FRA");
                string cultureInfo1      = newObjCultureInfo.getCultureInfoByCurrencyCD(TO_CRCY_CD, "FRA");
                model.FROM_TRANS_AMT_TXT = CommonLibrary.displayFormattedCurrency(model.FROM_TRANS_AMT, FROM_CRCY_CD, cultureInfo);
                model.FEE_AMT_TXT        = CommonLibrary.displayFormattedCurrency(model.FEE_AMT, FROM_CRCY_CD, cultureInfo);
                model.TOT_TO_PAY_AMT_TXT = CommonLibrary.displayFormattedCurrency(model.TOT_TO_PAY_AMT, FROM_CRCY_CD, cultureInfo);
                model.TO_TRANS_AMT_TXT   = CommonLibrary.displayFormattedCurrency(model.TO_TRANS_AMT, TO_CRCY_CD, cultureInfo1);

                model.SEND_RCPT_CD = SEND_RCPT_CD;
                model.FROM_CTRY_CD = FROM_CTRY_CD;
                model.TO_CTRY_CD   = TO_CTRY_CD;
                model.FROM_CRCY_CD = FROM_CRCY_CD;
                model.TO_CRCY_CD   = TO_CRCY_CD;
                model.FROM_SRVC_ID = FROM_SRVC_ID;
                model.TO_SRVC_ID   = TO_SRVC_ID;

                //handle the promo code
                if (model.FROM_CTRY_CD == "124") // Canada
                {
                    model.FEE_AMT_PROMO_CD = 0.0m;
                }
                if (model.FROM_CTRY_CD == "120" && model.TO_CTRY_CD == "120") // Cameroun
                {
                    model.FEE_AMT_PROMO_CD = model.FEE_AMT - 1000;
                    if (model.FEE_AMT_PROMO_CD < 0.0m)
                    {
                        model.FEE_AMT_PROMO_CD = 0.0m;
                    }
                }

                model.TOT_TO_PAY_AMT_PROMO_CD     = model.FROM_TRANS_AMT + model.FEE_AMT_PROMO_CD;
                model.FEE_AMT_TXT_PROMO_CD        = CommonLibrary.displayFormattedCurrency(model.FEE_AMT_PROMO_CD, FROM_CRCY_CD, cultureInfo);
                model.TOT_TO_PAY_AMT_TXT_PROMO_CD = CommonLibrary.displayFormattedCurrency(model.TOT_TO_PAY_AMT_PROMO_CD, FROM_CRCY_CD, cultureInfo);
                model.ERROR_TXT = "ok";
                return(model);
            }
            catch
            {
                return(null);
            }
        }