public async Task Archive(PendingPaymentModel pendingPaymentModel) { await _dbContext.AddAsync(pendingPaymentModel.Map()); pendingPaymentModel.PendingPaymentValidationResultModels.ToList().ForEach(async v => { await _dbContext.AddAsync(v.ArchiveMap(pendingPaymentModel.Id)); }); }
public static void AddPaymentsForFee(int membershipFeeId, ApplicationDbContext _context) { var membershipFee = _context.MembershipFees.FirstOrDefault(fee => fee.Id == membershipFeeId); if (membershipFee.Periodicity == FeePeriodicity.Year) { int month = membershipFee.Start.Month; for (int i = 1; i <= 12; i++) { PendingPaymentModel payment; if (i == 1 && membershipFee.Start.Day > 1) { int days = DateTime.DaysInMonth(membershipFee.Start.Year, membershipFee.Start.Month); double differense = Math.Floor((membershipFee.Start.Day - 1) * membershipFee.MonthlyPay / days); membershipFee.LeftOver -= differense; payment = new PendingPaymentModel() { MembershipFeeForeignKey = membershipFee.Id, Amount = (membershipFee.MonthlyPay - differense), PaymentDeadline = membershipFee.Start.AddMonths(i), Status = PaymentStatus.Pending, DepositOrDebt = -(membershipFee.MonthlyPay - differense) }; } else { payment = new PendingPaymentModel() { MembershipFeeForeignKey = membershipFee.Id, Amount = membershipFee.MonthlyPay, PaymentDeadline = membershipFee.Start.AddMonths(i), Status = PaymentStatus.Pending, DepositOrDebt = -membershipFee.MonthlyPay }; } _context.Payments.Add(payment); } _context.Update(membershipFee); } else { int month = membershipFee.Start.AddMonths(1).Month; var payment = new PendingPaymentModel() { MembershipFeeForeignKey = membershipFee.Id, Amount = Math.Floor(membershipFee.RealAmount / 12), PaymentDeadline = new DateTime(DateTime.Now.Year, month, 15), Status = PaymentStatus.Pending }; _context.Payments.Add(payment); } _context.SaveChanges(); }
public PendingPaymentDeleted( long accountId, long accountLegalEntityId, long uniqueLearnerNumber, PendingPaymentModel model) { AccountLegalEntityId = accountLegalEntityId; AccountId = accountId; UniqueLearnerNumber = uniqueLearnerNumber; Model = model; }
public void Arrange() { _fixture = new Fixture(); _dueDate = DateTime.Now.AddMonths(-1); short paymentYear = (short)DateTime.Now.Year; _periodNumber = _fixture.Create <byte>(); _nextPendingPaymentDue = _fixture.Build <PendingPaymentModel>() .With(pp => pp.PaymentMadeDate, (DateTime?)null) .With(pp => pp.PaymentYear, paymentYear) .With(pp => pp.PeriodNumber, _periodNumber) .With(pp => pp.DueDate, _dueDate)// earliest .Create(); _apprenticeshipIncentiveModel = _fixture.Build <ApprenticeshipIncentiveModel>() .With(a => a.PendingPaymentModels, new List <PendingPaymentModel>() { _fixture.Build <PendingPaymentModel>() .With(pp => pp.PaymentMadeDate, (DateTime?)null) .With(pp => pp.DueDate, _dueDate.AddMonths(1)) .With(pp => pp.PaymentYear, (short?)null) .Create(), _fixture.Build <PendingPaymentModel>() .With(pp => pp.PaymentMadeDate, (DateTime?)null) .With(pp => pp.DueDate, _dueDate.AddMonths(2)) .With(pp => pp.PaymentYear, (short?)null) .Create(), _nextPendingPaymentDue }) .Create(); _incentive = new ApprenticeshipIncentiveFactory().GetExisting(_apprenticeshipIncentiveModel.Id, _apprenticeshipIncentiveModel); _sut = _fixture.Create <LearnerSubmissionDto>(); _startTime = _dueDate.AddDays(-10); _testTrainingDto = _sut.Training.First(); _testTrainingDto.Reference = "ZPROG001"; _testPriceEpisodeDto = _testTrainingDto.PriceEpisodes.First(); _testPriceEpisodeDto.StartDate = _startTime; _testPriceEpisodeDto.EndDate = _dueDate.AddDays(10); _testPeriodDto = _testPriceEpisodeDto.Periods.First(); _testPeriodDto.ApprenticeshipId = _incentive.Apprenticeship.Id; _testPeriodDto.IsPayable = false; _testPeriodDto.Period = _periodNumber; }
internal static Models.Archive.PendingPayment Map(this PendingPaymentModel model) { return(new Models.Archive.PendingPayment { PendingPaymentId = model.Id, AccountId = model.Account.Id, AccountLegalEntityId = model.Account.AccountLegalEntityId, ApprenticeshipIncentiveId = model.ApprenticeshipIncentiveId, Amount = model.Amount, DueDate = model.DueDate, CalculatedDate = model.CalculatedDate, PeriodNumber = model.PeriodNumber, PaymentYear = model.PaymentYear, PaymentMadeDate = model.PaymentMadeDate, EarningType = model.EarningType, ClawedBack = model.ClawedBack, ArchiveDateUTC = DateTime.UtcNow }); }
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); }
public static PendingPayment Map(this PendingPaymentModel model) { return(PendingPayment.Get(model)); }