Exemple #1
0
        /// <summary>
        /// Check screen authority and permission
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult ICS101_Authority(ICS101_ScreenParameter param)
        {
            ICommonHandler handlerCommon  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

            ObjectResultData res = new ObjectResultData();

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

            // Check User Permission
            if (CheckUserPermission(ScreenID.C_SCREEN_ID_MONEY_COLLECTION_MANAGEMENT_INFO, FunctionID.C_FUNC_ID_OPERATE) == false)
            {
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                return(Json(res));
            }

            return(InitialScreenEnvironment <ICS101_ScreenParameter>("ICS101", param, res));
        }
Exemple #2
0
        public ActionResult ICS150_GetGroupName(DateTime?paymentDate, string createBy)
        {
            try
            {
                IIncomeHandler handler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                if (string.IsNullOrEmpty(createBy) && CommonUtil.dsTransData != null)
                {
                    createBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                }
                List <doGetMatchGroupNamePayment> lstGroupname = handler.getMatchGroupNameCbo(paymentDate, createBy);

                ComboBoxModel cboModel = new ComboBoxModel();
                cboModel.SetList <doGetMatchGroupNamePayment>(lstGroupname, "MatchRGroupName", "MatchRGroupName", true);
                return(Json(cboModel));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        public ActionResult ICS140()
        {
            var sparam = this.GetScreenObject <ICS140_ScreenParameter>();

            IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

            sparam.IsHQUser = false;
            if (CommonUtil.dsTransData != null && CommonUtil.dsTransData.dtUserData != null)
            {
                var permission = iincomeHandler.GetTbm_DebtTracingPermission(CommonUtil.dsTransData.dtUserData.EmpNo);
                if (permission != null && permission.Count > 0)
                {
                    sparam.IsHQUser = true;
                }
            }

            ViewBag.IsHQUser = sparam.IsHQUser;

            ViewBag.PaidButtonLabel  = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_INCOME, ScreenID.C_SCREEN_ID_DEBT_TRACING, "lblPaidButton");
            ViewBag.PaidConfirmParam = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_INCOME, ScreenID.C_SCREEN_ID_DEBT_TRACING, "PaidConfirmParam");

            return(View());
        }
