コード例 #1
0
        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
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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)");
 }
コード例 #4
0
        public async Task ShouldUpdate_LoanPayment_UsingLoanAgreementAggregate()
        {
            LoanAgreement agreement = await _loanAgreementRepo.GetByIdAsync(new Guid("1511c20b-6df0-4313-98a5-7c3561757dc2"));

            LoanPayment payment = agreement.LoanPayments.FirstOrDefault(p => p.Id == new Guid("2205ebde-58dc-4af7-958b-9124d9645b38"));

            payment.UpdatePaymentDueDate(PaymentDueDate.Create(new DateTime(2021, 1, 10)));
            payment.UpdateLoanInterestAmount(LoanInterestAmount.Create(360.07M));

            agreement.UpdateLoanPayment(payment);
            await _unitOfWork.Commit();

            LoanPayment result = agreement.LoanPayments.FirstOrDefault(p => p.Id == new Guid("2205ebde-58dc-4af7-958b-9124d9645b38"));

            Assert.Equal(new DateTime(2021, 1, 10), result.PaymentDueDate);
            Assert.Equal(360.07M, result.LoanInterestAmount);
        }