Example #1
0
        public ActionResult ICS031()
        {
            ViewBag.currencyLocal = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_LOCAL);
            ViewBag.currencyUs    = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_US);

            ICS031_ScreenParameter param = GetScreenObject <ICS031_ScreenParameter>();

            return(View());
        }
        /// <summary>
        /// Get header data of screen BLS090
        /// </summary>
        /// <param name="ContractCode"></param>
        /// <returns></returns>
        public ActionResult BLS090_GetHeader(string ContractCode)
        {
            CommonUtil cm = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            List <dtBillingContract> list = new List <dtBillingContract>();

            try
            {
                BLS090_ScreenParameter param = GetScreenObject <BLS090_ScreenParameter>();

                if (CommonUtil.IsNullOrEmpty(ContractCode))
                {
                    string lblContractCode = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_BILLING, "BLS090", "lblContractCode");
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { lblContractCode }, new string[] { "ContractCode" });
                    return(Json(res));
                }

                //string strContract_long = cm.ConvertContractCode(ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                string strContract_long = cm.ConvertBillingCode(ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                IBillingHandler handlerBilling = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                list = handlerBilling.GetBillingContract(strContract_long, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US);


                if (list.Count > 0)
                {
                    var detailList = handlerBilling.GetBillingBasicForRentalList(strContract_long);


                    if (detailList.Count > 0)
                    {
                        param.DetailData = detailList;

                        // Akat K. : ContractFee get from OrderContractFee (see sp_BL_GetBillingContract)
                        var sumOfFee = detailList.Sum(m => m.MonthlyBillingAmount);
                        //list[0].ContractFeeForDisplay = CommonUtil.TextNumeric(sumOfFee, 2);
                        //list[0].ContractFee = sumOfFee;
                        param.TotalFee = sumOfFee;

                        list[0].ContractFeeForDisplay = CommonUtil.TextNumeric(list[0].ContractFee, 2);
                        list[0].TotalFee           = sumOfFee;
                        list[0].TotalFeeForDisplay = CommonUtil.TextNumeric(sumOfFee, 2);
                        list[0].details            = detailList;

                        param.OrderContractFee = list[0].ContractFee;
                        //list[0].ContractFeeCurrency = MiscellaneousTypeUtil.getCurrenctName(list[0].ContractFeeCurrency) + " " + list[0].ContractFee?.ToString("#,##0.00");
                        ViewBag.Currency = MiscellaneousTypeCommon.getCurrencyName(list[0].ContractFeeCurrencyType);

                        res.ResultData = list[0];
                    }
                    else
                    {
                        res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                        res.AddErrorMessage(MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6082,
                                            new string[] { "lblContractCode" },
                                            new string[] { "ContractCode" });
                    }
                }
                else
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6057,
                                        new string[] { "lblContractCode" },
                                        new string[] { "ContractCode" });
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
 public ActionResult BLS090_GetCurrencyDisplay(string currencyCode)
 {
     return(Json(MiscellaneousTypeCommon.getCurrencyName(currencyCode)));
 }
        //Add by Jutarat A. on 05032014
        /// <summary>
        /// Get BillingOfficeDebtSummary list
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS030_LoadGetBillingOfficeDebtSummaryToGrid(ICS030_RegisterData data)
        {
            ICS030_ScreenParameter param = GetScreenObject <ICS030_ScreenParameter>();
            ObjectResultData       res   = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
            List <doGetBillingOfficeDebtSummary> _doGetBillingOfficeDebtSummaryList = new List <doGetBillingOfficeDebtSummary>();
            List <OfficeDataDo> _doOfficeDataDo = new List <OfficeDataDo>();

            //  Add by Jirawat Jannet @ 2016-10-10
            #region Init new data model for uing new billing office debt summary table datas

            string localCurrency = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_LOCAL);
            string UsCurrency    = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_US);

            List <ICS030_DebtActualTableData> _doDebtActualTabledatas = new List <ICS030_DebtActualTableData>();

            #endregion


            try
            {
                data.intMonth = data.RawdtpMonthYear.Month;
                data.intYear  = data.RawdtpMonthYear.Year;

                _doGetBillingOfficeDebtSummaryList = iincomeHandler.GetBillingOfficeDebtSummaryList(data.intMonth, data.intYear);
                _doOfficeDataDo = CommonUtil.dsTransData.dtOfficeData;

                if (_doGetBillingOfficeDebtSummaryList != null && _doGetBillingOfficeDebtSummaryList.Count > 0)
                {
                    foreach (doGetBillingOfficeDebtSummary billingData in _doGetBillingOfficeDebtSummaryList)
                    {
                        string strDisableLinkOfficeFlag = "1";
                        for (int i = 0; i < _doOfficeDataDo.Count; i++)
                        {
                            if (billingData.BillingOfficeCode == _doOfficeDataDo[i].OfficeCode)
                            {
                                strDisableLinkOfficeFlag = "0";
                                break;
                            }
                        }

                        billingData.DisableLinkOfficeFlag = strDisableLinkOfficeFlag;
                    }

                    #region Initial new datas for this table

                    foreach (var item in _doGetBillingOfficeDebtSummaryList)
                    {
                        #region Local currency

                        // local currency line 1
                        _doDebtActualTabledatas.Add(new ICS030_DebtActualTableData()
                        {
                            BillingOffice         = item.BillingOffice,
                            BillingOfficeCode     = item.BillingOfficeCode,
                            DisableLinkOfficeFlag = item.DisableLinkOfficeFlag,
                            BillingOfficeName     = item.BillingOfficeName,
                            Currency                        = localCurrency,
                            AllUnpaidActual                 = item.UnpaidAmountString,
                            AllUnpaidTarget                 = item.TargetAmountAllString,
                            AllUnpaidCompareTotarget        = item.TargetAmountAllShow,
                            UnpaidOver2MonthActual          = item.UnpaidAmount2MonthString,
                            UnpaidOver2MonthTarget          = item.TargetAmount2MonthString,
                            UnpaidOver2MonthCompareTotarget = item.TargetAmount2MonthShow,
                            UnpaidOver6Month                = item.UnpaidAmount6MonthString,

                            UnpaidAmount       = item.UnpaidAmount,
                            UnpaidAmount2Month = item.UnpaidAmount2Month,
                            UnpaidAmount6Month = item.UnpaidAmount6Month,
                            UnpaidDetail       = item.UnpaidDetail,
                            UnpaidDetail2Month = item.UnpaidDetail2Month,
                            UnpaidDetail6Month = item.UnpaidDetail6Month,
                            TargetAmountAll    = item.TargetAmountAll,
                            TargetAmount2Month = item.TargetAmount2Month,
                            TargetDetailAll    = item.TargetDetailAll,
                            TargetDetail2Month = item.TargetDetail2Month
                        });
                        // local currency line 2
                        _doDebtActualTabledatas.Add(new ICS030_DebtActualTableData()
                        {
                            BillingOffice         = item.BillingOffice,
                            BillingOfficeCode     = item.BillingOfficeCode,
                            DisableLinkOfficeFlag = item.DisableLinkOfficeFlag,
                            BillingOfficeName     = item.BillingOfficeName,
                            Currency                        = localCurrency,
                            AllUnpaidActual                 = item.UnpaidDetailString,
                            AllUnpaidTarget                 = item.TargetDetailAllString,
                            AllUnpaidCompareTotarget        = item.TargetDetailAllShow,
                            UnpaidOver2MonthActual          = item.UnpaidDetail2MonthString,
                            UnpaidOver2MonthTarget          = item.TargetDetail2MonthString,
                            UnpaidOver2MonthCompareTotarget = item.TargetDetail2MonthShow,
                            UnpaidOver6Month                = item.UnpaidDetail6MonthString,

                            UnpaidAmount       = 0,
                            UnpaidAmount2Month = 0,
                            UnpaidAmount6Month = 0,
                            UnpaidDetail       = 0,
                            UnpaidDetail2Month = 0,
                            UnpaidDetail6Month = 0,
                            TargetAmountAll    = 0,
                            TargetAmount2Month = 0,
                            TargetDetailAll    = 0,
                            TargetDetail2Month = 0
                        });

                        #endregion

                        #region US Currency

                        // us currency line 1
                        _doDebtActualTabledatas.Add(new ICS030_DebtActualTableData()
                        {
                            BillingOffice         = item.BillingOffice,
                            BillingOfficeCode     = item.BillingOfficeCode,
                            DisableLinkOfficeFlag = item.DisableLinkOfficeFlag,
                            BillingOfficeName     = item.BillingOfficeName,
                            Currency                        = UsCurrency,
                            AllUnpaidActual                 = item.UnpaidAmountUsdString,
                            AllUnpaidTarget                 = item.TargetAmountAllUsdString,
                            AllUnpaidCompareTotarget        = item.TargetAmountAllUsdShow,
                            UnpaidOver2MonthActual          = item.UnpaidAmount2MonthUsdString,
                            UnpaidOver2MonthTarget          = item.TargetAmount2MonthUsdString,
                            UnpaidOver2MonthCompareTotarget = item.TargetAmount2MonthUsdShow,
                            UnpaidOver6Month                = item.UnpaidAmount6MonthUsdString,

                            UnpaidAmount       = item.UnpaidAmountUsd,
                            UnpaidAmount2Month = item.UnpaidAmount2MonthUsd,
                            UnpaidAmount6Month = item.UnpaidAmount6MonthUsd,
                            UnpaidDetail       = item.UnpaidDetailUsd,
                            UnpaidDetail2Month = item.UnpaidDetail2MonthUsd,
                            UnpaidDetail6Month = item.UnpaidDetail6MonthUsd,
                            TargetAmountAll    = item.TargetAmountAllUsd,
                            TargetAmount2Month = item.TargetAmount2MonthUsd,
                            TargetDetailAll    = item.TargetDetailAllUsd,
                            TargetDetail2Month = item.TargetDetail2MonthUsd,
                        });
                        // us currency line 2
                        _doDebtActualTabledatas.Add(new ICS030_DebtActualTableData()
                        {
                            BillingOffice         = item.BillingOffice,
                            BillingOfficeCode     = item.BillingOfficeCode,
                            DisableLinkOfficeFlag = item.DisableLinkOfficeFlag,
                            BillingOfficeName     = item.BillingOfficeName,
                            Currency                        = UsCurrency,
                            AllUnpaidActual                 = item.UnpaidDetailUsdString,
                            AllUnpaidTarget                 = item.TargetDetailAllUsdString,
                            AllUnpaidCompareTotarget        = item.TargetDetailAllUsdShow,
                            UnpaidOver2MonthActual          = item.UnpaidDetail2MonthUsdString,
                            UnpaidOver2MonthTarget          = item.TargetDetail2MonthUsdString,
                            UnpaidOver2MonthCompareTotarget = item.TargetDetail2MonthUsdShow,
                            UnpaidOver6Month                = item.UnpaidDetail6MonthUsdString,

                            UnpaidAmount       = 0,
                            UnpaidAmount2Month = 0,
                            UnpaidAmount6Month = 0,
                            UnpaidDetail       = 0,
                            UnpaidDetail2Month = 0,
                            UnpaidDetail6Month = 0,
                            TargetAmountAll    = 0,
                            TargetAmount2Month = 0,
                            TargetDetailAll    = 0,
                            TargetDetail2Month = 0
                        });

                        #endregion
                    }

                    #endregion
                }

                if (param != null)
                {
                    param.doGetBillingOfficeDebtSummaryList    = _doGetBillingOfficeDebtSummaryList;
                    param.doNewGetBillingOfficeDebtSummaryList = _doDebtActualTabledatas;
                    param.doOfficeDataDo = _doOfficeDataDo;
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }

            //res.ResultData = CommonUtil.ConvertToXml<doGetBillingOfficeDebtSummary>(_doGetBillingOfficeDebtSummaryList, "Income\\ICS030_DebtActualTable", CommonUtil.GRID_EMPTY_TYPE.VIEW);
            res.ResultData = CommonUtil.ConvertToXml <ICS030_DebtActualTableData>(_doDebtActualTabledatas, "Income\\ICS030_DebtActualTable", CommonUtil.GRID_EMPTY_TYPE.VIEW);
            return(Json(res));
        }
        /// <summary>
        /// Retrieve billing office dept summary information list of specific screen mode and search initial information
        /// </summary>
        /// <param name="data">Initaial criteria</param>
        /// <returns></returns>
        public ActionResult ICS030_LoadGetBillingOfficeDebtSummaryData(ICS030_RegisterData data)
        {
            ICS030_ScreenParameter param = GetScreenObject <ICS030_ScreenParameter>();
            ObjectResultData       res   = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            //  Add by Jirawat Jannet @ 2016-10-10
            #region Init new data model for uing new billing office debt summary table datas

            string localCurrency = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_LOCAL);
            string UsCurrency    = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_US);

            #endregion

            try
            {
                if (param != null)
                {
                    //Comment by Jutarat A. on 06032012
                    //data.intMonth = data.RawdtpMonthYear.Month;
                    //data.intYear = data.RawdtpMonthYear.Year;

                    //IIncomeHandler iincomeHandler = ServiceContainer.GetService<IIncomeHandler>() as IIncomeHandler;
                    //List<doGetBillingOfficeDebtSummary> _doGetBillingOfficeDebtSummaryList = iincomeHandler.GetBillingOfficeDebtSummaryList(data.intMonth, data.intYear);
                    //param.doGetBillingOfficeDebtSummaryList = _doGetBillingOfficeDebtSummaryList;
                    //param.doOfficeDataDo = CommonUtil.dsTransData.dtOfficeData;
                    //End Comment

                    //Add by Jutarat A. on 05032014
                    doTotalBillingOfficeDebt _doTotalBillingOfficeDebt = new doTotalBillingOfficeDebt();

                    // Add by Jirawat Jannet on 2016-10-10
                    doTotalBillingOfficeDebt _doTotalBillingOfficeDebtLocal = new doTotalBillingOfficeDebt();
                    doTotalBillingOfficeDebt _doTotalBillingOfficeDebtUs    = new doTotalBillingOfficeDebt();
                    if (param.doNewGetBillingOfficeDebtSummaryList != null && param.doNewGetBillingOfficeDebtSummaryList.Count > 0)
                    {
                        _doTotalBillingOfficeDebt = (from t in param.doGetBillingOfficeDebtSummaryList
                                                     group t by t.GroupTotal into g
                                                     select new doTotalBillingOfficeDebt
                        {
                            TotalUnpaidAmount = g.Sum(p => p.UnpaidAmount),
                            TotalUnpaidAmount2Month = g.Sum(p => p.UnpaidAmount2Month),
                            TotalUnpaidAmount6Month = g.Sum(p => p.UnpaidAmount6Month),
                            TotalUnpaidDetail = g.Sum(p => p.UnpaidDetail),
                            TotalUnpaidDetail2Month = g.Sum(p => p.UnpaidDetail2Month),
                            TotalUnpaidDetail6Month = g.Sum(p => p.UnpaidDetail6Month),
                            TotalTargetAmountAll = g.Sum(p => p.TargetAmountAll),
                            TotalTargetAmount2Month = g.Sum(p => p.TargetAmount2Month),
                            TotalTargetDetailAll = g.Sum(p => p.TargetDetailAll),
                            TotalTargetDetail2Month = g.Sum(p => p.TargetDetail2Month)
                        }).FirstOrDefault <doTotalBillingOfficeDebt>();

                        // add by Jirawat Jannet
                        _doTotalBillingOfficeDebtLocal = (from t in param.doNewGetBillingOfficeDebtSummaryList
                                                          where t.Currency == localCurrency
                                                          group t by t.Currency into g
                                                          select new doTotalBillingOfficeDebt
                        {
                            Currency = g.Key,
                            TotalUnpaidAmount = g.Sum(p => p.UnpaidAmount),
                            TotalUnpaidAmount2Month = g.Sum(p => p.UnpaidAmount2Month),
                            TotalUnpaidAmount6Month = g.Sum(p => p.UnpaidAmount6Month),
                            TotalUnpaidDetail = g.Sum(p => p.UnpaidDetail),
                            TotalUnpaidDetail2Month = g.Sum(p => p.UnpaidDetail2Month),
                            TotalUnpaidDetail6Month = g.Sum(p => p.UnpaidDetail6Month),
                            TotalTargetAmountAll = g.Sum(p => p.TargetAmountAll),
                            TotalTargetAmount2Month = g.Sum(p => p.TargetAmount2Month),
                            TotalTargetDetailAll = g.Sum(p => p.TargetDetailAll),
                            TotalTargetDetail2Month = g.Sum(p => p.TargetDetail2Month)
                        }).FirstOrDefault <doTotalBillingOfficeDebt>();
                        // add by Jirawat Jannet
                        _doTotalBillingOfficeDebtUs = (from t in param.doNewGetBillingOfficeDebtSummaryList
                                                       where t.Currency == UsCurrency
                                                       group t by t.Currency into g
                                                       select new doTotalBillingOfficeDebt
                        {
                            Currency = g.Key,
                            TotalUnpaidAmount = g.Sum(p => p.UnpaidAmount),
                            TotalUnpaidAmount2Month = g.Sum(p => p.UnpaidAmount2Month),
                            TotalUnpaidAmount6Month = g.Sum(p => p.UnpaidAmount6Month),
                            TotalUnpaidDetail = g.Sum(p => p.UnpaidDetail),
                            TotalUnpaidDetail2Month = g.Sum(p => p.UnpaidDetail2Month),
                            TotalUnpaidDetail6Month = g.Sum(p => p.UnpaidDetail6Month),
                            TotalTargetAmountAll = g.Sum(p => p.TargetAmountAll),
                            TotalTargetAmount2Month = g.Sum(p => p.TargetAmount2Month),
                            TotalTargetDetailAll = g.Sum(p => p.TargetDetailAll),
                            TotalTargetDetail2Month = g.Sum(p => p.TargetDetail2Month)
                        }).FirstOrDefault <doTotalBillingOfficeDebt>();
                    }

                    param.doTotalBillingOfficeDebt      = _doTotalBillingOfficeDebt;
                    param.doTotalBillingOfficeDebtLocal = _doTotalBillingOfficeDebtLocal; // add by Jirawat Jannet
                    param.doTotalBillingOfficeDebtUs    = _doTotalBillingOfficeDebtUs;    // add by Jirawat Jannet
                    //End Add
                }

                // Save RegisterData in session
                if (param != null)
                {
                    param.RegisterData = data;
                }
                // return "1" to js is every thing OK
                if (res.MessageList == null || res.MessageList.Count == 0)
                {
                    res.ResultData = param;
                }
                else
                {
                    res.ResultData = null;
                }
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
        public ActionResult ICS033()
        {
            ICS033_ScreenParameter param = GetScreenObject <ICS033_ScreenParameter>();

            if (param != null)
            {
                #region Billing detail
                ViewBag.BillingOfficeCode      = param.BillingOfficeCode;
                ViewBag.BillingOfficeName      = param.BillingOfficeName;
                ViewBag.BillingClientNameEN    = param.BillingClientNameEN;
                ViewBag.BillingClientNameLC    = param.BillingClientNameLC;
                ViewBag.BillingClientAddressEN = param.BillingClientAddressEN;
                ViewBag.BillingClientAddressLC = param.BillingClientAddressLC;
                ViewBag.BillingClientTelNo     = param.BillingClientTelNo;
                ViewBag.ContactPersonName      = param.ContactPersonName;


                ViewBag.Mode = param.Mode;

                ViewBag.BillingTargetCode = param.BillingTargetCode;
                ViewBag.InvoiceNo         = param.InvoiceNo;
                ViewBag.InvoiceOCC        = param.InvoiceOCC;
                ViewBag.BillingCode       = param.BillingCode;
                #endregion

                #region Unpaid billing detail list
                #region Get data
                IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                if (param.Mode == ICS033_ScreenCallerMode.GetByBillingTarget)
                {
                    string billingTargetCodeLongFormat = new CommonUtil().ConvertBillingTargetCode(param.BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    param.UnpaidDetailDebtSummary = incomeHandler.GetUnpaidDetailDebtSummaryByBillingTargetList(billingTargetCodeLongFormat);
                }
                else if (param.Mode == ICS033_ScreenCallerMode.GetByInvoice)
                {
                    param.UnpaidDetailDebtSummary = incomeHandler.GetUnpaidDetailDebtSummaryByInvoiceList(param.InvoiceNo, param.InvoiceOCC);
                }
                else if (param.Mode == ICS033_ScreenCallerMode.GetByBillingCode)
                {
                    param.UnpaidDetailDebtSummary = incomeHandler.GetUnpaidDetailDebtSummaryByBillingCodeList(param.BillingCode);
                }
                #endregion

                #region Display Yes/No format
                string yesDisplay           = string.Empty;
                string noDisplay            = string.Empty;
                List <doMiscTypeCode> miscs = new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_FLAG_DISPLAY,
                        ValueCode = "%"
                    }
                };

                ICommonHandler        hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> lst  = hand.GetMiscTypeCodeList(miscs);

                foreach (doMiscTypeCode l in lst)
                {
                    if (l.ValueCode == FlagDisplay.C_FLAG_DISPLAY_NO)
                    {
                        yesDisplay = l.ValueDisplay;
                    }
                    if (l.ValueCode == FlagDisplay.C_FLAG_DISPLAY_YES)
                    {
                        noDisplay = l.ValueDisplay;
                    }
                }

                foreach (doGetUnpaidDetailDebtSummary item in param.UnpaidDetailDebtSummary)
                {
                    if (item.DebtTracingRegistered == 1)
                    {
                        item.DebtTracingRegisteredGridFormat = noDisplay;
                    }
                    else
                    {
                        item.DebtTracingRegisteredGridFormat = yesDisplay;
                    }
                }
                #endregion
                #endregion

                #region Calculate total unpaid
                decimal unpaidAmount   = 0;
                decimal unpaidAmountUs = 0;
                if (param.UnpaidDetailDebtSummary != null)
                {
                    unpaidAmount   = param.UnpaidDetailDebtSummary.Sum(d => d.BillingAmount).GetValueOrDefault();
                    unpaidAmountUs = param.UnpaidDetailDebtSummary.Sum(d => d.BillingAmountUsd).GetValueOrDefault();
                }
                ViewBag.UnpaidAmountString   = unpaidAmount.ToString("N2");
                ViewBag.unpaidAmountUsString = unpaidAmountUs.ToString("N2");
                #endregion

                // add by Jirawat Jannet @ 2016-10-17
                #region Currency Type

                ViewBag.CurrencyTypeLocalName = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_LOCAL);
                ViewBag.CurrencyTypeUsName    = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_US);

                #endregion
            }
            return(View());
        }
