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;
        }
        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;
        }
        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;
        }
        protected override FlowDocument GetReport()
        {
            var currentPeriod = ReportContext.CurrentWorkPeriod;
            var report = new SimpleReport("8cm");
            AddDefaultReportHeader(report, currentPeriod, Resources.CsvBuilder);
            report.Header.TextAlignment = TextAlignment.Left;
            report.AddHeader("");
            report.AddHeader(Resources.ClickLinksToExportData);
            report.AddHeader("");
            report.AddLink(Resources.ExportSalesData);
            HandleLink(Resources.ExportSalesData);

            return report.Document;
        }
        protected override FlowDocument GetReport()
        {
            var report = new SimpleReport("8cm");
            AddDefaultReportHeader(report, ReportContext.CurrentWorkPeriod, Resources.CostReport);

            var costItems = ReportContext.PeriodicConsumptions.SelectMany(x => x.WarehouseConsumptions).SelectMany(x=>x.CostItems)
                .GroupBy(x => new { ItemName = x.Name, x.PortionName })
                .Select(x => new { x.Key.ItemName, x.Key.PortionName, TotalQuantity = x.Sum(y => y.Quantity), TotalCost = x.Sum(y => y.Cost * y.Quantity) }).ToList();

            if (costItems.Any())
            {
                report.AddColumTextAlignment("Maliyet", TextAlignment.Left, TextAlignment.Left, TextAlignment.Right, TextAlignment.Right);
                report.AddColumnLength("Maliyet", "38*", "20*", "17*", "25*");
                report.AddTable("Maliyet", Resources.MenuItem, Resources.Portion, Resources.Quantity, Resources.AverageCost);

                foreach (var costItem in costItems)
                {
                    report.AddRow("Maliyet",
                        costItem.ItemName,
                        costItem.PortionName,
                        costItem.TotalQuantity.ToString("#,#0.##"),
                        (costItem.TotalCost / costItem.TotalQuantity).ToString(ReportContext.CurrencyFormat));
                }

                report.AddRow("Maliyet", Resources.Total, "", "", costItems.Sum(x => x.TotalCost).ToString(ReportContext.CurrencyFormat));
            }
            else report.AddHeader(Resources.ThereAreNoCostTransactionsInThisPeriod);

            return report.Document;
        }
        protected override FlowDocument GetReport()
        {
            var report = new SimpleReport("8cm");

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