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();
}