Package org.fenixedu.academic.util

Examples of org.fenixedu.academic.util.Money


    @Override
    protected Money doCalculationForAmountToPay(Event event, DateTime when, boolean applyDiscount) {
        final GratuityEvent gratuityEvent = (GratuityEvent) event;

        Money result = Money.ZERO;
        for (final Map.Entry<DegreeCurricularPlan, BigDecimal> entry : groupEctsByDegreeCurricularPlan(gratuityEvent).entrySet()) {
            result = result.add(calculateAmountForDegreeCurricularPlan(entry.getKey(), entry.getValue(), gratuityEvent));
        }

        return result;
    }
View Full Code Here


        if (gratuityExemption.isValueExemption()) {
            amountToPay = amountToPay.subtract(((ValueGratuityExemption) gratuityExemption).getValue());
        } else {
            PercentageGratuityExemption percentageGratuityExemption = (PercentageGratuityExemption) gratuityExemption;
            BigDecimal percentage = percentageGratuityExemption.getPercentage();
            Money toRemove = amountToPay.multiply(percentage);
            amountToPay = amountToPay.subtract(toRemove);
        }

        return amountToPay.isNegative() ? Money.ZERO : amountToPay;
    }
View Full Code Here

        final IGratuityPR gratuityPR =
                (IGratuityPR) degreeCurricularPlan.getServiceAgreementTemplate().findPostingRuleBy(EventType.GRATUITY,
                        gratuityEvent.getStartDate(), gratuityEvent.getEndDate());

        final Money degreeGratuityAmount = gratuityPR.getDefaultGratuityAmount(gratuityEvent.getExecutionYear());
        final BigDecimal creditsProporcion = enroledEcts.divide(getEctsForYear());

        if (hasAnyActiveDegreeRegistration(gratuityEvent)) {
            return degreeGratuityAmount.multiply(creditsProporcion);

        } else if (gratuityEvent.getDegree().isEmpty() || gratuityEvent.getDegree().isDEA()) {
            return degreeGratuityAmount.multiply(getGratuityFactor()).multiply(getEctsFactor().add(creditsProporcion));

        } else {
            return degreeGratuityAmount.multiply(creditsProporcion);
        }
    }
View Full Code Here

        return Collections.singleton(makeAccountingTransaction(user, event, fromAccount, toAccount, getEntryType(), entryDTOs
                .iterator().next().getAmountToPay(), transactionDetail));
    }

    private void checkIfCanAddAmount(Money amountToPay, Event event, DateTime whenRegistered) {
        final Money totalFinalAmount = event.getPayedAmount().add(amountToPay);

        if (totalFinalAmount.lessThan(calculateTotalAmountToPay(event, whenRegistered))) {
            throw new DomainExceptionWithLabelFormatter(
                    "error.accounting.postingRules.gratuity.StandaloneEnrolmentGratuityPR.amount.being.payed.must.be.equal.to.amount.in.debt",
                    event.getDescriptionForEntryType(getEntryType()));
        }
    }
View Full Code Here

                .calculateAmountToPay(when)));
    }

    @Override
    protected Money doCalculationForAmountToPay(Event event, DateTime when, boolean applyDiscount) {
        final Money amountToPay = ((PastDegreeGratuityEvent) event).getPastDegreeGratuityAmount();
        final PastDegreeGratuityEvent pastDegreeGratuityEvent = (PastDegreeGratuityEvent) event;
        final BigDecimal discountPercentage =
                applyDiscount ? pastDegreeGratuityEvent.calculateDiscountPercentage(amountToPay) : BigDecimal.ZERO;

        return amountToPay.multiply(BigDecimal.ONE.subtract(discountPercentage));
    }
