Beispiel #1
0
        public static BudgetEntry CreateBudgetEntry(params string[] components)
        {
            BudgetEntry result = null;

            double     amount;
            string     label;
            BudgetType budgetType;
            int        month;
            string     dayStart;
            int        weekPeriod;
            int        weekMax;

            string type;

            GetNextValueAndAdvance(ref components, out type);
            GetCommonParameters(ref components, out amount, out label, out budgetType);
            switch (type)
            {
            case "Annual":
                GetNextValueAndAdvance(ref components, out month);
                result = new BudgetEntryAnnual(amount, month, label, budgetType);
                break;

            case "BiAnnual":
                GetNextValueAndAdvance(ref components, out month);
                result = new BudgetEntryBiAnnual(amount, month, label, budgetType);
                break;

            case "Monthly":
                result = new BudgetEntryMonthly(amount, label, budgetType);
                break;

            case "BiMonthly":
                GetNextValueAndAdvance(ref components, out month);
                result = new BudgetEntryBiMonthly(amount, month, label, budgetType);
                break;

            case "Weekly":
                GetNextValueAndAdvance(ref components, out dayStart);
                GetNextValueAndAdvance(ref components, out weekPeriod);
                GetNextValueAndAdvance(ref components, out weekMax);
                result = new BudgetEntryWeekly(amount, label, budgetType, weekPeriod, dayStart, weekMax);
                break;

            case "Daily":
                GetNextValueAndAdvance(ref components, out dayStart);
                result = new BudgetEntryDaily(amount, label, budgetType, dayStart);
                break;

            default:
                throw new ArgumentException($"Invalid Budget Entry Type {type}");
            }
            return(result);
        }
Beispiel #2
0
 public void AddEntry(BudgetEntry budgetEntry)
 {
     BudgetEntries.Add(budgetEntry);
     for (int ii = 1; ii <= 12; ++ii)
     {
         var monthlyEntry = budgetEntry.GetMonthEntry(ii);
         if (BudgetCategory.IsIncome(budgetEntry.BudgetType))
         {
             _monthlyIncome[ii] += monthlyEntry;
             TotalIncome        += monthlyEntry;
         }
         else
         {
             _monthlyExpenses[ii] += monthlyEntry;
             TotalExpenses        += monthlyEntry;
         }
     }
 }
Beispiel #3
0
 public BudgetEntryDto(BudgetEntry budgetEntry)
 {
     Amount   = budgetEntry.Amount;
     Label    = budgetEntry.Label;
     Category = budgetEntry.Category;
 }