public async Task ShouldInsert_LoanPymt_UsingLoanAgreementAggregate() { LoanAgreement agreement = await _loanAgreementRepo.GetByIdAsync(new Guid("0a7181c0-3ce9-4981-9559-157fd8e09cfb")); EconomicEvent economicEvent = new EconomicEvent(Guid.NewGuid(), EventType.CashDisbursementForLoanPayment); await _loanAgreementRepo.AddEconomicEventAsync(economicEvent); LoanPayment loanPayment = new LoanPayment ( economicEvent, agreement, PaymentNumber.Create(1), PaymentDueDate.Create(new DateTime(2021, 12, 5)), LoanPrincipalAmount.Create(14135.13M), LoanInterestAmount.Create(984), LoanPrincipalRemaining.Create(160862.13M), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); agreement.AddLoanPayment(loanPayment); _loanAgreementRepo.Update(agreement); await _unitOfWork.Commit(); LoanPayment result = agreement.LoanPayments.FirstOrDefault(p => p.Id == loanPayment.EconomicEvent.Id); Assert.NotNull(result); }
public async Task ShouldInsert_LoanAgreementAndLoanPymt_UsingLoanAgreementAggregate() { LoanAgreement agreement = new LoanAgreement ( new EconomicEvent(Guid.NewGuid(), EventType.CashReceiptFromLoanAgreement), FinancierId.Create(new Guid("b49471a0-5c1e-4a4d-97e7-288fb0f6338a")), LoanAmount.Create(175000), InterestRate.Create(.0675), LoanDate.Create(new DateTime(2021, 11, 5)), MaturityDate.Create(new DateTime(2022, 11, 5)), PaymentsPerYear.Create(12), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); LoanPayment loanPayment = new LoanPayment ( new EconomicEvent(Guid.NewGuid(), EventType.CashDisbursementForLoanPayment), agreement, PaymentNumber.Create(1), PaymentDueDate.Create(new DateTime(2021, 12, 5)), LoanPrincipalAmount.Create(14135), LoanInterestAmount.Create(984), LoanPrincipalRemaining.Create(160862), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); agreement.AddLoanPayment(loanPayment); await _loanAgreementRepo.AddAsync(agreement); await _unitOfWork.Commit(); var result = await _loanAgreementRepo.Exists(agreement.Id); Assert.True(result); //TODO Test navigation to LoanPayment }
public void Configure(EntityTypeBuilder <LoanPayment> entity) { entity.ToTable("LoanPaymentSchedules", schema: "Finance"); entity.HasKey(e => e.Id); entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("LoanPaymentId"); entity.HasOne(p => p.EconomicEvent).WithOne().HasForeignKey <LoanPayment>(p => p.Id); entity.HasOne(p => p.LoanAgreement).WithMany(p => p.LoanPayments).HasForeignKey(p => p.LoanId); entity.Property(p => p.LoanId) .HasColumnType("UNIQUEIDENTIFIER") .HasColumnName("LoanId") .IsRequired(); entity.Property(p => p.PaymentNumber) .HasConversion(p => p.Value, p => PaymentNumber.Create(p)) .HasColumnType("int") .HasColumnName("PaymentNumber") .IsRequired(); entity.Property(p => p.PaymentDueDate) .HasConversion(p => p.Value, p => PaymentDueDate.Create(p)) .HasColumnType("DATETIME2(0)") .HasColumnName("PaymentDueDate") .IsRequired(); entity.Property(p => p.LoanPrincipalAmount) .HasConversion(p => p.Value, p => LoanPrincipalAmount.Create(p)) .HasColumnType("DECIMAL(18,2)") .HasColumnName("PrincipalAmount") .IsRequired(); entity.Property(p => p.LoanInterestAmount) .HasConversion(p => p.Value, p => LoanInterestAmount.Create(p)) .HasColumnType("DECIMAL(18,2)") .HasColumnName("InterestAmount") .IsRequired(); entity.Property(p => p.LoanPrincipalRemaining) .HasConversion(p => p.Value, p => LoanPrincipalRemaining.Create(p)) .HasColumnType("DECIMAL(18,2)") .HasColumnName("PrincipalRemaining") .IsRequired(); entity.Property(p => p.UserId) .HasConversion(p => p.Value, p => UserId.Create(p)) .HasColumnType("UNIQUEIDENTIFIER") .HasColumnName("UserId") .IsRequired(); entity.Property(e => e.CreatedDate) .HasColumnType("datetime2(7)") .ValueGeneratedOnAdd() .HasDefaultValueSql("sysdatetime()"); entity.Property(e => e.LastModifiedDate).HasColumnType("datetime2(7)"); }
protected Payment(DateTime paidDate, DateTime expiredDate, decimal total, decimal totalPaid, string payer, Document document, Address address) { Number = new PaymentNumber(); PaidDate = paidDate; ExpiredDate = expiredDate; Total = total; TotalPaid = totalPaid; Payer = payer; Document = document; Address = address; AddNotifications(new Contract() .Requires() .IsGreaterThan(0, Total, "Payment.Total", "The payment total must be greather than zero.") .IsGreaterThan(TotalPaid, Total, "Payment.TotalPaid", "The total paid cannot be greater than payment total.") ); }
public override string ToString() { return($"H,{PaymentNumber.Trim()},{PaymentAmount.Trim()},{PayeeId.Trim()},{PaymentDate.Trim()},{FreeFormAddress1?.Trim().EscapeCSV()},{FreeFormAddress2?.Trim().EscapeCSV()},{FreeFormAddress3?.Trim().EscapeCSV()},{FreeFormAddress4?.Trim().EscapeCSV()},{FreeFormAddress5?.Trim().EscapeCSV()}"); }