public OutlookDataSourceCalendar(Application app, string exchangeType, CalendarPeriod filter)
     : base(app,
            (exchangeType == "SIF") ? new OutlookToSyncMLSifE(app, filter) as OutlookToSyncMLX <AppointmentItem> : new OutlookToSyncMLICal(app, filter),
            (exchangeType == "SIF") ? new SyncMLSifEToOutlook(app, filter) as SyncMLXToOutlook <AppointmentItem> : new SyncMLICalendarToOutlook(app, filter),
            new OutlookCalendar(app, filter), DeletionLogForCalendar.Default)
 {
 }
Esempio n. 2
0
        public static IDictionary <CalendarPeriod, decimal> GetExpiredFunds(this IExpiredFunds expiredFundsService, IDictionary <CalendarPeriod, decimal> fundsIn, IDictionary <CalendarPeriod, decimal> fundsOut, IDictionary <CalendarPeriod, decimal> expired, int expiryPeriod, DateTime today)
        {
            var currentCalendarPeriod = new CalendarPeriod(today.Year, today.Month);
            var expiringFunds         = expiredFundsService.GetExpiringFunds(fundsIn, fundsOut, expired, expiryPeriod);

            var expiredFunds = expiringFunds
                               .Where(ef => ef.Key <= currentCalendarPeriod && ef.Value >= 0 && !expired.Any(e => e.Key == ef.Key && e.Value == ef.Value))
                               .ToDictionary(e => e.Key, e => e.Value);

            return(expiredFunds);
        }
        public void Then_The_Tax_Years_Are_Compared_Correctly_From_Transaction_Dates(string start, string end, bool expected)
        {
            //Arrange
            var startDate = new CalendarPeriod(Convert.ToInt32(start.Split('-')[0]), Convert.ToInt32(start.Split('-')[1]));
            var endDate   = new CalendarPeriod(Convert.ToInt32(end.Split('-')[0]), Convert.ToInt32(end.Split('-')[1]));

            //Act
            var actual = startDate.AreSameTaxYear(endDate);

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public static GenerateAccountProjectionCommand Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "TriggerGeneratePaymentProjections/{employerAccountId}")] CalendarPeriod req,
            long employerAccountId,
            TraceWriter log)
        {
            log.Verbose($"Received http request to generate payments projections for employer: {employerAccountId}");

            return(new GenerateAccountProjectionCommand
            {
                EmployerAccountId = employerAccountId,
                ProjectionSource = ProjectionSource.PaymentPeriodEnd,
                StartPeriod = req
            });
        }
 public IActionResult DeriveCalendarPeriod([FromBody] CalendarPeriod calendarPeriod)
 {
     try
     {
         return(Ok(_baseCalculatorService.DeriveCalendarPeriod(calendarPeriod)));
     }
     catch (Exception ex)
     {
         AMTErrorMessage errorMessage = new AMTErrorMessage
         {
             Message = ex.Message
         };
         return(BadRequest(errorMessage));
     }
 }
        private void GenerateProjections(long id, string url, int dayOfMonth)
        {
            DeleteAccountProjections(id);
            var projectionUrl = url.Replace("{employerAccountId}", id.ToString());

            Console.WriteLine($"Sending payment event to payment projection function: {projectionUrl}");

            var calendarPeriod = new CalendarPeriod
            {
                Year  = DateTime.Today.Year,
                Month = DateTime.Today.Month,
                Day   = dayOfMonth
            };

            var response = HttpClient.PostAsync(projectionUrl, new StringContent(JsonConvert.SerializeObject(calendarPeriod), Encoding.UTF8, "application/json")).Result;

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
Esempio n. 7
0
        public async Task Handle(DraftExpireAccountFundsCommand message, IMessageHandlerContext context)
        {
            _logger.Info($"DRAFT: Expiring funds for account ID '{message.AccountId}' with expiry period '{_configuration.FundsExpiryPeriod}'");

            var now     = _currentDateTime.Now;
            var fundsIn = await _levyFundsInRepository.GetLevyFundsIn(message.AccountId);

            var fundsOut             = (await _paymentFundsOutRepository.GetPaymentFundsOut(message.AccountId)).ToList();
            var existingExpiredFunds = await _expiredFundsRepository.GetDraft(message.AccountId);

            if (message.DateTo != null && fundsOut.Count > 0)
            {
                fundsOut = fundsOut.Where(c =>
                                          new DateTime(c.CalendarPeriodYear, c.CalendarPeriodMonth, 1) <
                                          new DateTime(message.DateTo.Value.Year, message.DateTo.Value.Month, 1)).ToList();
            }


            var expiredFunds = _expiredFunds.GetExpiredFunds(
                fundsIn.ToCalendarPeriodDictionary(),
                fundsOut.ToCalendarPeriodDictionary(),
                existingExpiredFunds.ToCalendarPeriodDictionary(),
                _configuration.FundsExpiryPeriod,
                now);

            if (!message.DateTo.HasValue)
            {
                message.DateTo = DateTime.UtcNow;
            }


            var currentCalendarPeriod = new CalendarPeriod(message.DateTo.Value.Year, message.DateTo.Value.Month);

            if (!expiredFunds.ContainsKey(currentCalendarPeriod))
            {
                expiredFunds.Add(currentCalendarPeriod, 0);
            }

            await _expiredFundsRepository.CreateDraft(message.AccountId, expiredFunds.Where(c => c.Key.Equals(currentCalendarPeriod)).ToDictionary(key => key.Key, value => value.Value).ToExpiredFundsList(), now);

            _logger.Info($"DRAFT: Expired '{expiredFunds.Count}' month(s) of funds for account ID '{message.AccountId}' with expiry period '{_configuration.FundsExpiryPeriod}'");
        }
Esempio n. 8
0
        public async Task Handle(ExpireAccountFundsCommand message, IMessageHandlerContext context)
        {
            _logger.Info($"Expiring funds for account ID '{message.AccountId}' with expiry period '{_configuration.FundsExpiryPeriod}'");

            var now     = _currentDateTime.Now;
            var fundsIn = await _levyFundsInRepository.GetLevyFundsIn(message.AccountId);

            var fundsOut = await _paymentFundsOutRepository.GetPaymentFundsOut(message.AccountId);

            var existingExpiredFunds = await _expiredFundsRepository.Get(message.AccountId);

            var expiredFunds = _expiredFunds.GetExpiredFunds(
                fundsIn.ToCalendarPeriodDictionary(),
                fundsOut.ToCalendarPeriodDictionary(),
                existingExpiredFunds.ToCalendarPeriodDictionary(),
                _configuration.FundsExpiryPeriod,
                now);

            var currentCalendarPeriod = new CalendarPeriod(_currentDateTime.Now.Year, _currentDateTime.Now.Month);

            if (!expiredFunds.ContainsKey(currentCalendarPeriod))
            {
                expiredFunds.Add(currentCalendarPeriod, 0);
            }

            await _expiredFundsRepository.Create(message.AccountId, expiredFunds.ToExpiredFundsList(), now);

            //todo: do we publish the event if no fund expired? we could add a bool like the levy declared message
            // once an account has an expired fund, we'll publish every run, even if no additional funds have expired
            if (expiredFunds.Any(ef => ef.Value != 0m))
            {
                await PublishAccountFundsExpiredEvent(context, message.AccountId);
            }

            _logger.Info($"Expired '{expiredFunds.Count}' month(s) of funds for account ID '{message.AccountId}' with expiry period '{_configuration.FundsExpiryPeriod}'");
        }
Esempio n. 9
0
 public SyncMLICalendarToOutlook(Application app, CalendarPeriod filter)
     : base(new OutlookCalendar(app, filter), new OutlookCalendarWithICal(app))
 {
 }
Esempio n. 10
0
 public OutlookToSyncMLICal(Application app, CalendarPeriod filter)
     : base(new OutlookCalendar(app, filter), new OutlookCalendarWithICal(app), DeletionLogForCalendar.Default)
 {
 }
Esempio n. 11
0
 public OutlookCalendar(Application app, CalendarPeriod filter)
     : base(app.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar) as Folder)
 {
     this.filter = filter;
 }
 public OutlookDataSourceCalendar(string exchangeType, CalendarPeriod filter)
     : this(new Application(), exchangeType, filter)
 {
 }
 public void SetCalendarPeriod1(int year, int month)
 {
     CalendarPeriod1 = new CalendarPeriod(year, month);
 }
 public WhenComparingCalendarPeriodsFixture()
 {
     CalendarPeriod2 = new CalendarPeriod(2018, 01);
 }