Ejemplo n.º 1
0
        public async Task And_Has_ErrorCode_DLock07_And_TriageStatus_Unknown_Then_ILR_Data_mismatch_Alert(
            Apprenticeship source,
            DataLockStatus dataLockStatus,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            source.PriceHistory = new List <PriceHistory> {
                priceHistory
            };
            source.IsProviderSearch     = true;
            dataLockStatus.ErrorCode    = DataLockErrorCode.Dlock07;
            dataLockStatus.TriageStatus = TriageStatus.Unknown;
            dataLockStatus.IsResolved   = false;
            source.PriceHistory         = new List <PriceHistory> {
                priceHistory
            };
            source.DataLockStatus = new List <DataLockStatus> {
                dataLockStatus
            };
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();

            var result = await mapper.Map(source);

            result.Alerts.Should().BeEquivalentTo(new List <Alerts> {
                Alerts.IlrDataMismatch
            });
        }
        public ChangeOfPartyRequest(Apprenticeship apprenticeship,
                                    ChangeOfPartyRequestType changeOfPartyType,
                                    Party originatingParty,
                                    long newPartyId,
                                    int?price,
                                    DateTime?startDate,
                                    DateTime?endDate,
                                    UserInfo userInfo,
                                    DateTime now)
        {
            CheckOriginatingParty(originatingParty);
            CheckRequestType(originatingParty, changeOfPartyType);
            CheckPrice(originatingParty, changeOfPartyType, price);

            StartTrackingSession(UserAction.CreateChangeOfPartyRequest, originatingParty, apprenticeship.Cohort.AccountLegalEntityId, apprenticeship.Cohort.ProviderId, userInfo);

            ApprenticeshipId     = apprenticeship.Id;
            ChangeOfPartyType    = changeOfPartyType;
            OriginatingParty     = originatingParty;
            AccountLegalEntityId = changeOfPartyType == ChangeOfPartyRequestType.ChangeEmployer ? newPartyId : default(long?);
            ProviderId           = changeOfPartyType == ChangeOfPartyRequestType.ChangeProvider ? newPartyId : default(long?);
            Price         = price;
            StartDate     = startDate;
            EndDate       = endDate;
            Status        = ChangeOfPartyRequestStatus.Pending;
            CreatedOn     = now;
            LastUpdatedOn = now;

            ChangeTrackingSession.TrackInsert(this);
            ChangeTrackingSession.CompleteTrackingSession();

            Publish(() => new ChangeOfPartyRequestCreatedEvent(Id, userInfo));
        }
        public virtual Cohort CreateCohort(Apprenticeship apprenticeship, Guid?reservationId, UserInfo userInfo)
        {
            long providerId;
            long accountId;
            long accountLegalEntityId;

            switch (ChangeOfPartyType)
            {
            case ChangeOfPartyRequestType.ChangeEmployer:
                providerId           = apprenticeship.Cohort.ProviderId;
                accountId            = AccountLegalEntity.AccountId;
                accountLegalEntityId = AccountLegalEntityId.Value;
                break;

            case ChangeOfPartyRequestType.ChangeProvider:
                providerId           = ProviderId.Value;
                accountId            = apprenticeship.Cohort.EmployerAccountId;
                accountLegalEntityId = apprenticeship.Cohort.AccountLegalEntityId;
                break;

            default:
                throw new Exception("Invalid ChangeOfPartyType");
            }

            return(new Cohort(providerId, accountId, accountLegalEntityId, apprenticeship, reservationId, this, userInfo));
        }
Ejemplo n.º 4
0
        public async Task And_Provider_Has_Unresolved_Errors_That_Have_Known_Triage_Status(
            Apprenticeship source,
            DataLockStatus dataLockStatus,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            //Arrange
            dataLockStatus.Status       = Status.Fail;
            dataLockStatus.TriageStatus = TriageStatus.Restart;
            dataLockStatus.IsResolved   = false;
            source.IsProviderSearch     = true;
            source.PriceHistory         = new List <PriceHistory> {
                priceHistory
            };
            source.DataLockStatus = new List <DataLockStatus> {
                dataLockStatus
            };
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();

            //Act
            var result = await mapper.Map(source);

            //Assert
            result.Alerts.Should().BeNullOrEmpty();
        }
