public FlowDocument CreateReport(string reportHeader, bool? returnReceivables, bool selectInternalAccounts) { var report = new SimpleReport("8cm"); report.AddHeader("Vero"); report.AddHeader(reportHeader); report.AddHeader(string.Format(Resources.As_f, DateTime.Now)); var accounts = GetBalancedAccounts(selectInternalAccounts); if (returnReceivables != null) accounts = returnReceivables.GetValueOrDefault(false) ? accounts.Where(x => x.Amount < 0) : accounts.Where(x => x.Amount > 0); report.AddColumTextAlignment("Tablo", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Tablo", "35*", "35*", "30*"); if (accounts.Count() > 0) { report.AddTable("Tablo", Resources.Accounts, "", ""); var total = 0m; foreach (var account in accounts) { total += Math.Abs(account.Amount); report.AddRow("Tablo", account.PhoneNumber, account.CustomerName, Math.Abs(account.Amount).ToString(ReportContext.CurrencyFormat)); } report.AddRow("Tablo", Resources.GrandTotal, "", total); } else { report.AddHeader(string.Format(Resources.NoTransactionsFoundFor_f, reportHeader)); } return report.Document; }
public void TestColumnsFromResultsTables() { SrmDocument srmDocument = ResultsUtil.DeserializeDocument("silac_1_to_4.sky", GetType()); using (Database database = new Database()) { database.AddSrmDocument(srmDocument); SimpleReport report = new SimpleReport { Columns = new[] { new ReportColumn(typeof(DbTransitionResult), "PrecursorResult", "PeptideResult", "ProteinResult", "ReplicateName"), new ReportColumn(typeof(DbTransition), "Precursor", "Peptide", "Protein", "Name"), new ReportColumn(typeof(DbTransition), "Precursor", "Peptide", "Sequence"), new ReportColumn(typeof(DbTransitionResult), "Area"), }, }; ColumnSet columnSet = ColumnSet.GetTransitionsColumnSet(database.GetSchema()); TreeView treeView = new TreeView(); treeView.Nodes.AddRange(columnSet.GetTreeNodes().ToArray()); List <NodeData> columnInfos; columnSet.GetColumnInfos(report, treeView, out columnInfos); Assert.AreEqual(report.Columns.Count, columnInfos.Count); SimpleReport reportCompare = (SimpleReport)columnSet.GetReport(columnInfos, null); Assert.IsTrue(ArrayUtil.EqualsDeep(report.Columns, reportCompare.Columns)); } }
public void TestReportSpecList() { ReportSpecList reportSpecList = new ReportSpecList(); using (Database database = new Database()) { ColumnSet columnSet = ColumnSet.GetTransitionsColumnSet(database.GetSchema()); TreeView treeView = new TreeView(); treeView.Nodes.AddRange(columnSet.GetTreeNodes().ToArray()); foreach (ReportSpec reportSpec in reportSpecList.GetDefaults()) { Report report = Report.Load(reportSpec); ResultSet resultSet = report.Execute(database); List <NodeData> nodeDatas; columnSet.GetColumnInfos(report, treeView, out nodeDatas); Assert.IsFalse(nodeDatas.Contains(null)); if (reportSpec.GroupBy == null) { SimpleReport simpleReport = (SimpleReport)report; Assert.AreEqual(simpleReport.Columns.Count, resultSet.ColumnInfos.Count); Assert.AreEqual(simpleReport.Columns.Count, nodeDatas.Count); } } } }
public void PrintAccountTransactions(Account account, WorkPeriod workPeriod, Printer printer, string filter) { var range = _accountService.GetDateRange(filter, workPeriod); var summary = _accountService.GetAccountTransactionSummary(account, workPeriod, range.Start, range.End); var totalBalance = summary.Transactions.Sum(x => x.Debit - x.Credit).ToString(LocalSettings.ReportCurrencyFormat); var report = new SimpleReport(""); report.AddParagraph("Header"); report.AddParagraphLine("Header", _settingService.ProgramSettings.UserInfo); report.AddParagraphLine("Header", Resources.AccountTransaction, true); report.AddParagraphLine("Header", ""); report.AddParagraphLine("Header", string.Format("{0}: {1}", string.Format(Resources.Name_f, Resources.Account), account.Name)); report.AddParagraphLine("Header", string.Format("{0}: {1}", Resources.Balance, totalBalance)); report.AddParagraphLine("Header", ""); report.AddColumnLength("Transactions", "15*", "35*", "15*", "15*", "20*"); report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right); report.AddTable("Transactions", Resources.Date, Resources.Description, Resources.Debit, Resources.Credit, Resources.Balance); foreach (var ad in summary.Transactions) { report.AddRow("Transactions", ad.Date.ToShortDateString(), ad.Name, ad.DebitStr, ad.CreditStr, ad.BalanceStr); } foreach (var sum in summary.Summaries) { report.AddBoldRow("Transactions", "", sum.Caption, sum.Debit, sum.Credit, sum.Balance); } _printerService.PrintReport(report.Document, printer); }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.CostReport); var costItems = ReportContext.PeriodicConsumptions.SelectMany(x => x.CostItems) .GroupBy(x => new { ItemName = x.Name, PortionName = x.Portion.Name }) .Select(x => new { x.Key.ItemName, x.Key.PortionName, TotalQuantity = x.Sum(y => y.Quantity), TotalCost = x.Sum(y => y.Cost * y.Quantity) }); if (costItems.Count() > 0) { report.AddColumTextAlignment("Maliyet", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Maliyet", "38*", "20*", "17*", "25*"); report.AddTable("Maliyet", Resources.MenuItem, Resources.Portion, Resources.Quantity, Resources.AverageCost); foreach (var costItem in costItems) { report.AddRow("Maliyet", costItem.ItemName, costItem.PortionName, costItem.TotalQuantity.ToString("#,#0.##"), (costItem.TotalCost / costItem.TotalQuantity).ToString(ReportContext.CurrencyFormat)); } report.AddRow("Maliyet", Resources.Total, "", "", costItems.Sum(x => x.TotalCost).ToString(ReportContext.CurrencyFormat)); } else report.AddHeader(Resources.ThereAreNoCostTransactionsInThisPeriod); return report.Document; }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); report.AddHeader("Samba POS"); report.AddHeader(Resources.InventoryReport); report.AddHeader(string.Format(Resources.As_f, DateTime.Now)); var lastPeriodicConsumption = ReportContext.GetCurrentPeriodicConsumption(); var consumptionItems = lastPeriodicConsumption.PeriodicConsumptionItems; if (consumptionItems.Count() > 0) { report.AddColumTextAlignment("InventoryTable", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("InventoryTable", "45*", "30*", "35*"); report.AddTable("InventoryTable", Resources.InventoryItem, Resources.Unit, Resources.Quantity); foreach (var costItem in consumptionItems) { report.AddRow("InventoryTable", costItem.InventoryItem.Name, costItem.InventoryItem.TransactionUnit??costItem.InventoryItem.BaseUnit, costItem.GetPhysicalInventory().ToString("#,#0.##")); } } else report.AddHeader(Resources.ThereAreNoCostTransactionsInThisPeriod); return report.Document; }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.CostReport); var costItems = ReportContext.PeriodicConsumptions.SelectMany(x => x.WarehouseConsumptions).SelectMany(x => x.CostItems) .GroupBy(x => new { ItemName = x.Name, x.PortionName }) .Select(x => new { x.Key.ItemName, x.Key.PortionName, TotalQuantity = x.Sum(y => y.Quantity), TotalCost = x.Sum(y => y.Cost * y.Quantity) }).ToList(); if (costItems.Any()) { report.AddColumTextAlignment("Maliyet", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Maliyet", "38*", "20*", "17*", "25*"); report.AddTable("Maliyet", Resources.MenuItem, Resources.Portion, Resources.Quantity, Resources.AverageCost); foreach (var costItem in costItems) { report.AddRow("Maliyet", costItem.ItemName, costItem.PortionName, costItem.TotalQuantity.ToString("#,#0.##"), (costItem.TotalCost / costItem.TotalQuantity).ToString(ReportContext.CurrencyFormat)); } report.AddRow("Maliyet", Resources.Total, "", "", costItems.Sum(x => x.TotalCost).ToString(ReportContext.CurrencyFormat)); } else { report.AddHeader(Resources.ThereAreNoCostTransactionsInThisPeriod); } return(report.Document); }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); report.AddHeader("Samba POS"); report.AddHeader(Resources.InventoryReport); report.AddHeader(string.Format(Resources.As_f, DateTime.Now)); var lastPeriodicConsumption = ReportContext.GetCurrentPeriodicConsumption(); var consumptionItems = lastPeriodicConsumption.PeriodicConsumptionItems; if (consumptionItems.Any()) { report.AddColumTextAlignment("InventoryTable", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("InventoryTable", "45*", "30*", "35*"); report.AddTable("InventoryTable", Resources.InventoryItem, Resources.Unit, Resources.Quantity); foreach (var costItem in consumptionItems) { report.AddRow("InventoryTable", costItem.InventoryItem.Name, costItem.InventoryItem.TransactionUnit ?? costItem.InventoryItem.BaseUnit, costItem.GetPhysicalInventory().ToString("#,#0.##")); } } else { report.AddHeader(Resources.ThereAreNoCostTransactionsInThisPeriod); } return(report.Document); }
private static void PrepareModificationTable(SimpleReport report, Func <TicketItem, bool> predicate, string title) { var modifiedItems = ReportContext.Tickets .SelectMany(x => x.TicketItems.Where(predicate) .OrderBy(y => y.ModifiedDateTime) .Select(y => new { Ticket = x, UserId = y.ModifiedUserId, MenuItem = y.MenuItemName, y.Quantity, y.ReasonId, y.ModifiedDateTime, Amount = y.GetItemValue() })); if (modifiedItems.Count() == 0) { return; } report.AddColumTextAlignment(title, TextAlignment.Left, TextAlignment.Left, TextAlignment.Left, TextAlignment.Left); report.AddColumnLength(title, "14*", "45*", "28*", "13*"); report.AddTable(title, title, "", "", ""); foreach (var voidItem in modifiedItems.GroupBy(x => x.ReasonId)) { if (voidItem.Key > 0) { report.AddRow(title, ReportContext.GetReasonName(voidItem.Key), "", "", ""); } foreach (var vi in voidItem) { report.AddRow(title, vi.Ticket.TicketNumber, vi.Quantity.ToString("#.##") + " " + vi.MenuItem, ReportContext.GetUserName(vi.UserId), vi.ModifiedDateTime.ToShortTimeString()); } } var voidGroups = from c in modifiedItems group c by c.UserId into grp select new { UserId = grp.Key, Amount = grp.Sum(x => x.Amount) }; report.AddColumTextAlignment("Personel" + title, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Personel" + title, "60*", "40*"); report.AddTable("Personel" + title, string.Format(Resources.ByPersonnel_f, title), ""); foreach (var voidItem in voidGroups.OrderByDescending(x => x.Amount)) { report.AddRow("Personel" + title, ReportContext.GetUserName(voidItem.UserId), voidItem.Amount.ToString(ReportContext.CurrencyFormat)); } if (voidGroups.Count() > 1) { report.AddRow("Personel" + title, Resources.Total, voidGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } }
private static void CreateDepartmentInfo(SimpleReport report, IEnumerable <Ticket> tickets, string header) { var rpKey = "Departman" + header; report.AddColumTextAlignment(rpKey, TextAlignment.Left, TextAlignment.Right); report.AddTable(rpKey, header, ""); var ticketGropus = tickets .GroupBy(x => new { x.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSum()) - x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())) - x.Sum(y => y.GetPostTaxServicesTotal()), Tax = x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())), Services = x.Sum(y => y.GetPostTaxServicesTotal()) }).ToList(); if (ticketGropus.Count() > 1) { foreach (var departmentInfo in ticketGropus) { report.AddRow(rpKey, departmentInfo.DepartmentName, departmentInfo.Amount.ToString(ReportContext.CurrencyFormat)); } } report.AddRow(rpKey, header.ToUpper() + " TOTAL", ticketGropus.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var vatSum = ticketGropus.Sum(x => x.Tax); var serviceSum = ticketGropus.Sum(x => x.Services); if (vatSum != 0 || serviceSum != 0) { if (serviceSum != 0) { ReportContext.Tickets.SelectMany(x => x.Calculations).Where(x => x.IncludeTax).GroupBy(x => x.CalculationTypeId).ToList().ForEach( x => { var template = ReportContext.CalculationTypes.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? template.Name : Resources.UndefinedWithBrackets; report.AddRow(rpKey, title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } if (vatSum != 0) { report.AddRow(rpKey, Resources.SubTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Services).ToString(ReportContext.CurrencyFormat)); report.AddRow(rpKey, Resources.TaxTotal.ToUpper(), vatSum.ToString(ReportContext.CurrencyFormat)); } report.AddRow(rpKey, Resources.GrandTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Tax + x.Services).ToString(ReportContext.CurrencyFormat)); } }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.InventoryPurchaseReport); var transactionGroups = ReportContext.Transactions.SelectMany(x => x.TransactionItems) .GroupBy(x => new { x.InventoryItem.GroupCode }) .Select(x => new { ItemName = x.Key.GroupCode, Total = x.Sum(y => (y.Price * y.Quantity)) }); if (transactionGroups.Count() > 0) { report.AddColumTextAlignment("GrupToplam", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("GrupToplam", "60*", "40*"); report.AddTable("GrupToplam", Resources.InventoryGroup, Resources.Total); if (transactionGroups.Count() > 1) { foreach (var transactionItem in transactionGroups) { report.AddRow("GrupToplam", !string.IsNullOrEmpty(transactionItem.ItemName) ? transactionItem.ItemName : Resources.UndefinedWithBrackets, transactionItem.Total.ToString(ReportContext.CurrencyFormat)); } } report.AddRow("GrupToplam", Resources.Total, transactionGroups.Sum(x => x.Total).ToString(ReportContext.CurrencyFormat)); } var transactionItems = ReportContext.Transactions.SelectMany(x => x.TransactionItems) .GroupBy(x => new { x.InventoryItem.Name, x.Unit }) .Select(x => new { ItemName = x.Key.Name, Quantity = x.Sum(y => y.Quantity), x.Key.Unit, Total = x.Sum(y => y.Price * y.Quantity) }); if (transactionItems.Count() > 0) { report.AddColumTextAlignment("Alımlar", TextAlignment.Left, TextAlignment.Right, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Alımlar", "40*", "20*", "15*", "25*"); report.AddTable("Alımlar", Resources.InventoryItem, Resources.Quantity, Resources.Unit, Resources.AveragePrice_ab); foreach (var transactionItem in transactionItems) { report.AddRow("Alımlar", transactionItem.ItemName, transactionItem.Quantity.ToString("#,#0.##"), transactionItem.Unit, (transactionItem.Total / transactionItem.Quantity).ToString(ReportContext.CurrencyFormat)); } } else { report.AddHeader(""); report.AddHeader(Resources.NoPurchaseTransactionInCurrentDateRange); } return report.Document; }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.InventoryPurchaseReport); var transactionGroups = ReportContext.Transactions.SelectMany(x => x.TransactionItems) .GroupBy(x => new { x.InventoryItem.GroupCode }) .Select(x => new { ItemName = x.Key.GroupCode, Total = x.Sum(y => (y.Price * y.Quantity)) }); if (transactionGroups.Count() > 0) { report.AddColumTextAlignment("GrupToplam", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("GrupToplam", "60*", "40*"); report.AddTable("GrupToplam", Resources.InventoryGroup, Resources.Total); if (transactionGroups.Count() > 1) { foreach (var transactionItem in transactionGroups) { report.AddRow("GrupToplam", !string.IsNullOrEmpty(transactionItem.ItemName) ? transactionItem.ItemName : Resources.UndefinedWithBrackets, transactionItem.Total.ToString(ReportContext.CurrencyFormat)); } } report.AddRow("GrupToplam", Resources.Total, transactionGroups.Sum(x => x.Total).ToString(ReportContext.CurrencyFormat)); } var transactionItems = ReportContext.Transactions.SelectMany(x => x.TransactionItems) .GroupBy(x => new { x.InventoryItem.Name, x.Unit }) .Select(x => new { ItemName = x.Key.Name, Quantity = x.Sum(y => y.Quantity), x.Key.Unit, Total = x.Sum(y => y.Price * y.Quantity) }); if (transactionItems.Count() > 0) { report.AddColumTextAlignment("Alımlar", TextAlignment.Left, TextAlignment.Right, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Alımlar", "40*", "20*", "15*", "25*"); report.AddTable("Alımlar", Resources.InventoryItem, Resources.Quantity, Resources.Unit, Resources.AveragePrice_ab); foreach (var transactionItem in transactionItems) { report.AddRow("Alımlar", transactionItem.ItemName, transactionItem.Quantity.ToString("#,#0.##"), transactionItem.Unit, (transactionItem.Total / transactionItem.Quantity).ToString(ReportContext.CurrencyFormat)); } } else { report.AddHeader(""); report.AddHeader(Resources.NoPurchaseTransactionInCurrentDateRange); } return(report.Document); }
public void EvaluateTypeSolve(ExecutionResult executionResult, ProcessItem processItem, CourseProblemCase @case) { var context = processItem.Context; var ccData = processItem.Item; var subcase = ccData.Results.First(i => i.Case == @case.Id); subcase.Duration = executionResult.Duration; subcase.Returncode = executionResult.ReturnCode; subcase.FullCommand = executionResult.ExecutionCommand.FullCmd; subcase.Command = executionResult.ExecutionCommand.Command; processItem.TimeBank.WallTime += executionResult.Duration; var pythonReportJson = context.TmpDir.RootFile(".report.json"); if (File.Exists(pythonReportJson)) { var report = PythonReport.FromJson(pythonReportJson.ReadAllText()); ccData.Results.AddRange( report.Report.Tests.Select(i => new CcDataCaseResult { Case = i.Name, Duration = i.Duration, Status = i.Outcome == "passed" ? (int)ProcessStatusCodes.AnswerCorrect : (int)ProcessStatusCodes.AnswerWrong }) ); File.Delete(pythonReportJson); } var simpleReportJson = context.TmpDir.RootFile(".report.simple.json"); if (File.Exists(simpleReportJson)) { var report = SimpleReport.FromJson(simpleReportJson.ReadAllText()); ccData.Results.AddRange( report.Tests.Select(i => new CcDataCaseResult { Case = i.Name, Duration = i.Duration, Message = i.Message, Status = i.Outcome == "passed" ? (int)ProcessStatusCodes.AnswerCorrect : (int)ProcessStatusCodes.AnswerWrong }) ); File.Delete(simpleReportJson); } FillBasicInfo(executionResult, processItem, @case); }
protected override FlowDocument GetReport() { var currentPeriod = ReportContext.CurrentWorkPeriod; var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, currentPeriod, Resources.CsvBuilder); report.Header.TextAlignment = TextAlignment.Left; report.AddHeader(""); report.AddHeader(Resources.ClickLinksToExportData); report.AddHeader(""); report.AddLink(Resources.ExportSalesData); HandleLink(Resources.ExportSalesData); return report.Document; }
protected override FlowDocument GetReport() { var currentPeriod = ReportContext.CurrentWorkPeriod; var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, currentPeriod, Resources.CsvBuilder); report.Header.TextAlignment = TextAlignment.Left; report.AddHeader(""); report.AddHeader(Resources.ClickLinksToExportData); report.AddHeader(""); report.AddLink(Resources.ExportSalesData); HandleLink(Resources.ExportSalesData); return(report.Document); }
private static void PrintPortionsSections(SimpleReport report, IEnumerable <MenuItem> items, MenuItemSellInfo menuItem, string reportTable) { var realMenuItem = items.FirstOrDefault(x => x.Name == menuItem.Name); var menuItemGroups = MenuGroupBuilder.CalculatePortionsItems(ReportContext.Tickets, realMenuItem) .OrderByDescending(x => x.Quantity); if (menuItemGroups.Count() > 1) { foreach (var menuItemInfo in menuItemGroups) { report.AddRow(reportTable, menuItemInfo.Name, string.Format("({0:0.##})", menuItemInfo.Quantity), "(" + menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat) + ")"); } } }
public void AddDefaultReportHeader(SimpleReport report, WorkPeriod workPeriod, string caption) { var userInfo = _settingService.ProgramSettings.UserInfo; report.AddHeader(!string.IsNullOrEmpty(userInfo) ? userInfo : "MagentixPOS"); report.AddHeader(caption); if (workPeriod.EndDate > workPeriod.StartDate) { report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + workPeriod.EndDate.ToString("dd MMMM yyyy HH:mm")); } else { report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + DateTime.Now.ToString("dd MMMM yyyy HH:mm")); } }
public IReport Analyze(IList <IEntry> entries) { var report = new SimpleReport(); foreach (var entry in entries) { if (report.Entries.ContainsKey(entry)) { report.Entries[entry] += 1; } else { report.Entries.Add(entry, 1); } } return(report); }
private void SimplifiedReport() { if (this.SelectedTemplate != null) { Report report = new SimpleReport(); var source = new ObjectDataSource(); source.DataSource = typeof(MainViewModel); source.DataMember = "GetDataSourceReport"; report.DataSource = source; var reportSource = new InstanceReportSource() { ReportDocument = report }; var reportWindow = new I_ReportViewer(this.SelectedTemplate.Name + " Simplified Report", reportSource, false, false, false); reportWindow.ShowDialog(); } }
private void OnPrint(string obj) { var report = new SimpleReport(""); report.AddParagraph("Header"); report.AddParagraphLine("Header", string.Format(_selectedAccountScreen.Name), true); report.AddParagraphLine("Header", ""); report.AddColumnLength("Transactions", "60*", "40*"); report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Right); report.AddTable("Transactions", string.Format(Resources.Name_f, Resources.Account), Resources.Balance); foreach (var ad in Accounts) { report.AddRow("Transactions", ad.Name, ad.BalanceStr); } _printerService.PrintReport(report.Document); }
public void PrintAccountScreen(AccountScreen accountScreen, WorkPeriod workperiod, Printer printer) { var accounts = _accountService.GetAccountScreenRows(accountScreen, workperiod); var report = new SimpleReport(""); report.AddParagraph("Header"); report.AddParagraphLine("Header", _settingService.ProgramSettings.UserInfo); report.AddParagraphLine("Header", string.Format(accountScreen.Name), true); report.AddParagraphLine("Header", ""); report.AddColumnLength("Transactions", "60*", "40*"); report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Right); report.AddTable("Transactions", string.Format(Resources.Name_f, Resources.Account), Resources.Balance); foreach (var ad in accounts) { report.AddRow("Transactions", ad.Name, ad.BalanceStr); } _printerService.PrintReport(report.Document, printer); }
public FlowDocument CreateReport(string reportHeader, bool?returnReceivables, bool selectInternalAccounts) { var report = new SimpleReport("8cm"); report.AddHeader("Samba POS"); report.AddHeader(reportHeader); report.AddHeader(string.Format(Resources.As_f, DateTime.Now)); var accounts = GetBalancedAccounts(selectInternalAccounts).ToList(); if (returnReceivables != null) { accounts = returnReceivables.GetValueOrDefault(false) ? accounts.Where(x => x.Amount < 0).ToList() : accounts.Where(x => x.Amount > 0).ToList(); } report.AddColumTextAlignment("Tablo", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Tablo", "35*", "35*", "30*"); if (accounts.Any()) { report.AddTable("Tablo", Resources.Accounts, "", ""); var total = 0m; foreach (var account in accounts) { total += Math.Abs(account.Amount); report.AddRow("Tablo", account.PhoneNumber, account.AccountName, Math.Abs(account.Amount).ToString(ReportContext.CurrencyFormat)); } report.AddRow("Tablo", Resources.GrandTotal, "", total.ToString(ReportContext.CurrencyFormat)); } else { report.AddHeader(string.Format(Resources.NoTransactionsFoundFor_f, reportHeader)); } return(report.Document); }
private void OnPrintAccount(string obj) { var report = new SimpleReport(""); report.AddParagraph("Header"); report.AddParagraphLine("Header", Resources.AccountTransaction.ToPlural(), true); report.AddParagraphLine("Header", ""); report.AddParagraphLine("Header", string.Format("{0}: {1}", string.Format(Resources.Name_f, Resources.Account), SelectedAccount.Name)); report.AddParagraphLine("Header", string.Format("{0}: {1}", Resources.Balance, TotalBalance)); report.AddParagraphLine("Header", ""); report.AddColumnLength("Transactions", "15*", "35*", "15*", "15*", "20*"); report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right); report.AddTable("Transactions", Resources.Date, Resources.Description, Resources.Credit, Resources.Debit, Resources.Balance); foreach (var ad in AccountDetails) { report.AddRow("Transactions", ad.Date.ToShortDateString(), ad.Name, ad.CreditStr, ad.DebitStr, ad.BalanceStr); } _printerService.PrintReport(report.Document); }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); report.AddHeader("Magentix POS"); report.AddHeader(Resources.InventoryReport); report.AddHeader(string.Format(Resources.As_f, DateTime.Now)); var lastPeriodicConsumption = ReportContext.GetCurrentPeriodicConsumption(); foreach (var warehouseConsumption in lastPeriodicConsumption.WarehouseConsumptions.OrderBy(GetWarehouseOrder)) { if (warehouseConsumption.PeriodicConsumptionItems.Any()) { var warehouse = _cacheService.GetWarehouses().SingleOrDefault(x => x.Id == warehouseConsumption.WarehouseId) ?? Warehouse.Undefined; var inventoryTableSlug = "InventoryTable_" + warehouseConsumption.WarehouseId; report.AddColumTextAlignment(inventoryTableSlug, TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength(inventoryTableSlug, "5*", "*", "*"); report.AddTable(inventoryTableSlug, warehouse.Name, "", ""); foreach (var periodicConsumptionItem in warehouseConsumption.PeriodicConsumptionItems) { report.AddRow(inventoryTableSlug, periodicConsumptionItem.InventoryItemName, periodicConsumptionItem.UnitName, periodicConsumptionItem.GetPhysicalInventory().ToString(LocalSettings.ReportQuantityFormat)); } } } return(report.Document); }
protected override FlowDocument GetReport() { var currentPeriod = ReportContext.CurrentWorkPeriod; var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, currentPeriod, Resources.WorkPeriodReport); //--------------- report.AddColumTextAlignment("Departman", TextAlignment.Left, TextAlignment.Right); report.AddTable("Departman", Resources.Sales, ""); var ticketGropus = ReportContext.Tickets .GroupBy(x => new { x.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSumWithoutTax()), Vat = x.Sum(y => y.CalculateTax()), TaxServices = x.Sum(y => y.GetTaxServicesTotal()) }); report.AddRow("Departman", Resources.TotalSales.ToUpper(), ticketGropus.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var vatSum = ticketGropus.Sum(x => x.Vat); var serviceSum = ticketGropus.Sum(x => x.TaxServices); if (vatSum > 0 || serviceSum > 0) { if (vatSum > 0) report.AddRow("Departman", Resources.VatTotal.ToUpper(), vatSum.ToString(ReportContext.CurrencyFormat)); if (serviceSum > 0) { ReportContext.Tickets.SelectMany(x => x.TaxServices).GroupBy(x => x.TaxServiceId).ForEach( x => { var template = ReportContext.TaxServiceTemplates.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? template.Name : Resources.UndefinedWithBrackets; report.AddRow("Departman", title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } report.AddRow("Departman", Resources.GrandTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Vat + x.TaxServices).ToString(ReportContext.CurrencyFormat)); } //--------------- if (ReportContext.Departments.Count() > 1) { var showDepartmentTotals = false; report.AddColumnLength("CrossSales", "65*", "40*"); report.AddColumTextAlignment("CrossSales", TextAlignment.Left, TextAlignment.Right); report.AddTable("CrossSales", Resources.DepartmentSales, ""); foreach (var departmentInfo in ticketGropus) { var info = departmentInfo; var crossSales = ReportContext.Tickets.Where(x => x.DepartmentId == info.DepartmentId) .SelectMany(ticket => ticket.TicketItems.Select(ticketItem => new { Ticket = ticket, TicketItem = ticketItem })) .Where(x => x.TicketItem.DepartmentId != x.Ticket.DepartmentId) .GroupBy(x => new { x.TicketItem.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, Amount = x.Sum(y => MenuGroupBuilder.CalculateTicketItemTotal(y.Ticket, y.TicketItem)) }); report.AddRow("CrossSales", string.Format("{0} {1}", departmentInfo.DepartmentName, Resources.Sales), (departmentInfo.Amount).ToString(ReportContext.CurrencyFormat)); if (crossSales.Count() > 0) { showDepartmentTotals = true; report.AddRow("CrossSales", " -" + departmentInfo.DepartmentName, (departmentInfo.Amount - crossSales.Sum(x => x.Amount)).ToString(ReportContext.CurrencyFormat)); foreach (var crossSale in crossSales) { var cs = crossSale; report.AddRow("CrossSales", " -" + cs.DepartmentName, cs.Amount.ToString(ReportContext.CurrencyFormat)); } } } if (showDepartmentTotals) { report.AddBoldRow("CrossSales", Resources.Department + " " + Resources.Totals, ""); var salesByOrder = ReportContext.Tickets.SelectMany(ticket => ticket.TicketItems.Select(ticketItem => new { Ticket = ticket, TicketItem = ticketItem })) .GroupBy(x => new { x.TicketItem.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, Amount = x.Sum(y => MenuGroupBuilder.CalculateTicketItemTotal(y.Ticket, y.TicketItem)) }); foreach (var sale in salesByOrder) { var cs = sale; report.AddRow("CrossSales", cs.DepartmentName, cs.Amount.ToString(ReportContext.CurrencyFormat)); } } } //--------------- var ac = ReportContext.GetOperationalAmountCalculator(); report.AddColumnLength("GelirlerTablosu", "45*", "Auto", "35*"); report.AddColumTextAlignment("GelirlerTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable("GelirlerTablosu", Resources.Incomes, "", ""); report.AddRow("GelirlerTablosu", Resources.Cash, ac.CashPercent, ac.CashTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.CreditCard, ac.CreditCardPercent, ac.CreditCardTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.Voucher, ac.TicketPercent, ac.TicketTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.AccountBalance, ac.AccountPercent, ac.AccountTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.TotalIncome.ToUpper(), "", ac.TotalAmount.ToString(ReportContext.CurrencyFormat)); //--------------- //Kasa raporu eklendiği için kasa özeti bu rapordan kaldırıldı. Başka bir rapora taşınabilir şimdilik bıraktım. //var cashTransactionTotal = ReportContext.GetCashTotalAmount(); //var creditCardTransactionTotal = ReportContext.GetCreditCardTotalAmount(); //var ticketTransactionTotal = ReportContext.GetTicketTotalAmount(); //report.AddColumnLength("Kasa", "25*", "18*", "18*", "18*", "21*"); //report.AddColumTextAlignment("Kasa", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right); //report.AddTable("Kasa", "Kasa", "Nakit", "K.Kartı", "Y.Çeki", "Toplam"); //report.AddRow("Kasa", "Gün Başı", // currentPeriod.CashAmount.ToString(ReportContext.CurrencyFormat), // currentPeriod.CreditCardAmount.ToString(ReportContext.CurrencyFormat), // currentPeriod.TicketAmount.ToString(ReportContext.CurrencyFormat), // (currentPeriod.CashAmount + currentPeriod.CreditCardAmount + currentPeriod.TicketAmount).ToString(ReportContext.CurrencyFormat)); //report.AddRow("Kasa", "Faaliyet", // ac.CashTotal.ToString(ReportContext.CurrencyFormat), // ac.CreditCardTotal.ToString(ReportContext.CurrencyFormat), // ac.TicketTotal.ToString(ReportContext.CurrencyFormat), // ac.GrandTotal.ToString(ReportContext.CurrencyFormat)); //report.AddRow("Kasa", "Hareketler", // cashTransactionTotal.ToString(ReportContext.CurrencyFormat), // creditCardTransactionTotal.ToString(ReportContext.CurrencyFormat), // ticketTransactionTotal.ToString(ReportContext.CurrencyFormat), // (cashTransactionTotal + creditCardTransactionTotal + ticketTransactionTotal).ToString(ReportContext.CurrencyFormat)); //var totalCash = currentPeriod.CashAmount + ac.CashTotal + cashTransactionTotal; //var totalCreditCard = currentPeriod.CreditCardAmount + ac.CreditCardTotal + creditCardTransactionTotal; //var totalTicket = currentPeriod.TicketAmount + ac.TicketTotal + ticketTransactionTotal; //report.AddRow("Kasa", "TOPLAM", // totalCash.ToString(ReportContext.CurrencyFormat), // totalCreditCard.ToString(ReportContext.CurrencyFormat), // totalTicket.ToString(ReportContext.CurrencyFormat), // (totalCash + totalCreditCard + totalTicket).ToString(ReportContext.CurrencyFormat)); //--------------- var propertySum = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Sum(x => x.GetPropertyPrice() * x.Quantity); var voids = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Voided) .Sum(x => x.GetItemValue()); var discounts = ReportContext.Tickets .SelectMany(x => x.Discounts) .Sum(x => x.DiscountAmount); var gifts = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Gifted) .Sum(x => x.GetItemValue()); report.AddColumTextAlignment("Bilgi", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Bilgi", "65*", "35*"); report.AddTable("Bilgi", Resources.GeneralInformation, ""); report.AddRow("Bilgi", Resources.ItemProperties, propertySum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.VoidsTotal, voids.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.DiscountsTotal, discounts.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.GiftsTotal, gifts.ToString(ReportContext.CurrencyFormat)); if (ticketGropus.Count() > 1) foreach (var departmentInfo in ticketGropus) { report.AddRow("Bilgi", departmentInfo.DepartmentName, departmentInfo.TicketCount); } var ticketCount = ticketGropus.Sum(x => x.TicketCount); report.AddRow("Bilgi", Resources.TicketCount, ticketCount); report.AddRow("Bilgi", Resources.SalesDivTicket, ticketCount > 0 ? (ticketGropus.Sum(x => x.Amount) / ticketGropus.Sum(x => x.TicketCount)).ToString(ReportContext.CurrencyFormat) : "0"); if (ticketGropus.Count() > 1) { foreach (var departmentInfo in ticketGropus) { var dPayments = ReportContext.Tickets .SelectMany(x => x.Payments) .Where(x => x.DepartmentId == departmentInfo.DepartmentId) .GroupBy(x => new { x.PaymentType }) .Select(x => new TenderedAmount { PaymentType = x.Key.PaymentType, Amount = x.Sum(y => y.Amount) }); report.AddColumnLength(departmentInfo.DepartmentName + Resources.Incomes, "40*", "Auto", "35*"); report.AddColumTextAlignment(departmentInfo.DepartmentName + Resources.Incomes, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable(departmentInfo.DepartmentName + Resources.Incomes, string.Format(Resources.Incomes_f, departmentInfo.DepartmentName), "", ""); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.Cash, GetPercent(0, dPayments), GetAmount(0, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.CreditCard, GetPercent(1, dPayments), GetAmount(1, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.Voucher, GetPercent(2, dPayments), GetAmount(2, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.AccountBalance, GetPercent(3, dPayments), GetAmount(3, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.TotalIncome, "", dPayments.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var dvoids = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Voided && x.DepartmentId == departmentInfo.DepartmentId) .Sum(x => x.GetItemValue()); var ddiscounts = ReportContext.Tickets .Where(x => x.DepartmentId == departmentInfo.DepartmentId) .SelectMany(x => x.Discounts) .Sum(x => x.DiscountAmount); var dgifts = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Gifted && x.DepartmentId == departmentInfo.DepartmentId) .Sum(x => x.GetItemValue()); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.VoidsTotal, "", dvoids.ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.DiscountsTotal, "", ddiscounts.ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.GiftsTotal, "", dgifts.ToString(ReportContext.CurrencyFormat)); } } //-- if (ReportContext.Tickets.Select(x => x.GetTagData()).Where(x => !string.IsNullOrEmpty(x)).Distinct().Count() > 0) { var dict = new Dictionary<string, List<Ticket>>(); foreach (var ticket in ReportContext.Tickets.Where(x => !string.IsNullOrEmpty(x.Tag))) { var tags = ticket.Tag.Split(new[] { '\r' }, StringSplitOptions.RemoveEmptyEntries); foreach (var tag in tags) { if (!dict.ContainsKey(tag)) dict.Add(tag, new List<Ticket>()); dict[tag].Add(ticket); } } var tagGroups = dict.Select(x => new TicketTagInfo { Amount = x.Value.Sum(y => y.GetSumWithoutTax()), TicketCount = x.Value.Count, TagName = x.Key }).OrderBy(x => x.TagName); var tagGrp = tagGroups.GroupBy(x => x.TagName.Split(':')[0]) .Where(x => ReportContext.TicketTagGroups.SingleOrDefault(y => y.Name == x.Key) != null); if (tagGrp.Count() > 0) { report.AddColumTextAlignment("Etiket", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Etiket", "45*", "Auto", "35*"); report.AddTable("Etiket", Resources.TicketTags, "", ""); } foreach (var grp in tagGrp) { var tag = ReportContext.TicketTagGroups.SingleOrDefault(x => x.Name == grp.Key); if (tag == null || tag.ExcludeInReports) continue; report.AddBoldRow("Etiket", grp.Key, "", ""); if (tag.PriceTags) { var tCount = grp.Sum(x => x.TicketCount); var tSum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); var amnt = grp.Sum(x => x.Amount); var rate = tSum / amnt; report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", tSum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.TicketCount, "", tCount); report.AddRow("Etiket", Resources.TicketTotal, "", amnt.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.Rate, "", rate.ToString("%#0.##")); continue; } foreach (var ticketTagInfo in grp) { report.AddRow("Etiket", ticketTagInfo.TagName.Split(':')[1], ticketTagInfo.TicketCount, ticketTagInfo.Amount.ToString(ReportContext.CurrencyFormat)); } var totalAmount = grp.Sum(x => x.Amount); report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", totalAmount.ToString(ReportContext.CurrencyFormat)); var sum = 0m; if (tag.NumericTags) { try { sum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", sum.ToString("#,##.##")); } catch (FormatException) { report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", "#Hata!"); } } else { sum = grp.Sum(x => x.TicketCount); } if (sum > 0) { var average = totalAmount / sum; report.AddRow("Etiket", string.Format(Resources.TotalAmountDivTag_f, tag.Name), "", average.ToString(ReportContext.CurrencyFormat)); } } } //---- var owners = ReportContext.Tickets.SelectMany(ticket => ticket.TicketItems.Select(ticketItem => new { Ticket = ticket, TicketItem = ticketItem })) .GroupBy(x => new { x.TicketItem.CreatingUserId }) .Select(x => new UserInfo { UserId = x.Key.CreatingUserId, Amount = x.Sum(y => MenuGroupBuilder.CalculateTicketItemTotal(y.Ticket, y.TicketItem)) }); report.AddColumTextAlignment("Garson", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Garson", "65*", "35*"); report.AddTable("Garson", Resources.UserSales, ""); foreach (var ownerInfo in owners) { report.AddRow("Garson", ownerInfo.UserName, ownerInfo.Amount.ToString(ReportContext.CurrencyFormat)); } //--- var uInfo = ReportContext.Tickets.SelectMany(x => x.Payments).Select(x => x.UserId).Distinct().Select( x => new UserInfo { UserId = x }); if (uInfo.Count() > 1) { foreach (var userInfo in uInfo) { var info = userInfo; var uPayments = ReportContext.Tickets .SelectMany(x => x.Payments) .Where(x => x.UserId == info.UserId) .GroupBy(x => new { x.PaymentType }) .Select(x => new TenderedAmount { PaymentType = x.Key.PaymentType, Amount = x.Sum(y => y.Amount) }); report.AddColumnLength(userInfo.UserName + Resources.Incomes, "40*", "Auto", "35*"); report.AddColumTextAlignment(userInfo.UserName + Resources.Incomes, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable(userInfo.UserName + Resources.Incomes, string.Format(Resources.ReceivedBy_f, userInfo.UserName), "", ""); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.Cash, GetPercent(0, uPayments), GetAmount(0, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.CreditCard, GetPercent(1, uPayments), GetAmount(1, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.Voucher, GetPercent(2, uPayments), GetAmount(2, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.AccountBalance, GetPercent(3, uPayments), GetAmount(3, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.Total, "", uPayments.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } } //--- var menuGroups = MenuGroupBuilder.CalculateMenuGroups(ReportContext.Tickets, ReportContext.MenuItems); report.AddColumTextAlignment("Gıda", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Gıda", "45*", "Auto", "35*"); report.AddTable("Gıda", Resources.ItemSales, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("Gıda", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.Rate), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("Gıda", Resources.Total.ToUpper(), "", menuGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); return report.Document; }
private static void CreateTicketTypeInfo(SimpleReport report, IEnumerable<Ticket> tickets, string header) { var rpKey = "TicketType" + header; report.AddColumTextAlignment(rpKey, TextAlignment.Left, TextAlignment.Right); report.AddTable(rpKey, header, ""); var ticketGropus = tickets .GroupBy(x => new { x.TicketTypeId }) .Select(x => new TicketTypeInfo { TicketTypeId = x.Key.TicketTypeId, TicketCount = x.Count(), Discount = x.Sum(y => y.GetPreTaxServicesTotal()), Amount = x.Sum(y => y.GetSum()) - x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())) - x.Sum(y => y.GetPostTaxServicesTotal()), Tax = x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())), Services = x.Sum(y => y.GetPostTaxServicesTotal()) }).ToList(); if (ticketGropus.Count() > 1) { foreach (var ticketTypeInfo in ticketGropus) { report.AddRow(rpKey, ticketTypeInfo.TicketTypeName, ticketTypeInfo.Amount.ToString(ReportContext.CurrencyFormat)); } } var discountSum = ticketGropus.Sum(x => x.Discount); if (discountSum != 0) { report.AddRow(rpKey, string.Format(Resources.Total_f, header.ToUpper()).ToUpper(), ticketGropus.Sum(x => x.Amount - x.Discount).ToString(ReportContext.CurrencyFormat)); var services = ReportContext.Tickets.SelectMany(x => x.Calculations).Where(x => !x.IncludeTax).OrderBy(x => x.Order); services.GroupBy(x => x.CalculationTypeId).ToList().ForEach( x => { var template = ReportContext.CalculationTypes.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? " " + template.Name : Resources.UndefinedWithBrackets; report.AddRow(rpKey, title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } report.AddRow(rpKey, string.Format(Resources.Total_f, header.ToUpper()).ToUpper(), ticketGropus.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var taxSum = ticketGropus.Sum(x => x.Tax); var serviceSum = ticketGropus.Sum(x => x.Services); if (taxSum != 0 || serviceSum != 0) { if (serviceSum != 0) { var services = ReportContext.Tickets.SelectMany(x => x.Calculations).Where(x => x.IncludeTax).OrderBy(x => x.Order); services.GroupBy(x => x.CalculationTypeId).ToList().ForEach( x => { var template = ReportContext.CalculationTypes.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? " " + template.Name : Resources.UndefinedWithBrackets; report.AddRow(rpKey, title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } if (taxSum != 0) { report.AddRow(rpKey, Resources.SubTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Services).ToString(ReportContext.CurrencyFormat)); if (ReportContext.TaxTemplates.Count() > 1) { foreach (var taxTemplate in ReportContext.TaxTemplates) { if (taxTemplate.AccountTransactionType != null) { var tax = ReportContext.Tickets.Sum(x => x.GetTaxTotal(taxTemplate.AccountTransactionType.Id, x.GetPreTaxServicesTotal(), x.GetPlainSum())); report.AddRow(rpKey, taxTemplate.Name, tax.ToString(ReportContext.CurrencyFormat)); } } } report.AddRow(rpKey, Resources.TaxTotal.ToUpper(), taxSum.ToString(ReportContext.CurrencyFormat)); } report.AddRow(rpKey, Resources.GrandTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Tax + x.Services).ToString(ReportContext.CurrencyFormat)); } }
static void Main(string[] args) { #region Strategy Orcamento orcamento = new Orcamento(); orcamento.Add(new Item("CANETA", 250.0)); orcamento.Add(new Item("LAPIS", 250.0)); IImposto novoImposto = new ICCC(); Console.WriteLine(novoImposto.Calcula(orcamento)); Console.ReadKey(); #endregion #region Chain of Responsibility CalculadorDeDescontos calculador = new CalculadorDeDescontos(); double desconto = calculador.Calcula(orcamento); Console.WriteLine(desconto); Console.ReadKey(); List <Request> requests = new List <Request>(); var xmlRequest = new Request(Format.XML); var csvRequest = new Request(Format.CSV); var percentRequest = new Request(Format.PERCENT); requests.Add(xmlRequest); requests.Add(csvRequest); requests.Add(percentRequest); var account = new Account("Raphael", "3252-2", 17508, 6000.99); var bankRequest = new BankRequester(); requests.ForEach(x => bankRequest.Response(x, account)); Console.ReadKey(); #endregion #region Template Method orcamento = new Orcamento(); orcamento.Add(new Item("CANETA", 250.0)); orcamento.Add(new Item("LAPIS", 250.0)); orcamento.Add(new Item("APAGADOR", 50.0)); orcamento.Add(new Item("BORRACHA", 10.0)); orcamento.Add(new Item("BORRACHA", 10.0)); orcamento.Add(new Item("BORRACHA", 10.0)); ICPP iCPP = new ICPP(); double tax; tax = iCPP.Calcula(orcamento); Console.WriteLine($"Valor do ICPP: {tax} "); IKCV iKCV = new IKCV(); tax = iKCV.Calcula(orcamento); Console.WriteLine($"Valor do IKCV: {tax} "); var iHIT = new IHIT(); tax = iHIT.Calcula(orcamento); Console.WriteLine($"Valor do IHIT: {tax} "); Console.ReadKey(); Bank bank = new Bank() { CorporateName = "Banco do Brasil S/A", Phone = "6666-12345", Address = "Av. Borges de Medeiros, Nº123", Email = "*****@*****.**", Date = DateTime.Now }; account = new Account("Pintado", "3252-2", 17508, 6000.99); IList <Account> accounts = new List <Account>(); accounts.Add(account); account = new Account("Raphael", "1404-5", 52223, 8500); accounts.Add(account); Console.WriteLine("Imprimindo relatório simplificado... "); IReport report = new SimpleReport(); report.Print(accounts, bank); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Imprimindo relatório completo... "); report = new ComplexReport(); report.Print(accounts, bank); Console.ReadKey(); #endregion #region Decorator e Comportamentos Compostos var iss = new ISS(new ICMS(new IKCV())); var imposto = new ImpostoAlto(new ICPP(new IHIT(new IKCV()))); orcamento = new Orcamento(); orcamento.Add(new Item("CANETA", 250.0)); orcamento.Add(new Item("LAPIS", 250.0)); double valor = imposto.Calcula(orcamento); Console.WriteLine($"Imposto Alto: R${valor}"); valor = iss.Calcula(orcamento); Console.WriteLine($"Valor do ISS: R${valor}"); Console.ReadKey(); account = new Account("Pintado", "3252-2", 17508, new DateTime(2015, 05, 07)); account.Deposit(50); accounts = new List <Account>(); accounts.Add(account); account = new Account("Raphael", "1404-5", 52223, new DateTime(2015, 05, 07)); account.Deposit(850000); accounts.Add(account); account = new Account("Teste", "3252-2", 666, 6500); accounts.Add(account); var filter = new CurrentMonthAccounts(new LowBallanceAccounts()); var filteredAccounts = filter.Search(accounts); bank = new Bank() { CorporateName = "Banco do Brasil S/A", Phone = "6666-12345", Address = "Av. Borges de Medeiros, Nº123", Email = "*****@*****.**", Date = DateTime.Now }; report = new ComplexReport(); report.Print(filteredAccounts, bank); Console.ReadKey(); #endregion #region State orcamento = new Orcamento(); orcamento.Add(new Item("Estados do Orçamento", 500)); Console.WriteLine($"Valor do Orçamento: R${orcamento.Valor}"); orcamento.ApplyExtraDiscount(); Console.WriteLine($"Orçamento em aprovação... Desconto extra de R${orcamento.Desconto}"); //orcamento.ApplyExtraDiscount(); teste para não aplicar desconto novamente no estado "Em aprovação" orcamento.Approves(); Console.WriteLine("Orçamento aprovado!"); orcamento.ApplyExtraDiscount(); Console.WriteLine($"Desconto extra de R${orcamento.Desconto}"); orcamento.Finalized(); Console.WriteLine("Orçamento finalizado!"); Console.WriteLine($"Orçamento final de R${orcamento.Valor}"); Console.ReadKey(); account = new Account("Pintado", "3252-2", 17508, 5000); account.CashWithDrawal(6000); Console.WriteLine("Saque Realizado!"); Console.WriteLine($"Nome:{account.Owner}, Saldo R${account.Balance}"); account.CashWithDrawal(2000); account.Deposit(2000); Console.WriteLine("Depósito Realizado!"); Console.WriteLine($"Nome:{account.Owner}, Saldo R${account.Balance}"); account.Deposit(2000); Console.WriteLine("Depósito Realizado!"); Console.WriteLine($"Nome:{account.Owner}, Saldo R${account.Balance}"); Console.ReadKey(); #endregion #region Builder var builder = new InvoiceBuilder(); builder.ToCompany("Alura Design Patterns LTDA.") .AddCnpj("45.429.459/0001-43") .Add(new InvoiceItem("Item 1", 100.0)) .Add(new InvoiceItem("Item 2", 200.0)) .AddObservation("Add some observation"); #region Observer Pattern Console.WriteLine(); Console.WriteLine("Executando ações de Observer pattern..."); builder.AddAction(new EmailSender()) .AddAction(new InvoiceDAO()) .AddAction(new SmsSender()) .AddAction(new Multiplier(5)); Console.WriteLine(); #endregion var nf = builder.Build(); Console.WriteLine(); Console.WriteLine($"Empresa: {nf.CorporateName}"); Console.WriteLine($"CNPJ {nf.Cnpj}"); Console.WriteLine($"Valor da Nota: R${nf.TotalValue}"); Console.WriteLine($"Taxas: R${nf.Taxes}"); Console.WriteLine($"Observações: {nf.Observations}"); Console.ReadKey(); #endregion }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.ItemSalesReport); var menuGroups = MenuGroupBuilder.CalculateMenuGroups(ReportContext.Tickets, ReportContext.MenuItems); report.AddColumTextAlignment("ÜrünGrubu", TextAlignment.Center, TextAlignment.Center, TextAlignment.Center); report.AddColumnLength("ÜrünGrubu", "40*", "Auto", "35*"); report.AddTable("ÜrünGrubu", Resources.SalesByItemGroup, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("ÜrünGrubu", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.Rate), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("ÜrünGrubu", Resources.Total, "", menuGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); //---------------------- report.AddColumTextAlignment("ÜrünGrubuMiktar", TextAlignment.Center, TextAlignment.Center, TextAlignment.Center); report.AddColumnLength("ÜrünGrubuMiktar", "40*", "Auto", "35*"); report.AddTable("ÜrünGrubuMiktar", Resources.QuantitiesByItemGroup, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("ÜrünGrubuMiktar", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.QuantityRate), menuItemInfo.Quantity.ToString("#")); } report.AddRow("ÜrünGrubuMiktar", Resources.Total, "", menuGroups.Sum(x => x.Quantity).ToString("#")); //---------------------- var menuItems = MenuGroupBuilder.CalculateMenuItems(ReportContext.Tickets, ReportContext.MenuItems) .OrderByDescending(x => x.Quantity); report.AddColumTextAlignment("ÜrünTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÜrünTablosu", "50*", "Auto", "25*"); report.AddTable("ÜrünTablosu", Resources.Amount,Resources.Quantity, Resources.MenuItem); foreach (var menuItemInfo in menuItems) { report.AddRow("ÜrünTablosu", menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat), string.Format("{0:0.##}", menuItemInfo.Quantity), menuItemInfo.Name); } report.AddRow("ÜrünTablosu", menuItems.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat),"",Resources.Total); //---------------------- PrepareModificationTable(report, x => x.Voided, Resources.Voids); PrepareModificationTable(report, x => x.Gifted, Resources.Gifts); var discounts = ReportContext.Tickets .SelectMany(x => x.Discounts.Select(y => new { x.TicketNumber, y.UserId, Amount = y.DiscountAmount })) .GroupBy(x => new { x.TicketNumber, x.UserId }).Select(x => new { x.Key.TicketNumber, x.Key.UserId, Amount = x.Sum(y => y.Amount) }); if (discounts.Count() > 0) { report.AddColumTextAlignment("İskontolarTablosu", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("İskontolarTablosu", "20*", "Auto", "35*"); report.AddTable("İskontolarTablosu", Resources.Discounts, "", ""); foreach (var discount in discounts.OrderByDescending(x => x.Amount)) { report.AddRow("İskontolarTablosu", discount.TicketNumber, ReportContext.GetUserName(discount.UserId), discount.Amount.ToString(ReportContext.CurrencyFormat)); } if (discounts.Count() > 1) report.AddRow("İskontolarTablosu", Resources.Total, "", discounts.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } //---------------------- var ticketGroups = ReportContext.Tickets .GroupBy(x => new { x.DepartmentId }) .Select(x => new { x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSumWithoutTax()) }); if (ticketGroups.Count() > 0) { report.AddColumTextAlignment("AdisyonlarTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("AdisyonlarTablosu", "40*", "20*", "40*"); report.AddTable("AdisyonlarTablosu", Resources.Tickets, "", ""); foreach (var ticketGroup in ticketGroups) { report.AddRow("AdisyonlarTablosu", ReportContext.GetDepartmentName(ticketGroup.DepartmentId), ticketGroup.TicketCount.ToString("#.##"), ticketGroup.Amount.ToString(ReportContext.CurrencyFormat)); } if (ticketGroups.Count() > 1) report.AddRow("AdisyonlarTablosu", Resources.Total, ticketGroups.Sum(x => x.TicketCount).ToString("#.##"), ticketGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } //---------------------- var properties = ReportContext.Tickets .SelectMany(x => x.TicketItems.Where(y => y.Properties.Count > 0)) .SelectMany(x => x.Properties.Where(y => y.MenuItemId == 0).Select(y => new { y.Name, x.Quantity })) .GroupBy(x => new { x.Name }) .Select(x => new { x.Key.Name, Quantity = x.Sum(y => y.Quantity) }); if (properties.Count() > 0) { report.AddColumTextAlignment("ÖzelliklerTablosu", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("ÖzelliklerTablosu", "60*", "40*"); report.AddTable("ÖzelliklerTablosu", Resources.Properties, ""); foreach (var property in properties.OrderByDescending(x => x.Quantity)) { report.AddRow("ÖzelliklerTablosu", property.Name, property.Quantity.ToString("#.##")); } } return report.Document; }
protected override FlowDocument GetReport() { var currentPeriod = ReportContext.CurrentWorkPeriod; var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, currentPeriod, Resources.WorkPeriodReport); var ticketGropus = ReportContext.Tickets .GroupBy(x => new { x.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSum()), Tax = x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())), Services = x.Sum(y => y.GetPostTaxServicesTotal()) }).ToList(); //--------------- CreateDepartmentInfo(report, ReportContext.Tickets.Where(x => x.TotalAmount >= 0), Resources.Sales); var refundTickets = ReportContext.Tickets.Where(x => x.TotalAmount < 0).ToList(); if (refundTickets.Any()) CreateDepartmentInfo(report, refundTickets, "Returns"); //--------------- var incomeCalculator = ReportContext.GetIncomeCalculator(); report.AddColumnLength("GelirlerTablosu", "45*", "Auto", "35*"); report.AddColumTextAlignment("GelirlerTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable("GelirlerTablosu", Resources.Incomes, "", ""); foreach (var paymentName in incomeCalculator.PaymentNames) report.AddRow("GelirlerTablosu", paymentName, incomeCalculator.GetPercent(paymentName), incomeCalculator.GetAmount(paymentName).ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.TotalIncome.ToUpper(), "", incomeCalculator.TotalAmount.ToString(ReportContext.CurrencyFormat)); //--------------- var refundCalculator = ReportContext.GetRefundCalculator(); if (refundCalculator.TotalAmount != 0) { report.AddColumnLength("İadeTablosu", "45*", "Auto", "35*"); report.AddColumTextAlignment("İadeTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable("İadeTablosu", "Refunds", "", ""); foreach (var paymentName in refundCalculator.PaymentNames) report.AddRow("İadeTablosu", paymentName, refundCalculator.GetPercent(paymentName), refundCalculator.GetAmount(paymentName).ToString(ReportContext.CurrencyFormat)); report.AddRow("İadeTablosu", "TOTAL REFUND", "", refundCalculator.TotalAmount.ToString(ReportContext.CurrencyFormat)); } //--------------- var propertySum = ReportContext.Tickets .SelectMany(x => x.Orders) .Sum(x => x.GetOrderTagPrice() * x.Quantity); var discounts = Math.Abs(ReportContext.Tickets.Sum(x => x.GetPreTaxServicesTotal())); report.AddColumTextAlignment("Bilgi", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Bilgi", "65*", "35*"); report.AddTable("Bilgi", Resources.GeneralInformation, ""); report.AddRow("Bilgi", Resources.ItemProperties, propertySum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.DiscountsTotal, discounts.ToString(ReportContext.CurrencyFormat)); if (ticketGropus.Count() > 1) { foreach (var departmentInfo in ticketGropus) { report.AddRow("Bilgi", departmentInfo.DepartmentName, departmentInfo.TicketCount.ToString()); } } ReportContext.Tickets .SelectMany(x => x.Orders) .Where(x => !string.IsNullOrEmpty(x.OrderStateGroupName)) .GroupBy(x => x.OrderStateGroupName) .Select(x => new { Name = string.Format(Resources.Total_f, x.Key), Amount = x.Sum(y => y.GetItemValue()) }) .ToList() .ForEach(x => report.AddRow("Bilgi", x.Name, x.Amount.ToString(ReportContext.CurrencyFormat))); var ticketCount = ticketGropus.Sum(x => x.TicketCount); report.AddRow("Bilgi", Resources.TicketCount, ticketCount.ToString()); report.AddRow("Bilgi", Resources.SalesDivTicket, ticketCount > 0 ? (ticketGropus.Sum(x => x.Amount) / ticketGropus.Sum(x => x.TicketCount)).ToString(ReportContext.CurrencyFormat) : "0"); if (ticketGropus.Count() > 1) { foreach (var departmentInfo in ticketGropus) { var dinfo = departmentInfo; var groups = ReportContext.Tickets .Where(x => x.DepartmentId == dinfo.DepartmentId) .SelectMany(x => x.Payments) .GroupBy(x => new { x.Name }) .Select(x => new TenderedAmount { PaymentName = x.Key.Name, Amount = x.Sum(y => y.Amount) }); var departmentAmountCalculator = new AmountCalculator(groups); report.AddColumnLength(departmentInfo.DepartmentName + Resources.Incomes, "40*", "Auto", "35*"); report.AddColumTextAlignment(departmentInfo.DepartmentName + Resources.Incomes, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable(departmentInfo.DepartmentName + Resources.Incomes, string.Format(Resources.Incomes_f, departmentInfo.DepartmentName), "", ""); foreach (var paymentName in departmentAmountCalculator.PaymentNames) { report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, paymentName, departmentAmountCalculator.GetPercent(paymentName), departmentAmountCalculator.GetAmount(paymentName).ToString(ReportContext.CurrencyFormat)); } report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.TotalIncome, "", departmentInfo.Amount.ToString(ReportContext.CurrencyFormat)); var ddiscounts = ReportContext.Tickets .Where(x => x.DepartmentId == dinfo.DepartmentId) .Sum(x => x.GetPreTaxServicesTotal()); ddiscounts = Math.Abs(ddiscounts); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.DiscountsTotal, "", ddiscounts.ToString(ReportContext.CurrencyFormat)); } } //-- if (ReportContext.Tickets.Select(x => x.GetTagData()).Where(x => !string.IsNullOrEmpty(x)).Distinct().Any()) { var dict = new Dictionary<string, List<Ticket>>(); foreach (var ticket in ReportContext.Tickets.Where(x => x.IsTagged)) { foreach (var tag in ticket.GetTicketTagValues().Select(x => x.TagName + ":" + x.TagValue)) { if (!dict.ContainsKey(tag)) dict.Add(tag, new List<Ticket>()); dict[tag].Add(ticket); } } var tagGroups = dict.Select(x => new TicketTagInfo { Amount = x.Value.Sum(y => y.GetPlainSum()), TicketCount = x.Value.Count, TagName = x.Key }).OrderBy(x => x.TagName); var tagGrp = tagGroups.GroupBy(x => x.TagName.Split(':')[0]); report.AddColumTextAlignment("Etiket", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Etiket", "45*", "Auto", "35*"); report.AddTable("Etiket", Resources.TicketTag.ToPlural(), "", ""); foreach (var grp in tagGrp) { var grouping = grp; var tag = ReportContext.TicketTagGroups.SingleOrDefault(x => x.Name == grouping.Key); if (tag == null) continue; report.AddBoldRow("Etiket", grp.Key, "", ""); if (tag.IsDecimal) { var tCount = grp.Sum(x => x.TicketCount); var tSum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); var amnt = grp.Sum(x => x.Amount); var rate = tSum / amnt; report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", tSum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.TicketCount, "", tCount.ToString()); report.AddRow("Etiket", Resources.TicketTotal, "", amnt.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.Rate, "", rate.ToString("%#0.##")); continue; } foreach (var ticketTagInfo in grp) { report.AddRow("Etiket", ticketTagInfo.TagName.Split(':')[1], ticketTagInfo.TicketCount.ToString(), ticketTagInfo.Amount.ToString(ReportContext.CurrencyFormat)); } var totalAmount = grp.Sum(x => x.Amount); report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", totalAmount.ToString(ReportContext.CurrencyFormat)); var sum = 0m; if (tag.IsInteger) { try { sum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", sum.ToString("#,##.##")); } catch (FormatException) { report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", "#Hata!"); } } else { sum = grp.Sum(x => x.TicketCount); } if (sum > 0) { var average = totalAmount / sum; report.AddRow("Etiket", string.Format(Resources.TotalAmountDivTag_f, tag.Name), "", average.ToString(ReportContext.CurrencyFormat)); } } } //---- var owners = ReportContext.Tickets.SelectMany(ticket => ticket.Orders.Where(x => !x.IncreaseInventory).Select(order => new { Ticket = ticket, Order = order })) .GroupBy(x => new { x.Order.CreatingUserName }) .Select(x => new UserInfo { UserName = x.Key.CreatingUserName, Amount = x.Sum(y => MenuGroupBuilder.CalculateOrderTotal(y.Ticket, y.Order)) }); report.AddColumTextAlignment("Garson", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Garson", "65*", "35*"); report.AddTable("Garson", Resources.UserSales, ""); foreach (var ownerInfo in owners) { report.AddRow("Garson", ownerInfo.UserName, ownerInfo.Amount.ToString(ReportContext.CurrencyFormat)); } //---- var refundOwners = ReportContext.Tickets.SelectMany(ticket => ticket.Orders.Where(x => x.IncreaseInventory).Select(order => new { Ticket = ticket, Order = order })) .GroupBy(x => new { x.Order.CreatingUserName }) .Select(x => new UserInfo { UserName = x.Key.CreatingUserName, Amount = x.Sum(y => MenuGroupBuilder.CalculateOrderTotal(y.Ticket, y.Order)) }).ToList(); if (refundOwners.Any()) { report.AddColumTextAlignment("Garsonİade", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Garsonİade", "65*", "35*"); report.AddTable("Garsonİade", "User Returns", ""); foreach (var ownerInfo in refundOwners) { report.AddRow("Garsonİade", ownerInfo.UserName, ownerInfo.Amount.ToString(ReportContext.CurrencyFormat)); } } var menuGroups = MenuGroupBuilder.CalculateMenuGroups(ReportContext.Tickets, ReportContext.MenuItems).ToList(); report.AddColumTextAlignment("Gıda", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Gıda", "45*", "Auto", "35*"); report.AddTable("Gıda", Resources.ItemSales, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("Gıda", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.Rate), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("Gıda", Resources.Total.ToUpper(), "", menuGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); return report.Document; }
public void AddDefaultReportHeader(SimpleReport report, WorkPeriod workPeriod, string caption) { var userInfo = _settingService.ProgramSettings.UserInfo; report.AddHeader(!string.IsNullOrEmpty(userInfo) ? userInfo : "SambaPOS"); report.AddHeader(caption); if (workPeriod.EndDate > workPeriod.StartDate) report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + workPeriod.EndDate.ToString("dd MMMM yyyy HH:mm")); else { report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + DateTime.Now.ToString("dd MMMM yyyy HH:mm")); } }
private void OnPrint(string obj) { var report = new SimpleReport(""); report.AddParagraph("Header"); report.AddParagraphLine("Header", string.Format(_selectedAccountScreen.Name), true); report.AddParagraphLine("Header", ""); report.AddColumnLength("Transactions", "60*", "40*"); report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Right); report.AddTable("Transactions", string.Format(Resources.Name_f, Resources.Account), Resources.Balance); foreach (var ad in Accounts) { report.AddRow("Transactions", ad.Name, ad.BalanceStr); } _printerService.PrintReport(report.Document); }
private static void CreateTicketTypeInfo(SimpleReport report, IEnumerable <Ticket> tickets, string header) { var rpKey = "TicketType" + header; report.AddColumTextAlignment(rpKey, TextAlignment.Left, TextAlignment.Right); report.AddTable(rpKey, header, ""); var ticketGropus = tickets .GroupBy(x => new { x.TicketTypeId }) .Select(x => new TicketTypeInfo { TicketTypeId = x.Key.TicketTypeId, TicketCount = x.Count(), Discount = x.Sum(y => y.GetPreTaxServicesTotal()), Amount = x.Sum(y => y.GetSum()) - x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())) - x.Sum(y => y.GetPostTaxServicesTotal()), Tax = x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())), Services = x.Sum(y => y.GetPostTaxServicesTotal()) }).ToList(); if (ticketGropus.Count() > 1) { foreach (var ticketTypeInfo in ticketGropus) { report.AddRow(rpKey, ticketTypeInfo.TicketTypeName, ticketTypeInfo.Amount.ToString(ReportContext.CurrencyFormat)); } } var discountSum = ticketGropus.Sum(x => x.Discount); if (discountSum != 0) { report.AddRow(rpKey, string.Format(Resources.Total_f, header.ToUpper()).ToUpper(), ticketGropus.Sum(x => x.Amount - x.Discount).ToString(ReportContext.CurrencyFormat)); var services = ReportContext.Tickets.SelectMany(x => x.Calculations).Where(x => !x.IncludeTax).OrderBy(x => x.Order); services.GroupBy(x => x.CalculationTypeId).ToList().ForEach( x => { var template = ReportContext.CalculationTypes.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? " " + template.Name : Resources.UndefinedWithBrackets; report.AddRow(rpKey, title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } report.AddRow(rpKey, string.Format(Resources.Total_f, header.ToUpper()).ToUpper(), ticketGropus.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var taxSum = ticketGropus.Sum(x => x.Tax); var serviceSum = ticketGropus.Sum(x => x.Services); if (taxSum != 0 || serviceSum != 0) { if (serviceSum != 0) { var services = ReportContext.Tickets.SelectMany(x => x.Calculations).Where(x => x.IncludeTax).OrderBy(x => x.Order); services.GroupBy(x => x.CalculationTypeId).ToList().ForEach( x => { var template = ReportContext.CalculationTypes.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? " " + template.Name : Resources.UndefinedWithBrackets; report.AddRow(rpKey, title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } if (taxSum != 0) { report.AddRow(rpKey, Resources.SubTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Services).ToString(ReportContext.CurrencyFormat)); if (ReportContext.TaxTemplates.Count() > 1) { foreach (var taxTemplate in ReportContext.TaxTemplates) { if (taxTemplate.AccountTransactionType != null) { var tax = ReportContext.Tickets.Sum(x => x.GetTaxTotal(taxTemplate.AccountTransactionType.Id, x.GetPreTaxServicesTotal(), x.GetPlainSum())); report.AddRow(rpKey, taxTemplate.Name, tax.ToString(ReportContext.CurrencyFormat)); } } } report.AddRow(rpKey, Resources.TaxTotal.ToUpper(), taxSum.ToString(ReportContext.CurrencyFormat)); } report.AddRow(rpKey, Resources.GrandTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Tax + x.Services).ToString(ReportContext.CurrencyFormat)); } }
protected override FlowDocument GetReport() { var currentPeriod = ReportContext.CurrentWorkPeriod; var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, currentPeriod, Resources.WorkPeriodReport); //--------------- CreateTicketTypeInfo(report, ReportContext.Tickets.Where(x => x.TotalAmount >= 0), Resources.Sales); var refundTickets = ReportContext.Tickets.Where(x => x.TotalAmount < 0).ToList(); if (refundTickets.Any()) { CreateTicketTypeInfo(report, refundTickets, "Returns"); } //--------------- var incomeCalculator = ReportContext.GetIncomeCalculator(); report.AddColumnLength("GelirlerTablosu", "45*", "Auto", "35*"); report.AddColumTextAlignment("GelirlerTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable("GelirlerTablosu", Resources.Incomes, "", ""); foreach (var paymentName in incomeCalculator.PaymentNames) { report.AddRow("GelirlerTablosu", paymentName, incomeCalculator.GetPercent(paymentName), incomeCalculator.GetAmount(paymentName).ToString(ReportContext.CurrencyFormat)); } report.AddRow("GelirlerTablosu", Resources.TotalIncome.ToUpper(), "", incomeCalculator.TotalAmount.ToString(ReportContext.CurrencyFormat)); //--------------- var refundCalculator = ReportContext.GetRefundCalculator(); if (refundCalculator.TotalAmount != 0) { report.AddColumnLength("İadeTablosu", "45*", "Auto", "35*"); report.AddColumTextAlignment("İadeTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable("İadeTablosu", "Refunds", "", ""); foreach (var paymentName in refundCalculator.PaymentNames) { report.AddRow("İadeTablosu", paymentName, refundCalculator.GetPercent(paymentName), refundCalculator.GetAmount(paymentName).ToString(ReportContext.CurrencyFormat)); } report.AddRow("İadeTablosu", "TOTAL REFUND", "", refundCalculator.TotalAmount.ToString(ReportContext.CurrencyFormat)); } //--------------- var ticketGropus = ReportContext.Tickets .GroupBy(x => new { x.TicketTypeId }) .Select(x => new TicketTypeInfo { TicketTypeId = x.Key.TicketTypeId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSum()), Tax = x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())), Services = x.Sum(y => y.GetPostTaxServicesTotal()) }).ToList(); var propertySum = ReportContext.Tickets .SelectMany(x => x.Orders) .Sum(x => x.GetOrderTagPrice() * x.Quantity); var discounts = Math.Abs(ReportContext.Tickets.Sum(x => x.GetPreTaxServicesTotal())); report.AddColumTextAlignment("Bilgi", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Bilgi", "65*", "35*"); report.AddTable("Bilgi", Resources.GeneralInformation, ""); report.AddRow("Bilgi", Resources.ItemProperties, propertySum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.DiscountsTotal, discounts.ToString(ReportContext.CurrencyFormat)); if (ticketGropus.Count() > 1) { foreach (var ticketTypeInfo in ticketGropus) { report.AddRow("Bilgi", ticketTypeInfo.TicketTypeName, ticketTypeInfo.TicketCount.ToString()); } } report.AddBoldRow("Bilgi", Resources.Orders, ""); var orderCount = ReportContext.Tickets.Sum(x => x.Orders.Count); report.AddRow("Bilgi", Resources.OrderCount, orderCount.ToString()); var orderStates = ReportContext.Tickets .SelectMany(x => x.Orders) .SelectMany(x => x.GetOrderStateValues()).Distinct().ToList(); if (orderStates.Any()) { foreach (var orderStateValue in orderStates.Where(x => _cacheService.CanShowStateOnEndOfDayReport(x.StateName, x.State)).OrderBy(x => x.OrderKey).ThenBy(x => x.StateValue)) { var value = orderStateValue; var items = ReportContext.Tickets.SelectMany(x => x.Orders).Where(x => x.IsInState(value.StateName, value.State, value.StateValue)).ToList(); var amount = items.Sum(x => x.GetValue()); var count = items.Count(); report.AddRow("Bilgi", string.Format("{0} {1} ({2})", orderStateValue.State, orderStateValue.StateValue, count), amount.ToString(ReportContext.CurrencyFormat)); } } var ticketStates = ReportContext.Tickets .SelectMany(x => x.GetTicketStateValues()).Distinct().ToList(); report.AddBoldRow("Bilgi", Resources.Tickets, ""); if (ticketStates.Any()) { foreach (var ticketStateValue in ticketStates.Where(x => _cacheService.CanShowStateOnEndOfDayReport(x.StateName, x.State))) { TicketStateValue value = ticketStateValue; var items = ReportContext.Tickets.Where(x => x.IsInState(value.StateName, value.State)).ToList(); var amount = items.Sum(x => x.GetSum()); var count = items.Count(); report.AddRow("Bilgi", string.Format("{0} ({1})", ticketStateValue.State, count), amount.ToString(ReportContext.CurrencyFormat)); } } var ticketCount = ticketGropus.Sum(x => x.TicketCount); report.AddRow("Bilgi", Resources.TicketCount, ticketCount.ToString()); report.AddRow("Bilgi", Resources.SalesDivTicket, ticketCount > 0 ? (ticketGropus.Sum(x => x.Amount) / ticketGropus.Sum(x => x.TicketCount)).ToString(ReportContext.CurrencyFormat) : "0"); if (ticketGropus.Count() > 1) { foreach (var ticketTypeInfo in ticketGropus) { var dinfo = ticketTypeInfo; var groups = ReportContext.Tickets .Where(x => x.TicketTypeId == dinfo.TicketTypeId) .SelectMany(x => x.Payments) .GroupBy(x => new { x.Name }) .Select(x => new TenderedAmount { PaymentName = x.Key.Name, Amount = x.Sum(y => y.Amount) }); var ticketTypeAmountCalculator = new AmountCalculator(groups); report.AddColumnLength(ticketTypeInfo.TicketTypeName + Resources.Incomes, "40*", "Auto", "35*"); report.AddColumTextAlignment(ticketTypeInfo.TicketTypeName + Resources.Incomes, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable(ticketTypeInfo.TicketTypeName + Resources.Incomes, string.Format(Resources.Incomes_f, ticketTypeInfo.TicketTypeName), "", ""); foreach (var paymentName in ticketTypeAmountCalculator.PaymentNames) { report.AddRow(ticketTypeInfo.TicketTypeName + Resources.Incomes, paymentName, ticketTypeAmountCalculator.GetPercent(paymentName), ticketTypeAmountCalculator.GetAmount(paymentName).ToString(ReportContext.CurrencyFormat)); } report.AddRow(ticketTypeInfo.TicketTypeName + Resources.Incomes, Resources.TotalIncome, "", ticketTypeInfo.Amount.ToString(ReportContext.CurrencyFormat)); var ddiscounts = ReportContext.Tickets .Where(x => x.TicketTypeId == dinfo.TicketTypeId) .Sum(x => x.GetPreTaxServicesTotal()); ddiscounts = Math.Abs(ddiscounts); report.AddRow(ticketTypeInfo.TicketTypeName + Resources.Incomes, Resources.DiscountsTotal, "", ddiscounts.ToString(ReportContext.CurrencyFormat)); report.AddRow(ticketTypeInfo.TicketTypeName + Resources.Incomes, Resources.TaxAmount, "", ticketTypeInfo.Tax.ToString(ReportContext.CurrencyFormat)); } } //-- if (ReportContext.Tickets.Select(x => x.GetTagData()).Where(x => !string.IsNullOrEmpty(x)).Distinct().Any()) { var dict = new Dictionary <string, List <Ticket> >(); foreach (var ticket in ReportContext.Tickets.Where(x => x.IsTagged)) { foreach (var tag in ticket.GetTicketTagValues().Select(x => x.TagName + ":" + x.TagValue)) { if (!dict.ContainsKey(tag)) { dict.Add(tag, new List <Ticket>()); } dict[tag].Add(ticket); } } var tagGroups = dict.Select(x => new TicketTagInfo { Amount = x.Value.Sum(y => y.GetPlainSum()), TicketCount = x.Value.Count, TagName = x.Key }).OrderBy(x => x.TagName); var tagGrp = tagGroups.GroupBy(x => x.TagName.Split(':')[0]).ToList(); if (tagGrp.Any()) { report.AddColumTextAlignment("Etiket", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Etiket", "45*", "Auto", "35*"); report.AddTable("Etiket", Resources.TicketTag.ToPlural(), "", ""); } foreach (var grp in tagGrp) { var grouping = grp; var tag = ReportContext.TicketTagGroups.SingleOrDefault(x => x.Name == grouping.Key); if (tag == null) { continue; } report.AddBoldRow("Etiket", grp.Key, "", ""); if (tag.IsDecimal) { var tCount = grp.Sum(x => x.TicketCount); var tSum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); var amnt = grp.Sum(x => x.Amount); var rate = tSum / amnt; report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", tSum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.TicketCount, "", tCount.ToString()); report.AddRow("Etiket", Resources.TicketTotal, "", amnt.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.Rate, "", rate.ToString("%#0.##")); continue; } foreach (var ticketTagInfo in grp) { report.AddRow("Etiket", ticketTagInfo.TagName.Split(':')[1], ticketTagInfo.TicketCount.ToString(), ticketTagInfo.Amount.ToString(ReportContext.CurrencyFormat)); } var totalAmount = grp.Sum(x => x.Amount); report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", totalAmount.ToString(ReportContext.CurrencyFormat)); var sum = 0m; if (tag.IsInteger) { try { sum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", sum.ToString("#,##.##")); } catch (FormatException) { report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", "#Hata!"); } } else { sum = grp.Sum(x => x.TicketCount); } if (sum > 0) { var average = totalAmount / sum; report.AddRow("Etiket", string.Format(Resources.TotalAmountDivTag_f, tag.Name), "", average.ToString(ReportContext.CurrencyFormat)); } } } //---- var owners = ReportContext.Tickets.SelectMany(ticket => ticket.Orders.Where(x => !x.IncreaseInventory).Select(order => new { Ticket = ticket, Order = order })) .GroupBy(x => new { x.Order.CreatingUserName }) .Select(x => new UserInfo { UserName = x.Key.CreatingUserName, Amount = x.Sum(y => MenuGroupBuilder.CalculateOrderTotal(y.Ticket, y.Order)) }).ToList(); if (owners.Any()) { report.AddColumTextAlignment("Garson", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Garson", "65*", "35*"); report.AddTable("Garson", Resources.UserSales, ""); } foreach (var ownerInfo in owners) { report.AddRow("Garson", ownerInfo.UserName, ownerInfo.Amount.ToString(ReportContext.CurrencyFormat)); } //---- var refundOwners = ReportContext.Tickets.SelectMany(ticket => ticket.Orders.Where(x => x.IncreaseInventory).Select(order => new { Ticket = ticket, Order = order })) .GroupBy(x => new { x.Order.CreatingUserName }) .Select(x => new UserInfo { UserName = x.Key.CreatingUserName, Amount = x.Sum(y => MenuGroupBuilder.CalculateOrderTotal(y.Ticket, y.Order)) }).ToList(); if (refundOwners.Any()) { report.AddColumTextAlignment("Garsonİade", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Garsonİade", "65*", "35*"); report.AddTable("Garsonİade", "User Returns", ""); foreach (var ownerInfo in refundOwners) { report.AddRow("Garsonİade", ownerInfo.UserName, ownerInfo.Amount.ToString(ReportContext.CurrencyFormat)); } } var uInfo = ReportContext.Tickets.SelectMany(x => x.Payments).Select(x => x.UserId).Distinct().Select(x => new UserInfo { UserId = x, UserName = ReportContext.GetUserName(x) }).ToList(); if (uInfo.Count() > 1) { foreach (var userInfo in uInfo) { var userIncomeCalculator = ReportContext.GetIncomeCalculatorByUser(userInfo.UserId); report.AddColumnLength(userInfo.UserName + Resources.Incomes, "40*", "Auto", "35*"); report.AddColumTextAlignment(userInfo.UserName + Resources.Incomes, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable(userInfo.UserName + Resources.Incomes, string.Format(Resources.SettledBy_f, userInfo.UserName), "", ""); foreach (var paymentName in userIncomeCalculator.PaymentNames) { report.AddRow(userInfo.UserName + Resources.Incomes, paymentName, userIncomeCalculator.GetPercent(paymentName), userIncomeCalculator.GetAmount(paymentName).ToString(ReportContext.CurrencyFormat)); } report.AddRow(userInfo.UserName + Resources.Incomes, Resources.TotalIncome.ToUpper(), "", userIncomeCalculator.TotalAmount.ToString(ReportContext.CurrencyFormat)); } } var menuGroups = MenuGroupBuilder.CalculateMenuGroups(ReportContext.Tickets, ReportContext.MenuItems).ToList(); report.AddColumTextAlignment("Gıda", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Gıda", "45*", "Auto", "35*"); report.AddTable("Gıda", Resources.ItemSales, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("Gıda", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.Rate), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("Gıda", Resources.Total.ToUpper(), "", menuGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); return(report.Document); }
private void mi_SimplePrint_Click(object sender, RoutedEventArgs e) { SimpleReport r = new SimpleReport(); r.ShowDialog(); }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.CashReport); if (ReportContext.CurrentWorkPeriod.Id == 0) { report.AddHeader(" "); report.AddHeader(Resources.DateRangeIsNotActiveWorkPeriod); report.AddHeader(Resources.ReportDoesNotContainsCashState); } var cashExpenseTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Cash && x.TransactionType == (int)TransactionType.Expense) .Sum(x => x.Amount); var creditCardExpenseTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.CreditCard && x.TransactionType == (int)TransactionType.Expense) .Sum(x => x.Amount); var ticketExpenseTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Ticket && x.TransactionType == (int)TransactionType.Expense) .Sum(x => x.Amount); var cashIncomeTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Cash && x.TransactionType == (int)TransactionType.Income) .Sum(x => x.Amount); var ticketIncomeTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Ticket && x.TransactionType == (int)TransactionType.Income) .Sum(x => x.Amount); var creditCardIncomeTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.CreditCard && x.TransactionType == (int)TransactionType.Income) .Sum(x => x.Amount); var expenseTransactions = ReportContext.CashTransactions.Where(x => x.TransactionType == (int)TransactionType.Expense); if (expenseTransactions.Count() > 0) { report.AddColumTextAlignment("Gider", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Gider", "15*", "Auto", "25*"); report.AddTable("Gider", Resources.Expenses, "", ""); report.AddBoldRow("Gider", Resources.CashTransactions.ToUpper(), "", ""); foreach (var cashTransaction in expenseTransactions) { report.AddRow("Gider", GetPaymentString(cashTransaction.PaymentType), Fct(cashTransaction), Fs(cashTransaction.Amount)); } report.AddBoldRow("Gider", Resources.Totals.ToUpper(), "", ""); report.AddRow("Gider", GetPaymentString(0), Resources.TotalExpense, Fs(cashExpenseTotal)); report.AddRow("Gider", GetPaymentString(1), Resources.TotalExpense, Fs(creditCardExpenseTotal)); report.AddRow("Gider", GetPaymentString(2), Resources.TotalExpense, Fs(ticketExpenseTotal)); report.AddRow("Gider", Resources.GrandTotal.ToUpper(), "", Fs(cashExpenseTotal + creditCardExpenseTotal + ticketExpenseTotal)); } var ac = ReportContext.GetOperationalAmountCalculator(); report.AddColumTextAlignment("Gelir", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Gelir", "15*", "Auto", "25*"); report.AddTable("Gelir", Resources.Incomes, "", ""); if (ReportContext.CurrentWorkPeriod.Id > 0) //devreden rakamları aktif çalışma dönemlerinden biri seçildiyse çalışır { var total = ReportContext.CurrentWorkPeriod.CashAmount + ReportContext.CurrentWorkPeriod.CreditCardAmount + ReportContext.CurrentWorkPeriod.TicketAmount; if (total > 0) { report.AddBoldRow("Gelir", Resources.StartAmount.ToUpper(), "", ""); if (ReportContext.CurrentWorkPeriod.CashAmount > 0) { report.AddRow("Gelir", GetPaymentString(0) + " " + Resources.StartAmount, "", Fs(ReportContext.CurrentWorkPeriod.CashAmount)); } if (ReportContext.CurrentWorkPeriod.CreditCardAmount > 0) { report.AddRow("Gelir", GetPaymentString(1) + " " + Resources.StartAmount, "", Fs(ReportContext.CurrentWorkPeriod.CreditCardAmount)); } if (ReportContext.CurrentWorkPeriod.TicketAmount > 0) { report.AddRow("Gelir", GetPaymentString(2) + " " + Resources.StartAmount, "", Fs(ReportContext.CurrentWorkPeriod.TicketAmount)); } report.AddRow("Gelir", Resources.Total.ToUpper(), "", Fs(total)); } } var incomeTransactions = ReportContext.CashTransactions.Where(x => x.TransactionType == (int)TransactionType.Income); if (incomeTransactions.Count() > 0) { report.AddBoldRow("Gelir", Resources.SalesIncome.ToUpper(), "", ""); if (ac.CashTotal > 0) { report.AddRow("Gelir", GetPaymentString(0) + " " + Resources.SalesIncome, "", Fs(ac.CashTotal)); } if (ac.CreditCardTotal > 0) { report.AddRow("Gelir", GetPaymentString(1) + " " + Resources.SalesIncome, "", Fs(ac.CreditCardTotal)); } if (ac.TicketTotal > 0) { report.AddRow("Gelir", GetPaymentString(2) + " " + Resources.SalesIncome, "", Fs(ac.TicketTotal)); } report.AddRow("Gelir", Resources.Total.ToUpper(), "", Fs(ac.CashTotal + ac.CreditCardTotal + ac.TicketTotal)); report.AddBoldRow("Gelir", Resources.CashTransactions.ToUpper(), "", ""); var it = 0m; foreach (var cashTransaction in incomeTransactions) { it += cashTransaction.Amount; report.AddRow("Gelir", GetPaymentString(cashTransaction.PaymentType), Fct(cashTransaction), Fs(cashTransaction.Amount)); } report.AddRow("Gelir", Resources.Total.ToUpper(), "", Fs(it)); } var totalCashIncome = cashIncomeTotal + ac.CashTotal + ReportContext.CurrentWorkPeriod.CashAmount; var totalCreditCardIncome = creditCardIncomeTotal + ac.CreditCardTotal + ReportContext.CurrentWorkPeriod.CreditCardAmount; var totalTicketIncome = ticketIncomeTotal + ac.TicketTotal + ReportContext.CurrentWorkPeriod.TicketAmount; report.AddBoldRow("Gelir", Resources.Income.ToUpper() + " " + Resources.Totals.ToUpper(), "", ""); report.AddRow("Gelir", GetPaymentString(0), Resources.TotalIncome, Fs(totalCashIncome)); report.AddRow("Gelir", GetPaymentString(1), Resources.TotalIncome, Fs(totalCreditCardIncome)); report.AddRow("Gelir", GetPaymentString(2), Resources.TotalIncome, Fs(totalTicketIncome)); report.AddRow("Gelir", Resources.GrandTotal.ToUpper(), "", Fs(totalCashIncome + totalCreditCardIncome + totalTicketIncome)); //-------------------- report.AddColumTextAlignment("Toplam", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Toplam", "Auto", "25*"); report.AddTable("Toplam", Resources.CashStatus, ""); report.AddRow("Toplam", Resources.Cash, Fs(totalCashIncome - cashExpenseTotal)); report.AddRow("Toplam", Resources.CreditCard, Fs(totalCreditCardIncome - creditCardExpenseTotal)); report.AddRow("Toplam", Resources.Voucher, Fs(totalTicketIncome - ticketExpenseTotal)); report.AddRow("Toplam", Resources.GrandTotal.ToUpper(), Fs((totalCashIncome - cashExpenseTotal) + (totalCreditCardIncome - creditCardExpenseTotal) + (totalTicketIncome - ticketExpenseTotal))); return(report.Document); }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.ItemSalesReport); var menuGroups = MenuGroupBuilder.CalculateMenuGroups(ReportContext.Tickets, ReportContext.MenuItems); report.AddColumTextAlignment("ÜrünGrubu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÜrünGrubu", "40*", "Auto", "35*"); report.AddTable("ÜrünGrubu", Resources.SalesByItemGroup, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("ÜrünGrubu", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.Rate), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("ÜrünGrubu", Resources.Total, "", menuGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); //---------------------- report.AddColumTextAlignment("ÜrünGrubuMiktar", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÜrünGrubuMiktar", "40*", "Auto", "35*"); report.AddTable("ÜrünGrubuMiktar", Resources.QuantitiesByItemGroup, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("ÜrünGrubuMiktar", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.QuantityRate), menuItemInfo.Quantity.ToString("#")); } report.AddRow("ÜrünGrubuMiktar", Resources.Total, "", menuGroups.Sum(x => x.Quantity).ToString("#")); //---------------------- var menuItems = MenuGroupBuilder.CalculateMenuItems(ReportContext.Tickets, ReportContext.MenuItems) .OrderByDescending(x => x.Quantity); report.AddColumTextAlignment("ÜrünTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÜrünTablosu", "50*", "Auto", "25*"); report.AddTable("ÜrünTablosu", Resources.MenuItem, Resources.Quantity, Resources.Amount); foreach (var menuItemInfo in menuItems) { report.AddRow("ÜrünTablosu", menuItemInfo.Name, string.Format("{0:0.##}", menuItemInfo.Quantity), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("ÜrünTablosu", Resources.Total, "", menuItems.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); //---------------------- PrepareModificationTable(report, x => x.Voided, Resources.Voids); PrepareModificationTable(report, x => x.Gifted, Resources.Gifts); var discounts = ReportContext.Tickets .SelectMany(x => x.Discounts.Select(y => new { x.TicketNumber, y.UserId, Amount = y.DiscountAmount })) .GroupBy(x => new { x.TicketNumber, x.UserId }).Select(x => new { x.Key.TicketNumber, x.Key.UserId, Amount = x.Sum(y => y.Amount) }); if (discounts.Count() > 0) { report.AddColumTextAlignment("İskontolarTablosu", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("İskontolarTablosu", "20*", "Auto", "35*"); report.AddTable("İskontolarTablosu", Resources.Discounts, "", ""); foreach (var discount in discounts.OrderByDescending(x => x.Amount)) { report.AddRow("İskontolarTablosu", discount.TicketNumber, ReportContext.GetUserName(discount.UserId), discount.Amount.ToString(ReportContext.CurrencyFormat)); } if (discounts.Count() > 1) { report.AddRow("İskontolarTablosu", Resources.Total, "", discounts.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } } //---------------------- var ticketGroups = ReportContext.Tickets .GroupBy(x => new { x.DepartmentId }) .Select(x => new { x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSumWithoutTax()) }); if (ticketGroups.Count() > 0) { report.AddColumTextAlignment("AdisyonlarTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("AdisyonlarTablosu", "40*", "20*", "40*"); report.AddTable("AdisyonlarTablosu", Resources.Tickets, "", ""); foreach (var ticketGroup in ticketGroups) { report.AddRow("AdisyonlarTablosu", ReportContext.GetDepartmentName(ticketGroup.DepartmentId), ticketGroup.TicketCount.ToString("#.##"), ticketGroup.Amount.ToString(ReportContext.CurrencyFormat)); } if (ticketGroups.Count() > 1) { report.AddRow("AdisyonlarTablosu", Resources.Total, ticketGroups.Sum(x => x.TicketCount).ToString("#.##"), ticketGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } } //---------------------- var properties = ReportContext.Tickets .SelectMany(x => x.TicketItems.Where(y => y.Properties.Count > 0)) .SelectMany(x => x.Properties.Where(y => y.MenuItemId == 0).Select(y => new { y.Name, x.Quantity })) .GroupBy(x => new { x.Name }) .Select(x => new { x.Key.Name, Quantity = x.Sum(y => y.Quantity) }); if (properties.Count() > 0) { report.AddColumTextAlignment("ÖzelliklerTablosu", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("ÖzelliklerTablosu", "60*", "40*"); report.AddTable("ÖzelliklerTablosu", Resources.Properties, ""); foreach (var property in properties.OrderByDescending(x => x.Quantity)) { report.AddRow("ÖzelliklerTablosu", property.Name, property.Quantity.ToString("#.##")); } } return(report.Document); }
public void AddDefaultReportHeader(SimpleReport report, WorkPeriod workPeriod, string caption) { report.AddHeader("Vero"); report.AddHeader(caption); if (workPeriod.EndDate > workPeriod.StartDate) report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + workPeriod.EndDate.ToString("dd MMMM yyyy HH:mm")); else { report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + DateTime.Now.ToString("dd MMMM yyyy HH:mm")); } if (!string.IsNullOrEmpty(workPeriod.Description)) report.AddHeader(workPeriod.Description); }
private static void DisplayGeneratorExamples() { bool exitToProducts = false; while (!exitToProducts) { Console.WriteLine("Select a DynamicPDF Generator for .NET example to run:"); Console.WriteLine(" A : Hello World"); Console.WriteLine(" B : All Page Elements"); Console.WriteLine(" C : Calender"); Console.WriteLine(" D : Charting"); Console.WriteLine(" E : Contact List"); Console.WriteLine(" F : AES 256 Bit Encryption"); Console.WriteLine(" G : RC4 128 Bit Encryption"); Console.WriteLine(" H : Hello World Languages"); Console.WriteLine(" I : Tagged Pdf"); Console.WriteLine(" J : HTML Tags"); Console.WriteLine(" K : HTML Tags With Styles"); Console.WriteLine(" L : HTML Layout"); Console.WriteLine(" M : Image With Alternate Text"); Console.WriteLine(" N : Mailing Labels"); Console.WriteLine(" O : Package PDF"); Console.WriteLine(" P : Simple Report"); Console.WriteLine(" Q : Simple XML Report"); Console.WriteLine(" R : Table Report"); Console.WriteLine(" S : Tagged PDF With Structure Elements"); Console.WriteLine(" T : Tiff To PDF"); Console.WriteLine(" U : Time Machine"); Console.WriteLine(" V : Time Machine Tagged PDF"); Console.WriteLine(" W : Watermark"); Console.WriteLine(" X : Invoice"); Console.WriteLine(" Y : USEnvelope"); Console.WriteLine(); Console.WriteLine("Press 'Backspace' for the main products menu"); Console.WriteLine("Press 'Esc' to exit application"); Console.WriteLine(); ConsoleKeyInfo runKey = Console.ReadKey(); Console.WriteLine(); string exampleName = string.Empty; string fileName = string.Empty; switch (runKey.Key) { case ConsoleKey.A: exampleName = "Hello World"; fileName = "HelloWorld.pdf"; Console.WriteLine(exampleName + " example is running..."); HelloWorld.Run(fileName); break; case ConsoleKey.B: exampleName = "All Page Elements"; fileName = "AllPageElements.pdf"; Console.WriteLine(exampleName + " example is running..."); AllPageElements.Run(fileName); break; case ConsoleKey.C: exampleName = "Calender"; fileName = "Calender.pdf"; Console.WriteLine(exampleName + " example is running..."); Calender.Run(fileName); break; case ConsoleKey.D: exampleName = "Charting"; fileName = "Charting.pdf"; Console.WriteLine(exampleName + " example is running..."); Charting.Run(fileName); break; case ConsoleKey.E: exampleName = "Contact List"; fileName = "ContactList.pdf"; Console.WriteLine(exampleName + " example is running..."); ContactList.Run(fileName); break; case ConsoleKey.F: Console.Clear(); exampleName = "AES 256 Bit Encryption"; fileName = "Aes256BitEncryption.pdf"; Console.WriteLine(exampleName + " example is running..."); Aes256BitEncryption.Run(fileName); break; case ConsoleKey.G: exampleName = "RC4 128 Bit Encryption"; fileName = "RC4128BitEncryption.pdf"; Console.WriteLine(exampleName + " example is running..."); RC4128BitEncryption.Run(fileName); break; case ConsoleKey.H: exampleName = "Hello World Languages"; fileName = "HelloWorldLanguages.pdf"; Console.WriteLine(exampleName + " example is running..."); HelloWorldLanguages.Run(fileName); break; case ConsoleKey.I: exampleName = "Tagged PDF"; fileName = "TaggedPdf.pdf"; Console.WriteLine(exampleName + " example is running..."); TaggedPdf.Run(fileName); break; case ConsoleKey.J: exampleName = "HTML Tags"; fileName = "HtmlTags.pdf"; Console.WriteLine(exampleName + " example is running..."); HtmlAreaPDF.Run_WithHtmlTags(fileName); break; case ConsoleKey.K: exampleName = "HTML Tags With Styles"; fileName = "HtmlTagsWithStyles.pdf"; Console.WriteLine(exampleName + " example is running..."); HtmlAreaPDF.Run_WithHtmlTagsAndStyles(fileName); break; case ConsoleKey.L: exampleName = "HTML Layout"; fileName = "HtmlLayout.pdf"; Console.WriteLine(exampleName + " example is running..."); HtmlLayoutPDF.Run(fileName); break; case ConsoleKey.M: exampleName = "Image With Alternate Text"; fileName = "ImageWithAltText.pdf"; Console.WriteLine(exampleName + " example is running..."); AltTextImage.Run(fileName); break; case ConsoleKey.N: exampleName = "Mailing Labels"; fileName = "MailingLabels.pdf"; Console.WriteLine(exampleName + " example is running..."); MailingLabels.Run(fileName); break; case ConsoleKey.O: exampleName = "Package PDF"; fileName = "PackagePdf.pdf"; Console.WriteLine(exampleName + " example is running..."); PackagePdf.Run(fileName); break; case ConsoleKey.P: exampleName = "Simple Report"; fileName = "SimpleReport.pdf"; Console.WriteLine(exampleName + " example is running..."); SimpleReport.Run(fileName); break; case ConsoleKey.Q: exampleName = "Simple XML Report"; fileName = "SimpleXmlReport.pdf"; Console.WriteLine(exampleName + " example is running..."); SimpleXMLReport.Run(fileName); break; case ConsoleKey.R: exampleName = "Table Report"; fileName = "TableReport.pdf"; Console.WriteLine(exampleName + " example is running..."); TableReport.Run(fileName); break; case ConsoleKey.S: exampleName = "Tagged PDF With Structure Elements"; fileName = "TaggedPdfWithStructureElements.pdf"; Console.WriteLine(exampleName + " example is running..."); TaggedPdfWithStructureElements.Run(fileName); break; case ConsoleKey.T: exampleName = "Tiff To PDF"; fileName = "TiffToPdf.pdf"; Console.WriteLine(exampleName + " example is running..."); TiffToPdf.Run(fileName); break; case ConsoleKey.U: exampleName = "Time Machine"; fileName = "TimeMachine.pdf"; Console.WriteLine(exampleName + " example is running..."); TimeMachine.Run(fileName); break; case ConsoleKey.V: exampleName = "Time Machine Tagged PDF"; fileName = "TimeMachineTaggedPdf.pdf"; Console.WriteLine(exampleName + " example is running..."); TimeMachineTaggedPdf.Run(fileName); break; case ConsoleKey.W: exampleName = "Watermark"; fileName = "Watermark.pdf"; Console.WriteLine(exampleName + " example is running..."); Watermark.Run(fileName); break; case ConsoleKey.X: exampleName = "Invoice"; fileName = "Invoice.pdf"; Console.WriteLine("Please enter the invoice number(s) to include. Use a comma ',' to seperate multiple entries (Ex: 10248,10249,10250):"); Console.WriteLine(); Console.WriteLine("10248"); Console.WriteLine("10249"); Console.WriteLine("10250"); Console.WriteLine("10251"); Console.WriteLine("10252"); Console.WriteLine("10360"); Console.WriteLine("10979"); Console.WriteLine("11077"); Console.WriteLine(); string invoiceNumbers = Console.ReadLine(); Console.WriteLine(exampleName + " example is running..."); byte[] pdf = GeneratorInvoice.Run(invoiceNumbers.Split(',')); File.WriteAllBytes(fileName, pdf); break; case ConsoleKey.Y: exampleName = "USEnvelope"; fileName = "USEnvelope.pdf"; Console.WriteLine(exampleName + " example is running..."); USEnvelope.Run(fileName); break; case ConsoleKey.Escape: System.Environment.Exit(0); break; case ConsoleKey.Backspace: exitToProducts = true; break; default: Console.WriteLine(); Console.WriteLine("Key not recognized."); break; } if (fileName != string.Empty) { DisplayOutputPathWithOptionToOpen(fileName); } } }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.CashReport); if (ReportContext.CurrentWorkPeriod.Id == 0) { report.AddHeader(" "); report.AddHeader(Resources.DateRangeIsNotActiveWorkPeriod); report.AddHeader(Resources.ReportDoesNotContainsCashState); } var cashExpenseTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Cash && x.TransactionType == (int)TransactionType.Expense) .Sum(x => x.Amount); var creditCardExpenseTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.CreditCard && x.TransactionType == (int)TransactionType.Expense) .Sum(x => x.Amount); var ticketExpenseTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Ticket && x.TransactionType == (int)TransactionType.Expense) .Sum(x => x.Amount); var cashIncomeTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Cash && x.TransactionType == (int)TransactionType.Income) .Sum(x => x.Amount); var ticketIncomeTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.Ticket && x.TransactionType == (int)TransactionType.Income) .Sum(x => x.Amount); var creditCardIncomeTotal = ReportContext.CashTransactions .Where(x => x.PaymentType == (int)PaymentType.CreditCard && x.TransactionType == (int)TransactionType.Income) .Sum(x => x.Amount); var expenseTransactions = ReportContext.CashTransactions.Where(x => x.TransactionType == (int)TransactionType.Expense); if (expenseTransactions.Count() > 0) { report.AddColumTextAlignment("Gider", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Gider", "15*", "Auto", "25*"); report.AddTable("Gider", Resources.Expenses, "", ""); report.AddBoldRow("Gider", Resources.CashTransactions.ToUpper(), "", ""); foreach (var cashTransaction in expenseTransactions) { report.AddRow("Gider", GetPaymentString(cashTransaction.PaymentType), Fct(cashTransaction), Fs(cashTransaction.Amount)); } report.AddBoldRow("Gider", Resources.Totals.ToUpper(), "", ""); report.AddRow("Gider", GetPaymentString(0), Resources.TotalExpense, Fs(cashExpenseTotal)); report.AddRow("Gider", GetPaymentString(1), Resources.TotalExpense, Fs(creditCardExpenseTotal)); report.AddRow("Gider", GetPaymentString(2), Resources.TotalExpense, Fs(ticketExpenseTotal)); report.AddRow("Gider", Resources.GrandTotal.ToUpper(), "", Fs(cashExpenseTotal + creditCardExpenseTotal + ticketExpenseTotal)); } var ac = ReportContext.GetOperationalAmountCalculator(); report.AddColumTextAlignment("Gelir", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Gelir", "15*", "Auto", "25*"); report.AddTable("Gelir", Resources.Incomes, "", ""); if (ReportContext.CurrentWorkPeriod.Id > 0) //devreden rakamları aktif çalışma dönemlerinden biri seçildiyse çalışır { var total = ReportContext.CurrentWorkPeriod.CashAmount + ReportContext.CurrentWorkPeriod.CreditCardAmount + ReportContext.CurrentWorkPeriod.TicketAmount; if (total > 0) { report.AddBoldRow("Gelir", Resources.StartAmount.ToUpper(), "", ""); if (ReportContext.CurrentWorkPeriod.CashAmount > 0) report.AddRow("Gelir", GetPaymentString(0) + " " + Resources.StartAmount, "", Fs(ReportContext.CurrentWorkPeriod.CashAmount)); if (ReportContext.CurrentWorkPeriod.CreditCardAmount > 0) report.AddRow("Gelir", GetPaymentString(1) + " " + Resources.StartAmount, "", Fs(ReportContext.CurrentWorkPeriod.CreditCardAmount)); if (ReportContext.CurrentWorkPeriod.TicketAmount > 0) report.AddRow("Gelir", GetPaymentString(2) + " " + Resources.StartAmount, "", Fs(ReportContext.CurrentWorkPeriod.TicketAmount)); report.AddRow("Gelir", Resources.Total.ToUpper(), "", Fs(total)); } } var incomeTransactions = ReportContext.CashTransactions.Where(x => x.TransactionType == (int)TransactionType.Income); if (incomeTransactions.Count() > 0) { report.AddBoldRow("Gelir", Resources.SalesIncome.ToUpper(), "", ""); if (ac.CashTotal > 0) report.AddRow("Gelir", GetPaymentString(0) + " " + Resources.SalesIncome, "", Fs(ac.CashTotal)); if (ac.CreditCardTotal > 0) report.AddRow("Gelir", GetPaymentString(1) + " " + Resources.SalesIncome, "", Fs(ac.CreditCardTotal)); if (ac.TicketTotal > 0) report.AddRow("Gelir", GetPaymentString(2) + " " + Resources.SalesIncome, "", Fs(ac.TicketTotal)); report.AddRow("Gelir", Resources.Total.ToUpper(), "", Fs(ac.CashTotal + ac.CreditCardTotal + ac.TicketTotal)); report.AddBoldRow("Gelir", Resources.CashTransactions.ToUpper(), "", ""); var it = 0m; foreach (var cashTransaction in incomeTransactions) { it += cashTransaction.Amount; report.AddRow("Gelir", GetPaymentString(cashTransaction.PaymentType), Fct(cashTransaction), Fs(cashTransaction.Amount)); } report.AddRow("Gelir", Resources.Total.ToUpper(), "", Fs(it)); } var totalCashIncome = cashIncomeTotal + ac.CashTotal + ReportContext.CurrentWorkPeriod.CashAmount; var totalCreditCardIncome = creditCardIncomeTotal + ac.CreditCardTotal + ReportContext.CurrentWorkPeriod.CreditCardAmount; var totalTicketIncome = ticketIncomeTotal + ac.TicketTotal + ReportContext.CurrentWorkPeriod.TicketAmount; report.AddBoldRow("Gelir", Resources.Income.ToUpper() + " " + Resources.Totals.ToUpper(), "", ""); report.AddRow("Gelir", GetPaymentString(0), Resources.TotalIncome, Fs(totalCashIncome)); report.AddRow("Gelir", GetPaymentString(1), Resources.TotalIncome, Fs(totalCreditCardIncome)); report.AddRow("Gelir", GetPaymentString(2), Resources.TotalIncome, Fs(totalTicketIncome)); report.AddRow("Gelir", Resources.GrandTotal.ToUpper(), "", Fs(totalCashIncome + totalCreditCardIncome + totalTicketIncome)); //-------------------- report.AddColumTextAlignment("Toplam", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Toplam", "Auto", "25*"); report.AddTable("Toplam", Resources.CashStatus, ""); report.AddRow("Toplam", Resources.Cash, Fs(totalCashIncome - cashExpenseTotal)); report.AddRow("Toplam", Resources.CreditCard, Fs(totalCreditCardIncome - creditCardExpenseTotal)); report.AddRow("Toplam", Resources.Voucher, Fs(totalTicketIncome - ticketExpenseTotal)); report.AddRow("Toplam", Resources.GrandTotal.ToUpper(), Fs((totalCashIncome - cashExpenseTotal) + (totalCreditCardIncome - creditCardExpenseTotal) + (totalTicketIncome - ticketExpenseTotal))); return report.Document; }
protected override FlowDocument GetReport() { var currentPeriod = ReportContext.CurrentWorkPeriod; var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, currentPeriod, Resources.WorkPeriodReport); //--------------- report.AddColumTextAlignment("Departman", TextAlignment.Left, TextAlignment.Right); report.AddTable("Departman", Resources.Sales, ""); var ticketGropus = ReportContext.Tickets .GroupBy(x => new { x.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSumWithoutTax()), Vat = x.Sum(y => y.CalculateTax()), TaxServices = x.Sum(y => y.GetTaxServicesTotal()) }); report.AddRow("Departman", Resources.TotalSales.ToUpper(), ticketGropus.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var vatSum = ticketGropus.Sum(x => x.Vat); var serviceSum = ticketGropus.Sum(x => x.TaxServices); if (vatSum > 0 || serviceSum > 0) { if (vatSum > 0) { report.AddRow("Departman", Resources.VatTotal.ToUpper(), vatSum.ToString(ReportContext.CurrencyFormat)); } if (serviceSum > 0) { ReportContext.Tickets.SelectMany(x => x.TaxServices).GroupBy(x => x.TaxServiceId).ForEach( x => { var template = ReportContext.TaxServiceTemplates.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? template.Name : Resources.UndefinedWithBrackets; report.AddRow("Departman", title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } report.AddRow("Departman", Resources.GrandTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Vat + x.TaxServices).ToString(ReportContext.CurrencyFormat)); } //--------------- if (ReportContext.Departments.Count() > 1) { var showDepartmentTotals = false; report.AddColumnLength("CrossSales", "65*", "40*"); report.AddColumTextAlignment("CrossSales", TextAlignment.Left, TextAlignment.Right); report.AddTable("CrossSales", Resources.DepartmentSales, ""); foreach (var departmentInfo in ticketGropus) { var info = departmentInfo; var crossSales = ReportContext.Tickets.Where(x => x.DepartmentId == info.DepartmentId) .SelectMany(ticket => ticket.TicketItems.Select(ticketItem => new { Ticket = ticket, TicketItem = ticketItem })) .Where(x => x.TicketItem.DepartmentId != x.Ticket.DepartmentId) .GroupBy(x => new { x.TicketItem.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, Amount = x.Sum(y => MenuGroupBuilder.CalculateTicketItemTotal(y.Ticket, y.TicketItem)) }); report.AddRow("CrossSales", string.Format("{0} {1}", departmentInfo.DepartmentName, Resources.Sales), (departmentInfo.Amount).ToString(ReportContext.CurrencyFormat)); if (crossSales.Count() > 0) { showDepartmentTotals = true; report.AddRow("CrossSales", " -" + departmentInfo.DepartmentName, (departmentInfo.Amount - crossSales.Sum(x => x.Amount)).ToString(ReportContext.CurrencyFormat)); foreach (var crossSale in crossSales) { var cs = crossSale; report.AddRow("CrossSales", " -" + cs.DepartmentName, cs.Amount.ToString(ReportContext.CurrencyFormat)); } } } if (showDepartmentTotals) { report.AddBoldRow("CrossSales", Resources.Department + " " + Resources.Totals, ""); var salesByOrder = ReportContext.Tickets.SelectMany(ticket => ticket.TicketItems.Select(ticketItem => new { Ticket = ticket, TicketItem = ticketItem })) .GroupBy(x => new { x.TicketItem.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, Amount = x.Sum(y => MenuGroupBuilder.CalculateTicketItemTotal(y.Ticket, y.TicketItem)) }); foreach (var sale in salesByOrder) { var cs = sale; report.AddRow("CrossSales", cs.DepartmentName, cs.Amount.ToString(ReportContext.CurrencyFormat)); } } } //--------------- var ac = ReportContext.GetOperationalAmountCalculator(); report.AddColumnLength("GelirlerTablosu", "45*", "Auto", "35*"); report.AddColumTextAlignment("GelirlerTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable("GelirlerTablosu", Resources.Incomes, "", ""); report.AddRow("GelirlerTablosu", Resources.Cash, ac.CashPercent, ac.CashTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.CreditCard, ac.CreditCardPercent, ac.CreditCardTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.Voucher, ac.TicketPercent, ac.TicketTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.AccountBalance, ac.AccountPercent, ac.AccountTotal.ToString(ReportContext.CurrencyFormat)); report.AddRow("GelirlerTablosu", Resources.TotalIncome.ToUpper(), "", ac.TotalAmount.ToString(ReportContext.CurrencyFormat)); //--------------- //Kasa raporu eklendiği için kasa özeti bu rapordan kaldırıldı. Başka bir rapora taşınabilir şimdilik bıraktım. //var cashTransactionTotal = ReportContext.GetCashTotalAmount(); //var creditCardTransactionTotal = ReportContext.GetCreditCardTotalAmount(); //var ticketTransactionTotal = ReportContext.GetTicketTotalAmount(); //report.AddColumnLength("Kasa", "25*", "18*", "18*", "18*", "21*"); //report.AddColumTextAlignment("Kasa", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right); //report.AddTable("Kasa", "Kasa", "Nakit", "K.Kartı", "Y.Çeki", "Toplam"); //report.AddRow("Kasa", "Gün Başı", // currentPeriod.CashAmount.ToString(ReportContext.CurrencyFormat), // currentPeriod.CreditCardAmount.ToString(ReportContext.CurrencyFormat), // currentPeriod.TicketAmount.ToString(ReportContext.CurrencyFormat), // (currentPeriod.CashAmount + currentPeriod.CreditCardAmount + currentPeriod.TicketAmount).ToString(ReportContext.CurrencyFormat)); //report.AddRow("Kasa", "Faaliyet", // ac.CashTotal.ToString(ReportContext.CurrencyFormat), // ac.CreditCardTotal.ToString(ReportContext.CurrencyFormat), // ac.TicketTotal.ToString(ReportContext.CurrencyFormat), // ac.GrandTotal.ToString(ReportContext.CurrencyFormat)); //report.AddRow("Kasa", "Hareketler", // cashTransactionTotal.ToString(ReportContext.CurrencyFormat), // creditCardTransactionTotal.ToString(ReportContext.CurrencyFormat), // ticketTransactionTotal.ToString(ReportContext.CurrencyFormat), // (cashTransactionTotal + creditCardTransactionTotal + ticketTransactionTotal).ToString(ReportContext.CurrencyFormat)); //var totalCash = currentPeriod.CashAmount + ac.CashTotal + cashTransactionTotal; //var totalCreditCard = currentPeriod.CreditCardAmount + ac.CreditCardTotal + creditCardTransactionTotal; //var totalTicket = currentPeriod.TicketAmount + ac.TicketTotal + ticketTransactionTotal; //report.AddRow("Kasa", "TOPLAM", // totalCash.ToString(ReportContext.CurrencyFormat), // totalCreditCard.ToString(ReportContext.CurrencyFormat), // totalTicket.ToString(ReportContext.CurrencyFormat), // (totalCash + totalCreditCard + totalTicket).ToString(ReportContext.CurrencyFormat)); //--------------- var propertySum = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Sum(x => x.GetPropertyPrice() * x.Quantity); var voids = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Voided) .Sum(x => x.GetItemValue()); var discounts = ReportContext.Tickets .SelectMany(x => x.Discounts) .Sum(x => x.DiscountAmount); var gifts = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Gifted) .Sum(x => x.GetItemValue()); report.AddColumTextAlignment("Bilgi", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Bilgi", "65*", "35*"); report.AddTable("Bilgi", Resources.GeneralInformation, ""); report.AddRow("Bilgi", Resources.ItemProperties, propertySum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.VoidsTotal, voids.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.DiscountsTotal, discounts.ToString(ReportContext.CurrencyFormat)); report.AddRow("Bilgi", Resources.GiftsTotal, gifts.ToString(ReportContext.CurrencyFormat)); if (ticketGropus.Count() > 1) { foreach (var departmentInfo in ticketGropus) { report.AddRow("Bilgi", departmentInfo.DepartmentName, departmentInfo.TicketCount); } } var ticketCount = ticketGropus.Sum(x => x.TicketCount); report.AddRow("Bilgi", Resources.TicketCount, ticketCount); report.AddRow("Bilgi", Resources.SalesDivTicket, ticketCount > 0 ? (ticketGropus.Sum(x => x.Amount) / ticketGropus.Sum(x => x.TicketCount)).ToString(ReportContext.CurrencyFormat) : "0"); if (ticketGropus.Count() > 1) { foreach (var departmentInfo in ticketGropus) { var dPayments = ReportContext.Tickets .SelectMany(x => x.Payments) .Where(x => x.DepartmentId == departmentInfo.DepartmentId) .GroupBy(x => new { x.PaymentType }) .Select(x => new TenderedAmount { PaymentType = x.Key.PaymentType, Amount = x.Sum(y => y.Amount) }); report.AddColumnLength(departmentInfo.DepartmentName + Resources.Incomes, "40*", "Auto", "35*"); report.AddColumTextAlignment(departmentInfo.DepartmentName + Resources.Incomes, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable(departmentInfo.DepartmentName + Resources.Incomes, string.Format(Resources.Incomes_f, departmentInfo.DepartmentName), "", ""); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.Cash, GetPercent(0, dPayments), GetAmount(0, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.CreditCard, GetPercent(1, dPayments), GetAmount(1, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.Voucher, GetPercent(2, dPayments), GetAmount(2, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.AccountBalance, GetPercent(3, dPayments), GetAmount(3, dPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.TotalIncome, "", dPayments.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var dvoids = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Voided && x.DepartmentId == departmentInfo.DepartmentId) .Sum(x => x.GetItemValue()); var ddiscounts = ReportContext.Tickets .Where(x => x.DepartmentId == departmentInfo.DepartmentId) .SelectMany(x => x.Discounts) .Sum(x => x.DiscountAmount); var dgifts = ReportContext.Tickets .SelectMany(x => x.TicketItems) .Where(x => x.Gifted && x.DepartmentId == departmentInfo.DepartmentId) .Sum(x => x.GetItemValue()); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.VoidsTotal, "", dvoids.ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.DiscountsTotal, "", ddiscounts.ToString(ReportContext.CurrencyFormat)); report.AddRow(departmentInfo.DepartmentName + Resources.Incomes, Resources.GiftsTotal, "", dgifts.ToString(ReportContext.CurrencyFormat)); } } //-- if (ReportContext.Tickets.Select(x => x.GetTagData()).Where(x => !string.IsNullOrEmpty(x)).Distinct().Count() > 0) { var dict = new Dictionary <string, List <Ticket> >(); foreach (var ticket in ReportContext.Tickets.Where(x => !string.IsNullOrEmpty(x.Tag))) { var tags = ticket.Tag.Split(new[] { '\r' }, StringSplitOptions.RemoveEmptyEntries); foreach (var tag in tags) { if (!dict.ContainsKey(tag)) { dict.Add(tag, new List <Ticket>()); } dict[tag].Add(ticket); } } var tagGroups = dict.Select(x => new TicketTagInfo { Amount = x.Value.Sum(y => y.GetSumWithoutTax()), TicketCount = x.Value.Count, TagName = x.Key }).OrderBy(x => x.TagName); var tagGrp = tagGroups.GroupBy(x => x.TagName.Split(':')[0]) .Where(x => ReportContext.TicketTagGroups.SingleOrDefault(y => y.Name == x.Key) != null); if (tagGrp.Count() > 0) { report.AddColumTextAlignment("Etiket", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Etiket", "45*", "Auto", "35*"); report.AddTable("Etiket", Resources.TicketTags, "", ""); } foreach (var grp in tagGrp) { var tag = ReportContext.TicketTagGroups.SingleOrDefault(x => x.Name == grp.Key); if (tag == null || tag.ExcludeInReports) { continue; } report.AddBoldRow("Etiket", grp.Key, "", ""); if (tag.PriceTags) { var tCount = grp.Sum(x => x.TicketCount); var tSum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); var amnt = grp.Sum(x => x.Amount); var rate = tSum / amnt; report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", tSum.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.TicketCount, "", tCount); report.AddRow("Etiket", Resources.TicketTotal, "", amnt.ToString(ReportContext.CurrencyFormat)); report.AddRow("Etiket", Resources.Rate, "", rate.ToString("%#0.##")); continue; } foreach (var ticketTagInfo in grp) { report.AddRow("Etiket", ticketTagInfo.TagName.Split(':')[1], ticketTagInfo.TicketCount, ticketTagInfo.Amount.ToString(ReportContext.CurrencyFormat)); } var totalAmount = grp.Sum(x => x.Amount); report.AddRow("Etiket", string.Format(Resources.TotalAmount_f, tag.Name), "", totalAmount.ToString(ReportContext.CurrencyFormat)); var sum = 0m; if (tag.NumericTags) { try { sum = grp.Sum(x => Convert.ToDecimal(x.TagName.Split(':')[1]) * x.TicketCount); report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", sum.ToString("#,##.##")); } catch (FormatException) { report.AddRow("Etiket", string.Format(Resources.TicketTotal_f, tag.Name), "", "#Hata!"); } } else { sum = grp.Sum(x => x.TicketCount); } if (sum > 0) { var average = totalAmount / sum; report.AddRow("Etiket", string.Format(Resources.TotalAmountDivTag_f, tag.Name), "", average.ToString(ReportContext.CurrencyFormat)); } } } //---- var owners = ReportContext.Tickets.SelectMany(ticket => ticket.TicketItems.Select(ticketItem => new { Ticket = ticket, TicketItem = ticketItem })) .GroupBy(x => new { x.TicketItem.CreatingUserId }) .Select(x => new UserInfo { UserId = x.Key.CreatingUserId, Amount = x.Sum(y => MenuGroupBuilder.CalculateTicketItemTotal(y.Ticket, y.TicketItem)) }); report.AddColumTextAlignment("Garson", TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Garson", "65*", "35*"); report.AddTable("Garson", Resources.UserSales, ""); foreach (var ownerInfo in owners) { report.AddRow("Garson", ownerInfo.UserName, ownerInfo.Amount.ToString(ReportContext.CurrencyFormat)); } //--- var uInfo = ReportContext.Tickets.SelectMany(x => x.Payments).Select(x => x.UserId).Distinct().Select( x => new UserInfo { UserId = x }); if (uInfo.Count() > 1) { foreach (var userInfo in uInfo) { var info = userInfo; var uPayments = ReportContext.Tickets .SelectMany(x => x.Payments) .Where(x => x.UserId == info.UserId) .GroupBy(x => new { x.PaymentType }) .Select(x => new TenderedAmount { PaymentType = x.Key.PaymentType, Amount = x.Sum(y => y.Amount) }); report.AddColumnLength(userInfo.UserName + Resources.Incomes, "40*", "Auto", "35*"); report.AddColumTextAlignment(userInfo.UserName + Resources.Incomes, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddTable(userInfo.UserName + Resources.Incomes, string.Format(Resources.ReceivedBy_f, userInfo.UserName), "", ""); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.Cash, GetPercent(0, uPayments), GetAmount(0, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.CreditCard, GetPercent(1, uPayments), GetAmount(1, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.Voucher, GetPercent(2, uPayments), GetAmount(2, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.AccountBalance, GetPercent(3, uPayments), GetAmount(3, uPayments).ToString(ReportContext.CurrencyFormat)); report.AddRow(userInfo.UserName + Resources.Incomes, Resources.Total, "", uPayments.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } } //--- var menuGroups = MenuGroupBuilder.CalculateMenuGroups(ReportContext.Tickets, ReportContext.MenuItems); report.AddColumTextAlignment("Gıda", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("Gıda", "45*", "Auto", "35*"); report.AddTable("Gıda", Resources.ItemSales, "", ""); foreach (var menuItemInfo in menuGroups) { report.AddRow("Gıda", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.Rate), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("Gıda", Resources.Total.ToUpper(), "", menuGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); return(report.Document); }
/// <summary> /// 管理员处理,是禁止还是警告这个人。 /// </summary> /// <param name="userId"></param> /// <returns></returns> public ActionResult ReportUser(int userId) { var user = LoveDb.GetUninUser(userId); var reports = LoveDb.ReportAll().Where(n => n.ReportedUserId == userId).ToList(); var total = reports.Count(); var undone = reports.Count(n => n.IsDone == false); var sreport = new List <SimpleReport>(); foreach (var report in reports.Where(n => n.IsDone == false)) { var sre = new SimpleReport { ReportRaw = report }; var report1 = report; switch (report.ReportType) { case ReportType.Personal: sre.Content = "直接举报本人"; break; case ReportType.Message: var c = LoveDb.One((Message m) => m.Id == report1.RelateId); sre.Content = "私信举报:"; if (c != null) { sre.Content = c.Content.Length < 20 ? c.Content : c.Content.Substring(0, 16) + "..."; } else { sre.Content = "相关信息已经被删除!"; } break; case ReportType.Topic: sre.Content = "话题举报:"; var top = LoveDb.One((Topic m) => m.Id == report1.RelateId); if (top != null) { sre.Content += string.Format("<a href='/Interactive/Detail?topicId={0}'>{1}</a>", top.Id, top.Title); } else { sre.Content = "相关信息已经被删除!"; } break; case ReportType.Comment: sre.Content = "评论举报:"; var com = LoveDb.One((Comment m) => m.Id == report1.RelateId); if (com != null) { sre.Content += com.Content; } else { sre.Content = "相关信息已经被删除!"; } break; default: sre.Content = "管理员还未处理此类型"; break; } sreport.Add(sre); } var rdu = new ReportDetailUser { UninUser = user, Reports = sreport, Sum = new ReportSum { ReportedNum = total, UnDone = undone, Done = total - undone } }; return(PartialView(rdu)); }
public void AddDefaultReportHeader(SimpleReport report, WorkPeriod workPeriod, string caption) { report.AddHeader("Samba POS"); report.AddHeader(caption); if (workPeriod.EndDate > workPeriod.StartDate) report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + workPeriod.EndDate.ToString("dd MMMM yyyy HH:mm")); else { report.AddHeader(workPeriod.StartDate.ToString("dd MMMM yyyy HH:mm") + " - " + DateTime.Now.ToString("dd MMMM yyyy HH:mm")); } }
private static void CreateDepartmentInfo(SimpleReport report, IEnumerable<Ticket> tickets, string header) { var rpKey = "Departman" + header; report.AddColumTextAlignment(rpKey, TextAlignment.Left, TextAlignment.Right); report.AddTable(rpKey, header, ""); var ticketGropus = tickets .GroupBy(x => new { x.DepartmentId }) .Select(x => new DepartmentInfo { DepartmentId = x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSum()) - x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())) - x.Sum(y => y.GetPostTaxServicesTotal()), Tax = x.Sum(y => y.CalculateTax(y.GetPlainSum(), y.GetPreTaxServicesTotal())), Services = x.Sum(y => y.GetPostTaxServicesTotal()) }).ToList(); if (ticketGropus.Count() > 1) { foreach (var departmentInfo in ticketGropus) { report.AddRow(rpKey, departmentInfo.DepartmentName, departmentInfo.Amount.ToString(ReportContext.CurrencyFormat)); } } report.AddRow(rpKey, header.ToUpper() + " TOTAL", ticketGropus.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); var vatSum = ticketGropus.Sum(x => x.Tax); var serviceSum = ticketGropus.Sum(x => x.Services); if (vatSum != 0 || serviceSum != 0) { if (serviceSum != 0) { ReportContext.Tickets.SelectMany(x => x.Calculations).Where(x => x.IncludeTax).GroupBy(x => x.CalculationTypeId).ToList().ForEach( x => { var template = ReportContext.CalculationTypes.SingleOrDefault(y => y.Id == x.Key); var title = template != null ? template.Name : Resources.UndefinedWithBrackets; report.AddRow(rpKey, title, x.Sum(y => y.CalculationAmount).ToString(ReportContext.CurrencyFormat)); }); } if (vatSum != 0) { report.AddRow(rpKey, Resources.SubTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Services).ToString(ReportContext.CurrencyFormat)); report.AddRow(rpKey, Resources.TaxTotal.ToUpper(), vatSum.ToString(ReportContext.CurrencyFormat)); } report.AddRow(rpKey, Resources.GrandTotal.ToUpper(), ticketGropus.Sum(x => x.Amount + x.Tax + x.Services).ToString(ReportContext.CurrencyFormat)); } }
protected override FlowDocument GetReport() { var report = new SimpleReport("8cm"); AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.ItemSalesReport); var menuGroups = MenuGroupBuilder.CalculateMenuGroups(ReportContext.Tickets, ReportContext.MenuItems).ToList(); report.AddColumTextAlignment("ÜrünGrubu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÜrünGrubu", "40*", "Auto", "35*"); report.AddTable("ÜrünGrubu", Resources.SalesByItemGroup, "", ""); foreach (var menuItemInfo in menuGroups.Where(x => x.Rate != 0)) { report.AddRow("ÜrünGrubu", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.Rate), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("ÜrünGrubu", Resources.Total, "", menuGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); //---------------------- report.AddColumTextAlignment("ÜrünGrubuMiktar", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÜrünGrubuMiktar", "40*", "Auto", "35*"); report.AddTable("ÜrünGrubuMiktar", Resources.QuantitiesByItemGroup, "", ""); foreach (var menuItemInfo in menuGroups.Where(x => x.QuantityRate != 0)) { report.AddRow("ÜrünGrubuMiktar", menuItemInfo.GroupName, string.Format("%{0:0.00}", menuItemInfo.QuantityRate), menuItemInfo.Quantity.ToString("#")); } report.AddRow("ÜrünGrubuMiktar", Resources.Total, "", menuGroups.Sum(x => x.Quantity).ToString("#")); //---------------------- var menuItems = MenuGroupBuilder.CalculateMenuItems(ReportContext.Tickets, ReportContext.MenuItems) .OrderByDescending(x => x.Quantity); report.AddColumTextAlignment("ÜrünTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÜrünTablosu", "50*", "Auto", "25*"); report.AddTable("ÜrünTablosu", Resources.MenuItem, Resources.Quantity, Resources.Amount); foreach (var menuItemInfo in menuItems) { report.AddRow("ÜrünTablosu", menuItemInfo.Name, string.Format("{0:0.##}", menuItemInfo.Quantity), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); PrintPortionsSections(report, ReportContext.MenuItems, menuItemInfo, "ÜrünTablosu"); } report.AddRow("ÜrünTablosu", Resources.Total, "", menuItems.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); //---------------------- var returnedMenuItems = MenuGroupBuilder.CalculateReturnedItems(ReportContext.Tickets, ReportContext.MenuItems) .OrderByDescending(x => x.Quantity); if (returnedMenuItems.Any()) { report.AddColumTextAlignment("IadeTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("IadeTablosu", "50*", "Auto", "25*"); report.AddTable("IadeTablosu", Resources.MenuItem, Resources.Quantity, Resources.Amount); foreach (var menuItemInfo in returnedMenuItems) { report.AddRow("IadeTablosu", menuItemInfo.Name, string.Format("{0:0.##}", menuItemInfo.Quantity), menuItemInfo.Amount.ToString(ReportContext.CurrencyFormat)); } report.AddRow("IadeTablosu", Resources.Total, "", returnedMenuItems.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); } //---------------------- //PrepareModificationTable(report, x => x.Voided, Resources.Voids); //PrepareModificationTable(report, x => x.Gifted, Resources.Gifts); //var discounts = ReportContext.Tickets // .SelectMany(x => x.Discounts.Select(y => new { x.TicketNumber, y.UserId, Amount = y.DiscountAmount })) // .GroupBy(x => new { x.TicketNumber, x.UserId }).Select(x => new { x.Key.TicketNumber, x.Key.UserId, Amount = x.Sum(y => y.Amount) }); //if (discounts.Count() > 0) //{ // report.AddColumTextAlignment("İskontolarTablosu", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right); // report.AddColumnLength("İskontolarTablosu", "20*", "Auto", "35*"); // report.AddTable("İskontolarTablosu", Resources.Discounts, "", ""); // foreach (var discount in discounts.OrderByDescending(x => x.Amount)) // { // report.AddRow("İskontolarTablosu", discount.TicketNumber, ReportContext.GetUserName(discount.UserId), discount.Amount.ToString(ReportContext.CurrencyFormat)); // } // if (discounts.Count() > 1) // report.AddRow("İskontolarTablosu", Resources.Total, "", discounts.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); //} //---------------------- //var ticketGroups = ReportContext.Tickets // .GroupBy(x => new { x.DepartmentId }) // .Select(x => new { x.Key.DepartmentId, TicketCount = x.Count(), Amount = x.Sum(y => y.GetSumWithoutTax()) }); //if (ticketGroups.Count() > 0) //{ // report.AddColumTextAlignment("AdisyonlarTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); // report.AddColumnLength("AdisyonlarTablosu", "40*", "20*", "40*"); // report.AddTable("AdisyonlarTablosu", Resources.Tickets, "", ""); // foreach (var ticketGroup in ticketGroups) // { // report.AddRow("AdisyonlarTablosu", ReportContext.GetDepartmentName(ticketGroup.DepartmentId), ticketGroup.TicketCount.ToString("#.##"), ticketGroup.Amount.ToString(ReportContext.CurrencyFormat)); // } // if (ticketGroups.Count() > 1) // report.AddRow("AdisyonlarTablosu", Resources.Total, ticketGroups.Sum(x => x.TicketCount).ToString("#.##"), ticketGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); //} //---------------------- var orderTags = ReportContext.Tickets .SelectMany(x => x.Orders.Where(y => !string.IsNullOrEmpty(y.OrderTags) && (y.IncreaseInventory || y.DecreaseInventory))) .SelectMany(x => x.GetOrderTagValues(y => y.MenuItemId == 0).Select(y => new { Name = y.TagValue, x.Quantity, Total = y.Price * x.Quantity })) .GroupBy(x => new { x.Name }) .Select(x => new { x.Key.Name, Quantity = x.Sum(y => y.Quantity), Amount = x.Sum(y => y.Total) }).ToList(); if (orderTags.Any()) { report.AddColumTextAlignment("ÖzelliklerTablosu", TextAlignment.Left, TextAlignment.Right, TextAlignment.Right); report.AddColumnLength("ÖzelliklerTablosu", "50*", "20*", "30*"); report.AddTable("ÖzelliklerTablosu", Resources.Properties, "", ""); foreach (var property in orderTags.OrderByDescending(x => x.Quantity)) { report.AddRow("ÖzelliklerTablosu", property.Name, property.Quantity.ToString(LocalSettings.ReportQuantityFormat), property.Amount.ToString(LocalSettings.ReportCurrencyFormat)); } } return(report.Document); }
private static void PrepareModificationTable(SimpleReport report, Func<TicketItem, bool> predicate, string title) { var modifiedItems = ReportContext.Tickets .SelectMany(x => x.TicketItems.Where(predicate) .OrderBy(y => y.ModifiedDateTime) .Select(y => new { Ticket = x, UserId = y.ModifiedUserId, MenuItem = y.MenuItemName, y.Quantity, y.ReasonId, y.ModifiedDateTime, Amount = y.GetItemValue() })); if (modifiedItems.Count() == 0) return; report.AddColumTextAlignment(title, TextAlignment.Left, TextAlignment.Left, TextAlignment.Left, TextAlignment.Left); report.AddColumnLength(title, "14*", "45*", "28*", "13*"); report.AddTable(title, title, "", "", ""); foreach (var voidItem in modifiedItems.GroupBy(x => x.ReasonId)) { if (voidItem.Key > 0) report.AddRow(title, ReportContext.GetReasonName(voidItem.Key), "", "", ""); foreach (var vi in voidItem) { report.AddRow(title, vi.Ticket.TicketNumber, vi.Quantity.ToString("#.##") + " " + vi.MenuItem, ReportContext.GetUserName(vi.UserId), vi.ModifiedDateTime.ToShortTimeString()); } } var voidGroups = from c in modifiedItems group c by c.UserId into grp select new { UserId = grp.Key, Amount = grp.Sum(x => x.Amount) }; report.AddColumTextAlignment("Personel" + title, TextAlignment.Left, TextAlignment.Right); report.AddColumnLength("Personel" + title, "60*", "40*"); report.AddTable("Personel" + title, string.Format(Resources.ByPersonnel_f, title), ""); foreach (var voidItem in voidGroups.OrderByDescending(x => x.Amount)) { report.AddRow("Personel" + title, ReportContext.GetUserName(voidItem.UserId), voidItem.Amount.ToString(ReportContext.CurrencyFormat)); } if (voidGroups.Count() > 1) report.AddRow("Personel" + title, Resources.Total, voidGroups.Sum(x => x.Amount).ToString(ReportContext.CurrencyFormat)); }
private void OnPrintAccount(string obj) { var report = new SimpleReport(""); report.AddParagraph("Header"); report.AddParagraphLine("Header", Resources.AccountTransaction.ToPlural(), true); report.AddParagraphLine("Header", ""); report.AddParagraphLine("Header", string.Format("{0}: {1}", string.Format(Resources.Name_f, Resources.Account), SelectedAccount.Name)); report.AddParagraphLine("Header", string.Format("{0}: {1}", Resources.Balance, TotalBalance)); report.AddParagraphLine("Header", ""); report.AddColumnLength("Transactions", "15*", "35*", "15*", "15*", "20*"); report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right, TextAlignment.Right); report.AddTable("Transactions", Resources.Date, Resources.Description, Resources.Credit, Resources.Debit, Resources.Balance); foreach (var ad in AccountDetails) { report.AddRow("Transactions", ad.Date.ToShortDateString(), ad.Name, ad.CreditStr, ad.DebitStr, ad.BalanceStr); } _printerService.PrintReport(report.Document); }