public LocalDate getFirstInstallmentPaymentLocalDate() { if (!getRegistration().hasToPayGratuityOrInsurance()) { return null; } GratuityEventWithPaymentPlan gratuityEventWithPaymentPlan = getStudentCurricularPlan() .getGratuityEvent(getForExecutionYear(), GratuityEventWithPaymentPlan.class); Installment firstInstallment = gratuityEventWithPaymentPlan.getInstallments().iterator().next(); /* * iterate the non adjusting accounting transactions until its paid */ Money paidForFirstInstallment = Money.ZERO; for (AccountingTransaction accountingTransaction : gratuityEventWithPaymentPlan.getNonAdjustingTransactions()) { paidForFirstInstallment = paidForFirstInstallment.add(accountingTransaction.getAmountWithAdjustment()); if (paidForFirstInstallment.greaterOrEqualThan(firstInstallment.getAmount())) { return accountingTransaction.getWhenRegistered().toLocalDate(); } } return firstInstallment.getEndDate().toLocalDate(); }
private Money getTotalAdjustedAmount() { Money result = Money.ZERO; for (final AccountingTransaction transaction : getAccountingTransaction().getAdjustmentTransactionsSet()) { result = result.add(transaction.getEntryFor(getAccount()).getOriginalAmount()); } return result; }