Example #1
0
  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 getRemainingAmount() {
    Map<Installment, Money> calculateInstallmentRemainingAmounts =
        event
            .getGratuityPaymentPlan()
            .calculateInstallmentRemainingAmounts(
                event, new DateTime(), event.getPostingRule().getDiscountPercentage(event));

    for (Map.Entry<Installment, Money> entry : calculateInstallmentRemainingAmounts.entrySet()) {
      if (entry.getKey() == this.installment) {
        return entry.getValue().toPlainString();
      }
    }

    return Money.ZERO.toPlainString();
  }
Example #3
0
  public Money getGratuityAmount() {
    if (getRegistration() == null) {
      return Money.ZERO;
    }

    if (!getRegistration().hasToPayGratuityOrInsurance()) {
      return Money.ZERO;
    }

    GratuityEventWithPaymentPlan event =
        getStudentCurricularPlan()
            .getGratuityEvent(getForExecutionYear(), GratuityEventWithPaymentPlan.class);

    if (event == null) {
      return Money.ZERO;
    }

    return event.getOriginalAmountToPay();
  }
 @Override
 public String getAmountToPay() {
   return installment
       .calculateAmount(
           event,
           installment.getStartDate().toLocalDate().toDateTimeAtStartOfDay(),
           BigDecimal.ZERO,
           event.getGratuityPaymentPlan().isToApplyPenalty(event, this.installment))
       .toPlainString();
 }