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(); }
@Override public String getAmountToPay() { return installment .calculateAmount( event, installment.getStartDate().toLocalDate().toDateTimeAtStartOfDay(), BigDecimal.ZERO, event.getGratuityPaymentPlan().isToApplyPenalty(event, this.installment)) .toPlainString(); }
@Override public String getExpirationDate() { return installment.getEndDate().toString("dd/MM/yyyy"); }