public void DeletePayday(Payday payday) { if (payday == null) { throw new ArgumentException("payday is null."); } this.context.AddUpdateDeletePayday(null, null, payday); }
public Payday GetPayday(int id) { Payday item = null; using (var context = new PBEntities()) { item = context.Paydays.Where(s => s.Id == id).FirstOrDefault(); } return(item); }
public int GetPaydayEmployer(int id, string fromStr, string toStr) { var employer = _context.Employers.Find(id); double salary = employer.Salary; string group = employer.Group; if (fromStr.Length < 1 || toStr.Length < 1) { return(0); } int dayFrom = Int32.Parse(fromStr.Substring(0, 2)); int monthFrom = Int32.Parse(fromStr.Substring(3, 2)); int yearFrom = Int32.Parse(fromStr.Substring(6, 2)); DateTime dateTimeFrom = new DateTime(yearFrom, monthFrom, dayFrom); int dayTo = Int32.Parse(toStr.Substring(0, 2)); int monthTo = Int32.Parse(toStr.Substring(3, 2)); int yearTo = Int32.Parse(toStr.Substring(6, 2)); DateTime dateTimeTo = new DateTime(yearTo, monthTo, dayTo); int countMonth = (int)(dateTimeTo - dateTimeFrom).TotalDays / 30; // TODO: fix this int expYear = (int)( (DateTime.Parse(employer.WorkedAt) - DateTime.Now.AddMonths(countMonth) ).TotalDays / 365); // SUB List <double> subEmployersSalary = new List <double>(); var subEmployers = _context.Employers .Where(x => x.BossesId == id) .Select(x => x.Id) .ToList(); foreach (var i in subEmployers) { if (i == id) { continue; } subEmployersSalary.Add( GetPaydayEmployer(i, "", "") ); } var paydayHelper = new Payday(); int result = (int)paydayHelper .GetPaydayEmployer(salary, group, expYear, subEmployersSalary); return(result * countMonth - countMonth); }
public async Task <Payday> DetermineNextPayDateWeekly(DateTime startDate, PayType frequency) { DateTime calculatedDate = DetermineWeeklyNextDate(startDate, frequency); var singlePayday = new Payday { PayDate = calculatedDate, DayOfWeek = calculatedDate.DayOfWeek, Regularity = frequency }; return(singlePayday); }
internal void SetSeed(ref Payday seed, int PreviousPeriodsToShow) { DateTime today = DateTime.Now; bool FoundCurrent = false; while (!FoundCurrent) { //this will find the current pay period seed.Paydate = seed.Paydate.AddDays(14); FoundCurrent = (today > seed.Paydate && today < seed.Paydate.AddDays(14)); } seed.Paydate = seed.Paydate.AddDays((PreviousPeriodsToShow * 14) * -1); }
public HttpResponseMessage UpdatePayday(Payday payday) { if (payday == null) { throw new ArgumentException("payday is null."); } if (ModelState.IsValid) { this.context.AddUpdateDeletePayday(null, payday, null); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public HttpResponseMessage CreatePayday(Payday payday) { Payday tempItem = new Payday(); if (payday == null) { throw new ArgumentException("payday is null."); } if (ModelState.IsValid) { tempItem = this.context.AddUpdateDeletePayday(payday, null, null); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, tempItem); response.Headers.Location = new Uri(this.Request.RequestUri.AbsoluteUri + "/" + tempItem.Id); return(response); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public Payday AddUpdateDeletePayday(Payday AddItem, Payday UpdateItem, Payday DeleteItem) { if (AddItem != null) { Payday newItem = this.uow.PaydayRepository.Insert(AddItem); this.uow.Save(); return(newItem); } if (UpdateItem != null) { this.uow.PaydayRepository.Update(UpdateItem); } if (DeleteItem != null) { this.uow.PaydayRepository.Delete(DeleteItem); } this.uow.Save(); return(null); }
public HomePageViewModel(Guid userid) { SettingsViewModel settings = SettingsViewModel.GetSettings(userid); this.Paychecks = new List <PaycheckDetailsViewModel>(); DayViewModel day = null; PaycheckSummaryViewModel summary = null; PBProxy p = new PBProxy(); Payday PayDaySeed = p.GetPaydays(userid).FirstOrDefault(); SetSeed(ref PayDaySeed, settings.PreviousPeriodsToShow); ListBillsViewModel AllBills = new ListBillsViewModel(userid); int CurrentMonth = 0; bool WillMonthChange = false; for (int checkIndex = 0; checkIndex < settings.ChecksToShow; checkIndex++) { DateTime thisdate = PayDaySeed.Paydate.AddDays(checkIndex * 14); string PaycheckType = thisdate.Day <= 14 ? "A" : "B"; PaycheckDetailsViewModel paycheckdetails = new PaycheckDetailsViewModel(); PaycheckViewModel Paycheck = new PaycheckViewModel(userid, PaycheckType); summary = new PaycheckSummaryViewModel(); summary.Payday = thisdate; summary.Credits = Paycheck.PayCheck.Amount; #region For Each Day In Pay Period for (int dayIndex = 0; dayIndex < 14; dayIndex++) { DateTime tempdate = thisdate.AddDays(dayIndex); if (CurrentMonth == 0 | tempdate.Day == 31 | tempdate.Day < 28) { WillMonthChange = false; } else { WillMonthChange = tempdate.AddDays(1).Month != CurrentMonth; } CurrentMonth = tempdate.Month; day = new DayViewModel(); day.Date = tempdate; #region Tithe if (dayIndex == 0) { if (settings.AddTithe) { BillViewModel Tithe = new BillViewModel(); Tithe.Name = "Tithe"; Tithe.Amount = Paycheck.PayCheck.Amount * settings.TitheMultiplier; Tithe.BackgroundColor = settings.TitheBGColor; Tithe.ForeColor = settings.TitheForeColor; summary.Debits += Tithe.Amount; Tithe.DueDay = tempdate.Day; day.Bills.Add(Tithe); } } #endregion if (tempdate.ToShortDateString() == DateTime.Now.ToShortDateString()) { summary.CurrentClass = "list-group-item-info"; } if (AllBills.Bills.Any(b => b.DueDay == tempdate.Day)) { List <BillViewModel> todaysbills = AllBills.Bills.Where(b => b.DueDay == tempdate.Day).ToList(); foreach (BillViewModel todaysbill in todaysbills) { CustomBillsViewModel CustomBills = new CustomBillsViewModel(todaysbill.Id); CustomBillViewModel thiscustombill = CustomBills.CustomBills.FirstOrDefault( cb => cb.BillDate.Year == tempdate.Year && cb.BillDate.Month == tempdate.Month); if (thiscustombill != null) { BillViewModel billcopy = new BillViewModel(todaysbill); //billcopy.Name = "* " + billcopy.Name; billcopy.Amount = thiscustombill.Amount; day.Bills.Add(billcopy); summary.Debits += billcopy.Amount; } else { day.Bills.Add(todaysbill); summary.Debits += todaysbill.Amount; } } } #region Month Changed if (WillMonthChange) { for (int d = tempdate.Day + 1; d < 32; d++) { if (AllBills.Bills.Any(b => b.DueDay == d)) { List <BillViewModel> todaysbills = AllBills.Bills.Where(b => b.DueDay == d).ToList(); foreach (BillViewModel todaysbill in todaysbills) { CustomBillsViewModel CustomBills = new CustomBillsViewModel(todaysbill.Id); CustomBillViewModel thiscustombill = CustomBills.CustomBills.FirstOrDefault(cb => cb.BillDate.Month == CurrentMonth); if (thiscustombill != null) { BillViewModel billcopy = new BillViewModel(todaysbill); //billcopy.Name = "* " + billcopy.Name + " (" + d.ToString() + ")"; billcopy.Amount = thiscustombill.Amount; day.Bills.Add(billcopy); summary.Debits += billcopy.Amount; } else { //todaysbill.Name = todaysbill.Name + " (" + d.ToString() + ")"; day.Bills.Add(todaysbill); summary.Debits += todaysbill.Amount; } } } } } #endregion paycheckdetails.Days.Add(day); } #endregion paycheckdetails.Summary = summary; summary = null; this.Paychecks.Add(paycheckdetails); paycheckdetails = null; } p = null; }
private DateTime FindFirstDay(Payday payDaySeed) { var dowIndex = (int)payDaySeed.Paydate.DayOfWeek; return(payDaySeed.Paydate.AddDays(0 - dowIndex)); }
private async Task LoadDataByEntryDate(Payday payday) { if (payday == null) { return; } if (Globals.isDataLoaded == true) { return; } Globals.isDataLoaded = true; DataInputs.Clear(); var dataInputs = await _dataInputInterface.GetDataInputByUserId(Globals.currentUser.Id); foreach (DataInput data in dataInputs) { int cutOff = data.EntryDate.Day > 15 ? 2 : 1; if (payday.Month == data.EntryDate.Month && payday.CutOff == cutOff) { DataInputs.Add(new DataInputViewModel(data)); } } ListViewData.Clear(); if (DataInputs.Count != 0) { ListViewData.Clear(); foreach (DataInputViewModel dmodel in DataInputs) { if (dmodel.Type == _type) { ListViewData.Add(dmodel); } } } TotalExpense = DataInputs.Where(x => x.Type == "E").Sum(x => x.Amount); TotalFund = DataInputs.Where(x => x.Type == "F").Sum(x => x.Amount); TotalBalance = TotalFund - TotalExpense; Savings = Globals.currentUser.Savings; Globals.gvTotalExpense = DataInputs.Where(x => x.Type == "E").Sum(x => x.Amount); Globals.gvTotalFund = DataInputs.Where(x => x.Type == "F").Sum(x => x.Amount); Globals.gvTotalBalance = Globals.gvTotalFund - Globals.gvTotalExpense; PieChart.Clear(); ChartData = new ChartData { Amount = Globals.gvTotalExpense, Type = "Remaining Balance" }; PieChart.Add(new ChartDataViewModel(ChartData)); ChartData = new ChartData { Amount = Globals.gvTotalFund, Type = "Expenses" }; PieChart.Add(new ChartDataViewModel(ChartData)); if (Globals.currentUser.isNotify == true) { if (Savings > Globals.gvTotalBalance) { if (await _pageService.DisplayAlert("MEESEES", "Your remaining balance is less than your Savings, have you already set aside the savings from this amount?", "YES", "NO")) { return; } else { await _pageService.DisplayAlert("MEESEES", "Please set aside the savings amount now!", "OK"); return; } } } }
public void Setup() { paydayHelper = new Payday(); }