Exemple #4
0
        /// <summary>
        /// Generate xml for invoice list of specific billing target code of screen session
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS082_GetInvoiceGrid()
        {
            List <doUnpaidInvoice> doUnpaidInvoice = new List <doUnpaidInvoice>();
            ObjectResultData       res             = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            try
            {
                if (ICS082_ScreenData != null && !string.IsNullOrEmpty(ICS082_ScreenData.BillingTargetCode))
                {
                    //Get Data
                    IIncomeHandler handler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                    doUnpaidInvoice = handler.GetUnpaidInvoiceByBillingTarget(ICS082_ScreenData.BillingTargetCode);
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
            res.ResultData = CommonUtil.ConvertToXml <doUnpaidInvoice>(doUnpaidInvoice, "Income\\ICS082", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
            return(Json(res));
        }
        /// <summary>
        /// Event when click register button
        /// </summary>
        /// <param name="data">screen input information</param>
        /// <returns></returns>
        public ActionResult ICS032_Register(ICS032_RegisterData data)
        {
            string conModeRadio1rdo1Invoice       = "1";
            string conModeRadio1rdo1BillingTarget = "2";

            ICS032_ScreenParameter param        = GetScreenObject <ICS032_ScreenParameter>();
            ICS032_RegisterData    RegisterData = new ICS032_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            ValidatorUtil validator = new ValidatorUtil();

            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);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }

                // Check User Permission

                //if (!CheckUserPermission(ScreenID.C_SCREEN_ID_REGISTER_CREDIT_NOTE, FunctionID.C_FUNC_ID_DEL))
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                //    return Json(res);
                //}

                // null value = select ALL

                if (data.Header.cboTracingResault == null)
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                              "ICS032",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "cboTracingResault", "lblTracingResault", "cboTracingResault");

                    //return Json(res);
                }

                if (String.IsNullOrEmpty(data.Header.dtpLastContractDate.ToString()))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                              "ICS032",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "dtpLastContractDate", "lblLastContractDate", "dtpLastContractDate");

                    //return Json(res);
                }

                //if (String.IsNullOrEmpty(data.Header.dtpExpectedPaymentdate.ToString()))
                //{
                //    validator.AddErrorMessage(MessageUtil.MODULE_INCOME,
                //                         "ICS032",
                //                         MessageUtil.MODULE_COMMON,
                //                         MessageUtil.MessageList.MSG0007,
                //                         "dtpExpectedPaymentdate", "lblExpectedPaymentdate", "dtpExpectedPaymentdate");

                //    //return Json(res);
                //}

                //if (data.Header.cboPaymentMethods == null)
                //{
                //    validator.AddErrorMessage(MessageUtil.MODULE_INCOME,
                //                         "ICS032",
                //                         MessageUtil.MODULE_COMMON,
                //                         MessageUtil.MessageList.MSG0007,
                //                         "cboPaymentMethods", "lblPaymentMethods", "cboPaymentMethods");

                //    //return Json(res);
                //}
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                if (res.IsError)
                {
                    return(Json(res));
                }

                // 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 = "1";
                }
                else
                {
                    res.ResultData = "0";
                }

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

            return(Json(res));
        }
        /// <summary>
        /// Retrieve debt tracing memo history list
        /// </summary>
        /// <param name="data">Search criteria</param>
        /// <returns></returns>
        public ActionResult ICS032_SearchMEMO(ICS032_RegisterData data)
        {
            ICS032_ScreenParameter param        = GetScreenObject <ICS032_ScreenParameter>();
            ICS032_RegisterData    RegisterData = new ICS032_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            string strMemoBillingTargetCode = string.Empty;
            string strMemoInvoiceNo         = string.Empty;
            int    intMemo = 0;

            try
            {
                // Common Check Sequence

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

                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

                // load GetDebtTracingMemo
                if (param.doBillingTargetDebtSummaryList != null)
                {
                    if (param.doBillingTargetDebtSummaryList.Count != 0)
                    {
                        strMemoBillingTargetCode = param.doBillingTargetDebtSummaryList[0].BillingTargetCode;
                    }
                }

                if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList != null)
                {
                    if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList.Count != 0)
                    {
                        strMemoInvoiceNo = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceNo;
                        intMemo          = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceOCC;
                    }
                }


                param.doGetDebtTracingMemoList = iincomeHandler.GetDebtTracingMemoList(
                    strMemoBillingTargetCode,
                    strMemoInvoiceNo,
                    intMemo);

                // 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));
        }
        /// <summary>
        /// Retrieve unpaid details debt summary information list of specific screen mode and search criteria information
        /// </summary>
        /// <param name="data">Search criteria</param>
        /// <returns></returns>
        public ActionResult ICS032_SearchData(ICS032_RegisterData data)
        {
            ICS032_ScreenParameter param        = GetScreenObject <ICS032_ScreenParameter>();
            ICS032_RegisterData    RegisterData = new ICS032_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            string strMemoBillingTargetCode = string.Empty;
            string strMemoInvoiceNo         = string.Empty;
            int    intMemo = 0;

            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));
                }

                // Check User Permission

                //if (!CheckUserPermission(ScreenID.C_SCREEN_ID_MONEY_COLLECTION_MANAGEMENT_INFO, FunctionID.C_FUNC_ID_OPERATE) )
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                //    return Json(res);
                //}


                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

                //Add by budd, support multi-language
                IOfficeMasterHandler masterHandler = ServiceContainer.GetService <IOfficeMasterHandler>() as IOfficeMasterHandler;
                List <tbm_Office>    doTbm_Office  = masterHandler.GetTbm_Office(param.strBillingOfficeCode);

                if (doTbm_Office != null && doTbm_Office.Count > 0)
                {
                    CommonUtil.MappingObjectLanguage <tbm_Office>(doTbm_Office);
                    param.strBillingOfficeName = doTbm_Office[0].OfficeName;
                }



                // load GetBillingCodeDeptSummary
                if (param.doGetUnpaidDetailDebtSummaryByBillingCodeList != null)
                {
                    if (param.doGetUnpaidDetailDebtSummaryByBillingCodeList.Count != 0)
                    {
                        param.doGetBillingCodeDebtSummaryList = iincomeHandler.GetBillingCodeDebtSummaryList(
                            param.doGetUnpaidDetailDebtSummaryByBillingCodeList[0].BillingCode);
                    }
                }
                // load GetDebtTracingMemo
                if (param.doBillingTargetDebtSummaryList != null)
                {
                    if (param.doBillingTargetDebtSummaryList.Count != 0)
                    {
                        strMemoBillingTargetCode = param.doBillingTargetDebtSummaryList[0].BillingTargetCode;
                    }
                }

                if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList != null)
                {
                    if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList.Count != 0)
                    {
                        strMemoInvoiceNo = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceNo;
                        intMemo          = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceOCC;
                    }
                }


                param.doGetDebtTracingMemoList = iincomeHandler.GetDebtTracingMemoList(
                    strMemoBillingTargetCode,
                    strMemoInvoiceNo,
                    intMemo);

                // 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));
        }
Exemple #8
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));
        }
        //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));
        }
Exemple #10
0
 public IncomeController(ILogger <IncomeController> logger, IIncomeHandler incomeHandler) : base(logger) => _incomeHandler = incomeHandler;
