Example #1
0
        public async Task CalculateEarnings(IIncentivePaymentProfilesService incentivePaymentProfilesService, ICollectionCalendarService collectionCalendarService)
        {
            if (Model.Status == IncentiveStatus.Withdrawn)
            {
                return;
            }

            var paymentProfiles = await incentivePaymentProfilesService.Get();

            var collectionCalendar = await collectionCalendarService.Get();

            var incentive = new Incentive(Apprenticeship.DateOfBirth, StartDate, paymentProfiles);

            if (!incentive.IsEligible)
            {
                ClawbackAllPayments(collectionCalendar.GetActivePeriod());
                return;
            }

            foreach (var payment in incentive.Payments)
            {
                AddPendingPaymentsAndClawbackWhereRequired(payment, collectionCalendar);
            }

            AddEvent(new EarningsCalculated
            {
                ApprenticeshipIncentiveId = Id,
                AccountId                   = Account.Id,
                ApprenticeshipId            = Apprenticeship.Id,
                ApplicationApprenticeshipId = Model.ApplicationApprenticeshipId
            });

            Model.RefreshedLearnerForEarnings = false;
        }
        public static async Task <Incentive> Create(
            ApprenticeshipIncentive incentive,
            IIncentivePaymentProfilesService incentivePaymentProfilesService)
        {
            var paymentProfiles = await incentivePaymentProfilesService.Get();

            return(Create(incentive.Phase.Identifier, incentive.Apprenticeship.DateOfBirth, incentive.StartDate, paymentProfiles, incentive.BreakInLearnings));
        }
        public static async Task <Incentive> Create(
            IncentiveApplicationApprenticeshipDto incentiveApplication,
            IIncentivePaymentProfilesService incentivePaymentProfilesService)
        {
            var paymentProfiles = await incentivePaymentProfilesService.Get();

            return(Create(incentiveApplication.Phase, incentiveApplication.DateOfBirth, incentiveApplication.PlannedStartDate, paymentProfiles, new List <BreakInLearning>()));
        }
Example #4
0
 public CalculateEarningsCommandHandler(
     IApprenticeshipIncentiveDomainRepository domainRepository,
     IIncentivePaymentProfilesService incentivePaymentProfilesService,
     ICollectionCalendarService collectionCalendarService)
 {
     _domainRepository = domainRepository;
     _incentivePaymentProfilesService = incentivePaymentProfilesService;
     _collectionCalendarService       = collectionCalendarService;
 }
 public GetApplicationQueryHandler(IQueryRepository <IncentiveApplicationDto> applicationQueryRepository, IQueryRepository <LegalEntityDto> legalEntityQueryRepository, IIncentivePaymentProfilesService incentivePaymentProfilesService)
 {
     _applicationQueryRepository      = applicationQueryRepository;
     _legalEntityQueryRepository      = legalEntityQueryRepository;
     _incentivePaymentProfilesService = incentivePaymentProfilesService;
 }