Ejemplo n.º 1
0
        public async Task <PendingPayment> HandlePaymentCallback(PaymentConfirmDto dto)
        {
            SignedPaymentInfo signed = new SignedPaymentInfo(dto.data, dto.signature);
            string            id     = LiqPay.GetOrderId(signed);

            if (!PendingPayments.ContainsKey(id))
            {
                throw new NotFoundException("payment with such id");
            }

            if (!LiqPay.IsSucceed(signed))
            {
                throw new ValidationException();
            }

            PendingPayment payment = PendingPayments[id];

            if (!LiqPay.IsPaymentAuthorized(signed, payment.PaymentInfo))
            {
                throw new UnauthorizedAccessException();
            }

            foreach (OrderEntity order in payment.PaidOrders)
            {
                await OrderRepo.MarkPaid(order.Id);
            }

            return(payment);
        }
        public WithdrawalByComplianceSteps(TestContext testContext) : base(testContext)
        {
            _testContext      = testContext;
            _fixture          = new Fixture();
            _connectionString = _testContext.SqlDatabase.DatabaseInfo.ConnectionString;

            _application    = _fixture.Create <IncentiveApplication>();
            _apprenticeship = _fixture
                              .Build <IncentiveApplicationApprenticeship>()
                              .With(a => a.IncentiveApplicationId, _application.Id)
                              .With(a => a.WithdrawnByCompliance, false)
                              .Create();

            _apprenticeship2 = _fixture
                               .Build <IncentiveApplicationApprenticeship>()
                               .With(a => a.IncentiveApplicationId, _application.Id)
                               .With(a => a.ULN, _apprenticeship.ULN)
                               .With(a => a.WithdrawnByCompliance, false)
                               .Create();

            _apprenticeshipIncentive = _fixture
                                       .Build <ApprenticeshipIncentive>()
                                       .With(i => i.IncentiveApplicationApprenticeshipId, _apprenticeship.Id)
                                       .With(i => i.AccountLegalEntityId, _application.AccountLegalEntityId)
                                       .With(i => i.AccountId, _application.AccountId)
                                       .With(i => i.ULN, _apprenticeship.ULN)
                                       .With(i => i.Status, IncentiveStatus.Active)
                                       .Create();

            _pendingPayment = _fixture
                              .Build <PendingPayment>()
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(i => i.AccountId, _apprenticeshipIncentive.AccountId)
                              .With(i => i.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                              .With(p => p.PaymentMadeDate, (DateTime?)null)
                              .Create();

            _paidPendingPayment = _fixture
                                  .Build <PendingPayment>()
                                  .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                                  .With(i => i.AccountId, _apprenticeshipIncentive.AccountId)
                                  .With(i => i.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                                  .Create();

            _payment = _fixture
                       .Build <Payment>()
                       .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                       .With(i => i.AccountId, _apprenticeshipIncentive.AccountId)
                       .With(i => i.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                       .With(p => p.PendingPaymentId, _paidPendingPayment.Id)
                       .Create();

            _pendingPaymentValidationResult = _fixture
                                              .Build <PendingPaymentValidationResult>()
                                              .With(p => p.PendingPaymentId, _pendingPayment.Id)
                                              .With(p => p.Step, "Invalid")
                                              .With(p => p.PeriodNumber, 1)
                                              .With(p => p.PaymentYear, 2021)
                                              .Create();
        }
 private static decimal?PaymentAmount(PendingPayment pendingPayment, Payment payment)
 {
     if (payment != null)
     {
         return(payment.Amount);
     }
     return(pendingPayment.Amount);
 }
Ejemplo n.º 4
0
 private void RemoveDeletedValidationResults(PendingPayment updatedPendingPayment, PendingPayment existingPendingPayment)
 {
     foreach (var existingValidationResult in existingPendingPayment.ValidationResults)
     {
         if (!updatedPendingPayment.ValidationResults.Any(c => c.Id == existingValidationResult.Id))
         {
             _dbContext.PendingPaymentValidationResults.Remove(existingValidationResult);
         }
     }
 }
Ejemplo n.º 5
0
        public void Then_is_true_when_the_payment_year_changes()
        {
            // arrange

            _newPendingPaymentModel.CollectionPeriod = new CollectionPeriod(_sut.CollectionPeriod.PeriodNumber, (short)(_sut.CollectionPeriod.AcademicYear + 1));
            _newPendingPayment = PendingPayment.Get(_newPendingPaymentModel);

            // act
            var result = _sut.RequiresNewPayment(_newPendingPayment);

            // assert
            result.Should().BeTrue();
        }
        private void SetupPendingPayments()
        {
            _pendingPayment1 = _fixture.Build <PendingPayment>().Create();


            var pendingPayments = new List <PendingPayment>
            {
                _pendingPayment1
            };

            _context.PendingPayments.AddRange(pendingPayments);
            _context.SaveChanges();
        }
Ejemplo n.º 7
0
        public void Then_is_true_when_the_amount_change()
        {
            // arrange

            _newPendingPaymentModel.Amount = _sut.Amount + 1;
            _newPendingPayment             = PendingPayment.Get(_newPendingPaymentModel);

            // act
            var result = _sut.RequiresNewPayment(_newPendingPayment);

            // assert
            result.Should().BeTrue();
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _sut          = _fixture.Create <LearnerSubmissionDto>();
            _startDate    = DateTime.Now;
            _endDate      = _startDate.AddMonths(2);
            _periodNumber = 3;
            var dueDate = _startDate.AddMonths(1);

            var pendingPaymentModel = _fixture
                                      .Build <PendingPaymentModel>()
                                      .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                                      .With(p => p.DueDate, dueDate)
                                      .Create();

            _apprenticeshipIncentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>()
                                            .With(p => p.Apprenticeship, _fixture.Create <Apprenticeship>())
                                            .With(p => p.PendingPaymentModels, new List <PendingPaymentModel> {
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, dueDate.AddMonths(1))
                .With(pp => pp.CollectionPeriod, (Domain.ValueObjects.CollectionPeriod)null)
                .Create(),
                _fixture.Build <PendingPaymentModel>()
                .With(pp => pp.PaymentMadeDate, (DateTime?)null)
                .With(pp => pp.DueDate, dueDate.AddMonths(2))
                .With(pp => pp.CollectionPeriod, (Domain.ValueObjects.CollectionPeriod)null)
                .Create(),
                pendingPaymentModel
            })
                                            .Create();

            _incentive      = new ApprenticeshipIncentiveFactory().GetExisting(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel);
            _pendingPayment = _incentive.PendingPayments.Single(p => p.Id == pendingPaymentModel.Id);

            _testTrainingDto           = _sut.Training.First();
            _testTrainingDto.Reference = "ZPROG001";

            _testPriceEpisodeDto           = _testTrainingDto.PriceEpisodes.First();
            _testPriceEpisodeDto.StartDate = _startDate;
            _testPriceEpisodeDto.EndDate   = _endDate;

            _testPeriodDto = _testPriceEpisodeDto.Periods.First();

            _testPeriodDto.ApprenticeshipId = _apprenticeshipIncentiveModel.Apprenticeship.Id;
            _testPeriodDto.Period           = _periodNumber;
            _testPeriodDto.IsPayable        = true;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Clear Pending Payment :
        /// 1. Update Pending Payment
        /// 2. Update Sale Amount
        /// 3. Add Payment Transaction
        /// </summary>
        /// <param name="payment"></param>
        public void ClearPendingPayment(PendingPayment payment)
        {
            using (DataAccess da = new DataAccess())
            {
                #region Update pending payment
                Dictionary <string, string> pendingPaymentModel = new Dictionary <string, string>();
                pendingPaymentModel.Add("Id", payment.Id.ToString());
                pendingPaymentModel.Add("SaleId", payment.SaleId.ToString());
                pendingPaymentModel.Add("SalePersonId", payment.SalePersonId.ToString());
                pendingPaymentModel.Add("PendingAmount", payment.PendingAmount.ToString());
                pendingPaymentModel.Add("IsPaid", (payment.IsPaid == true ? "1" : "0"));// true
                pendingPaymentModel.Add("PaidDate", payment.PaidDate.ToString(ConfigurationManager.AppSettings["DateOnly"]));
                pendingPaymentModel.Add("IsDiscount", (payment.IsDiscount == true ? "1" : "0"));
                //Note : Discounted payment shd more than purchase total amount
                pendingPaymentModel.Add("PaidAmount", payment.PaidAmount.ToString());
                int pendingPaymentId = da.InsertOrUpdatePendingPayment(pendingPaymentModel, "tblPendingPayment");
                if (pendingPaymentId > 0)
                {
                    #region Update Sale PaidAmount
                    // update Sale
                    Dictionary <string, string> smModel = new Dictionary <string, string>();
                    smModel.Add("Id", payment.SaleId.ToString());
                    smModel.Add("AmountPaid", payment.PaidAmount.ToString());
                    smModel.Add("ModifiedDate", payment.PaidDate.ToString(ConfigurationManager.AppSettings["DateOnly"]));
                    da.InsertOrUpdateSaleMaster(smModel, "tblSaleMaster");
                    #endregion

                    #region Add Payment Transaction
                    // add payment transaction
                    PaymentTransaction pt = new PaymentTransaction();
                    bool paymentStatus    = pt.AddPaymentTransaction(Global.UserId, payment.PaidAmount, CommonEnum.PaymentStatus.PENDING_PAYMENT, pendingPaymentId, da);
                    if (paymentStatus)
                    {
                        MessageBoxResult result = MessageBox.Show("Payment Updated Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        //this.Close();
                    }
                    else
                    {
                        MessageBoxResult result = MessageBox.Show((string)Application.Current.FindResource("StandardProcessingErrorMessage"), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    #endregion
                }
                else
                {
                    MessageBoxResult result = MessageBox.Show((string)Application.Current.FindResource("StandardProcessingErrorMessage"), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                #endregion
            }
        }
Ejemplo n.º 10
0
        public async Task <SignedPaymentInfo> GetPaymentForm(string login)
        {
            IEnumerable <OrderEntity> oldUnpayedOrders = await GetOldUnpayedOrders(login);

            if (oldUnpayedOrders.Count() == 0)
            {
                throw new NotFoundException("orders to pay for");
            }

            int    tax = GetTaxAmount(oldUnpayedOrders);
            string id  = Guid.NewGuid().ToString();

            PaymentPrepareModel paymentPrepare = new PaymentPrepareModel(id, tax, CALLBACK_URL);
            SignedPaymentInfo   signedPayment  = LiqPay.CreatePayment(paymentPrepare);
            PendingPayment      pending        = new PendingPayment(id, signedPayment, oldUnpayedOrders);

            PendingPayments.Add(id, pending);
            return(signedPayment);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create Pending Payment If Any
        /// </summary>
        /// <param name="pendingPayment"></param>
        /// <param name="da"></param>
        /// <returns></returns>
        private int CreatePendingPayment(PendingPayment pendingPayment, DataAccess da)
        {
            Dictionary <string, string> pendingPmt = new Dictionary <string, string>();

            pendingPmt.Add("Id", null);
            pendingPmt.Add("SaleId", pendingPayment.SaleId.ToString());
            pendingPmt.Add("SalePersonId", pendingPayment.SalePersonId.ToString());
            pendingPmt.Add("PendingAmount", pendingPayment.PendingAmount.ToString());
            // If Discounted Payment Then Paid the amt with IsDiscount=true, PaidAmt
            if (pendingPayment.IsDiscount)
            {
                pendingPmt.Add("IsPaid", "1"); pendingPmt.Add("IsDiscount", (pendingPayment.IsDiscount == true ? "1" : "0"));
                pendingPmt.Add("PaidAmount", "0" /*pendingPayment.PaidAmount.ToString()*/);
                pendingPmt.Add("PaidDate", DateTime.Now.ToString(ConfigurationManager.AppSettings["DateOnly"]));
                //ConfigurationManager.AppSettings["DateOnly"]
            }
            int pendingPaymentId = da.InsertOrUpdatePendingPayment(pendingPmt, "tblPendingPayment");

            return(pendingPaymentId);
        }
Ejemplo n.º 12
0
        private void UpdatePendingPayment(PendingPayment updatedPendingPayment, PendingPayment existingPendingPayment)
        {
            _dbContext.Entry(existingPendingPayment).CurrentValues.SetValues(updatedPendingPayment);

            RemoveDeletedValidationResults(updatedPendingPayment, existingPendingPayment);

            foreach (var validationResult in updatedPendingPayment.ValidationResults)
            {
                var existingValidationResult = existingPendingPayment.ValidationResults.SingleOrDefault(v => v.Id == validationResult.Id);

                if (existingValidationResult != null)
                {
                    _dbContext.Entry(existingValidationResult).CurrentValues.SetValues(validationResult);
                }
                else
                {
                    _dbContext.PendingPaymentValidationResults.Add(validationResult);
                }
            }
        }
        public ApprenticeshipIncentiveCreatedSteps(TestContext testContext) : base(testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();
            var today = new DateTime(2021, 6, 30);

            _accountModel = _fixture.Create <Account>();

            _applicationModel = _fixture.Build <IncentiveApplication>()
                                .With(p => p.Status, IncentiveApplicationStatus.InProgress)
                                .With(p => p.AccountId, _accountModel.Id)
                                .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                .Create();

            _apprenticeshipsModels = _fixture.Build <IncentiveApplicationApprenticeship>()
                                     .With(p => p.IncentiveApplicationId, _applicationModel.Id)
                                     .With(p => p.PlannedStartDate, today.AddMonths(-2))
                                     .With(p => p.DateOfBirth, today.AddYears(-20))
                                     .With(p => p.EarningsCalculated, false)
                                     .With(p => p.WithdrawnByCompliance, false)
                                     .With(p => p.WithdrawnByEmployer, false)
                                     .With(p => p.Phase, Phase.Phase1)
                                     .CreateMany(NumberOfApprenticeships).ToList();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.IncentiveApplicationApprenticeshipId, _apprenticeshipsModels.First().Id)
                                       .With(p => p.AccountId, _applicationModel.AccountId)
                                       .With(p => p.AccountLegalEntityId, _applicationModel.AccountLegalEntityId)
                                       .With(p => p.ApprenticeshipId, _apprenticeshipsModels.First().ApprenticeshipId)
                                       .With(p => p.StartDate, today.AddDays(1))
                                       .With(p => p.DateOfBirth, today.AddYears(-20))
                                       .With(p => p.Phase, Phase.Phase2)
                                       .Create();

            _pendingPayment = _fixture.Build <PendingPayment>()
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                              .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                              .Create();
        }
        private static DateTime?PaymentDate(
            PendingPayment pendingPayment,
            Payment payment,
            Domain.ValueObjects.CollectionPeriod nextActivePeriod)
        {
            if (payment != null)
            {
                if (payment.PaidDate != null)
                {
                    return(payment.PaidDate.Value);
                }
                return(payment.CalculatedDate);
            }

            var activePeriodDate = new DateTime(nextActivePeriod.OpenDate.Year, nextActivePeriod.OpenDate.Month, nextActivePeriod.OpenDate.Day);
            var paymentDueDate   = new DateTime(pendingPayment.DueDate.Year, pendingPayment.DueDate.Month, pendingPayment.DueDate.Day);

            if (paymentDueDate < activePeriodDate)
            {
                return(new DateTime(nextActivePeriod.CalendarYear, nextActivePeriod.CalendarMonth, 27));
            }
            return(pendingPayment.DueDate.AddMonths(1));
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _sutModel = _fixture
                        .Build <PendingPaymentModel>()
                        .With(p => p.DueDate, DateTime.Today)
                        .With(p => p.CollectionPeriod, new CollectionPeriod(1, 2021))
                        .With(p => p.EarningType, EarningType.FirstPayment)
                        .Create();

            _newPendingPaymentModel =
                _fixture
                .Build <PendingPaymentModel>()
                .With(p => p.Account, _sutModel.Account)
                .With(p => p.ApprenticeshipIncentiveId, _sutModel.ApprenticeshipIncentiveId)
                .With(p => p.Amount, _sutModel.Amount)
                .With(p => p.CollectionPeriod, new CollectionPeriod(_sutModel.CollectionPeriod.PeriodNumber, _sutModel.CollectionPeriod.AcademicYear))
                .Create();

            _newPendingPayment = PendingPayment.Get(_newPendingPaymentModel);

            _sut = PendingPayment.Get(_sutModel);
        }
Ejemplo n.º 16
0
        private void PendingPayment_Click(object sender, RoutedEventArgs e)
        {
            PendingPayment pendingPayment = new PendingPayment();

            pendingPayment.Show();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Create Sales Order :
        /// 1. Create Sale Person If New
        /// 2. Add SaleMaster
        /// 3. Add Sales Invoice
        /// 4. Add Pending Payment if any
        /// 5. Add payment transaction
        /// 6. Update Stock
        /// </summary>
        /// <returns></returns>
        public int CreateSalesOrder(Sale _sale)
        {
            int salesOrderId = 0;

            using (DataAccess da = new DataAccess())
            {
                try
                {
                    // add Sale Contact
                    if (_sale.Contact.Id == 0)
                    {
                        _sale.Contact.Id = CreateSalePersonForSale(da, _sale.Contact);
                    }
                    if (_sale.Contact.Id > 0)
                    {
                        double total      = _sale.Quantity * _sale.Price;
                        bool   isPending  = (total > _sale.AmountPaid ? true : false);
                        double pendingAmt = total - _sale.AmountPaid;
                        #region Create Sales Master Object
                        //Add SaleMaster
                        Dictionary <string, string> saleMaster = new Dictionary <string, string>();
                        saleMaster.Add("Id", _sale.Id == 0 ? null : _sale.Id.ToString());
                        saleMaster.Add("StockId", _sale.StockId.ToString());
                        saleMaster.Add("SalePersonId", _sale.Contact.Id.ToString());
                        saleMaster.Add("Quantity", _sale.Quantity.ToString());
                        saleMaster.Add("Price", _sale.Price.ToString());
                        saleMaster.Add("Total", _sale.Total.ToString());
                        saleMaster.Add("AmountPaid", _sale.AmountPaid.ToString());
                        //saleMasterModel.Add("Pending", pendingAmt.ToString());
                        saleMaster.Add("SaleDate", _sale.SaleDate.ToString(ConfigurationManager.AppSettings["DateOnly"]));
                        saleMaster.Add("CreatedDate", DateTime.Now.ToString(ConfigurationManager.AppSettings["DateTimeFormat"]));
                        #endregion
                        salesOrderId = da.InsertOrUpdateSaleMaster(saleMaster, "tblSaleMaster");
                        if (salesOrderId > 0 && _sale.Id == 0)
                        {
                            #region Add Sales Invoice
                            // Adding Sales Invoice
                            Dictionary <string, string> invoice = new Dictionary <string, string>();
                            invoice.Add("Id", null);
                            invoice.Add("SalesId", salesOrderId.ToString());
                            invoice.Add("InvoiceNumber", CommonMethods.GenerateInvoice(salesOrderId, _sale.SaleDate));
                            da.InsertOrUpdateInvoiceMaster(invoice, "tblInvoiceMaster");
                            #endregion

                            #region Add Pending Payment
                            if (isPending)
                            {
                                PendingPayment pendingPayment = new PendingPayment()
                                {
                                    SaleId       = salesOrderId, SalePersonId = _sale.Contact.Id, PendingAmount = pendingAmt
                                    , IsDiscount = _sale.IsDiscounted
                                };
                                CreatePendingPayment(pendingPayment, da);
                            }
                            #endregion

                            #region Add Payment Transaction
                            // add payment transaction
                            PaymentTransaction paymentTransaction = new PaymentTransaction();
                            bool paymentStatus = paymentTransaction.AddPaymentTransaction(Global.UserId, _sale.AmountPaid, CommonEnum.PaymentStatus.SALE_PAYMENT, salesOrderId, da);
                            if (paymentStatus)
                            {
                                #region Update Stock Quantity
                                Dictionary <string, string> stockModel = new Dictionary <string, string>();
                                stockModel.Add("Id", _sale.StockId.ToString());
                                stockModel.Add("AvlQuantity", _sale.Quantity.ToString());
                                stockModel.Add("ModifiedDate", DateTime.Now.ToString(ConfigurationManager.AppSettings["DateTimeFormat"]));
                                int isUpdated = da.UpdateStockQuantity(stockModel, "tblStockMaster");
                                #endregion
                                if (isUpdated == 1)
                                {
                                    SendMailService ms = new SendMailService();
                                    ms.SendSalesOrderCreateMail(_sale);

                                    MessageBoxResult result = MessageBox.Show("Sale Added Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                                }
                                else
                                {
                                    MessageBoxResult result = MessageBox.Show("Error While Updating Stock!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                }
                            }
                            else
                            {
                                MessageBoxResult result = MessageBox.Show("Error While Adding Payment Transaction!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                            #endregion
                        }
                        else
                        {
                            MessageBoxResult result = MessageBox.Show((string)Application.Current.FindResource("StandardProcessingErrorMessage"), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    logger.LogException(ex);
                    da.RollbackTransaction();
                }
            }
            return(salesOrderId);
        }
 public static PendingPayment Map(this PendingPaymentModel model)
 {
     return(PendingPayment.Get(model));
 }
Ejemplo n.º 19
0
        public LearningStoppedSteps(TestContext testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();

            _plannedStartDate = new DateTime(2020, 8, 1);
            _breakInLearning  = 15;
            _accountModel     = _fixture.Create <Account>();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.DateOfBirth, _plannedStartDate.AddYears(-24).AddMonths(-10)) // under 25
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .With(p => p.HasPossibleChangeOfCircumstances, false)
                                       .With(p => p.StartDate, new DateTime(2020, 11, 1))
                                       .With(p => p.Phase, Phase.Phase1)
                                       .Create();

            _pendingPayment = _fixture.Build <PendingPayment>()
                              .With(p => p.AccountId, _accountModel.Id)
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(p => p.DueDate, _plannedStartDate.AddMonths(1))
                              .With(p => p.ClawedBack, false)
                              .With(p => p.EarningType, EarningType.FirstPayment)
                              .Without(p => p.PaymentMadeDate)
                              .Create();

            _periodEndDate = DateTime.Today.AddDays(-10);

            _learner = _fixture
                       .Build <Learner>()
                       .With(p => p.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                       .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                       .With(p => p.ULN, _apprenticeshipIncentive.ULN)
                       .With(p => p.Ukprn, _apprenticeshipIncentive.UKPRN)
                       .With(p => p.LearningFound, true)
                       .With(p => p.StartDate, _plannedStartDate.AddDays(-10))
                       .Create();

            _learningPeriod1 = _fixture
                               .Build <LearningPeriod>()
                               .With(p => p.LearnerId, _learner.Id)
                               .With(p => p.StartDate, _plannedStartDate.AddDays(-20).AddDays(_breakInLearning * -1))
                               .With(p => p.EndDate, _plannedStartDate.AddDays(-10).AddDays(_breakInLearning * -1))
                               .Create();

            _stoppedLearnerMatchApiData = _fixture
                                          .Build <LearnerSubmissionDto>()
                                          .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                          .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                          .With(l => l.Training, new List <TrainingDto> {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _plannedStartDate)
                    .With(pe => pe.EndDate, _periodEndDate)
                    .Create()
                }
                      )
                .Create()
            }
                                                )
                                          .Create();

            _resumedLearnerMatchApiData = _fixture
                                          .Build <LearnerSubmissionDto>()
                                          .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                          .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                          .With(l => l.Training, new List <TrainingDto> {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _plannedStartDate)
                    .With(pe => pe.EndDate, DateTime.Today.AddDays(10))
                    .Create()
                }
                      )
                .Create()
            }
                                                )
                                          .Create();

            _resumedLearnerWithBreakInLearningMatchApiData = _fixture
                                                             .Build <LearnerSubmissionDto>()
                                                             .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                                             .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                                             .With(l => l.Training, new List <TrainingDto> {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _plannedStartDate)
                    .With(pe => pe.EndDate, DateTime.Today.AddDays(_breakInLearning * -1))
                    .Create(),
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, DateTime.Today)
                    .With(pe => pe.EndDate, DateTime.Today.AddDays(10))
                    .Create()
                }
                      )
                .Create()
            }
                                                                   )
                                                             .Create();

            _apprenticeshipBreakInLearning = _fixture
                                             .Build <ApprenticeshipBreakInLearning>()
                                             .With(b => b.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                                             .With(b => b.StartDate, _plannedStartDate.AddDays(_breakInLearning * -1))
                                             .With(b => b.EndDate, (DateTime?)null)
                                             .Create();

            _resumedLearnerWithIncorrectlyRecordedBreakInLearningMatchApiData = _fixture
                                                                                .Build <LearnerSubmissionDto>()
                                                                                .With(s => s.Ukprn, _apprenticeshipIncentive.UKPRN)
                                                                                .With(s => s.Uln, _apprenticeshipIncentive.ULN)
                                                                                .With(l => l.Training, new List <TrainingDto>
            {
                _fixture
                .Build <TrainingDto>()
                .With(p => p.Reference, "ZPROG001")
                .With(p => p.PriceEpisodes, new List <PriceEpisodeDto>()
                {
                    _fixture.Build <PriceEpisodeDto>()
                    .With(pe => pe.Periods, new List <PeriodDto>()
                    {
                        _fixture.Build <PeriodDto>()
                        .With(period => period.ApprenticeshipId,
                              _apprenticeshipIncentive.ApprenticeshipId)
                        .With(period => period.IsPayable, true)
                        .With(period => period.Period, _pendingPayment.PeriodNumber)
                        .Create()
                    })
                    .With(pe => pe.StartDate, _apprenticeshipBreakInLearning.StartDate)
                    .With(pe => pe.EndDate, DateTime.Today.AddMonths(12))
                    .Create(),
                }
                      )
                .Create()
            }
                                                                                      )
                                                                                .Create();
        }
Ejemplo n.º 20
0
        public LearningResumedSteps(TestContext testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();

            _plannedStartDate = new DateTime(2020, 11, 10);
            _breakInLearning  = 15;
            _accountModel     = _fixture.Create <Account>();
            _periodNumber     = 1;

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.DateOfBirth, new DateTime(1995, 10, 15)) // under 25
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .With(p => p.HasPossibleChangeOfCircumstances, false)
                                       .With(p => p.StartDate, _plannedStartDate)
                                       .With(p => p.RefreshedLearnerForEarnings, true)
                                       .With(p => p.PausePayments, false)
                                       .With(p => p.Status, IncentiveStatus.Stopped)
                                       .With(p => p.BreakInLearnings, new List <ApprenticeshipBreakInLearning>())
                                       .With(p => p.Phase, Phase.Phase1)
                                       .Create();

            _apprenticeshipBreakInLearning = _fixture
                                             .Build <ApprenticeshipBreakInLearning>()
                                             .With(b => b.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                                             .With(b => b.StartDate, new DateTime(2021, 02, 08))
                                             .With(b => b.EndDate, (DateTime?)null)
                                             .Create();

            _pendingPayment = _fixture.Build <PendingPayment>()
                              .With(p => p.AccountId, _accountModel.Id)
                              .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                              .With(p => p.DueDate, new DateTime(2021, 02, 07))
                              .With(p => p.ClawedBack, false)
                              .With(p => p.EarningType, EarningType.FirstPayment)
                              .With(p => p.PaymentYear, (short)2021)
                              .With(p => p.PeriodNumber, (byte)7)
                              .With(p => p.Amount, 750)
                              .Without(p => p.PaymentMadeDate)
                              .Create();

            _payment = _fixture.Build <Payment>()
                       .With(d => d.PendingPaymentId, _pendingPayment.Id)
                       .With(d => d.AccountId, _accountModel.Id)
                       .With(d => d.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                       .With(d => d.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                       .With(d => d.PaymentPeriod, _pendingPayment.PeriodNumber)
                       .With(d => d.PaymentYear, _pendingPayment.PaymentYear)
                       .With(d => d.PaidDate, _pendingPayment.DueDate)
                       .With(d => d.Amount, _pendingPayment.Amount)
                       .Create();

            _clawbackPayment = _fixture.Build <ClawbackPayment>()
                               .With(d => d.PendingPaymentId, _pendingPayment.Id)
                               .With(d => d.PaymentId, _payment.Id)
                               .With(d => d.DateClawbackSent, _pendingPayment.DueDate.AddDays(5))
                               .With(d => d.AccountId, _accountModel.Id)
                               .With(d => d.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                               .With(d => d.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                               .With(d => d.CollectionPeriod, _pendingPayment.PeriodNumber)
                               .With(d => d.CollectionPeriodYear, _pendingPayment.PaymentYear)
                               .Create();
        }