Beispiel #1
0
        /// <summary>
        /// Retrieve invoice information of specfic invoice no. and inputted infoice information
        /// </summary>
        /// <param name="param">invoice no. and inputted invoice information</param>
        /// <returns></returns>
        public ActionResult ICS090_GetInvoice(ICS090_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            ICS090_InvoiceInfo invoiceInfo = new ICS090_InvoiceInfo();

            try
            {
                //Validate invoice business
                invoiceInfo = ICS090_ValidateInvoiceBusiness(param, res, false);
                if (res.IsError || invoiceInfo == null)
                {
                    return(Json(res));
                }

                //Pass
                res.ResultData = invoiceInfo;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res             = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Display invoice/tax invoice pdf report
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS090_DisplayReport()
        {
            ICS090_ScreenParameter screenSession = GetScreenObject <ICS090_ScreenParameter>();

            if (screenSession != null && !string.IsNullOrEmpty(screenSession.PDFFilePath))
            {
                IDocumentHandler handlerDocument = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           filestream      = handlerDocument.GetDocumentReportFileStream(screenSession.PDFFilePath);
                return(File(filestream, "application/pdf"));
            }
            else
            {
                //Do nothing
                ObjectResultData res = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                return(Json(res));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Check screen authority and permission
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult ICS090_Authority(ICS090_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

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

                // Check permission
                if (!ICS090_IsAllowOperate(res))
                {
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(InitialScreenEnvironment <ICS090_ScreenParameter>("ICS090", param, res));
        }
Beispiel #4
0
        public ActionResult ICS090()
        {
            ICS090_ScreenParameter param = GetScreenObject <ICS090_ScreenParameter>();

            return(View());
        }
Beispiel #5
0
        /// <summary>
        /// Validate business for specific invoice no. and cancelling information
        /// </summary>
        /// <param name="param">invoice no., cancelling information</param>
        /// <param name="res"></param>
        /// <param name="isConfirmCancel">validate when click confirm cancel button</param>
        /// <returns></returns>
        private ICS090_InvoiceInfo ICS090_ValidateInvoiceBusiness(ICS090_ScreenParameter param, ObjectResultData res, bool isConfirmCancel)
        {
            ValidatorUtil validator = new ValidatorUtil();

            if (CommonUtil.IsNullOrEmpty(param.InvoiceNo))
            {
                validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS090"
                                          , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                          , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                return(null);
            }

            if (isConfirmCancel == true)
            {
                if (CommonUtil.IsNullOrEmpty(param.CorrectionReason))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS090"
                                              , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                              , "CorrectionReason", "lblCorrectionReason", "CorrectionReason");
                }
                if (CommonUtil.IsNullOrEmpty(param.ApproveNo))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS090"
                                              , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                              , "ApproveNo", "lblApproveNo", "ApproveNo");
                }
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                if (res.IsError)
                {
                    return(null);
                }
            }



            //Get invoice Data
            var       billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
            doInvoice doInvoice      = billingHandler.GetInvoice(param.InvoiceNo);

            if (doInvoice == null)
            {
                validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS050"
                                          , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7003
                                          , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                return(null);
            }

            //Validate business
            if ((doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_BANK_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_AUTO_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_CASH_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_CHEQUE_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_NOTE_MATCHED ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_NOTE_ENCASHED ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_CASHIER_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_POST_MATCHED ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_POST_ENCASHED ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_AUTO_FAIL_BANK_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_NOTE_FAIL_BANK_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_POST_FAIL_BANK_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_PARTIALLY_PAID ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_PAID_WITH_PARTIAL_CN ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_PARTIALLY_PAID_CN ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_PAID_WITH_PARTIAL_REFUND ||
                 doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_REFUND_PAID) == false)
            {
                validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS090"
                                          , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7095
                                          , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                return(null);
            }

            //Edit by Patcharee T. 22/02/2013
            //CRC 6.12 The income type are cheque or other may be matching have mistake and issue receipt before matching invoice
            //therefore not need to cancel receipt if select correction reason is matching mistake.

            //Other case than encash
            //if (doInvoice.InvoicePaymentStatus != PaymentStatus.C_PAYMENT_STATUS_NOTE_ENCASHED
            //    && doInvoice.InvoicePaymentStatus != PaymentStatus.C_PAYMENT_STATUS_POST_ENCASHED)
            //{
            //    bool isIssued = billingHandler.CheckExistReceiptForInvoice(doInvoice.InvoiceNo, doInvoice.InvoiceOCC);
            //    if (isIssued == true)
            //    {
            //        validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS090"
            //            , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7041
            //            , "");
            //        ValidatorUtil.BuildErrorMessage(res, validator, null);
            //        return null;
            //    }
            //}

            //Edit by Patcharee T. 22/02/2013
            //CRC 6.12 The income type are cheque or other may be matching have mistake and issue receipt before matching invoice
            //therefore not need to cancel receipt if select correction reason is matching mistake.

            ICS090_InvoiceInfo invoiceInfo = new ICS090_InvoiceInfo();

            invoiceInfo.doInvoice = doInvoice;

            //Update Current payment status
            invoiceInfo.PaymentStatus = ICS090_GetPaymentStatusDesctription(invoiceInfo.doInvoice.InvoicePaymentStatus);

            //Update Next payment status, Require correctionReason, No need assign
            invoiceInfo.NextPaymentStatus = string.Empty;


            //Success
            return(invoiceInfo);
        }
Beispiel #6
0
        /// <summary>
        /// Event when click confirm cancel button, this function will cancel the payment matching information of specific invoice no. and inputted cancelling information to the system.
        /// </summary>
        /// <param name="param">invoice no. and inputted cancelling information</param>
        /// <returns></returns>
        public ActionResult ICS090_cmdConfirmCancel(ICS090_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            try
            {
                if (IsSuspend(res))
                {
                    return(Json(res));
                }

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


                //Validate invoice business
                ICS090_InvoiceInfo invoiceInfo = ICS090_ValidateInvoiceBusiness(param, res, true);
                if (res.IsError || invoiceInfo == null || invoiceInfo.doInvoice == null)
                {
                    return(Json(res));
                }


                //Connect db
                doInvoice doInvoice = invoiceInfo.doInvoice;
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;

                        //Comment by Jutarat A. on 25122013

                        /*if (doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_NOTE_ENCASHED
                        || doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_POST_ENCASHED)
                        || {
                        #region Encash
                        ||
                        ||  var incomeHandler = ServiceContainer.GetService<IIncomeHandler>() as IIncomeHandler;
                        ||  bool isSuccess = incomeHandler.CancelPaymentMatching(doInvoice, param.CorrectionReason, param.ApproveNo);
                        ||  if (!isSuccess)
                        ||      throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7116, null);
                        ||
                        ||  //Success, return result
                        ||  scope.Complete();
                        ||  res.ResultData = "1";
                        ||  return Json(res);
                        #endregion
                        || }
                        || else
                        || {*/
                        //End Comment
                        #region Other case
                        //Cancel payment matching
                        bool isTaxInvoiceIssued = billingHandler.CheckInvoiceIssuedTaxInvoice(doInvoice.InvoiceNo, doInvoice.InvoiceOCC);

                        var  incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                        bool isSuccess     = incomeHandler.CancelPaymentMatching(doInvoice, param.CorrectionReason, param.ApproveNo);
                        if (!isSuccess)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7042, null);
                        }


                        //Create new invoice (with pdf)
                        tbt_Invoice doTbt_Invoice = ICS090_CreateNewInvoice(doInvoice, param.CorrectionReason, isTaxInvoiceIssued);
                        if (doTbt_Invoice == null)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7043, null);
                        }


                        //Success, return result
                        scope.Complete();
                        if ((doTbt_Invoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_FAIL_NOTE_INV_BANK ||
                             doTbt_Invoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_FAIL_CHEQUE_INV_BANK))
                        {
                            //Success, Display PDF and information
                            ICS090_ScreenParameter screenSession = GetScreenObject <ICS090_ScreenParameter>();
                            screenSession.PDFFilePath = doTbt_Invoice.FilePath;
                            res.ResultData            = "PDF";
                            return(Json(res));
                        }
                        else
                        {
                            //Success, Display information popup only
                            res.ResultData = "1";
                            return(Json(res));
                        }
                        #endregion
                        //}
                    }
                    catch (Exception ex)
                    {
                        scope.Dispose();
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }