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 decimal CalculatorMonthlyRepayment(LoanAmount loanAmount, decimal annualInterestRate, LoanTerm loanTermm) { // 月收益=月利率*时间*本金 var monthly = (double)annualInterestRate / 100 / 12 * (double)loanAmount.Principal * loanTermm.ToMonths(); return(decimal.Parse(monthly.ToString())); }
private SendEmailRequest CreateSendEmailRequest(EmailAddress emailAddress, LoanAmount requestedLoanAmount) => new SendEmailRequest { Source = SourceEmail, Destination = new Destination { ToAddresses = new List <string> { emailAddress.Value } }, Message = new Message { Subject = new Content { Data = LoanRequestedEmailSubject }, Body = new Body { Html = new Content { Data = GetEmailBody() .Replace( LoanAmountHtmlPlaceholder, requestedLoanAmount.Value.ToString() ) .Replace( FrontendApplicationUrlHtmlPlaceholder, _config.FrontendApplicationUrl ) } } } };
private void Validation() { string validationString = string.Empty; if (LoanAmount.Equals(0)) { validationString += "principal amount"; } if (Interest.Equals(0)) { if (validationString != string.Empty) { validationString += ", "; } validationString += "interest rate"; } if (Term.Equals(0)) { if (validationString != string.Empty) { validationString += ", "; } validationString += "loan term"; } Application.Current.MainPage.DisplayAlert(string.Empty, "Please enter valid " + validationString + ".", "Ok"); }
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(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,LoanId,LoanNumber,CustomerId")] LoanAmount loanAmount) { if (id != loanAmount.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loanAmount); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoanAmountExists(loanAmount.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "City", loanAmount.CustomerId); ViewData["LoanId"] = new SelectList(_context.Loan, "Id", "Name", loanAmount.LoanId); return(View(loanAmount)); }
public void Accept() { var loanProduct = new LoanProduct(1, "Loan", 8.35m); var loanAmount = new LoanAmount("inr", 3500000); var loanApplication = new LoanApplication(1, loanProduct, loanAmount, "Vatan", 35, "Ekta Nagar", 100000); var mockIdentityVerifier = new Mock <IIdentityVerifier>(); //mockIdentityVerifier.Setup(x => x.Validate("Vatan", 35, "Ekta Nagar")).Returns(true); //Setup for any type matching args mockIdentityVerifier.Setup(x => x.Validate(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>())).Returns(true); //set below property hierarchy Autometically, Score is int //_creditScorer.ScoreResult.ScoreValue.Score //Below code set default values to hierarchy like 0 to Score var mockCreditScorer = new Mock <ICreditScorer>() { DefaultValue = DefaultValue.Mock }; //below code set specific value mockCreditScorer.Setup(x => x.ScoreResult.ScoreValue.Score).Returns(300); var lap = new LoanApplicationProcessor(mockIdentityVerifier.Object, mockCreditScorer.Object); lap.Process(loanApplication); //It fails as LoanApplicationProcessor dont accept Null arguments. Assert.That(loanApplication.GetIsAccepted(), Is.True); }
public override string ToString() { return(" \n For Customer with First Name and Last Name " + CustomerFirstName + "\t" + CustomerLastName + " \t the Loan Number is: " + LoanNumber + " \t and for the Loan Amount: " + LoanAmount.ToString("C") + "\t and for a Loan Term of " + NumberofYearsLoanTerm + " years, the Interest rate is : " + InterestRate + "%"); }
public void RespectValueEquality3() { var a = new LoanAmount("USD", 100m); var b = new LoanAmount("USD", 100m); Assert.IsTrue(ValueObject.EqualOperator(a, b)); }
public override string ToString() { return("Customer: " + CustomerFirst + " " + CustomerLast + "\nLoan amount: " + LoanAmount.ToString("C") + "\nInterest Rate: " + InterestRate.ToString("p2") + "\nLoan Duration: " + TermYears); }
public void RespectValueEquality2() { var a = new LoanAmount("USD", 100m); var b = new LoanAmount("USD", 100m); // == 操作符还是 object 的 Assert.IsFalse(a == b); }
public void It_should_create_correct_loan_amount_for_correct_value(int correctValue) { // When var loanAmount = new LoanAmount(correctValue); // Then loanAmount.Should().NotBeNull(); loanAmount.Value.Should().IsSameOrEqualTo(correctValue); }
public void RespectValueEquality() { // 继承自ValueObject,只要他们的原子数据都指向同一个引用,那么他们相等 var a = new LoanAmount("USD", 100m); var b = new LoanAmount("USD", 100m); // EqualTo 调用的是 Equal()方法 Assert.That(a, Is.EqualTo(b)); }
private void ShareLoanDetails() { if (Interest.Equals(0) || LoanAmount.Equals(0) || Term.Equals(0)) { Validation(); return; } Calculate(); shareService.ShareLoanDetails(LoanAmount, Interest, Term, TermType, emiAmount, TotalPayment, TotalInterestAmount); }
public override string ToString() { // return base.ToString(); return("loanNumber: " + LoanNumber + "\nCustomer First Name: " + CustomerFirstName + "\nCustomer Last Name: " + CustomerLastName + "\nInterest Rate: " + InterestRate.ToString("p2") + "\nLoan Amount: " + LoanAmount.ToString("c") + "\nLoan Term: " + NumberOfYearsInLoanTerm); }
public override string GetInfo() { return(FirstName + " " + LastName + " " + " " + "\nLoan Amount: " + "" + LoanAmount.ToString("c") + " " + "\nSquare Feet: " + squareFeet.ToString() + "\nNumber of Rooms: " + numberOfRooms.ToString() + "\nInterest Rate: " + "8.8%" + "\nLoan Number: " + "000561111" + "\nType: " + "single family detached" + "\nNumber of Years: " + "30"); }
public override string GetInfo() { return(FirstName + " " + LastName + " " + "\nLoan Amount:" + " " + LoanAmount.ToString("c") + "\nYear: " + year.ToString() + "\nMake: " + make.ToString() + "\nModel: " + model.ToString() + "\nInterest Rate: " + "8.8%" + "\nLoan Number: " + "0058711111" + "\nNumber of years: " + "15"); }
private async Task <string> PostLoanAsync() { var handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; HttpClient httpClient = new HttpClient(handler); var request = new { referrerEmail = this.ReferrerEmail, party = new { name = new { firstName = FirstName, lastName = LastName }, email = Email, homePhone = HomePhone, dateOfBirth = DateOfBirth, currentAddress = new { streetAddressLine1 = CurrentAddressStreet, city = CurrentAddressCity, state = CurrentAddressState, zipCode = CurrentAddressZip } }, loanPurposeType = "PURCHASE", loanAmount = LoanAmount.ToString(), propertyValue = PropertyValue.ToString(), propertyAddress = new { streetAddressLine1 = PropertyAddressStreet, city = PropertyAddressCity, state = PropertyAddressState, zipCode = PropertyAddressZip }, sendEmailInvite = false }; var payload = JsonSerializer.Serialize(request); var req = new HttpRequestMessage(HttpMethod.Post, "https://localhost:5000/api/LoanController"); req.Content = new StringContent(payload, Encoding.UTF8, "application/json"); var result = await httpClient.SendAsync(req); Message = "Result: " + result.StatusCode; return(await result.Content.ReadAsStringAsync()); }
public async Task RequestLoan(string offerId, int requestedAmount) { var offerEntityIdentity = new EntityIdentity(offerId); var requestedLoanAmount = new LoanAmount(requestedAmount); var loanOffer = await _loanOfferRepository.GetAsync(offerEntityIdentity); loanOffer.SetRequestedLoanAmount(requestedLoanAmount); await _loanOfferRepository.UpdateAsync(loanOffer); await _emailNotificationService.SendLoanRequestedMessage(loanOffer.EmailAddress, loanOffer.RequestedLoanAmount); }
//Override ToString method to display data about the loan public override string ToString() { return("Loan Information: " + "\n\tLoan Type: " + LoanType + "\n\tLoan Number: " + LoanNumber + "\n\tCustomer First Name: " + CustomerFirstName + "\n\tCustomer Last Name: " + CustomerLastName + "\n\tInterest Rate: " + InterestRate.ToString("p2") + "\n\tLoan Amount: " + LoanAmount.ToString("C") + "\n\tNumber of Years in the loan's term: " + NumOfYearsLoanTerm + "\n\tInterest: " + CalculateInterest().ToString("C")); }
public void It_should_correctly_set_max_loan_amount(int scoringValue, int maxLoanAmountValue) { // Given var loanOffer = new LoanOfferBuilder().Build(); var score = new Score(scoringValue); var expectedMaxLoanAmountValue = new LoanAmount(maxLoanAmountValue); // When loanOffer.CalculateOffer(score); // Then loanOffer.MaxLoanAmount.Value.IsSameOrEqualTo(expectedMaxLoanAmountValue.Value); }
public async Task <IActionResult> Create([Bind("Id,LoanId,LoanNumber,CustomerId")] LoanAmount loanAmount) { if (ModelState.IsValid) { _context.Add(loanAmount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "City", loanAmount.CustomerId); ViewData["LoanId"] = new SelectList(_context.Loan, "Id", "Name", loanAmount.LoanId); return(View(loanAmount)); }
public void It_should_throw_exception_for_greater_value_than_max_amount() { // Given var maxLoanAmount = new LoanAmount(MaxLoanAmountValue); var requestedLoanAmount = new LoanAmount(MaxLoanAmountValue + 100); var loanOffer = new LoanOfferBuilder().WithMaxLoanAmount(maxLoanAmount).Build(); // When var action = new Action(() => loanOffer.SetRequestedLoanAmount(requestedLoanAmount)); // Then action.Should().Throw <RequestedLoanAmountIsGreaterThanMaxLoanAmountException>(); }
public void It_should_correctly_point_greater_loan_amount() { // Given const int greaterValue = 500; const int smallerValue = 400; // When var greaterLoanAmount = new LoanAmount(greaterValue); var smallerLoanAmount = new LoanAmount(smallerValue); var isGreaterLoanAmountGreater = greaterLoanAmount > smallerLoanAmount; // Then isGreaterLoanAmountGreater.Should().BeTrue(); }
public async Task ShouldUpdate_LoanAgreement_UsingLoanAgreementRepo() { LoanAgreement agreement = await _loanAgreementRepo.GetByIdAsync(new Guid("09b53ffb-9983-4cde-b1d6-8a49e785177f")); agreement.UpdateInterestRate(InterestRate.Create(.0975)); agreement.UpdateLoanAmount(LoanAmount.Create(52128M)); await _unitOfWork.Commit(); LoanAgreement result = await _loanAgreementRepo.GetByIdAsync(new Guid("09b53ffb-9983-4cde-b1d6-8a49e785177f")); Assert.Equal(.0975, result.InterestRate); Assert.Equal(52128M, result.LoanAmount); }
public void It_should_correctly_set_for_not_greater_value_than_max_amount() { // Given var maxLoanAmount = new LoanAmount(MaxLoanAmountValue); var requestedLoanAmount = new LoanAmount(MaxLoanAmountValue - 100); var loanOffer = new LoanOfferBuilder().WithMaxLoanAmount(maxLoanAmount).Build(); // When loanOffer.SetRequestedLoanAmount(requestedLoanAmount); // Then loanOffer.RequestedLoanAmount.Should().NotBeNull(); loanOffer.RequestedLoanAmount.Value.IsSameOrEqualTo(requestedLoanAmount.Value); }
public void DeclineLowSalary() { var loanProduct = new LoanProduct(1, "Loan", 8.35m); var loanAmount = new LoanAmount("inr", 3500000); var loanApplication = new LoanApplication(1, loanProduct, loanAmount, "Vatan", 35, "Ekta Nagar", 50000); var mockIdentityVerifier = new Mock <IIdentityVerifier>(); var mockCreditScorer = new Mock <ICreditScorer>(); var lap = new LoanApplicationProcessor(mockIdentityVerifier.Object, mockCreditScorer.Object); lap.Process(loanApplication); //It fails as LoanApplicationProcessor dont accept Null arguments. Assert.That(loanApplication.GetIsAccepted(), Is.False); }
public async Task It_should_call_set_requested_loan_amount_with_given_loan_amount() { // Given const int requestedAmountPrimitive = 5000; var requestedLoanAmount = new LoanAmount(requestedAmountPrimitive); var offerEntityIdentity = EntityIdentity.New; var loanOffer = new Mock <ILoanOffer>(); var repositoryMock = CreateLoanOfferRepositoryMock(offerEntityIdentity, loanOffer); var service = CreateRequestLoanService(repositoryMock); // When await service.RequestLoan(offerEntityIdentity.ToString(), requestedLoanAmount.Value); // Then loanOffer.Verify(m => m.SetRequestedLoanAmount(It.Is <LoanAmount>(amount => amount.Value == requestedLoanAmount.Value)), Times.Once); }
public async Task It_should_call_update_in_repository_using_the_same_loan_offer() { // Given const int requestedAmountPrimitive = 5000; var requestedLoanAmount = new LoanAmount(requestedAmountPrimitive); var offerEntityIdentity = EntityIdentity.New; var loanOffer = new Mock <ILoanOffer>(); var repositoryMock = CreateLoanOfferRepositoryMock(offerEntityIdentity, loanOffer); var service = CreateRequestLoanService(repositoryMock); // When await service.RequestLoan(offerEntityIdentity.ToString(), requestedLoanAmount.Value); // Then repositoryMock.Verify(m => m.UpdateAsync(loanOffer.Object), Times.Once); }
public async Task InitializeAsync() { if (Interest.Equals(0) || LoanAmount.Equals(0) || Term.Equals(0)) { Validation(); return; } Calculate(); paymentDetails = emiService.GetAmortizationDetails(Interest, MonthlyPayment, LoanAmount, Term, TermType, PaymentStartMonth); AddValueKeyPair("loanAmount", LoanAmount); AddValueKeyPair("interest", Interest); AddValueKeyPair("emi", MonthlyPayment); AddValueKeyPair("term", Term); AddValueKeyPair("termType", TermType); await NavigationService.NavigateToAsync <StatisticPageViewModel>(paymentDetails); }