View Full Code Here

    private void makeGratuityPostingRule(CreateGratuityPhdBean bean, PhdProgram phdProgram) {
        if (bean.getPeriods().size() == 0) {
            throw new RuntimeException("error.empty.periods");
        }
        PhdGratuityPR postingRule =
                new PhdGratuityPR(bean.getStartDate(), bean.getEndDate(), phdProgram.getServiceAgreementTemplate(), new Money(
                        bean.getGratuity()), bean.getFineRate());

        for (CreateGratuityPhdPRPeriodBean periodBean : bean.getPeriods()) {
            PhdGratuityPaymentPeriod period =
                    new PhdGratuityPaymentPeriod(periodBean.getPeriodStartDate(), periodBean.getPeriodEndDate(),
                            periodBean.getLimitePaymentDay());
            postingRule.addPhdGratuityPaymentPeriods(period);
            period.setRootDomainObject(Bennu.getInstance());
        }

        for (CreateGratuityPhdPRQuickBean quirkBean : bean.getExceptions()) {
            PhdGratuityPriceQuirk quirk = new PhdGratuityPriceQuirk(quirkBean.getYear(), new Money(quirkBean.getGratuity()));
            postingRule.addPhdGratuityPriceQuirks(quirk);
            quirk.setRootDomainObject(Bennu.getInstance());
        }
        postingRule.setRootDomainObject(Bennu.getInstance());
View Full Code Here

    }

    private void checkIfCanAddAmountForCompleteEnrolmentModel(final Money amountToAdd, final Event event, final DateTime when) {

        if (hasAlreadyPayedAnyAmount(event, when)) {
            final Money totalFinalAmount = event.getPayedAmount().add(amountToAdd);
            if (!(totalFinalAmount.greaterOrEqualThan(calculateTotalAmountToPay(event, when)) || totalFinalAmount
                    .equals(getPartialPaymentAmount(event, when)))) {
                throw new DomainExceptionWithLabelFormatter(
                        "error.accounting.postingRules.gratuity.SpecializationDegreeGratuityPR.amount.being.payed.must.be.equal.to.amout.in.debt",
                        event.getDescriptionForEntryType(getEntryType()));
            }
View Full Code Here

        return calculateTotalAmountToPay(event, when).multiply(getSpecializationDegreePartialAcceptedPercentage());
    }

    @Override
    protected Money doCalculationForAmountToPay(Event event, DateTime when, boolean applyDiscount) {
        final Money result;
        if (((GratuityEvent) event).isCustomEnrolmentModel()) {
            result = calculateSpecializationDegreeGratuityTotalAmountToPay(event);
        } else {
            result = getSpecializationDegreeTotalAmount();
        }
View Full Code Here

        addParameter("documentIdNumber",
                FenixStringTools.multipleLineRightPad(documentIdNumber, LINE_LENGTH - fithParagraphLength, END_CHAR));
    }

    final private void setAmounts(final Person person, final Integer civilYear) {
        Money gratuityPayedAmount = person.getMaxDeductableAmountForLegalTaxes(EventType.GRATUITY, civilYear);
        Money othersPayedAmount = calculateOthersPayedAmount(person, civilYear);

        final StringBuilder eventTypes = new StringBuilder();
        final StringBuilder payedAmounts = new StringBuilder();
        if (!gratuityPayedAmount.isZero()) {
            eventTypes.append("- ")
                    .append(BundleUtil.getString(Bundle.ENUMERATION, getLocale(), EventType.GRATUITY.getQualifiedName()))
                    .append(LINE_BREAK);
            payedAmounts.append("*").append(gratuityPayedAmount.toPlainString()).append("Eur").append(LINE_BREAK);
        }

        if (!othersPayedAmount.isZero()) {
            eventTypes.append(
                    BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.academicDocument.irs.declaration.eighthParagraph"))
                    .append(LINE_BREAK);
            payedAmounts.append("*").append(othersPayedAmount.toPlainString()).append("Eur").append(LINE_BREAK);
        }
        addParameter("eventTypes", eventTypes.toString());
        addParameter("payedAmounts", payedAmounts.toString());

        Money totalPayedAmount = othersPayedAmount.add(gratuityPayedAmount);
        addParameter("totalPayedAmount", "*" + totalPayedAmount.toString() + "Eur");
        addParameter("total", BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.academicDocument.irs.declaration.total"));

    }
View Full Code Here

        addParameter("total", BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.academicDocument.irs.declaration.total"));

    }

    private Money calculateOthersPayedAmount(final Person person, final Integer civilYear) {
        Money result = Money.ZERO;

        for (final EventType eventType : EventType.values()) {
            if (eventType != EventType.GRATUITY) {
                result = result.add(person.getMaxDeductableAmountForLegalTaxes(eventType, civilYear));
            }
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.fenixedu.academic.util.Money

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.