Exemplo n.º 1
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);
            }
        }