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; }
@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; }
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"); } }
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())); } }
public boolean canApplyReimbursement(final Money amountToReimburse) { return canApplyAdjustment(amountToReimburse.negate()); }