Exemple #1
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);
            }
        }
Exemple #2
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));
        }
Exemple #3
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 #4
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);
        }