public void CanPersistStoreHours()
        {
            using (var session = _sessionFactory.OpenSession())
            {
                using (var trx = session.BeginTransaction())
                {
                    var day1 = new BusinessDay()
                    {
                        BusinessDate = new DateTime(2016, 1, 11),
                        StartOfDay   = new DateTime(2016, 1, 11, 9, 0, 0),
                        EndOfDay     = new DateTime(2016, 1, 11, 17, 0, 0)
                    };

                    var hours = new StoreHours()
                    {
                        Name        = "Westridge Kiosk",
                        StartOfWeek = new DateTime(2016, 1, 11),
                        EndOfWeek   = new DateTime(2016, 1, 17),
                        Hours       = new List <BusinessDay>()
                        {
                            day1
                        }
                    };

                    session.Save(hours);
                    trx.Commit();
                    Assert.AreNotEqual(hours.Id, 0);
                }
            }
        }
        public override double NAVCalculation(BusinessDay date)
        {
            double val = NPV(date);

            CommitNAVCalculation(date, val, TimeSeriesType.Last);
            return(val);
        }
 public void BusinessDayOnOrBefore()
 {
     Assert.AreEqual(new DateTime(2019, 12, 30), NewYearsEve.BusinessDayOnOrBefore(Calendar));
     Assert.AreEqual(new DateTime(2019, 12, 30), NewYears.BusinessDayOnOrBefore(Calendar));
     Assert.AreEqual(BusinessDayInDecember, BusinessDayInDecember.BusinessDayOnOrBefore(Calendar));
     Assert.AreEqual(BusinessDay, BusinessDay.BusinessDayOnOrBefore(Calendar));
 }
 public void Delete(BusinessDay entity)
 {
     if (AuthorizedUsers["Delete"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         BusinessDayController.Delete(entity);
     }
 }
        public static CashFlow CreateStrategy(Instrument instrument, BusinessDay initialDate, double amount, BusinessDay date, CashFlowGroup group)
        {
            if (instrument.InstrumentType == InstrumentType.Strategy)
            {
                CashFlow Strategy = new CashFlow(instrument);

                Strategy.Amount = amount;
                Strategy.Date   = date.DateTime;

                //Strategy.AddMemoryPoint(DateTime.MinValue, amount, -(int)MemoryType.Amount);
                //Strategy.AddMemoryPoint(DateTime.MinValue, date.DateTime.ToOADate(), -(int)MemoryType.Date);
                if (group != null)
                {
                    Strategy.Group = group;
                }
                //Strategy.AddMemoryPoint(DateTime.MinValue, group.ID, -(int)MemoryType.GroupID);
                double npv = Strategy.NPV(initialDate);
                Strategy.Startup(initialDate, npv, null);

                Strategy.InitialDate = new DateTime(1990, 01, 06);

                return(Strategy);
            }
            else
            {
                throw new Exception("Instrument not a Strategy");
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,StartDate,EndDate,MonthId,YearId,TeamId")] BusinessDay businessDay)
        {
            if (id != businessDay.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(businessDay);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BusinessDayExists(businessDay.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Teams, "Id", "Id", businessDay.TeamId);
            return(View(businessDay));
        }
 public void FreePeriod(BusinessDay businessDay, List <DateTime> period)
 {
     if (AuthorizedUsers["FreePeriod"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         BusinessDayController.FreePeriod(businessDay, period);
     }
 }
 public void Edit(BusinessDay entity)
 {
     if (AuthorizedUsers["Edit"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         BusinessDayController.Edit(entity);
     }
 }
Beispiel #9
0
        public async Task <ActionResult <BusinessDay> > PostBusinessDay(BusinessDay businessDay)
        {
            _context.BusinessDays.Add(businessDay);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBusinessDay", new { id = businessDay.BusinessDayId }, businessDay));
        }
        public override double NAVCalculation(BusinessDay date)
        {
            double val = this.Portfolio[date.DateTime, TimeSeriesType.Last, TimeSeriesRollType.Last];

            CommitNAVCalculation(date, val, TimeSeriesType.Last);
            return(val);
        }
 public void BusinessDayOnOrAfter()
 {
     Assert.AreEqual(new DateTime(2020, 01, 02), NewYearsEve.BusinessDayOnOrAfter(Calendar));
     Assert.AreEqual(new DateTime(2020, 01, 02), NewYears.BusinessDayOnOrAfter(Calendar));
     Assert.AreEqual(BusinessDayInDecember, BusinessDayInDecember.BusinessDayOnOrAfter(Calendar));
     Assert.AreEqual(BusinessDay, BusinessDay.BusinessDayOnOrAfter(Calendar));
 }
        public void CanPersistStoreHours()
        {
            using (var session = _sessionFactory.OpenSession())
            {
                using (var trx = session.BeginTransaction())
                {
                    var day1 = new BusinessDay()
                    {
                        BusinessDate = new DateTime(2016, 1, 11),
                        StartOfDay = new DateTime(2016, 1, 11, 9, 0, 0),
                        EndOfDay = new DateTime(2016, 1, 11, 17, 0, 0)
                    };

                    var hours = new StoreHours()
                    {
                        Name = "Westridge Kiosk",
                        StartOfWeek = new DateTime(2016, 1, 11),
                        EndOfWeek = new DateTime(2016, 1, 17),
                        Hours = new List<BusinessDay>() {day1}
                    };

                    session.Save(hours);
                    trx.Commit();
                    Assert.AreNotEqual(hours.Id,0);
                }
            }
        }
 public void MarkAsOccupied(List <Period> period, BusinessDay businessDay)
 {
     if (AuthorizedUsers["MarkAsOccupied"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         BusinessDayController.MarkAsOccupied(period, businessDay);
     }
 }
Beispiel #14
0
        public ActionResult Start()
        {
            try
            {
                var _BusinessDay = new BusinessDay
                {
                    BusinessDayId   = Guid.NewGuid(),
                    StartTime       = DateTime.Now,
                    EndTime         = null,
                    BusinessDayDate = DateTime.Now.Date,
                };

                var _ValidationErrors = new List <ValidationError>();
                if ((m_Manager as BusinessDayManager).Save(_BusinessDay, _ValidationErrors))
                {
                    return(null);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception Ew)
            {
                m_Logger.TraceException(Ew.Message, Ew);
                return(null);
            }
        }
Beispiel #15
0
        public Boolean ChangeDoctorShift(BusinessDay newShift)
        {
            TimeSpan shiftDuration = new TimeSpan();

            shiftDuration = newShift.Shift.EndDate - newShift.Shift.StartDate;

            double periodTotalMinutes = 0;

            if (newShift.ScheduledPeriods == null)
            {
                return(true);
            }

            foreach (Period period in newShift.ScheduledPeriods)
            {
                periodTotalMinutes += durationOfExamination;
            }


            if (shiftDuration.TotalMinutes < periodTotalMinutes)
            {
                return(false);
            }

            foreach (Period period in newShift.ScheduledPeriods)
            {
                if (!periodCorrespondsToNewShift(newShift.Shift, period))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #16
0
        private void MacFTPChecker_Load(object sender, EventArgs e)
        {
            //as a default, set the date times to today
            dtpClientStatements.Value = dtpRawData.Value = BusinessDay.GetLastBusinessDayDateTime(DateTime.Today);

            updateFromFTP();
        }
Beispiel #17
0
        public async Task <IActionResult> PutBusinessDay(int id, BusinessDay businessDay)
        {
            if (id != businessDay.BusinessDayId)
            {
                return(BadRequest());
            }

            _context.Entry(businessDay).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessDayExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public void AddBusinessDays()
 {
     Assert.AreEqual(BusinessDay, BusinessDay.AddBusinessDays(0, Calendar));
     Assert.AreEqual(WeekendDay, WeekendDay.AddBusinessDays(0, Calendar));
     Assert.AreEqual(new DateTime(2019, 10, 17), WeekendDay.AddBusinessDays(-1, Calendar));
     Assert.AreEqual(new DateTime(2019, 10, 24), new DateTime(2019, 10, 19).AddBusinessDays(2, Calendar));
     Assert.AreEqual(new DateTime(2020, 01, 02), NewYears.AddBusinessDays(1, Calendar));
 }
Beispiel #19
0
 public IRZeroCurve GetCurve(BusinessDay day)
 {
     if (!_curve_dictionary.ContainsKey(day.DateTime))
     {
         GenerateCurve(day);
     }
     return(_curve_dictionary[day.DateTime]);
 }
 public Boolean ChangeDoctorShift(BusinessDay newShift)
 {
     if (AuthorizedUsers["ChangeDoctorShift"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         return(BusinessDayController.ChangeDoctorShift(newShift));
     }
     return(false);
 }
 public BusinessDay Save(BusinessDay entity)
 {
     if (AuthorizedUsers["Save"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         return(BusinessDayController.Save(entity));
     }
     return(null);
 }
        private void SaveBusinessDay(BusinessDayIdentifier identifier)
        {
            if (identifier == null)
                throw new ArgumentNullException(nameof(identifier));

            var personIdentifiers = AttendeesView.GetCollection().Select(p => p.Identifier);
            var businessDay = new BusinessDay(identifier, personIdentifiers);
            RepositoryManager.Save(businessDay);
            RepositoryManager.FlushBusinessDayRepositoryToDisk();
        }
Beispiel #23
0
 public BusinessDay Save(BusinessDay entity)
 {
     if (validateDates(entity))
     {
         return(_businessDayRepository.Save(entity));
     }
     else
     {
         return(null);
     }
 }
        public double NPV(BusinessDay businessDay)
        {
            double val = 0.0;

            foreach (CashFlow flow in CashFlows(businessDay.DateTime).Values.ToList())
            {
                val += flow.NPV(businessDay);
            }

            return(val);
        }
        public BusinessDay DeleteBusinessDay(long BusinessDayID)
        {
            BusinessDay dbEntry = context.BusinessDay.Find(BusinessDayID);

            if (dbEntry != null)
            {
                context.BusinessDay.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
Beispiel #26
0
        public IRZeroCurve GenerateCurve(BusinessDay currentDate)
        {
            if (_curve_dictionary.ContainsKey(currentDate.DateTime))
            {
                return(_curve_dictionary[currentDate.DateTime]);
            }

            IRZeroCurve curve = new IRZeroCurve(currentDate);

            foreach (InterestRate rate in _interest_rate_lst)
            {
                try
                {
                    double value = rate[currentDate.DateTime, TimeSeriesType.Last, DataProvider.DefaultProvider, TimeSeriesRollType.Exact] / 100.0;

                    if (double.IsNaN(value))
                    {
                        value = rate[Calendar.Close(currentDate.DateTime), TimeSeriesType.Last, DataProvider.DefaultProvider, TimeSeriesRollType.Last] / 100.0;
                    }

                    if (!double.IsNaN(value))
                    {
                        // Console.WriteLine("Generate Curve: " + this._currency + " " + currentDate.DateTime + " " + rate + " " + value);

                        if (rate.InstrumentType == InstrumentType.Deposit)
                        {
                            Deposit deposit = (rate as Deposit);
                            curve.AddCashFlow(value, deposit.MaturityType, deposit.Maturity, deposit.MaturityType, deposit.Maturity, deposit.DayCountConvention);

                            // Console.WriteLine("     Add deposit:" + rate + " " + deposit.MaturityType + " " + deposit.Maturity + " " + deposit.MaturityType + " " + deposit.Maturity + " " + deposit.DayCountConvention);
                        }
                        else if (rate.InstrumentType == InstrumentType.InterestRateSwap)
                        {
                            InterestRateSwap swap = (rate as InterestRateSwap);
                            curve.AddCashFlow(value, swap.FixedFrequencyType, swap.FixedFrequency, swap.MaturityType, swap.Maturity, swap.FixedDayCountConvention);
                            // Console.WriteLine("     Add Swap:" + rate + " " + swap.FixedFrequency + " " + swap.MaturityType + " " + swap.Maturity + " " + swap.FixedDayCountConvention);
                        }
                    }
                }
                catch { }
            }

            curve.BootStrap();
            if (_curve_dictionary.ContainsKey(currentDate.DateTime))
            {
                _curve_dictionary[currentDate.DateTime] = curve;
            }
            else
            {
                _curve_dictionary.TryAdd(currentDate.DateTime, curve);
            }

            return(curve);
        }
Beispiel #27
0
        private bool validateDates(BusinessDay entity)
        {
            foreach (BusinessDay businessDay in GetBusinessDaysByDoctor(entity.doctor)) //15/07 - 25/-7
            {
                if (businessDay.Shift.StartDate.Date == entity.Shift.StartDate.Date)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #28
0
        public async Task <IActionResult> Create([Bind("Id,StartDate,EndDate,MonthId,YearId,TeamId")] BusinessDay businessDay)
        {
            if (ModelState.IsValid)
            {
                _context.Add(businessDay);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Teams, "Id", "Id", businessDay.TeamId);
            return(View(businessDay));
        }
Beispiel #29
0
        void updateMacqFTPStatusLabel()
        {
            //get ftp directory listing
            List <string> contents = FTPToolkit.getFTPDirectoryContents(
                Constants.MacFTPLocationSignedInAsMacquarie,
                Constants.MacFTPLocationUser,
                Constants.MacFTPLocationPass);

            int totalStatements = FilenameChecker.howManyClientStatements(contents, BusinessDay.GetLastBusinessDayDateTime(DateTime.Today))
                                  + FilenameChecker.howManyRawDataStatements(contents, BusinessDay.GetLastBusinessDayDateTime(DateTime.Today));

            lblMacqFTPStatusAnswer.Text = totalStatements.ToString() + " statements waiting";
        }
Beispiel #30
0
        internal int?GetBusinessDayId()
        {
            // BusinessDay bday = cn.BusinessDays.Where(b=>

            //     {b.TeamId==GetTeam().Id;}

            // ).SingleOrDefault();

            BusinessDay bday = cn.BusinessDays.Where(b => b.TeamId == GetTeam().Id)
                               .Where(b => b.MonthId == GetMonthId()).SingleOrDefault(); //side effect

            return(bday.Id);                                                             //very bad, you gonna take back//kya karu me
        }
        public void DeleteBusinessDayFromDoctor(BusinessDay businessDay)
        {
            Doctor doctor = Get(businessDay.doctor.Id);

            foreach (BusinessDay business in doctor.BusinessDay)
            {
                if (business.Id == businessDay.Id)
                {
                    doctor.BusinessDay.Remove(business);
                    Edit(doctor);
                    break;
                }
            }
        }
Beispiel #32
0
        public void AddBusinessDay(BusinessDay bday)
        {
            lock (objLock)
            {
                if (_dateTables.ContainsKey(bday.CalendarID))
                {
                    DataTable table = _dateTables[bday.CalendarID];
                    DataRow   r     = table.NewRow();

                    r["ID"]               = bday.CalendarID;
                    r["Timestamp"]        = bday.DateTime;
                    r["BusinessDayMonth"] = bday.DayMonth;
                    r["BusinessDayYear"]  = bday.DayYear;
                    r["BusinessDayIndex"] = bday.DayIndex;
                    table.Rows.Add(r);
                }
            }
        }
        public void BusinessHours()
        {
            var day = new BusinessDay(DateTime.Today.DayOfWeek,
                DateTime.Now.Subtract(TimeSpan.FromHours(1)).TimeOfDay,
                DateTime.Now.AddHours(1).TimeOfDay);

            bool isDay = day.IsBusinessDay(DateTime.Now);
            Assert.IsTrue(isDay);

            // day of week test
            isDay = day.IsBusinessDay(DateTime.Now.AddDays(1));
            Assert.IsFalse(isDay);

            // to early test
            isDay = day.IsBusinessDay(DateTime.Today);
            Assert.IsFalse(isDay);

            // to late test
            isDay = day.IsBusinessDay(DateTime.Now.AddHours(2));
            Assert.IsFalse(isDay);
        }
        public void BusinessHours() {
            var date = DateTime.Now.StartOfDay().AddHours(8);

            var day = new BusinessDay(date.Date.DayOfWeek,
                date.Subtract(TimeSpan.FromHours(1)).TimeOfDay,
                date.AddHours(1).TimeOfDay);

            bool isDay = day.IsBusinessDay(date);
            Assert.True(isDay);

            // day of week test
            isDay = day.IsBusinessDay(date.AddDays(1));
            Assert.False(isDay);

            // to early test
            isDay = day.IsBusinessDay(date.Date);
            Assert.False(isDay);

            // to late test
            isDay = day.IsBusinessDay(date.AddHours(2));
            Assert.False(isDay);
        }
 private void SaveBusinessDay()
 {
     var repository = RepositoryManager.GetBusinessDayRepositoryInstance();
     var attendances = attendanceCollectionControl1.GetAttendancesCollection().ToArray();
     var businessDay = new BusinessDay(DateTime.Now, attendances);
     repository.Save(businessDay);
     repository.FlushRepositoryToDisk();
 }