/// <summary>
        ///
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CMS480_UpdateManageCarryOverProfit(List <CMS480_ManageCarryOverProfit_Param> param, string productTypeCode)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                if (param == null && param.Count == 0)
                {
                    throw new ArgumentNullException("param", "\"Manage carry over profit\" data can't be empty");
                }

                CommonUtil com = new CommonUtil();

                using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 5, 0)))
                {
                    foreach (CMS480_ManageCarryOverProfit_Param item in param)
                    {
                        string reportMonth  = !string.IsNullOrEmpty(item.ReportMonthYear) ? item.ReportMonthYear.Split('/')[0] : null;
                        string reportYear   = !string.IsNullOrEmpty(item.ReportMonthYear) ? item.ReportMonthYear.Split('/')[1] : null;
                        string contractCode = !string.IsNullOrEmpty(item.BillingCode) ? item.BillingCode.Split('-')[0] : null;
                        string billingOCC   = !string.IsNullOrEmpty(item.BillingCode) ? item.BillingCode.Split('-')[1] : null;

                        if (item.ReceiveAmountCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                        {
                            item.ReceiveAmountUsd = item.ReceiveAmount;
                            item.ReceiveAmount    = null;
                        }
                        if (item.IncomeRentalFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                        {
                            //item.IncomeRentalFeeUsd = item.ReceiveAmount;
                            item.IncomeRentalFeeUsd = item.IncomeRentalFee;
                            item.IncomeRentalFee    = null;
                        }
                        if (item.AccumulatedReceiveAmountCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                        {
                            // item.AccumulatedReceiveAmountUsd = item.ReceiveAmount;
                            item.AccumulatedReceiveAmountUsd = item.AccumulatedReceiveAmount;
                            item.AccumulatedReceiveAmount    = null;
                        }
                        if (item.AccumulatedUnpaidCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                        {
                            // item.AccumulatedUnpaidUsd = item.ReceiveAmount;
                            item.AccumulatedUnpaidUsd = item.AccumulatedUnpaid;
                            item.AccumulatedUnpaid    = null;
                        }
                        if (item.IncomeVatCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                        {
                            // item.IncomeVatUsd = item.ReceiveAmount;
                            item.IncomeVatUsd = item.IncomeVat;
                            item.IncomeVat    = null;
                        }

                        ICommonHandler srvCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                        srvCommon.UpdateTbtManageCarryOverProfit(reportYear, reportMonth, com.ConvertContractCode(contractCode, CommonUtil.CONVERT_TYPE.TO_LONG), billingOCC,
                                                                 item.ReceiveAmount, item.ReceiveAmountUsd, item.ReceiveAmountCurrencyType,
                                                                 item.IncomeRentalFee, item.IncomeRentalFeeUsd, item.IncomeRentalFeeCurrencyType,
                                                                 item.AccumulatedReceiveAmount, item.AccumulatedReceiveAmountUsd, item.AccumulatedReceiveAmountCurrencyType,
                                                                 item.AccumulatedUnpaid, item.AccumulatedUnpaidUsd, item.AccumulatedUnpaidCurrencyType,
                                                                 item.IncomeVat, item.IncomeVatUsd, item.IncomeVatCurrencyType, item.UnpaidPeriod, item.IncomeDate, CommonUtil.dsTransData.dtUserData.EmpNo);
                    }

                    trans.Complete();
                    this.Dispose();
                }

                // - Generate CSV Files -
                string paramReportMonth = param[0].ReportMonthYear.Split('/')[0];
                string paramReportYear  = param[0].ReportMonthYear.Split('/')[1];

                IDocumentHandler documentHandler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                documentHandler.GenerateCMR020FilePath(paramReportYear, paramReportMonth, productTypeCode, ProcessID.C_PROCESS_ID_GEN_ACCOUNT_CARRY_OVER_AND_PROFIT, DateTime.Now, false);

                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.ResultData  = this.CMS480_UpdateManageCarryOverProfit_CreateResult(true);

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