Ejemplo n.º 5
0
        public async Task And_Employer_Has_Unresolved_Errors_That_Have_Known_Triage_Status_And_Has_Course_DataLock_Changes_Requested_Only_One_Changes_Requested_Added(
            Apprenticeship source,
            DataLockStatus dataLockStatus,
            DataLockStatus dataLockStatus2,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            //Arrange
            dataLockStatus.Status        = Status.Fail;
            dataLockStatus.TriageStatus  = TriageStatus.Restart;
            dataLockStatus.IsResolved    = false;
            dataLockStatus2.ErrorCode    = DataLockErrorCode.Dlock03;
            dataLockStatus2.TriageStatus = TriageStatus.Restart;
            dataLockStatus2.IsResolved   = false;
            source.IsProviderSearch      = false;
            source.DataLockStatus        = new List <DataLockStatus> {
                dataLockStatus, dataLockStatus2
            };
            source.PriceHistory = new List <PriceHistory> {
                priceHistory
            };
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();

            //Act
            var result = await mapper.Map(source);

            //Assert
            result.Alerts.Should().NotBeNullOrEmpty();
            result.Alerts.Should().BeEquivalentTo(new List <Alerts> {
                Alerts.ChangesRequested
            });
        }
        public virtual void SetNewApprenticeship(Apprenticeship apprenticeship, UserInfo userInfo, Party modifyingParty)
        {
            CheckNewApprenticeshipIdNotSet(apprenticeship.Id);

            StartTrackingSession(UserAction.SetNewApprenticeshipId, modifyingParty, apprenticeship.Cohort.EmployerAccountId, apprenticeship.Cohort.ProviderId, userInfo);
            ChangeTrackingSession.TrackUpdate(this);

            NewApprenticeshipId = apprenticeship.Id;

            ChangeTrackingSession.CompleteTrackingSession();
        }
        /// <summary>
        /// Creates a Cohort from a Change of Party Request
        /// </summary>
        internal Cohort(long providerId,
                        long accountId,
                        long accountLegalEntityId,
                        Apprenticeship apprenticeship,
                        Guid?reservationId,
                        ChangeOfPartyRequest changeOfPartyRequest,
                        UserInfo userInfo)
            : this(providerId,
                   accountId,
                   accountLegalEntityId,
                   null,
                   changeOfPartyRequest.OriginatingParty,
                   userInfo)
        {
            ChangeOfPartyRequestId = changeOfPartyRequest.Id;

            Approvals = changeOfPartyRequest.IsPreApproved();

            WithParty = changeOfPartyRequest.OriginatingParty.GetOtherParty();
            IsDraft   = false;

            if (changeOfPartyRequest.ChangeOfPartyType == ChangeOfPartyRequestType.ChangeProvider)
            {
                TransferSenderId = apprenticeship.Cohort.TransferSenderId;
            }

            var draftApprenticeship = apprenticeship.CreateCopyForChangeOfParty(changeOfPartyRequest, reservationId);

            Apprenticeships.Add(draftApprenticeship);

            //Retained for backwards-compatibility:
            EditStatus       = WithParty.ToEditStatus();
            LastAction       = LastAction.Amend;
            CommitmentStatus = CommitmentStatus.Active;

            Publish(() => new CohortWithChangeOfPartyCreatedEvent(Id, changeOfPartyRequest.Id, changeOfPartyRequest.OriginatingParty, DateTime.UtcNow, userInfo));

            if (changeOfPartyRequest.ChangeOfPartyType == ChangeOfPartyRequestType.ChangeEmployer)
            {
                Publish(() => new CohortAssignedToEmployerEvent(Id, DateTime.UtcNow, Party.Provider));
            }
            else
            {
                Publish(() => new CohortAssignedToProviderEvent(Id, DateTime.UtcNow));
            }

            StartTrackingSession(UserAction.CreateCohortWithChangeOfParty, changeOfPartyRequest.OriginatingParty, accountId, providerId, userInfo);
            ChangeTrackingSession.TrackInsert(this);
            ChangeTrackingSession.TrackInsert(draftApprenticeship);
            ChangeTrackingSession.CompleteTrackingSession();
        }
