public Fund Build() { Fund fund = null; if (_parentFund != null) { fund = new Fund(_parentFund, _name, _fundBalance); fund.Duration = _parentFund.Duration; fund.User = _parentFund.User; fund.ParentFund = _parentFund; _parentFund.SubFunds = _parentFund.SubFunds?.Append(fund) ?? new List <Fund>() { fund }; fund.Id = _id; } else { BudgetDurationBase budgetDuration = _durationBuilder.Build(); fund = new Fund( _id, _name, _fundBalance, budgetDuration, _ownerId ); } if (_owner != null) { fund.User = _owner; } return(fund); }
public Fund(string name, decimal fundBalance, BudgetDurationBase duration, Guid userId) { this.Name = name; this.FundBalance = fundBalance; this.Duration = duration; this.UserId = userId; this.SubFunds = new List <Fund>(); }
public BudgetDurationResponse(BudgetDurationBase durationBase) { Id = durationBase.Id; if (durationBase is DaySpanDuration) { DurationType = DurationTypeDaySpan; NumberDays = ((DaySpanDuration)durationBase).NumberDays; } else { DurationType = DurationTypeMonthlyBookEnded; EndDayOfMonth = ((MonthlyBookEndedDuration)durationBase).EndDayOfMonth; RolloverEndDateOnSmallMonths = ((MonthlyBookEndedDuration)durationBase).RolloverEndDateOnSmallMonths; } }
public void Test_SetAmountDefaultsTo0_WhenCreatingBudget() { IBudgetDurationBuilder durationBuilder = _builderFactoryFixture.GetService <BudgetDurationBuilderProvider>().GetBuilder <MonthlyBookEndedDuration>(); BudgetDurationBase randomDuration = durationBuilder.Build(); Fund fund = _builderFactoryFixture.FundBuilder.Build(); DateTime now = DateTime.Now; Budget subject = new Budget( fund, new BudgetPeriod(now, fund.Duration.GetEndDateFromStartDate(now)) ); decimal expectedDefaultSetAmount = 0; Assert.Equal(expectedDefaultSetAmount, subject.SetAmount); }
public IBudgetPeriodBuilder ForDuration(BudgetDurationBase duration) { this.duration = duration; return(this); }