Esempio n. 1
0
        public void RemoveBudgetedAmount(BudgetedAmount budgetedAmount)
        {
            var amountToRemove = BudgetedAmounts.FirstOrDefault(x => x == budgetedAmount);

            if (amountToRemove == null)
            {
                throw new BusinessException("Budgeted amount not found");
            }

            BudgetedAmounts.Remove(amountToRemove);
        }
Esempio n. 2
0
        public BudgetedAmount AddBudgetedAmount(MoneyAmount amount, DateTime validFrom)
        {
            var budgetedAmount = BudgetedAmount.Create(this, amount, validFrom);

            if (BudgetedAmounts.Any(x => x.ValidFrom == budgetedAmount.ValidFrom))
            {
                throw new BusinessException("Another budgeted amount starting at same date");
            }

            BudgetedAmounts.Add(budgetedAmount);
            return(budgetedAmount);
        }
Esempio n. 3
0
            internal static BudgetedAmount Create(BudgetCategory budgetCategory, MoneyAmount amount, DateTime validFrom)
            {
                var instance = new BudgetedAmount()
                {
                    BudgetedAmountId = new BudgetedAmountId(),
                    BudgetCategoryId = budgetCategory.BudgetCategoryId
                };

                instance.SetAmount(amount);
                instance.SetValidFromDate(validFrom);
                return(instance);
            }
Esempio n. 4
0
        public void UpdateBudgetedAmount(BudgetedAmount budgetedAmount)
        {
            var amountToUpdate = BudgetedAmounts.FirstOrDefault(x => x == budgetedAmount);

            if (amountToUpdate == null)
            {
                throw new NotFoundException("Budgeted amount does not exist");
            }

            if (BudgetedAmounts.Any(x => x.BudgetedAmountId != budgetedAmount.BudgetedAmountId && x.ValidFrom == budgetedAmount.ValidFrom))
            {
                throw new BusinessException("Another budgeted amount starting at same date");
            }

            amountToUpdate.SetValidFromDate(budgetedAmount.ValidFrom);
            amountToUpdate.SetAmount(budgetedAmount.Amount);
        }
Esempio n. 5
0
 public string GetBudgetedDisplayString()
 {
     return(UsePercentage
                ? BudgetedPercentage.FormatPercentage()
                : BudgetedAmount.FormatCurrency());
 }