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 static async Task Execute ( CreateLoanAgreementInfo model, ILoanAgreementAggregateRepository loanAgreementRepo, IFinancierAggregateRepository financierRepo, IUnitOfWork unitOfWork ) { if (await loanAgreementRepo.Exists(model.Id)) { throw new InvalidOperationException($"This loan agreement already exists!"); } string errMsg = $"Unable to create loan agreement info, a financier with id {model.FinancierId} could not be found!"; Financier financier = await financierRepo.GetByIdAsync(model.FinancierId) ?? throw new InvalidOperationException(errMsg); LoanAgreement loanAgreement = new LoanAgreement ( new EconomicEvent(model.Id, EventType.CashReceiptFromLoanAgreement), FinancierId.Create(financier.Id), LoanAmount.Create(model.LoanAmount), InterestRate.Create(model.InterestRate), LoanDate.Create(model.LoanDate), MaturityDate.Create(model.MaturityDate), PaymentsPerYear.Create(model.PaymentsPerYear), model.UserId ); await loanAgreementRepo.AddAsync(loanAgreement); await unitOfWork.Commit(); }
/// <summary> /// Determines whether the specified <see cref="System.Object" />, is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { Loan loan = obj as Loan; if (Id == loan.Id && LoanDate.Equals(loan.LoanDate)) { return(true); } return(false); }
public void ShouldReturn_NewLoanAgreement() { var economicEvent = new EconomicEvent(Guid.NewGuid(), EventType.CashReceiptFromLoanAgreement); Financier financier = GetFinancier(); LoanAgreement agreement = new LoanAgreement ( economicEvent, FinancierId.Create(financier.Id), LoanAmount.Create(10000), InterestRate.Create(.006), LoanDate.Create(new DateTime(2020, 12, 31)), MaturityDate.Create(new DateTime(2021, 12, 31)), PaymentsPerYear.Create(12), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); Assert.IsType <LoanAgreement>(agreement); }
public void Configure(EntityTypeBuilder <LoanAgreement> entity) { entity.ToTable("LoanAgreements", schema: "Finance"); entity.HasKey(e => e.Id); entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("LoanId"); entity.HasOne(p => p.EconomicEvent).WithOne().HasForeignKey <LoanAgreement>(p => p.Id); entity.Property(p => p.FinancierId).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("FinancierId"); entity.Property(p => p.LoanAmount) .HasConversion(p => p.Value, p => LoanAmount.Create(p)) .HasColumnType("DECIMAL(18,2)") .HasColumnName("LoanAmount") .IsRequired(); entity.Property(p => p.InterestRate) .HasConversion(p => p.Value, p => InterestRate.Create(p)) .HasColumnType("NUMERIC(9,6)") .HasColumnName("InterestRate") .IsRequired(); entity.Property(p => p.LoanDate) .HasConversion(p => p.Value, p => LoanDate.Create(p)) .HasColumnType("DATETIME2(0)") .HasColumnName("LoanDate") .IsRequired(); entity.Property(p => p.MaturityDate) .HasConversion(p => p.Value, p => MaturityDate.Create(p)) .HasColumnType("DATETIME2(0)") .HasColumnName("MaturityDate") .IsRequired(); entity.Property(p => p.PaymentsPerYear) .HasConversion(p => p.Value, p => PaymentsPerYear.Create(p)) .HasColumnType("INT") .HasColumnName("PymtsPerYear") .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)"); }
public static async Task Execute ( EditLoanAgreementInfo model, ILoanAgreementAggregateRepository loanAgreementRepo, IUnitOfWork unitOfWork ) { string errMsg = $"Unable to locate loan agreement with LoanId '{model.Id}'!"; LoanAgreement loanAgreement = await loanAgreementRepo.GetByIdAsync(model.Id) ?? throw new InvalidOperationException(errMsg); loanAgreement.UpdateLoanAmount(LoanAmount.Create(model.LoanAmount)); loanAgreement.UpdateInterestRate(InterestRate.Create(model.InterestRate)); loanAgreement.UpdateLoanDate(LoanDate.Create(model.LoanDate)); loanAgreement.UpdateMaturityDate(MaturityDate.Create(model.MaturityDate)); loanAgreement.UpdatePaymentsPerYear(PaymentsPerYear.Create(model.PaymentsPerYear)); loanAgreement.UpdateUserId(model.UserId); loanAgreement.UpdateLastModifiedDate(); await unitOfWork.Commit(); }
public void ShouldRaiseError_DefaultLoanDate() { var economicEvent = new EconomicEvent(Guid.NewGuid(), EventType.CashReceiptFromLoanAgreement); Financier financier = GetFinancier(); Assert.Throws <ArgumentNullException>(() => { new LoanAgreement ( economicEvent, FinancierId.Create(financier.Id), LoanAmount.Create(10000), InterestRate.Create(.006), LoanDate.Create(new DateTime()), MaturityDate.Create(new DateTime(2021, 12, 31)), PaymentsPerYear.Create(12), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); }); }
public async Task ShouldInsert_LoanAgreement_UsingLoanAgreementRepo() { 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")) ); await _loanAgreementRepo.AddAsync(agreement); await _unitOfWork.Commit(); var result = await _loanAgreementRepo.Exists(agreement.Id); Assert.True(result); }
public String ToCSV() { return($"{IdCustomer};{TumbleNumber};{LoanDate.ToString("dd/MM/yyyy")};{ReturnDate.ToString("dd/MM/yyyy")};{LoanStatus}"); }