Ejemplo n.º 8
0
        public async Task And_No_DataLocks_Then_No_Alerts(
            Apprenticeship source,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            source.DataLockStatus = new List <DataLockStatus>();
            source.PriceHistory   = new List <PriceHistory> {
                priceHistory
            };
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();

            var result = await mapper.Map(source);

            result.Alerts.Should().BeEmpty();
        }
Ejemplo n.º 9
0
        public async Task And_Has_PendingUpdateOriginator_Null_Then_No_Alert(
            Apprenticeship source,
            DataLockStatus dataLockStatus,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();
            source.ApprenticeshipUpdate = null;
            source.DataLockStatus       = new List <DataLockStatus> {
                dataLockStatus
            };
            source.PriceHistory = new List <PriceHistory> {
                priceHistory
            };

            var result = await mapper.Map(source);

            result.Alerts.Should().BeEmpty();
        }
Ejemplo n.º 10
0
        public async Task And_Has_ErrorCode_None_And_TriageStatus_Unknown_Then_No_Alerts(
            Apprenticeship source,
            DataLockStatus dataLockStatus,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            dataLockStatus.ErrorCode    = DataLockErrorCode.None;
            dataLockStatus.TriageStatus = TriageStatus.Unknown;
            source.PriceHistory         = new List <PriceHistory> {
                priceHistory
            };
            source.DataLockStatus = new List <DataLockStatus> {
                dataLockStatus
            };
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();

            var result = await mapper.Map(source);

            result.Alerts.Should().BeEmpty();
        }
Ejemplo n.º 11
0
        public async Task And_Has_Resolved_Alert_Then_Nothing_Is_Mapped(
            Apprenticeship source,
            DataLockStatus dataLockStatus,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            dataLockStatus.ErrorCode    = DataLockErrorCode.Dlock07;
            dataLockStatus.TriageStatus = TriageStatus.Change;
            dataLockStatus.IsResolved   = true;
            source.DataLockStatus       = new List <DataLockStatus> {
                dataLockStatus
            };
            source.PriceHistory = new List <PriceHistory> {
                priceHistory
            };
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();

            var result = await mapper.Map(source);

            result.Alerts.Should().BeEmpty();
        }
Ejemplo n.º 12
0
        public async Task And_Has_PendingUpdateOriginator_Provider_Then_Changes_Pending_Alert(
            Apprenticeship source,
            ApprenticeshipUpdate apprenticeshipUpdate,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            source.ApprenticeshipUpdate     = new List <ApprenticeshipUpdate>();
            apprenticeshipUpdate.Originator = Originator.Provider;
            apprenticeshipUpdate.Status     = (byte)ApprenticeshipUpdateStatus.Pending;
            source.ApprenticeshipUpdate.Add(apprenticeshipUpdate);
            source.DataLockStatus = new List <DataLockStatus>();
            source.PriceHistory   = new List <PriceHistory> {
                priceHistory
            };

            var result = await mapper.Map(source);

            result.Alerts.Should().BeEquivalentTo(new List <Alerts> {
                Alerts.ChangesForReview
            });
        }
Ejemplo n.º 13
0
        public async Task And_Has_ErrorCode_DLock03_And_TriageStatus_Restart_Then_Changes_Requested_Alert(
            Apprenticeship source,
            DataLockStatus dataLockStatus,
            PriceHistory priceHistory,
            ApprenticeshipToApprenticeshipDetailsMapper mapper)
        {
            dataLockStatus.ErrorCode    = DataLockErrorCode.Dlock03;
            dataLockStatus.TriageStatus = TriageStatus.Restart;
            dataLockStatus.IsResolved   = false;
            source.PriceHistory         = new List <PriceHistory> {
                priceHistory
            };
            source.DataLockStatus = new List <DataLockStatus> {
                dataLockStatus
            };
            source.ApprenticeshipUpdate = new List <ApprenticeshipUpdate>();

            var result = await mapper.Map(source);

            result.Alerts.Should().BeEquivalentTo(new List <Alerts> {
                Alerts.ChangesRequested
            });
        }