/// <summary> /// Method to create flash report /// </summary> /// <param name="totals">Totals</param> /// <param name="departments">Departments</param> /// <param name="content">Report</param> /// <returns>Flash report model</returns> private FlashReportModel CreateFlashReport(FlashReportTotals totals, List <Department> departments, string content) { var flashReport = new FlashReportModel { Totals = new Totals { ProductSales = totals.ProductSales.ToString(Constants.CurrencyFormat), LineDiscount = (-1 * totals.LineDiscount).ToString(Constants.DiscountFormat), InvoiceDiscount = (-1 * totals.InvoiceDiscount).ToString(Constants.DiscountFormat), SalesAfterDiscount = totals.SalesAfterDiscount.ToString(Constants.DiscountFormat), Taxes = totals.Tax.ToString(Constants.CurrencyFormat), Charges = totals.Charge.ToString(Constants.CurrencyFormat), Refunded = totals.Refund.ToString(Constants.DiscountFormat), TotalsReceipts = totals.TotalReceipt.ToString(Constants.CurrencyFormat) }, Report = new ReportModel { ReportName = Constants.FlasReportFile, ReportContent = content, Copies = 1 } }; foreach (var department in departments) { flashReport.Departments.Add(new Dept { Department = department.Dept, Description = department.DeptName, NetSales = department.Sales.ToString(Constants.CurrencyFormat) }); } return(flashReport); }
public HttpResponseMessage GetFlashReport(int tillNumber) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,ReportController,GetFlashReport,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); var till = _tillService.GetTill(tillNumber); if (till == null) { var errorMessage = new ErrorMessage { MessageStyle = new MessageStyle { Message = Resource.TillNotExist }, }; _performancelog.Debug($"End,ReportController,GetFlashReport,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorResponse { Error = errorMessage.MessageStyle })); } if (!_receiptManager.IsFlashReportAvailable(tillNumber)) { var store = CacheManager.GetStoreInfo(); var offSet = store?.OffSet ?? 0; MessageType temp_VbStyle11 = (int)MessageType.Exclamation + MessageType.OkOnly; var errorMessage = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 0, 5688, null, temp_VbStyle11) }; _performancelog.Debug($"End,ReportController,GetFlashReport,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorResponse { Error = errorMessage.MessageStyle })); } var totals = _receiptManager.GetTotalsForFlashReport(tillNumber); var departments = _receiptManager.GetDepartmentDetailsForFlashReport(tillNumber); var fs = _receiptManager.PrintFlashReport(till, totals, departments); try { var content = Helper.CreateBytes(fs); FlashReportModel flashReport = CreateFlashReport(totals, departments, content); _performancelog.Debug($"End,ReportController,GetFlashReport,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, flashReport)); } catch { _performancelog.Debug($"End,ReportController,GetTillAuditReport,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorResponse { Error = new MessageStyle { Message = Resource.Error, MessageType = 0 } })); } }