Exemple #11
0
        /// <summary>
        /// Retrieve money collection management info information list of specific screen mode and search criteria information
        /// </summary>
        /// <param name="data">Search criteria</param>
        /// <returns></returns>
        public ActionResult ICS101_SearchData(ICS101_RegisterData data)
        {
            ICS101_ScreenParameter param        = GetScreenObject <ICS101_ScreenParameter>();
            ICS101_RegisterData    RegisterData = new ICS101_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            List <doGetMoneyCollectionManagementInfo> _doGetMoneyCollectionManagementInfoList = new List <doGetMoneyCollectionManagementInfo>();

            try
            {
                // Common Check Sequence

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

                bool bolInput1 = false;
                bool bolInput2 = false;
                bool bolInput3 = false;

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

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

                if (data == null)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                        "ICS101",
                                        MessageUtil.MODULE_COMMON,
                                        MessageUtil.MessageList.MSG0006);

                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }
                if (data.Header == null)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                        "ICS101",
                                        MessageUtil.MODULE_COMMON,
                                        MessageUtil.MessageList.MSG0006);

                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                if (data.Header.dtpExpectedCollectDateFrom == Convert.ToDateTime("01-01-0001"))
                {
                    bolInput1 = true;
                    data.Header.dtpExpectedCollectDateFrom = null;
                }
                if (data.Header.dtpExpectedCollectDateFrom == null)
                {
                    bolInput1 = true;
                }
                if (data.Header.dtpExpectedCollectDateTo == Convert.ToDateTime("01-01-0001"))
                {
                    bolInput2 = true;
                    data.Header.dtpExpectedCollectDateTo = null;
                }
                if (data.Header.dtpExpectedCollectDateTo == null)
                {
                    bolInput2 = true;
                }

                string strDummyCollectionArea = string.Empty;

                if (data.Header.chklCollectionArea != null)
                {
                    strDummyCollectionArea = ",";
                    foreach (string _string in data.Header.chklCollectionArea)
                    {
                        strDummyCollectionArea = strDummyCollectionArea + _string + ",";
                    }
                }
                else
                {
                    bolInput3 = true;
                }

                if (bolInput1 && bolInput2 && bolInput3)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                        "ICS101",
                                        MessageUtil.MODULE_COMMON,
                                        MessageUtil.MessageList.MSG0006);

                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                _doGetMoneyCollectionManagementInfoList =
                    iincomeHandler.GetMoneyCollectionManagementInfoList(data.Header.dtpExpectedCollectDateFrom
                                                                        , data.Header.dtpExpectedCollectDateTo
                                                                        , strDummyCollectionArea);

                //if (_doGetMoneyCollectionManagementInfoList != null)
                //{
                //    if (_doGetMoneyCollectionManagementInfoList.Count > CommonValue.MAX_GRID_ROWS)
                //    {
                //        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0052
                //            , new string[] { CommonValue.MAX_GRID_ROWS.ToString("#,##0") });

                //        return Json(res);
                //    }
                //}
                param.RegisterData = data;
                param.doGetMoneyCollectionManagementInfo = _doGetMoneyCollectionManagementInfoList;

                // return "1" to js is every thing OK
                if (res.MessageList == null || res.MessageList.Count == 0)
                {
                    List <ICS101_doGetMoneyCollectionManagementInfo> lst = CommonUtil.ClonsObjectList <doGetMoneyCollectionManagementInfo, ICS101_doGetMoneyCollectionManagementInfo>(_doGetMoneyCollectionManagementInfoList);
                    //res.ResultData = param;
                    res.ResultData = CommonUtil.ConvertToXml <ICS101_doGetMoneyCollectionManagementInfo>(
                        lst,
                        "Income\\ICS101_MoneyCollectionManagementInformation",
                        CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                }
                else
                {
                    res.ResultData = null;
                }

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

            return(Json(res));
        }
Exemple #12
0
        /// <summary>
        /// Retrieve receipt information of specific screen mode and search criteria information
        /// </summary>
        /// <param name="data">Search criteria</param>
        /// <returns></returns>
        public ActionResult ICS100_RetrieveData(ICS100_RegisterData data)
        {
            ICS100_ScreenParameter param        = GetScreenObject <ICS100_ScreenParameter>();
            ICS100_RegisterData    RegisterData = new ICS100_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            ValidatorUtil validator = new ValidatorUtil();

            try
            {
                IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                doReceipt _doReceipt = new doReceipt();
                List <tbt_MoneyCollectionInfo> _dotbt_MoneyCollectionInfoList = new List <tbt_MoneyCollectionInfo>();

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

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

                if (data == null)
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                              "ICS100",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "txtReceiptNo", "lblReceiptNo", "txtReceiptNo");
                }
                if (data.Header == null)
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                              "ICS100",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "txtReceiptNo", "lblReceiptNo", "txtReceiptNo");
                }

                /////////////////////////////////////////////////////////////////////
                if (String.IsNullOrEmpty(data.Header.txtReceiptNo))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                              "ICS100",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "txtReceiptNo", "lblReceiptNo", "txtReceiptNo");
                }

                ValidatorUtil.BuildErrorMessage(res, validator, null);
                if (res.IsError)
                {
                    return(Json(res));
                }
                //--------------------------------------------------------------

                param._dotbt_MoneyCollectionInfo = null;
                param.doReceipt = null;

                _doReceipt = incomeHandler.GetReceipt(data.Header.txtReceiptNo);
                if (_doReceipt == null)
                {
                    //MSG7003
                    res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                        "ICS100",
                                        MessageUtil.MODULE_INCOME,
                                        MessageUtil.MessageList.MSG7003,
                                        new string[] { "lblReceiptNo" },
                                        new string[] { "txtReceiptNo" });
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }
                else
                {
                    if (_doReceipt.AdvanceReceiptStatus != AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_ISSUED)
                    {
                        //MSG7028
                        res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                            "ICS100",
                                            MessageUtil.MODULE_INCOME,
                                            MessageUtil.MessageList.MSG7028,
                                            new string[] { data.Header.txtReceiptNo },
                                            new string[] { "txtReceiptNo" });
                        return(Json(res));
                    }
                    _dotbt_MoneyCollectionInfoList = incomeHandler.GetTbt_MoneyCollectionInfo(data.Header.txtReceiptNo);
                }
                if (_dotbt_MoneyCollectionInfoList != null)
                {
                    if (_dotbt_MoneyCollectionInfoList.Count > 0)
                    {
                        param._dotbt_MoneyCollectionInfo = _dotbt_MoneyCollectionInfoList[0];
                    }
                }

                param.doReceipt = _doReceipt;

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

            return(Json(res));
        }
Exemple #13
0
        /// <summary>
        /// validate input data confirm and register data into database
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS100_Confirm()
        {
            ICS100_ScreenParameter param        = GetScreenObject <ICS100_ScreenParameter>();
            ICS100_RegisterData    RegisterData = new ICS100_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();

            try
            {
                // Common Check Sequence

                // System Suspend
                ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                IIncomeHandler incomeHandler = 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_MoneyCollectionInfo
                        for (int i = 0; i < RegisterData.Detail1.Count; i++)
                        {
                            decimal?ra             = (decimal?)Convert.ToDecimal(RegisterData.Detail1[i].txtReceiptAmount);
                            string  raCurrencyType = RegisterData.Detail1[i].txtReceiptAmountCurrencyType;
                            tbt_MoneyCollectionInfo _dotbt_MoneyCollectionInfo = new tbt_MoneyCollectionInfo()
                            {
                                ReceiptNo           = RegisterData.Detail1[i].txtReceiptNo,
                                ReceiptDate         = RegisterData.Detail1[i].dtpReceiptDate,
                                BillingTargetCode   = RegisterData.Detail1[i].txtBillingTargetCode,
                                CollectionArea      = RegisterData.Detail1[i].txtCollectionArea,
                                ExpectedCollectDate = (DateTime)RegisterData.Detail1[i].dtpExpectedCollectDate,
                                Memo = RegisterData.Detail1[i].txtMemo,

                                // add by jirawat jannet on 2016-10-28
                                ReceiptAmount             = raCurrencyType == CurrencyUtil.C_CURRENCY_LOCAL ? ra : null,
                                ReceiptAmountCurrencyType = RegisterData.Detail1[i].txtReceiptAmountCurrencyType,
                                ReceiptAmountUsd          = raCurrencyType == CurrencyUtil.C_CURRENCY_US ? ra : null
                            };
                            // Comment by Jirawat Jannet on 2016-10-28
                            //_dotbt_MoneyCollectionInfo.ReceiptNo = RegisterData.Detail1[i].txtReceiptNo;
                            //_dotbt_MoneyCollectionInfo.ReceiptDate = RegisterData.Detail1[i].dtpReceiptDate;
                            //_dotbt_MoneyCollectionInfo.BillingTargetCode = RegisterData.Detail1[i].txtBillingTargetCode;
                            //_dotbt_MoneyCollectionInfo.ReceiptAmount = (decimal?)Convert.ToDecimal(RegisterData.Detail1[i].txtReceiptAmount);
                            //_dotbt_MoneyCollectionInfo.CollectionArea = RegisterData.Detail1[i].txtCollectionArea;
                            //_dotbt_MoneyCollectionInfo.ExpectedCollectDate = (DateTime)RegisterData.Detail1[i].dtpExpectedCollectDate;
                            //_dotbt_MoneyCollectionInfo.Memo = RegisterData.Detail1[i].txtMemo;

                            if (incomeHandler.CreateTbt_MoneyCollectionInfo(_dotbt_MoneyCollectionInfo) == 0)
                            {
                                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7122, null);
                            }
                        }
                        #endregion

                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        // Fail rollback all
                        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));
        }
        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());
        }
        /// <summary>
        /// validate input data confirm and register data into database
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS032_Confirm()
        {
            string conModeRadio1rdo1Invoice       = "1";
            string conModeRadio1rdo1BillingTarget = "2";

            ICS032_ScreenParameter param        = GetScreenObject <ICS032_ScreenParameter>();
            ICS032_RegisterData    RegisterData = new ICS032_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;

            try
            {
                // Common Check Sequence

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

                tbt_InvoiceDebtTracing       _dotbt_InvoiceDebtTracing       = new tbt_InvoiceDebtTracing();
                tbt_BillingTargetDebtTracing _dotbt_BillingTargetDebtTracing = new tbt_BillingTargetDebtTracing();

                //Already checked at ICS032_Register()
                //if (handlerCommon.IsSystemSuspending())
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                //    return Json(res);
                //}

                // Check User Permission

                //if (!CheckUserPermission(ScreenID.C_SCREEN_ID_REGISTER_CREDIT_NOTE, FunctionID.C_FUNC_ID_DEL) )
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                //    return Json(res);
                //}

                string strBillingTargetCode = string.Empty;
                string strInvoiceNo         = string.Empty;
                int    intInvoiceOCC        = 0;

                if (param.doBillingTargetDebtSummaryList != null)
                {
                    if (param.doBillingTargetDebtSummaryList.Count != 0)
                    {
                        strBillingTargetCode = param.doBillingTargetDebtSummaryList[0].BillingTargetCode;
                    }
                }

                if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList != null)
                {
                    if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList.Count != 0)
                    {
                        strInvoiceNo  = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceNo;
                        intInvoiceOCC = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceOCC;
                    }
                }

                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        if (strInvoiceNo != string.Empty)
                        {
                            if (param.RegisterData.Header.rdoProcessType == conModeRadio1rdo1Invoice)
                            {
                                #region Tbt_InvoiceDebtTracing
                                _dotbt_InvoiceDebtTracing                   = new tbt_InvoiceDebtTracing();
                                _dotbt_InvoiceDebtTracing.InvoiceNo         = strInvoiceNo;
                                _dotbt_InvoiceDebtTracing.InvoiceOCC        = intInvoiceOCC;
                                _dotbt_InvoiceDebtTracing.TracingResult     = param.RegisterData.Header.cboTracingResault;
                                _dotbt_InvoiceDebtTracing.LastContactDate   = param.RegisterData.Header.dtpLastContractDate;
                                _dotbt_InvoiceDebtTracing.ExpectPaymentDate = param.RegisterData.Header.dtpExpectedPaymentdate;
                                _dotbt_InvoiceDebtTracing.PaymentMethod     = param.RegisterData.Header.cboPaymentMethods;
                                _dotbt_InvoiceDebtTracing.Memo              = param.RegisterData.Header.txtaMemo;

                                if (iincomeHandler.InsertTbt_InvoiceDebtTracing(_dotbt_InvoiceDebtTracing) <= 0)
                                {
                                    //res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                    //             "ICS032",
                                    //             MessageUtil.MODULE_INCOME,
                                    //             MessageUtil.MessageList.MSG7006,
                                    //             new string[] { },
                                    //             new string[] { });
                                    //return Json(res);

                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7006, null);
                                }
                                #endregion
                            }
                        }
                        if (strBillingTargetCode != string.Empty)
                        {
                            if (param.RegisterData.Header.rdoProcessType == conModeRadio1rdo1BillingTarget)
                            {
                                #region Tbt_BillingTargetDebtTracing
                                _dotbt_BillingTargetDebtTracing = new tbt_BillingTargetDebtTracing();
                                _dotbt_BillingTargetDebtTracing.BillingTargetCode = strBillingTargetCode;
                                _dotbt_BillingTargetDebtTracing.TracingResult     = param.RegisterData.Header.cboTracingResault;
                                _dotbt_BillingTargetDebtTracing.LastContactDate   = param.RegisterData.Header.dtpLastContractDate;
                                _dotbt_BillingTargetDebtTracing.ExpectPaymentDate = param.RegisterData.Header.dtpExpectedPaymentdate;
                                _dotbt_BillingTargetDebtTracing.PaymentMethod     = param.RegisterData.Header.cboPaymentMethods;
                                _dotbt_BillingTargetDebtTracing.Memo = param.RegisterData.Header.txtaMemo;

                                if (iincomeHandler.InsertTbt_BillingTargetDebtTracing(_dotbt_BillingTargetDebtTracing) <= 0)
                                {
                                    //res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                    //             "ICS032",
                                    //             MessageUtil.MODULE_INCOME,
                                    //             MessageUtil.MessageList.MSG7006,
                                    //             new string[] { },
                                    //             new string[] { });
                                    //return Json(res);
                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7006, 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 = null;
                }

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
Exemple #16
0
        //IncomeHandler-BatchGenAdvanceReceipt
        /// <summary>
        /// Batch Process to generate advance receipt pdf report on shared report folder
        /// </summary>
        /// <param name="UserId">employee no.</param>
        /// <param name="BatchDate">process datetime</param>
        /// <returns></returns>
        public doBatchProcessResult ICP011_BatchGenAdvanceReceiptProcess(string UserId, DateTime BatchDate)
        {
            #region Prepare
            //Handler
            IBillingHandler         billingHandler         = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
            IBillingDocumentHandler billingDocumentHandler = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler;
            IIncomeHandler          incomeHandler          = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
            IIncomeDocumentHandler  incomeDocumentHandler  = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;

            //Get data
            List <doInvoiceAdvanceReceipt> invoiceAdvanceReceipts = this.GetInvoiceAdvanceReceipt();

            //Result
            doBatchProcessResult result = new doBatchProcessResult();
            result.Result       = FlagType.C_FLAG_ON;
            result.BatchStatus  = null;
            result.Total        = invoiceAdvanceReceipts.Count;
            result.Failed       = 0;
            result.Complete     = 0;
            result.ErrorMessage = string.Empty;
            result.BatchUser    = UserId;
            #endregion

            if (invoiceAdvanceReceipts.Count > 0)
            {
                foreach (doInvoiceAdvanceReceipt doAdvanceReceipt in invoiceAdvanceReceipts)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            doInvoice   doInvoice = CommonUtil.CloneObject <doInvoiceAdvanceReceipt, doInvoice>(doAdvanceReceipt);
                            tbt_Receipt doReceipt = incomeHandler.IssueAdvanceReceipt(doInvoice, doInvoice.IssueInvDate.Value
                                                                                      , ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_ADVANCE, BatchDate);
                            if (doReceipt != null)
                            {
                                //ICR010 Receipt report
                                incomeDocumentHandler.GenerateICR010FilePath(doReceipt.ReceiptNo
                                                                             , ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_ADVANCE
                                                                             , BatchDate);
                            }
                            else
                            {
                                throw new Exception("Error issue receipt");
                            }

                            //Success
                            scope.Complete();
                            result.Complete++;
                        }
                        catch (Exception ex)
                        {
                            scope.Dispose();
                            result.Failed++;
                            result.ErrorMessage += string.Format("Invoice no. {0} has Error : {1} {2}\n", doAdvanceReceipt.InvoiceNo, ex.Message, ex.InnerException != null ? ex.InnerException.Message : string.Empty);
                        }
                    }
                }
                //Update batch result,     at lease one transaction fail => batch fail
                result.Result = (result.Failed == 0);
            }
            return(result);
        }