Example #7
0
        /// <summary>
        /// validate input data confirm and register data into database
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS031_Confirm()
        {
            ICS031_ScreenParameter param        = GetScreenObject <ICS031_ScreenParameter>();
            ICS031_RegisterData    RegisterData = new ICS031_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            // reuse param that send on Register Click
            if (param != null)
            {
                RegisterData = param.RegisterData;
            }

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            ObjectResultData resByIssue   = new ObjectResultData();
            ObjectResultData resByInvoice = new ObjectResultData();

            tbt_DebtTarget doTbt_DebtTarget = new tbt_DebtTarget();

            try
            {
                // Common Check Sequence

                // System Suspend
                ICommonHandler handlerCommon  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

                if (handlerCommon.IsSystemSuspending())
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }


                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        #region tbt_DebtTarget
                        // Comment by Jirawat Jannet @ 2016-10-13
                        //for (int i = 0; i < RegisterData.Detail1.Count; i++)
                        //{
                        //    doTbt_DebtTarget = new tbt_DebtTarget();
                        //    doTbt_DebtTarget.BillingOfficeCode = RegisterData.Detail1[i].txtBillingOfficeCode;

                        //    doTbt_DebtTarget.AmountAll = (decimal?)Convert.ToDecimal(RegisterData.Detail1[i].txtAmountAll);
                        //    doTbt_DebtTarget.DetailAll = (int?)Convert.ToInt32(RegisterData.Detail1[i].txtDetailAll);
                        //    doTbt_DebtTarget.Amount2Month = (decimal?)Convert.ToDecimal(RegisterData.Detail1[i].txtAmount2Month);
                        //    doTbt_DebtTarget.Detail2Month = (int?)Convert.ToInt32(RegisterData.Detail1[i].txtDetail2Month);
                        //    if (iincomeHandler.UpdateTbt_DebtTarget(doTbt_DebtTarget) == 0)
                        //    {
                        //        throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7121, null);
                        //    }
                        //}
                        #endregion

                        // add by Jirawat jannet @ 2016-10-13
                        #region tbt_DebtTarget edit by Jirawat Jannet

                        string currencyLocal = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_LOCAL);
                        string currencyUs    = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_US);

                        foreach (var g in RegisterData.Detail1.GroupBy(m => m.txtBillingOfficeCode).Select(m => m.Key))
                        {
                            var local = RegisterData.Detail1.Where(m => m.txtBillingOfficeCode == g && m.txtCurrency == currencyLocal).First();
                            var us    = RegisterData.Detail1.Where(m => m.txtBillingOfficeCode == g && m.txtCurrency == currencyUs).First();

                            doTbt_DebtTarget = new tbt_DebtTarget();
                            doTbt_DebtTarget.BillingOfficeCode = local.txtBillingOfficeCode;

                            doTbt_DebtTarget.AmountAll    = (decimal?)Convert.ToDecimal(local.txtAmountAll);
                            doTbt_DebtTarget.DetailAll    = (int?)Convert.ToInt32(local.txtDetailAll);
                            doTbt_DebtTarget.Amount2Month = (decimal?)Convert.ToDecimal(local.txtAmount2Month);
                            doTbt_DebtTarget.Detail2Month = (int?)Convert.ToInt32(local.txtDetail2Month);

                            doTbt_DebtTarget.AmountAllUsd    = (decimal?)Convert.ToDecimal(us.txtAmountAll);
                            doTbt_DebtTarget.DetailAllUsd    = (int?)Convert.ToInt32(us.txtDetailAll);
                            doTbt_DebtTarget.Amount2MonthUsd = (decimal?)Convert.ToDecimal(us.txtAmount2Month);
                            doTbt_DebtTarget.Detail2MonthUsd = (int?)Convert.ToInt32(us.txtDetail2Month);

                            if (iincomeHandler.UpdateTbt_DebtTarget(doTbt_DebtTarget) == 0)
                            {
                                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7121, null);
                            }
                        }

                        #endregion



                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        // Fail rollback all record
                        scope.Dispose();
                        res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                        res.AddErrorMessage(ex);
                        return(Json(res));
                    }
                }


                // return "1" to js is every thing OK
                if (res.MessageList == null || res.MessageList.Count == 0)
                {
                    res.ResultData = "1";
                }
                else
                {
                    res.ResultData = "0";
                }
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
Example #8
0
        /// <summary>
        /// Retrieve dept target information list of specific screen mode and search criteria information
        /// </summary>
        /// <param name="data">Search criteria</param>
        /// <returns></returns>
        public ActionResult ICS031_SearchData(ICS031_RegisterData data)
        {
            ICS031_ScreenParameter param        = GetScreenObject <ICS031_ScreenParameter>();
            ICS031_RegisterData    RegisterData = new ICS031_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            List <doGetDebtTarget> _doGetDebtTargetList = new List <doGetDebtTarget>();

            try
            {
                // Common Check Sequence

                // System Suspend
                ICommonHandler handlerCommon  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

                if (handlerCommon.IsSystemSuspending())
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }

                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                ICS031_ScreenParameter sParam = GetScreenObject <ICS031_ScreenParameter>();

                _doGetDebtTargetList = iincomeHandler.GetDebtTarget();


                // add by Jirawat Jannet @ 2016-10-13
                #region Initial detail input datas for  bindinh to data grid

                string currencyLocal = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_LOCAL);
                string currencyUs    = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_US);

                List <ICS031_DetailData> _detailInputDatas = new List <ICS031_DetailData>();
                int no = 1;
                if (_doGetDebtTargetList != null)
                {
                    foreach (var item in _doGetDebtTargetList)
                    {
                        // local currency
                        _detailInputDatas.Add(new ICS031_DetailData()
                        {
                            No = no,
                            BillingOfficeCode            = item.BillingOfficeCode,
                            BillingOfficeName            = item.OfficeName,
                            AllUnpaidTargetAmount        = item.AmountAll,
                            AllUnpaidTargetBillingDetail = item.DetailAll,
                            UnpaidOverTargetAmount       = item.Amount2Month,
                            UnpaidOverBillingDetail      = item.Detail2Month,
                            CurrencyType     = CurrencyUtil.C_CURRENCY_LOCAL,
                            CurrencyTypeName = currencyLocal
                        });
                        // us currency
                        _detailInputDatas.Add(new ICS031_DetailData()
                        {
                            No = no,
                            BillingOfficeCode            = item.BillingOfficeCode,
                            BillingOfficeName            = item.OfficeName,
                            AllUnpaidTargetAmount        = item.AmountAllUsd,
                            AllUnpaidTargetBillingDetail = item.DetailAllUsd,
                            UnpaidOverTargetAmount       = item.Amount2MonthUsd,
                            UnpaidOverBillingDetail      = item.Detail2MonthUsd,
                            CurrencyType     = CurrencyUtil.C_CURRENCY_US,
                            CurrencyTypeName = currencyUs
                        });
                        no++;
                    }
                }

                #endregion

                param.RegisterData        = data;
                param.doGetDebtTargetList = _doGetDebtTargetList;
                param.detailInputDatas    = _detailInputDatas;

                // return "1" to js is every thing OK
                if (res.MessageList == null || res.MessageList.Count == 0)
                {
                    res.ResultData = param;
                }
                else
                {
                    res.ResultData = null;
                }

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }