Search in sources :

Example 1 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class IncomingDocAsOrderViewModel method init.

@Programmatic
public void init() {
    final Order order = getDomainObject();
    setOrderNumber(order.getOrderNumber());
    setSellerOrderReference(order.getSellerOrderReference());
    setOrderDate(order.getOrderDate());
    setSeller(order.getSeller());
    setBuyer(order.getBuyer());
    setProperty(order.getProperty());
    final Optional<OrderItem> firstItemIfAny = getFirstItemIfAny();
    if (firstItemIfAny.isPresent()) {
        OrderItem orderItem = firstItemIfAny.get();
        setCharge(orderItem.getCharge());
        setDescription(orderItem.getDescription());
        setNetAmount(orderItem.getNetAmount());
        setVatAmount(orderItem.getVatAmount());
        setGrossAmount(orderItem.getGrossAmount());
        setTax(orderItem.getTax());
        setPeriod(periodFrom(orderItem.getStartDate(), orderItem.getEndDate()));
        setProperty(orderItem.getProperty());
        setProject(orderItem.getProject());
        setBudgetItem(orderItem.getBudgetItem());
    }
}
Also used : Order(org.estatio.module.capex.dom.order.Order) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) OrderItem(org.estatio.module.capex.dom.order.OrderItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class BudgetOverrideImportExport method importData.

// @Override
// public List<Class> importAfter() {
// return Lists.newArrayList();
// }
@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
    if (getInvoiceChargeReference() == null) {
        throw new ApplicationException("Incoming charge reference cannot be empty");
    }
    if (getReason() == null) {
        throw new ApplicationException("Reason cannot be empty");
    }
    BudgetCalculationType budgetCalculationType;
    budgetCalculationType = getType() == null ? null : BudgetCalculationType.valueOf(getType());
    BudgetOverride budgetOverride;
    Charge incomingCharge = getIncomingChargeReference() == null ? null : fetchCharge(getIncomingChargeReference());
    switch(getClassName()) {
        case "BudgetOverrideForMax":
            validate();
            budgetOverride = budgetOverrideRepository.newBudgetOverrideForMax(getMaxValue(), fetchLease(getLeaseReference()), getStartDate(), getEndDate(), fetchCharge(getInvoiceChargeReference()), incomingCharge, budgetCalculationType, getReason());
            break;
        case "BudgetOverrideForFixed":
            validate();
            budgetOverride = budgetOverrideRepository.newBudgetOverrideForFixed(getFixedValue(), fetchLease(getLeaseReference()), getStartDate(), getEndDate(), fetchCharge(getInvoiceChargeReference()), incomingCharge, budgetCalculationType, getReason());
            break;
        case "BudgetOverrideForFlatRate":
            validate();
            budgetOverride = budgetOverrideRepository.newBudgetOverrideForFlatRate(getValuePerM2(), getWeightedArea(), fetchLease(getLeaseReference()), getStartDate(), getEndDate(), fetchCharge(getInvoiceChargeReference()), incomingCharge, budgetCalculationType, getReason());
            break;
        default:
            throw new ApplicationException(String.format("Classname %s is not valid.", getClassName()));
    }
    return Lists.newArrayList(budgetOverride);
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride) BudgetCalculationType(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType) Charge(org.estatio.module.charge.dom.Charge) Programmatic(org.apache.isis.applib.annotation.Programmatic) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride)

Example 3 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class BudgetCalculationResult method calculate.

@Programmatic
public void calculate() throws IllegalArgumentException {
    validateOverrides();
    BigDecimal valueCalculatedByBudget = valueAsCalculatedByBudget();
    BigDecimal annualOverrideValue = BigDecimal.ZERO;
    List<Charge> incomingChargesOnOverrides = new ArrayList<>();
    if (overrideValueForInvoiceCharge() != null) {
        // SCENARIO: one override for all
        annualOverrideValue = annualOverrideValue.add(overrideValueForInvoiceCharge().getValue());
    } else {
        // SCENARIO: overrides on incoming charge level
        BigDecimal valueToSubtract = BigDecimal.ZERO;
        for (BudgetOverrideValue value : getOverrideValues()) {
            incomingChargesOnOverrides.add(value.getBudgetOverride().getIncomingCharge());
            annualOverrideValue = annualOverrideValue.add(value.getValue());
        }
        for (Charge charge : incomingChargesOnOverrides) {
            for (BudgetCalculation calculation : getBudgetCalculations().stream().filter(x -> x.getIncomingCharge().equals(charge)).collect(Collectors.toList())) {
                valueToSubtract = valueToSubtract.add(calculation.getValue());
            }
        }
        annualOverrideValue = annualOverrideValue.add(valueCalculatedByBudget).subtract(valueToSubtract);
    }
    BigDecimal overrideValue = annualOverrideValue.multiply(getFractionOfYear());
    setValue(overrideValue.setScale(2, BigDecimal.ROUND_HALF_UP));
    setShortfall(valueCalculatedByBudget.subtract(overrideValue).setScale(2, BigDecimal.ROUND_HALF_UP));
}
Also used : IdGeneratorStrategy(javax.jdo.annotations.IdGeneratorStrategy) BudgetOverrideValue(org.estatio.module.budgetassignment.dom.override.BudgetOverrideValue) BudgetOverrideRepository(org.estatio.module.budgetassignment.dom.override.BudgetOverrideRepository) Setter(lombok.Setter) Getter(lombok.Getter) BudgetCalculationRepository(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationRepository) Column(javax.jdo.annotations.Column) RepositoryService(org.apache.isis.applib.services.repository.RepositoryService) VersionStrategy(javax.jdo.annotations.VersionStrategy) Unique(javax.jdo.annotations.Unique) Programmatic(org.apache.isis.applib.annotation.Programmatic) ArrayList(java.util.ArrayList) PropertyLayout(org.apache.isis.applib.annotation.PropertyLayout) Inject(javax.inject.Inject) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) BigDecimal(java.math.BigDecimal) IdentityType(javax.jdo.annotations.IdentityType) Action(org.apache.isis.applib.annotation.Action) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride) Charge(org.estatio.module.charge.dom.Charge) BudgetCalculation(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculation) Where(org.apache.isis.applib.annotation.Where) Collectors(java.util.stream.Collectors) Query(javax.jdo.annotations.Query) Auditing(org.apache.isis.applib.annotation.Auditing) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) List(java.util.List) DomainObject(org.apache.isis.applib.annotation.DomainObject) UdoDomainObject2(org.estatio.module.base.dom.UdoDomainObject2) TitleBuilder(org.incode.module.base.dom.utils.TitleBuilder) Contributed(org.apache.isis.applib.annotation.Contributed) Publishing(org.apache.isis.applib.annotation.Publishing) Charge(org.estatio.module.charge.dom.Charge) ArrayList(java.util.ArrayList) BudgetOverrideValue(org.estatio.module.budgetassignment.dom.override.BudgetOverrideValue) BigDecimal(java.math.BigDecimal) BudgetCalculation(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculation) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class KeyItemImportExportLineItem method getKeyTable.

@Programmatic
public KeyTable getKeyTable() {
    if (keyTable == null) {
        Budget budget = budgetRepository.findByPropertyAndStartDate(getProperty(), getStartDate());
        keyTable = keyTableRepository.findByBudgetAndName(budget, getKeyTableName());
    }
    return keyTable;
}
Also used : Budget(org.estatio.module.budget.dom.budget.Budget) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class BudgetOverride method getCalculatedValueByBudget.

@Programmatic
BigDecimal getCalculatedValueByBudget(final LocalDate budgetStartDate, final BudgetCalculationType type) {
    BigDecimal value = BigDecimal.ZERO;
    List<Unit> unitsForLease = new ArrayList<>();
    List<BudgetCalculation> calculationsForLeaseAndCharges = new ArrayList<>();
    for (Occupancy occupancy : getLease().getOccupancies()) {
        unitsForLease.add(occupancy.getUnit());
    }
    Budget budget = budgetRepository.findByPropertyAndDate(getLease().getProperty(), budgetStartDate);
    if (getIncomingCharge() == null) {
        for (Unit unit : unitsForLease) {
            calculationsForLeaseAndCharges.addAll(budgetCalculationRepository.findByBudgetAndUnitAndInvoiceChargeAndType(budget, unit, getInvoiceCharge(), type));
        }
    } else {
        for (Unit unit : unitsForLease) {
            calculationsForLeaseAndCharges.addAll(budgetCalculationRepository.findByBudgetAndUnitAndInvoiceChargeAndIncomingChargeAndType(budget, unit, getInvoiceCharge(), getIncomingCharge(), type));
        }
    }
    for (BudgetCalculation calculation : calculationsForLeaseAndCharges) {
        value = value.add(calculation.getEffectiveValue());
    }
    return value;
}
Also used : Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) ArrayList(java.util.ArrayList) Budget(org.estatio.module.budget.dom.budget.Budget) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal) BudgetCalculation(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculation) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Programmatic (org.apache.isis.applib.annotation.Programmatic)162 Party (org.estatio.module.party.dom.Party)21 Lease (org.estatio.module.lease.dom.Lease)16 DomainObject (org.apache.isis.applib.annotation.DomainObject)11 BankAccount (org.estatio.module.financial.dom.BankAccount)11 Charge (org.estatio.module.charge.dom.Charge)10 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)10 LocalDate (org.joda.time.LocalDate)10 BigDecimal (java.math.BigDecimal)9 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)9 ApplicationException (org.apache.isis.applib.ApplicationException)8 Property (org.estatio.module.asset.dom.Property)8 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)8 ArrayList (java.util.ArrayList)7 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)7 InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)7 Inject (javax.inject.Inject)6 Unit (org.estatio.module.asset.dom.Unit)6 Document (org.incode.module.document.dom.impl.docs.Document)6