コード例 #1
0
        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) }).ToList();

            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.Any())
            {
                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;
        }
コード例 #2
0
        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.WarehouseConsumptions.SelectMany(x=>x.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.InventoryItemName,
                        costItem.UnitName,
                        costItem.GetPhysicalInventory().ToString("#,#0.##"));
                }
            }
            else report.AddHeader(Resources.ThereAreNoCostTransactionsInThisPeriod);

            return report.Document;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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();

            foreach (var warehouseConsumption in lastPeriodicConsumption.WarehouseConsumptions.OrderBy(GetWarehouseOrder))
            {
                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, "55*", "15*", "30*");
                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;
        }
コード例 #6
0
        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, _applicationState.CurrentTerminal.ReportPrinter);
        }
コード例 #7
0
        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, _applicationState.CurrentTerminal.ReportPrinter);
        }
コード例 #8
0
        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)
            {
                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));

            //----------------------

            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 properties = ReportContext.Tickets
                .SelectMany(x => x.Orders.Where(y => !string.IsNullOrEmpty(y.OrderTags)))
                .SelectMany(x => x.GetOrderTagValues(y => y.MenuItemId == 0).Select(y => new { Name = y.TagValue, x.Quantity }))
                .GroupBy(x => new { x.Name })
                .Select(x => new { x.Key.Name, Quantity = x.Sum(y => y.Quantity) }).ToList();

            if (properties.Any())
            {

                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;
        }
コード例 #9
0
        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());
                }
            }

            var orderStates = ReportContext.Tickets
                               .SelectMany(x => x.Orders)
                               .SelectMany(x => x.GetOrderStateValues()).Distinct().ToList();

            if (orderStates.Any())
            {
                report.AddBoldRow("Bilgi", Resources.Orders, "");

                foreach (var orderStateValue in orderStates)
                {
                    var value = orderStateValue;
                    var items =
                        ReportContext.Tickets.SelectMany(x => x.Orders).Where(x => x.IsInState(value.StateName, value.State)).ToList();
                    var amount = items.Sum(x => x.GetValue());
                    var count = items.Count();
                    report.AddRow("Bilgi", string.Format("{0} ({1})", orderStateValue.State, count), amount.ToString(ReportContext.CurrencyFormat));
                }
            }

            var ticketStates = ReportContext.Tickets
                .SelectMany(x => x.GetTicketStateValues()).Distinct().ToList();

            if (ticketStates.Any())
            {
                report.AddBoldRow("Bilgi", Resources.Tickets, "");
                foreach (var ticketStateValue in ticketStates)
                {
                    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));
                }
            }

            //--

            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;
        }
コード例 #10
0
        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(),
                                     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));
                }
            }

            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)
                {
                    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 (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));
            }
        }