Exemple #17
0
        /// <summary>
        /// Event when click confirm cancel button, this function will cancel the issued receipt information of specific receipt no. to the system.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult ICS060_cmdConfirmCancel(ICS060_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            doReceipt doReceipt;

            try
            {
                if (IsSuspend(res))
                {
                    return(Json(res));
                }

                if (!ICS060_IsAllowOperate(res))
                {
                    return(Json(res));
                }


                //Validate receipt business
                doReceipt = ICS060_ValidateReceiptBusiness(param, res);
                if (res.IsError || doReceipt == null)
                {
                    return(Json(res));
                }


                //Connect db
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        //Cancel receipt
                        IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

                        bool isSuccess = incomeHandler.CancelReceipt(doReceipt);
                        if (!isSuccess)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7031, null);
                        }

                        IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                        //Get Invoice
                        doInvoice doInvoice = billingHandler.GetInvoice(doReceipt.InvoiceNo);
                        if (doInvoice == null)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7031, null);
                        }

                        //string invoiceType = billingHandler.GetInvoiceType(doInvoice.BillingTypeCode);
                        //if ((invoiceType == InvoiceType.C_INVOICE_TYPE_DEPOSIT || invoiceType == InvoiceType.C_INVOICE_TYPE_SERVICE)
                        //    && (doInvoice.IssueReceiptTiming != IssueRecieptTime.C_ISSUE_REC_TIME_SAME_INV
                        //        || (doInvoice.IssueReceiptTiming == IssueRecieptTime.C_ISSUE_REC_TIME_SAME_INV
                        //             && doInvoice.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_MESSENGER_TRANSFER)))
                        bool isIssuedTaxInvoice = billingHandler.CheckInvoiceIssuedTaxInvoice(doReceipt.InvoiceNo, doReceipt.InvoiceOCC);
                        if (isIssuedTaxInvoice == true)
                        {
                            if (param.CancelMethod == CancelReceiptTarget.C_CANCEL_TAX_INVOICE_RECEIPT)
                            {
                                //Cancel tax invoice (Update cancel flag only)
                                isSuccess = billingHandler.CancelTaxInvoice(doReceipt.TaxInvoiceNo);
                                if (!isSuccess)
                                {
                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null);
                                }
                            }
                            else
                            {
                                //Clear receipt no.
                                isSuccess = billingHandler.UpdateReceiptNo(doReceipt.InvoiceNo, doReceipt.InvoiceOCC, null);
                                if (!isSuccess)
                                {
                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null);
                                }
                            }
                        }


                        //Clear receipt no, invoice no of deposit fee
                        if (doInvoice.BillingTypeCode == BillingType.C_BILLING_TYPE_DEPOSIT &&
                            (doReceipt.AdvanceReceiptStatus == AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_NOT ||
                             doReceipt.AdvanceReceiptStatus == AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_PAID))
                        {
                            isSuccess = billingHandler.UpdateReceiptNoDepositFeeCancelReceipt(doInvoice.InvoiceNo, doReceipt.ReceiptNo
                                                                                              , CommonUtil.dsTransData.dtUserData.EmpNo
                                                                                              , CommonUtil.dsTransData.dtOperationData.ProcessDateTime);

                            if (!isSuccess)
                            {
                                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null);
                            }
                        }


                        //Show attention in case of paid receipt
                        if (doReceipt.AdvanceReceiptStatus == SECOM_AJIS.Common.Util.ConstantValue.AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_NOT ||
                            doReceipt.AdvanceReceiptStatus == SECOM_AJIS.Common.Util.ConstantValue.AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_PAID)
                        {
                            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION_OK;
                            res.AddErrorMessage(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7030);
                        }

                        //Success
                        scope.Complete();
                        res.ResultData = "1";
                    }
                    catch (Exception ex)
                    {
                        scope.Dispose();
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
Exemple #18
0
        //IncomeHandler-BatchGenReceiptAfterPayment
        /// <summary>
        /// Batch Process to generate tax invoice pdf report, receipt pdf report after payment on shared report folder
        /// </summary>
        /// <param name="UserId">employee no.</param>
        /// <param name="BatchDate">process datetime</param>
        /// <returns></returns>
        public doBatchProcessResult ICP010_BatchGenReceiptAfterPaymentProcess(string UserId, DateTime BatchDate)
        {
            #region Prepare
            //Handler
            IBillingHandler         billingHandler         = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
            IBillingDocumentHandler billingDocumentHandler = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler;
            IIncomeHandler          incomeHandler          = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
            IIncomeDocumentHandler  incomeDocumentHandler  = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;

            //Get data
            List <doPaidInvoiceNoReceipt> paidInvoices = this.GetPaidInvoiceNoReceipt();

            //Initial batch result
            doBatchProcessResult result = new doBatchProcessResult();
            result.Result       = FlagType.C_FLAG_ON;
            result.BatchStatus  = null;
            result.Total        = paidInvoices.Count;
            result.Failed       = 0;
            result.Complete     = 0;
            result.ErrorMessage = string.Empty;
            result.BatchUser    = UserId;
            #endregion

            if (paidInvoices.Count > 0)
            {
                foreach (doPaidInvoiceNoReceipt doPaidInvoice in paidInvoices)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            doInvoice doInvoice = billingHandler.GetInvoice(doPaidInvoice.InvoiceNo);

                            if (doPaidInvoice.BillingTypeGroup != BillingTypeGroup.C_BILLING_TYPE_GROUP_SALE &&
                                (doPaidInvoice.IssueReceiptTiming == IssueRecieptTime.C_ISSUE_REC_TIME_NOT_ISSUE ||
                                 doPaidInvoice.IssueReceiptTiming == IssueRecieptTime.C_ISSUE_REC_TIME_AFTER_PAYMENT)
                                )
                            {
                                #region Issue tax invoice

                                tbt_TaxInvoice doCheckTaxInvoice = billingHandler.GetTaxInvoiceData(doInvoice.InvoiceNo, doInvoice.InvoiceOCC); //Add by Jutarat A. on 04072013

                                if (doCheckTaxInvoice != null)                                                                                  //Add by Jutarat A. on 14112013
                                {
                                    //Add by Jutarat A. on 17102013
                                    List <tbt_TaxInvoice> doCheckTaxInvoiceList = new List <tbt_TaxInvoice>();
                                    doCheckTaxInvoiceList.Add(doCheckTaxInvoice);

                                    doCheckTaxInvoiceList = (from t in doCheckTaxInvoiceList
                                                             where t.TaxInvoiceCanceledFlag == false
                                                             select t).ToList <tbt_TaxInvoice>();

                                    if (doCheckTaxInvoiceList != null && doCheckTaxInvoiceList.Count > 0)
                                    {
                                        doCheckTaxInvoice = CommonUtil.CloneObject <tbt_TaxInvoice, tbt_TaxInvoice>(doCheckTaxInvoiceList[0]);
                                    }
                                    else
                                    {
                                        doCheckTaxInvoice = null;
                                    }
                                    //End Add
                                }

                                if (doCheckTaxInvoice == null) //Add by Jutarat A. on 04072013 (Check not exist TaxInvoice)
                                {
                                    tbt_TaxInvoice doTaxInvoice = billingHandler.IssueTaxInvoice(
                                        doInvoice,
                                        doPaidInvoice.PaymentDate,
                                        ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT,
                                        BatchDate);
                                    if (doTaxInvoice != null)
                                    {
                                        // Comment by Jirawat Jannet
                                        //BLR020 TaxInvoice report
                                        //billingDocumentHandler.GenerateBLR020FilePath(
                                        //    doTaxInvoice.TaxInvoiceNo
                                        //    , ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT
                                        //    , BatchDate);
                                        throw new Exception("กำลังดำเนินการแก้ไข report BLR020");
                                    }
                                    else
                                    {
                                        throw new Exception("Error generate tax invoice");
                                    }
                                }

                                #endregion

                                #region Issue receipt
                                tbt_Receipt doReceipt = incomeHandler.IssueReceipt(doInvoice, doPaidInvoice.PaymentDate, ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT, BatchDate, false); //Add (isWriteTransLog) by Jutarat A. on 07062013
                                if (doReceipt != null)
                                {
                                    //ICR010 Receipt report
                                    incomeDocumentHandler.GenerateICR010FilePath(doReceipt.ReceiptNo
                                                                                 , ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT
                                                                                 , BatchDate);

                                    if (doInvoice.BillingTypeCode == BillingType.C_BILLING_TYPE_DEPOSIT)
                                    {
                                        bool isSuccess = billingHandler.UpdateReceiptNoDepositFee(doPaidInvoice.InvoiceNo, doReceipt.ReceiptNo, ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT, BatchDate);
                                        if (!isSuccess)
                                        {
                                            throw new Exception("Error update receipt no to deposit table");
                                        }
                                    }
                                }
                                else
                                {
                                    throw new Exception("Error generate receipt");
                                }
                                #endregion
                            }
                            else
                            {
                                #region Issued receipt only

                                DateTime receiptDate = doPaidInvoice.PaymentDate;

                                if (doPaidInvoice.BillingTypeGroup != BillingTypeGroup.C_BILLING_TYPE_GROUP_SALE &&
                                    doPaidInvoice.IssueReceiptTiming == IssueRecieptTime.C_ISSUE_REC_TIME_SAME_INV &&
                                    (doPaidInvoice.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_BANK_TRANSFER ||
                                     doPaidInvoice.PaymentMethod == PaymentMethodType.C_PAYMENT_METHOD_MESSENGER))
                                {
                                    receiptDate = doPaidInvoice.IssueInvDate.Value;
                                }
                                tbt_Receipt doReceipt = incomeHandler.IssueReceipt(doInvoice, receiptDate, ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT, BatchDate, false); //Add (isWriteTransLog) by Jutarat A. on 07062013
                                if (doReceipt != null)
                                {
                                    //ICR010 Receipt report
                                    incomeDocumentHandler.GenerateICR010FilePath(doReceipt.ReceiptNo
                                                                                 , ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT
                                                                                 , BatchDate);

                                    if (doInvoice.BillingTypeCode == BillingType.C_BILLING_TYPE_DEPOSIT)
                                    {
                                        bool isSuccess = billingHandler.UpdateReceiptNoDepositFee(doPaidInvoice.InvoiceNo, doReceipt.ReceiptNo, ProcessID.C_PROCESS_ID_GENERATE_RECEIPT_AFTER_PAYMENT, BatchDate);
                                        if (!isSuccess)
                                        {
                                            throw new Exception("Error update receipt no to deposit table");
                                        }
                                    }
                                }
                                else
                                {
                                    throw new Exception("Error generate receipt");
                                }
                                #endregion
                            }

                            //Success
                            scope.Complete();
                            result.Complete++;
                        }
                        catch (Exception ex)
                        {
                            scope.Dispose();
                            result.Failed++;
                            result.ErrorMessage += string.Format("Invoice no. {0} has Error : {1} {2}\n", doPaidInvoice.InvoiceNo, ex.Message, ex.InnerException != null ? ex.InnerException.Message : string.Empty);
                        }
                    }
                }
                //Update batch result,     at lease one transaction fail => batch fail
                result.Result = (result.Failed == 0);
            }
            return(result);
        }
Exemple #19
0
        /// <summary>
        /// Force issue taxinvoice/receipt pdf report of specific invoice information
        /// </summary>
        /// <param name="doInvoice">invoice information</param>
        /// <param name="issueInvoiceDate">issue invoice date</param>
        /// <param name="validator"></param>
        /// <returns></returns>
        public string ICS050_IssueTaxInvoiceReceipt(doInvoice doInvoice, DateTime issueInvoiceDate, ValidatorUtil validator)
        {
            ///Issue tax invoice
            IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
            tbt_TaxInvoice  doTaxInvoice   = billingHandler.ForceIssueTaxInvoice(doInvoice, issueInvoiceDate);

            if (doTaxInvoice != null)
            {
                //Issue receipt
                IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                tbt_Receipt    doReceipt     = incomeHandler.ForceIssueReceipt(doInvoice, issueInvoiceDate);

                if (doReceipt != null)
                {
                    //Generate pdf on server
                    IIncomeDocumentHandler incomeDocumentHandler = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
                    //string pdfFilePath = string.Empty;
                    // comment by Jirawta Jannet @ 2016-10-17
                    string pdfFilePath = incomeDocumentHandler.GenerateBLR020_ICR010FilePath(
                        doTaxInvoice.TaxInvoiceNo
                        , doReceipt.ReceiptNo
                        , CommonUtil.dsTransData.dtUserData.EmpNo
                        , CommonUtil.dsTransData.dtOperationData.ProcessDateTime);


                    if (doInvoice.BillingTypeCode == BillingType.C_BILLING_TYPE_DEPOSIT &&
                        doReceipt.AdvanceReceiptStatus == AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_NOT)
                    {
                        bool isSuccess = billingHandler.UpdateReceiptNoDepositFee(doInvoice.InvoiceNo, doReceipt.ReceiptNo
                                                                                  , CommonUtil.dsTransData.dtUserData.EmpNo
                                                                                  , CommonUtil.dsTransData.dtOperationData.ProcessDateTime);

                        if (!isSuccess)
                        {
                            //Cannot issue receipt
                            validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS050"
                                                      , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7010
                                                      , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                            return(null);
                        }
                    }

                    //Success
                    return(pdfFilePath);
                }
                else
                {
                    //Cannot issue receipt
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS050"
                                              , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7010
                                              , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                    return(null);
                }
            }
            else
            {
                //Cannot issue tax invoice
                validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS050"
                                          , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7011
                                          , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                return(null);
            }
        }
Exemple #20
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));
        }