LOGGER.trace("Sanitizing investment #{} for loan #{}.", investment.getId(), investment.getLoanId()); this.loanId = investment.getLoanId(); this.id = investment.getId(); this.currentTerm = investment.getCurrentTerm(); this.originalTerm = investment.getLoanTermInMonth(); this.remainingMonths = investment.getRemainingMonths(); this.daysPastDue = investment.getLegalDpd(); this.investmentDate.set(investment.getInvestmentDate()); this.nextPaymentDate = investment.getNextPaymentDate(); this.canBeOffered = investment.isCanBeOffered(); this.isOnSmp = investment.isOnSmp(); this.originalPrincipal = investment.getPurchasePrice(); this.interestRate = investment.getInterestRate(); this.paidPrincipal = investment.getPaidPrincipal(); this.duePrincipal = investment.getDuePrincipal(); this.paidInterest = investment.getPaidInterest(); this.dueInterest = investment.getDueInterest(); this.expectedInterest = investment.getExpectedInterest(); this.paidPenalty = investment.getPaidPenalty(); this.remainingPrincipal = investment.getRemainingPrincipal(); this.smpFee = investment.getSmpFee(); this.smpSoldFor = investment.getSmpSoldFor(); this.rating = investment.getRating(); this.isInWithdrawal = investment.isInWithdrawal(); this.status = investment.getStatus(); this.paymentStatus = investment.getPaymentStatus(); this.isInsuranceActive = investment.isInsuranceActive(); this.areInstalmentsPostponed = investment.isInstalmentPostponement(); setInsuranceHistory(investment.getInsuranceHistory());
public SellRequest(final RawInvestment investment) { this.investmentId = investment.getId(); this.remainingPrincipal = investment.getRemainingPrincipal(); this.feeAmount = investment.getSmpFee(); }
@Test void correctlyGuessesInvestmentDateFromTransactionHistory() { final Loan loan = Loan.custom() .setId(1) .build(); final Investment i = Investment.fresh(loan, 200) .build(); final RawInvestment r = spy(new RawInvestment(i)); when(r.getInvestmentDate()).thenReturn(null); // enforce so that the date-guessing code has a chance to trigger final PaginatedApi<RawInvestment, PortfolioApi> pa = mockApi(Collections.singletonList(r)); final Transaction irrelevant1 = new Transaction(i, BigDecimal.ZERO, TransactionCategory.SMP_BUY, TransactionOrientation.OUT); final Transaction irrelevant2 = new Transaction(i, BigDecimal.ZERO, TransactionCategory.SMP_SELL, TransactionOrientation.IN); final Transaction relevant = new Transaction(i, BigDecimal.ZERO, TransactionCategory.PAYMENT, TransactionOrientation.IN); final PaginatedApi<Transaction, TransactionApi> ta = mockApi(Arrays.asList(irrelevant1, relevant, irrelevant2)); final Zonky z = mockZonky(pa, ta); final Optional<Investment> result = z.getInvestmentByLoanId(loan.getId()); assertThat(result).isPresent(); final Investment actual = result.get(); final LocalDate investmentDate = actual.getInvestmentDate().toLocalDate(); assertThat(investmentDate).isEqualTo(relevant.getTransactionDate().minusMonths(1)); }
public void sell(final Investment investment) { LOGGER.debug("Offering to sell investment in loan #{}.", investment.getLoanId()); controlApi.run(api -> api.offer(new SellRequest(new RawInvestment(investment)))); }
public SellRequest(final RawInvestment investment) { this.investmentId = investment.getId(); this.remainingPrincipal = investment.getRemainingPrincipal(); this.feeAmount = investment.getSmpFee(); }
public void sell(final Investment investment) { LOGGER.debug("Offering to sell investment in loan #{}.", investment.getLoanId()); controlApi.run(api -> api.offer(new SellRequest(new RawInvestment(investment)))); }
LOGGER.trace("Sanitizing investment #{} for loan #{}.", investment.getId(), investment.getLoanId()); this.loanId = investment.getLoanId(); this.id = investment.getId(); this.currentTerm = investment.getCurrentTerm(); this.originalTerm = investment.getLoanTermInMonth(); this.remainingMonths = investment.getRemainingMonths(); this.daysPastDue = investment.getLegalDpd(); this.investmentDate.set(investment.getInvestmentDate()); this.nextPaymentDate = investment.getNextPaymentDate(); this.canBeOffered = investment.isCanBeOffered(); this.isOnSmp = investment.isOnSmp(); this.originalPrincipal = investment.getPurchasePrice(); this.interestRate = investment.getInterestRate(); this.paidPrincipal = investment.getPaidPrincipal(); this.duePrincipal = investment.getDuePrincipal(); this.paidInterest = investment.getPaidInterest(); this.dueInterest = investment.getDueInterest(); this.expectedInterest = investment.getExpectedInterest(); this.paidPenalty = investment.getPaidPenalty(); this.remainingPrincipal = investment.getRemainingPrincipal(); this.smpFee = investment.getSmpFee(); this.smpSoldFor = investment.getSmpSoldFor(); this.rating = investment.getRating(); this.isInWithdrawal = investment.isInWithdrawal(); this.status = investment.getStatus(); this.paymentStatus = investment.getPaymentStatus(); this.isInsuranceActive = investment.isInsuranceActive(); this.areInstalmentsPostponed = investment.isInstalmentPostponement(); setInsuranceHistory(investment.getInsuranceHistory());
public void invest(final Investment investment) { LOGGER.debug("Investing into loan #{}.", investment.getLoanId()); controlApi.run(api -> api.invest(new RawInvestment(investment))); }
public void invest(final Investment investment) { LOGGER.debug("Investing into loan #{}.", investment.getLoanId()); controlApi.run(api -> api.invest(new RawInvestment(investment))); }