public ActionResult BLP010_GenerateReportFromTable() { ObjectResultData res = new ObjectResultData(); IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; IBillingDocumentHandler billingDocumentHandler = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.ResultData = true; try { List <string> lstInvoiceNo = billingHandler.GetTbt_InvoiceReprint(); foreach (string invoiceno in lstInvoiceNo) { try { billingDocumentHandler.GenerateBLR010FilePath(invoiceno, ProcessID.C_PROCESS_ID_MANAGE_INVOICE, DateTime.Now); } catch (Exception ex) { res.ResultData = false; res.AddErrorMessage(ex); } } } catch (Exception ex) { res.ResultData = false; res.AddErrorMessage(ex); } return(Json(res)); }
public ActionResult BLP020_GenerateReport(string strInvoiceNo) { ObjectResultData res = new ObjectResultData(); IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; IBillingDocumentHandler billingDocumentHandler = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; try { // Comment by Jirawat Jannet //List<tbt_TaxInvoice> taxInvoiceList = billingHandler.GetTbt_TaxInvoice(strInvoiceNo); //if (taxInvoiceList != null && taxInvoiceList.Count > 0) //{ // billingDocumentHandler.GenerateBLR020FilePath(taxInvoiceList[0].TaxInvoiceNo, ProcessID.C_PROCESS_ID_MANAGE_INVOICE, taxInvoiceList[0].CreateDate.Value); //} throw new Exception("กำลังดำเนินการแก้ไข report BLR020"); //ICommonHandler comHandler = ServiceContainer.GetService<ICommonHandler>() as ICommonHandler; //List<tbt_DocumentList> documentList = comHandler.GetTbt_DocumentList(null, null, null); //if (documentList != null && documentList.Count > 0) //{ // foreach (tbt_DocumentList data in documentList) // { // billingDocumentHandler.GenerateBLR020FilePath(data.DocumentNo, ProcessID.C_PROCESS_ID_MANAGE_INVOICE, data.CreateDate.Value); // } //} } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
public ActionResult BLP010_GenerateReport(string strInvoiceNo) { ObjectResultData res = new ObjectResultData(); IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; IBillingDocumentHandler billingDocumentHandler = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; try { List <tbt_Invoice> invoiceList = billingHandler.GetTbt_Invoice(strInvoiceNo, null).OrderByDescending(t => t.InvoiceOCC).ToList <tbt_Invoice>(); if (invoiceList != null && invoiceList.Count > 0) { billingDocumentHandler.GenerateBLR010FilePath(invoiceList[0].InvoiceNo, ProcessID.C_PROCESS_ID_MANAGE_INVOICE, invoiceList[0].CreateDate.Value); } //ICommonHandler comHandler = ServiceContainer.GetService<ICommonHandler>() as ICommonHandler; //List<tbt_DocumentList> documentList = comHandler.GetTbt_DocumentList(null, null, null); //if (documentList != null && documentList.Count > 0) //{ // foreach (tbt_DocumentList data in documentList) // { // billingDocumentHandler.GenerateBLR010FilePath(data.DocumentNo, ProcessID.C_PROCESS_ID_MANAGE_INVOICE, data.CreateDate.Value); // } //} } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
public ActionResult BLR030_PaymentForm(string invoiceNo) { try { IBillingDocumentHandler handlerBillingDocument = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; // Mothed #1: Directly generate //List<dtRptPaymentForm> rptList = handlerBillingDocument.GetRptPaymentForm("201205A00204"); //ReportDocument rptH = new ReportDocument(); //string path = ReportUtil.GetReportPath("Reports/BLR030_Payment.rpt", Server.MapPath("/")); //rptH.Load(path); //rptH.SetDataSource(rptList); //Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //rptH.Close(); //return File(stream, "application/pdf"); // Mothed #2: Official generate //Stream stream2 = handlerBillingDocument.GenerateBLR030("201205A00204", "500575", DateTime.Now); // Comment by Jirawat Jannet //Stream stream2 = handlerBillingDocument.GenerateBLR030(invoiceNo, CommonUtil.dsTransData.dtUserData.EmpNo, DateTime.Now); //return File(stream2, "application/pdf"); throw new Exception("กำลังดำเนินการแก้ไข report BLR030"); } catch (Exception ex) { throw ex; } }
public ActionResult BLR010_Invoice(string invoiceNo) { try { IBillingDocumentHandler handlerBillingDocument = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; //// Mothed #1: Directly generate //List<dtRptInvoice> rptList = handlerBillingDocument.GetRptInvoice("201205A00121", MiscType.C_SHOW_DUEDATE, ShowDueDate.C_SHOW_DUEDATE_7, ShowDueDate.C_SHOW_DUEDATE_30); //// Update value //foreach (var item in rptList) //{ // item.RPT_InvoicePaper = InvoiceDocument.C_INVOICE_DOC_ORIGINAL_CUST_EN + "\n" + InvoiceDocument.C_INVOICE_DOC_ORIGINAL_CUST_TH; //} //ReportDocument rptH = new ReportDocument(); //string path = ReportUtil.GetReportPath("Reports/BLR010_Invoice.rpt", Server.MapPath("/")); //rptH.Load(path); //rptH.SetDataSource(rptList); //rptH.SetParameterValue("C_PAYMENT_METHOD_BANK_TRANSFER", PaymentMethodType.C_PAYMENT_METHOD_BANK_TRANSFER); //Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //rptH.Close(); //return File(stream, "application/pdf"); // Mothed #2: Official generate Stream stream2 = handlerBillingDocument.GenerateBLR010(invoiceNo, CommonUtil.dsTransData.dtUserData.EmpNo, DateTime.Now); return(File(stream2, "application/pdf")); ////Test by Jutarat A. //for (int i = 0; i < 300; i++) //{ // handlerBillingDocument.GenerateBLR010FilePath("201210A00001", "490430", DateTime.Now); // handlerBillingDocument.GenerateBLR020FilePath("201210B00001", "490430", DateTime.Now); //} //return null; ////End Test } catch (Exception ex) { throw ex; } }
public ActionResult BLR020_Invoice(string invoiceNo) { try { IBillingDocumentHandler handlerBillingDocument = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; // Mothed #2: Official generate Stream stream2 = handlerBillingDocument.GenerateBLR020(invoiceNo, CommonUtil.dsTransData.dtUserData.EmpNo, DateTime.Now); return(File(stream2, "application/pdf")); } catch (Exception ex) { throw ex; } }
public ActionResult BLR020_TaxInvoice(string taxInvoice) { try { IBillingDocumentHandler handlerBillingDocument = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; //List<dtRptTaxInvoice> rptList = handlerBillingDocument.GetRptTaxInvoice("201112B90046", MiscType.C_SHOW_DUEDATE, ShowDueDate.C_SHOW_DUEDATE_7, ShowDueDate.C_SHOW_DUEDATE_30); //// Update value //foreach (var item in rptList) //{ // item.RPT_InvoicePaper = InvoiceDocument.C_INVOICE_DOC_ORIGINAL_CUST_EN + "\n" + InvoiceDocument.C_INVOICE_DOC_ORIGINAL_CUST_TH; //} //ReportDocument rptH = new ReportDocument(); //string path = ReportUtil.GetReportPath("Reports/BLR020_TaxInvoice.rpt", Server.MapPath("/")); //rptH.Load(path); //rptH.SetDataSource(rptList); //Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //rptH.Close(); //return File(stream, "application/pdf"); // Mothed #2: Official generate //Stream stream2 = handlerBillingDocument.GenerateBLR020("201112B90046", "500575", DateTime.Now); // Comment by Jirawat Jannet //Stream stream2 = handlerBillingDocument.GenerateBLR020(taxInvoice, CommonUtil.dsTransData.dtUserData.EmpNo, DateTime.Now); //return File(stream2, "application/pdf"); throw new Exception("ไม่ใช้แล้ว"); } catch (Exception ex) { throw ex; } }
//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); }
//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); }
public ActionResult BLP030_ManageInvoiceProcessTemp() { ObjectResultData res = new ObjectResultData(); IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; ICommonHandler comHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; IBillingDocumentHandler billingDocumentHandler = ServiceContainer.GetService <IBillingDocumentHandler>() as IBillingDocumentHandler; try { //using (TransactionScope scope = new TransactionScope()) //{ List <tbt_Invoice> invoiceList = billingHandler.GetTbt_Invoice(null, null); List <tbt_DocumentList> documentList = comHandler.GetTbt_DocumentList(null, null, null); invoiceList = (from t in invoiceList where //t.CreateBy == "BLP030" //&& t.InvoicePaymentStatus != "08" //&& t.CreateDate <= new DateTime(2013, 6, 21) && t.CreateDate > new DateTime(2013, 6, 20) && !documentList.Any(d => (d.DocumentNo == t.InvoiceNo)) select t).ToList <tbt_Invoice>(); foreach (tbt_Invoice data in invoiceList) { billingDocumentHandler.GenerateBLR010FilePath(data.InvoiceNo, ProcessID.C_PROCESS_ID_MANAGE_INVOICE, data.CreateDate.Value); } // Comment by Jirawat Jannet //List<tbt_TaxInvoice> taxInvoiceList = billingHandler.GetTbt_TaxInvoice(null); //taxInvoiceList = (from t in taxInvoiceList // where // //t.CreateBy == "BLP030" // //&& // t.CreateDate <= new DateTime(2013, 6, 21) // && t.CreateDate > new DateTime(2013, 6, 20) // && !documentList.Any(d => (d.DocumentNo == t.TaxInvoiceNo)) // select t).ToList<tbt_TaxInvoice>(); // Comment by Jirawat Jannet //foreach (tbt_TaxInvoice data in taxInvoiceList) //{ // billingDocumentHandler.GenerateBLR020FilePath(data.TaxInvoiceNo, ProcessID.C_PROCESS_ID_MANAGE_INVOICE, data.CreateDate.Value); //} // scope.Complete(); // res.ResultData = "Process Complete."; //} res.ResultData = "Process Complete."; } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }