Example #1
0
        public ActionResult ICR020_CreditNote(string creditNoteNo)
        {
            IIncomeDocumentHandler incomeDocHandler = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
            Stream stream2 = incomeDocHandler.GenerateICR020(creditNoteNo,
                                                             CommonUtil.dsTransData.dtUserData.EmpNo,
                                                             CommonUtil.dsTransData.dtOperationData.ProcessDateTime);

            return(File(stream2, "application/pdf"));
        }
Example #2
0
        public ActionResult ICS150_ExportExcelData(doMatchRReport dtIncome)
        {
            ICS150_ScreenParameter param = GetScreenObject <ICS150_ScreenParameter>();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;


            try
            {
                ValidatorUtil validator = new ValidatorUtil();

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

                if (dtIncome == null || CommonUtil.IsNullAllField(dtIncome))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                }
                else
                {
                    IIncomeHandler handler  = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                    ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    if (string.IsNullOrEmpty(dtIncome.CreateBy) && CommonUtil.dsTransData != null)
                    {
                        dtIncome.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    }
                    var lst = handler.GetListIRC050(dtIncome);

                    if (lst.Count != 0)
                    {
                        IIncomeDocumentHandler docService = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
                        param.PendingDownloadFilePath = docService.GenerateICR050Report(lst, dtIncome);
                        param.PendingDownloadFileName = "ICR050Report.xlsx";
                        res.ResultData = true;
                    }
                    else
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    }
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Example #3
0
        /// <summary>
        /// Force issue 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_IssueReceipt(doInvoice doInvoice, DateTime issueInvoiceDate, ValidatorUtil validator)
        {
            //Issue receipt
            IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
            tbt_Receipt    doReceipt     = incomeHandler.ForceIssueReceipt(doInvoice, issueInvoiceDate);

            if (doReceipt != null)
            {
                IIncomeDocumentHandler incomeDocumentHandler = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
                //ICR010 Receipt report
                //string pdfFilePath = string.Empty;
                // Comment by Jirawat Jannet @ 2016-10-17
                string pdfFilePath = incomeDocumentHandler.GenerateICR010FilePath(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)
                {
                    IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                    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
            {
                validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS050"
                                          , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7010
                                          , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                return(null);
            }
        }
Example #4
0
        public ActionResult ICR010_GenerateReport(string receiptNo)
        {
            ObjectResultData       res              = new ObjectResultData();
            IIncomeHandler         incomeHandler    = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
            IIncomeDocumentHandler incomeDocHandler = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;

            try
            {
                doReceipt receiptData = incomeHandler.GetReceipt(receiptNo);
                if (receiptData != null)
                {
                    incomeDocHandler.GenerateICR010FilePath(receiptData.ReceiptNo, receiptData.CreateBy, receiptData.CreateDate.Value);
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        public ActionResult ICS130_DownloadReport()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                ValidatorUtil validator = new ValidatorUtil();
                var           hand      = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                var           param     = this.GetScreenObject <ICS130_ScreenParameter>();

                string reportPath = "", reportName = "";

                if (param.CachedReportType == ICS130_ScreenParameter.eCacheReportType.Account)
                {
                    if (param.CachedAccountReport == null)
                    {
                        // add by jirawat jannet on 2016-11-08
                        ObjectResultData re = new ObjectResultData();
                        re.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                        re.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS130"
                                           , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0018);
                        return(Json(re));
                        //throw new HttpException(404, "NotFound");
                    }
                    else
                    {
                        IIncomeDocumentHandler docService = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
                        reportPath = docService.GenerateICS130ForAccount(param.CachedAccountReport, param.CachedPeriodFrom);
                        reportName = "WHTReport_ACC.xlsx";
                    }
                }
                else if (param.CachedReportType == ICS130_ScreenParameter.eCacheReportType.IMS)
                {
                    if (param.CachedIMSReport == null)
                    {
                        // add by jirawat jannet on 2016-11-08
                        ObjectResultData re = new ObjectResultData();
                        re.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                        re.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS130"
                                           , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0018);
                        return(Json(re));
                        //throw new HttpException(404, "NotFound");
                    }
                    else
                    {
                        IIncomeDocumentHandler docService = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
                        reportPath = docService.GenerateICS130ForIMS(param.CachedIMSReport, param.CachedPeriodFrom, param.CachedPeriodTo);
                        reportName = "WHTReport_IMS.xlsx";
                    }
                }

                if (string.IsNullOrEmpty(reportPath) || !System.IO.File.Exists(reportPath))
                {
                    // add by jirawat jannet on 2016-11-08
                    ObjectResultData re = new ObjectResultData();
                    re.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    re.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS130"
                                       , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0018);
                    return(Json(re));
                    //throw new HttpException(404, "NotFound");
                }

                var stream = new FileStream(reportPath, FileMode.Open, FileAccess.Read);
                reportPath = null;
                return(File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", reportName));
            }
            catch (Exception ex)
            {
                // add by jirawat jannet on 2016-11-08
                ObjectResultData re = new ObjectResultData();
                re.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                re.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS130"
                                   , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0018);
                return(Json(re));
                //throw new HttpException(404, "NotFound", ex);
            }
        }
Example #6
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);
        }
Example #7
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);
        }