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)); } }
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); }
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); }
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 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); }
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)); } }
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); 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; }
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)); } }
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); }
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)); } }
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); }
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); }
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 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 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); }
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)); }
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); }
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"); 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; }