public ApplicantAggregateBuilder accountBalance(int balance) { this.accountBalance = new AccountBalance(new Money(balance)); return this; }
public ApplicantAggregate build() { if(this.accountBalance == null) { this.accountBalance = new AccountBalance(new Money()); } return new ApplicantAggregate(this); } }
int calculateScoringPoints() { if(balance.isGreaterThan(new Money(8000))) { return 10; } else { return 0; } } }
public int calculateScoringPoints() { Money monthlyBalance = rootEntity.sum(); if(monthlyBalance.isGreaterThan(new Money(2000))) { return 20; } else if(monthlyBalance.isGreaterThan(new Money(1000))) { return 15; } else if(monthlyBalance.isGreaterThan(new Money(750))) { return 10; } else if(monthlyBalance.isGreaterThan(new Money(500))) { return 5; } else if (monthlyBalance.isGreaterThan(new Money(250))) { return 2; } else if( monthlyBalance.isGreaterThan(new Money(0))) { return 0; } else { return -20; } }
public Money add(Money money) { BigDecimal total = this.getAmount().add(money.getAmount()); return new Money(total); }
@StreamListener(ApplicationProcessChannels.APPLICATION_SUBMITTED) public void receiveApplicationSubmission(@Payload ApplicationSubmittedEvent applicationSubmittedEvent) { Applicant firstApplicant = applicationSubmittedEvent.getFirstApplicant(); MonthlyExpenses monthlyExpenses = applicationSubmittedEvent.getHousehold().getMonthlyExpenses(); EarningCapacity earningCapacity = applicationSubmittedEvent.getHousehold().getEarningCapacity(); CreditApplication creditApplication = new CreditApplication.CreditApplicationBuilder(new ApplicationNumber(applicationSubmittedEvent.getApplicationNumber())) .withApplicant(firstApplicant.getFirstName(), firstApplicant.getLastName(), firstApplicant.getAddress().getStreet(), firstApplicant.getAddress().getPostCode(), firstApplicant.getAddress().getCity()) .withFinancialSituation(new Money(monthlyExpenses.getCostOfLiving()), new Money(earningCapacity.getFurtherIncome()), new Money(monthlyExpenses.getRent()), new Money(earningCapacity.getSalaryFirstApplicant())) .build(); scoringApplicationService.scoreApplication(creditApplication); }