Ejemplo n.º 1
0
        private void FillSummaryGrid(BillingPeriod period)
        {
            var startDate             = period.startDate.ToString("dd.MM.yyyy");
            var endDate               = period.endDate.ToString("dd.MM.yyyy");
            var net                   = period.GetSumOfIncomes(Income.IncomeType.Salary);
            var incSum                = period.GetSumOfIncomes();
            var add                   = incSum - net;
            var expSum                = period.GetSumOfExpenses();
            var monthlyExpSum         = period.GetSumOfMonthlyExpenses();
            var dailyExpSum           = expSum - monthlyExpSum;
            var savings               = period.plannedSavings;
            var balance               = incSum - expSum - savings;
            var isActualBillingPeriod = (DateTime.Today - period.startDate).Days >= 0 && (period.endDate - DateTime.Today).Days >= 0;
            var daysLeft              = (period.endDate - DateTime.Today).Days + 1;
            var balanceWithoutToday   = balance + period.GetSumOfAllExpensesOfDate(DateTime.Today);
            var estimatedExpense      = isActualBillingPeriod ? Math.Round(balanceWithoutToday / daysLeft, 2) : Math.Round(balance, 2);
            var todayExpenses         = period.GetSumOfDailyExpensesOfDate(DateTime.Today);
            var todayExpensesPercent  = todayExpenses / estimatedExpense * 100;

            PeriodDatesTextBlock.Text           = "Podsumowanie dla " + startDate + "-" + endDate + ":";
            NetIncomeTextBlock.Text             = net.ToString("F") + " zł";
            AddIncomeTextBlock.Text             = add.ToString("F") + " zł";
            IncomeSumTextBlock.Text             = incSum.ToString("F") + " zł";
            IncomeSumTextBlock2.Text            = incSum.ToString("F") + " zł";
            DailyExpensesSumTextBlock.Text      = dailyExpSum.ToString("F") + " zł";
            MonthlyExpensesSumTextBlock.Text    = monthlyExpSum.ToString("F") + " zł";
            ExpensesSumTextBlock.Text           = expSum.ToString("F") + " zł";
            ExpensesSumTextBlock2.Text          = expSum.ToString("F") + " zł";
            PlannedSavingsTextBlock.Text        = savings.ToString("F") + " zł";
            BalanceTextBlock.Text               = (balance > 0 ? "+" : "") + balance.ToString("F") + " zł";
            DaysLeftTextBlock.Text              = isActualBillingPeriod ? daysLeft.ToString() : "-";
            EstimatedDailyExpenseTextBlock.Text = isActualBillingPeriod ? estimatedExpense.ToString("F") + " zł" : "-";
            SumOfTodayExpenses.Text             = isActualBillingPeriod ? todayExpenses.ToString("F") + " zł" : "-";
            PercentOfTodayExpenses.Text         = isActualBillingPeriod ? todayExpensesPercent.ToString("F0") + "%" : "-";
        }
 public BillingPeriodDataItem(BillingPeriod bp)
 {
     startDate             = bp.startDate;
     endDate               = bp.endDate;
     incomes               = Utilities.EmptyIfZero(bp.GetSumOfIncomes(), " zł");
     plannedSavings        = Utilities.EmptyIfZero(bp.plannedSavings, " zł");
     originalBillingPeriod = bp;
 }
Ejemplo n.º 3
0
        private double GetIncomeSum(ExpensesType type)
        {
            var sum = (double)(period.GetSumOfIncomes());

            switch (type)
            {
            case ExpensesType.Daily:
                sum -= (double)period.GetSumOfMonthlyExpenses();
                break;

            case ExpensesType.All:
                break;
            }
            return(sum);
        }