Exemplo n.º 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();
  }
Exemplo n.º 2
0
  private Money getTotalAdjustedAmount() {
    Money result = Money.ZERO;
    for (final AccountingTransaction transaction :
        getAccountingTransaction().getAdjustmentTransactionsSet()) {
      result = result.add(transaction.getEntryFor(getAccount()).getOriginalAmount());
    }

    return result;
  }
Exemplo n.º 3
0
  @Override
  protected Money subtractFromExemptions(
      Event event, DateTime when, boolean applyDiscount, Money amountToPay) {

    if (event instanceof AcademicEvent) {
      final AcademicEvent requestEvent = (AcademicEvent) event;
      if (requestEvent.hasAcademicEventExemption()) {
        amountToPay = amountToPay.subtract(requestEvent.getAcademicEventExemption().getValue());
      }

      return amountToPay.isPositive() ? amountToPay : Money.ZERO;
    }

    return amountToPay;
  }
Exemplo n.º 4
0
 private void checkBudget(MicroPaymentEvent event, Money amountToPay) {
   Money totalCredit = calculateBalance(event);
   if (amountToPay.greaterThan(totalCredit)) {
     throw new DomainException(
         "error.accounting.AccountingTransaction.amount.to.spend.exceeds.account");
   }
 }
 private void checkParameters(Money pastAdministrativeOfficeFeeAndInsuranceAmount) {
   if (pastAdministrativeOfficeFeeAndInsuranceAmount == null
       || pastAdministrativeOfficeFeeAndInsuranceAmount.isZero()) {
     throw new DomainException(
         "error.net.sourceforge.fenixedu.domain.accounting.events.PastAdministrativeOfficeFeeAndInsuranceEvent.pastAdministrativeOfficeFeeAndInsuranceAmount.cannot.be.null.and.must.be.greather.than.zero");
   }
 }
Exemplo n.º 6
0
 protected void checkIfCanAddAmount(Money amountToPay, final Event event, final DateTime when) {
   if (amountToPay.compareTo(calculateTotalAmountToPay(event, when)) < 0) {
     throw new DomainExceptionWithLabelFormatter(
         "error.accounting.postingRules.FixedAmountPR.amount.being.payed.must.match.amount.to.pay",
         event.getDescriptionForEntryType(getEntryType()));
   }
 }
 private void checkIfCanAddAmount(
     final Money amountToPay, final Event event, final DateTime when) {
   if (amountToPay.compareTo(calculateTotalAmountToPay(event, when)) < 0) {
     throw new DomainExceptionWithLabelFormatter(
         "error.DegreeChangeIndividualCandidacyPR.amount.being.payed.must.match.amount.to.pay",
         event.getDescriptionForEntryType(getEntryType()));
   }
 }
Exemplo n.º 8
0
 public boolean canApplyReimbursement(final Money amountToReimburse) {
   return canApplyAdjustment(amountToReimburse.negate());
 }