public Period AddUsingTransactionDate(DateTime transactionDate) { var retValue = new Period(); retValue.PeriodStart = new DateTime(transactionDate.Year, transactionDate.Month, 1); retValue.PeriodEnd = new DateTime(transactionDate.Year, transactionDate.Month, 1) .AddMonths(1).AddTicks(-1); retValue.Year = transactionDate.Year; retValue.Name = mMonthNames[retValue.PeriodStart.Month]; base.Add(retValue); EntryPeriod newEntryPeriod; // Add a EntryPeriod object for all existing entries. foreach (var entry in mEntryDataService.GetAll()) { newEntryPeriod = new EntryPeriod() { Entry = entry, Period = retValue, }; mEntryPeriodDataService.Add(newEntryPeriod); } return(retValue); }
public IEnumerable <Transaction> GetByEntryPeriod(EntryPeriod entryPeriod) { if (entryPeriod != null) { using (var unitOfWork = mUOWFactory.Create()) { var repository = unitOfWork.GetRepository <Transaction>(); var retValue = repository.GetQuery() .Where(e => e.EntryPeriodKey == entryPeriod.Key); return(retValue.ToList()); } } return(null); }
private void updateParentTotals(EntryPeriod entryPeriod, decimal amount) { if (entryPeriod.Entry.ParentEntryKey.HasValue) { var parentEntryPeriod = mEntryPeriods.Where(ep => (ep.EntryKey == entryPeriod.Entry.ParentEntryKey) && (ep.Period.Key == entryPeriod.Period.Key)).FirstOrDefault(); if (parentEntryPeriod != null) { parentEntryPeriod.TotalAmount += amount; mEntryPeriodDataService.Update(parentEntryPeriod); updateParentTotals(parentEntryPeriod, amount); } else { throw new Exception($"Parent entry period of {entryPeriod.Key} does not exist"); } } }
public override bool Add(Entry entity) { // First add the entry to the database. entity.ActiveFrom = new DateTime(DateTime.Now.Year, 1, 1); var result = base.Add(entity); // Then create a EntryPeriod for each period in the database. var periods = mPeriodDataService.Value.GetAll(); foreach (var period in periods) { var newEntryPeriod = new EntryPeriod { Entry = entity, Period = period }; mEntryPeriodDataService.Add(newEntryPeriod); } return(result); }
public Column(EntryPeriod entryPeriod, decimal amount) { EntryPeriod = entryPeriod; Amount = amount; }