Exemple #1
0
        private string GetItemExpense(JsonReportEntry currentEntity)
        {
            if (this.SQLiteData
                .GetAll()
                .Select(x => x.Name)
                .Contains(currentEntity.ProductName))
            {
                var item = this.SQLiteData
                           .GetAll(i => i.Name == currentEntity.ProductName)
                           .Select(i => new
                {
                    Expense = i.Taxes
                })
                           .First();

                return(item.Expense);
            }

            return("0%");
        }
Exemple #2
0
        private void FillCurrentRowWithData(ExcelWorksheet worksheet, JsonReportEntry currentEntity)
        {
            var productId          = currentEntity.ProductId;
            var productName        = currentEntity.ProductName;
            var manufacturererName = currentEntity.ManufacturerName;
            var quantity           = currentEntity.TotalQuantitySold;
            var totalIncome        = currentEntity.TotalIncome;
            var expensePerItem     = this.GetItemExpense(currentEntity);
            var totalExpenses      = (totalIncome / 100) * decimal.Parse(expensePerItem.Substring(0, expensePerItem.Length - 1));
            var clearIncome        = totalIncome - totalExpenses;

            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.ProductIdColumn].Value = string.Format("{0:}",
                                                                                                            productId);
            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.ProductNameColumn].Value      = productName;
            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.ManufacturerNameColumn].Value = manufacturererName;
            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.QuantityColumn].Value         = string.Format("{0:}", quantity);
            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.TotalIncomeColumn].Value      = totalIncome.ToCurrency();
            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.ExpensePerItemColumn].Value   = expensePerItem;
            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.TotalExpensesColumn].Value    = totalExpenses.ToCurrency();
            worksheet.Cells[this.bodyRowPosition, (int)ReportColumns.RevenueColumn].Value          = clearIncome.ToCurrency();
        }