Search in sources :

Example 1 with PartitionItem

use of org.estatio.module.budget.dom.partioning.PartitionItem in project estatio by estatio.

the class BudgetImportExport method removeExistingBudgetItemsIfNotLinked.

private void removeExistingBudgetItemsIfNotLinked() {
    Property property = propertyRepository.findPropertyByReference(getPropertyReference());
    Budget budget = budgetRepository.findOrCreateBudget(property, getBudgetStartDate(), getBudgetEndDate());
    for (BudgetItem item : budget.getItems()) {
        if (orderItemRepository.findByBudgetItem(item).size() == 0 && incomingInvoiceItemRepository.findByBudgetItem(item).size() == 0) {
            for (PartitionItem pItem : item.getPartitionItems()) {
                pItem.remove();
            }
            repositoryService.removeAndFlush(item);
        }
    }
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) Property(org.estatio.module.asset.dom.Property) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem)

Example 2 with PartitionItem

use of org.estatio.module.budget.dom.partioning.PartitionItem in project estatio by estatio.

the class BudgetItem method createCopyFor.

@Programmatic
public BudgetItem createCopyFor(final Budget budget) {
    // only copies of budgeted values are made
    BudgetItem newBudgetItemCopy = budget.newBudgetItem(getBudgetedValue(), getCharge());
    for (PartitionItem partitionItem : partitionItemRepository.findByBudgetItem(this)) {
        // only copies of budgeted items are made
        if (partitionItem.getPartitioning().getType() == BudgetCalculationType.BUDGETED) {
            String keyTableName = partitionItem.getKeyTable().getName();
            KeyTable correspondingTableOnbudget = keyTableRepository.findByBudgetAndName(budget, keyTableName);
            newBudgetItemCopy.createPartitionItemForBudgeting(partitionItem.getCharge(), correspondingTableOnbudget, partitionItem.getPercentage());
        }
    }
    return newBudgetItemCopy;
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 3 with PartitionItem

use of org.estatio.module.budget.dom.partioning.PartitionItem in project estatio by estatio.

the class PartitioningBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("budget", executionContext, Budget.class);
    defaultParam("startDate", executionContext, budget.getStartDate());
    defaultParam("endDate", executionContext, budget.getEndDate());
    defaultParam("budgetCalculationType", executionContext, BudgetCalculationType.BUDGETED);
    Partitioning partitioning = partitioningRepository.newPartitioning(budget, startDate, endDate, budgetCalculationType);
    executionContext.addResult(this, partitioning);
    for (ItemSpec spec : itemSpec) {
        final Charge itemCharge = spec.itemCharge;
        final BudgetItem budgetItem = budget.findByCharge(itemCharge);
        PartitionItem partitionItem = partitionItemRepository.newPartitionItem(partitioning, spec.charge, spec.keyTable, budgetItem, spec.percentage);
        executionContext.addResult(this, partitionItem);
    }
    object = partitioning;
}
Also used : Partitioning(org.estatio.module.budget.dom.partioning.Partitioning) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem)

Example 4 with PartitionItem

use of org.estatio.module.budget.dom.partioning.PartitionItem in project estatio by estatio.

the class Budget_Remove method removeBudget.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public void removeBudget(@ParameterLayout(named = "This will delete the budget and all associated data including keytables, calculations, runs, results and lease terms. (You may consider downloading the budget and the keytables beforehand.) Are you sure?") final boolean areYouSure) {
    // delete results and runs
    for (BudgetCalculationRun run : budgetCalculationRunRepository.allBudgetCalculationRuns().stream().filter(x -> x.getBudget().equals(budget)).collect(Collectors.toList())) {
        for (BudgetCalculationResult result : run.getBudgetCalculationResults()) {
            // delete links and lease terms
            for (BudgetCalculationResultLink link : budgetCalculationResultLinkRepository.findByCalculationResult(result)) {
                LeaseTermForServiceCharge leaseTermToRemove = null;
                if (link.getLeaseTermForServiceCharge() != null) {
                    leaseTermToRemove = link.getLeaseTermForServiceCharge();
                }
                link.remove();
                if (leaseTermToRemove != null) {
                    leaseTermToRemove.remove();
                }
            }
        }
        run.remove();
    }
    // delete overrides and values
    for (Lease lease : leaseRepository.findByAssetAndActiveOnDate(budget.getProperty(), budget.getStartDate())) {
        for (BudgetOverride override : budgetOverrideRepository.findByLease(lease)) {
            override.remove();
        }
    }
    // delete partition items
    for (BudgetItem budgetItem : budget.getItems()) {
        for (PartitionItem item : partitionItemRepository.findByBudgetItem(budgetItem)) {
            item.remove();
        }
    }
    budget.remove();
}
Also used : BudgetOverrideRepository(org.estatio.module.budgetassignment.dom.override.BudgetOverrideRepository) BudgetCalculationRepository(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationRepository) EstatioRole(org.estatio.module.base.dom.EstatioRole) Lease(org.estatio.module.lease.dom.Lease) Inject(javax.inject.Inject) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) BudgetCalculationRun(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun) Budget(org.estatio.module.budget.dom.budget.Budget) UserService(org.apache.isis.applib.services.user.UserService) Action(org.apache.isis.applib.annotation.Action) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) BudgetCalculationType(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType) BudgetCalculationResultLinkRepository(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResultLinkRepository) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) BudgetCalculationResultLink(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResultLink) Collectors(java.util.stream.Collectors) PartitionItemRepository(org.estatio.module.budget.dom.partioning.PartitionItemRepository) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) ParameterLayout(org.apache.isis.applib.annotation.ParameterLayout) Contributed(org.apache.isis.applib.annotation.Contributed) BudgetCalculationRunRepository(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRunRepository) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) BudgetCalculationResultLink(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResultLink) Lease(org.estatio.module.lease.dom.Lease) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) BudgetCalculationRun(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 5 with PartitionItem

use of org.estatio.module.budget.dom.partioning.PartitionItem in project estatio by estatio.

the class Budget method removeAllBudgetItems.

@Action(restrictTo = RestrictTo.PROTOTYPING, semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout()
public Budget removeAllBudgetItems() {
    for (BudgetItem budgetItem : this.getItems()) {
        for (PartitionItem pItem : budgetItem.getPartitionItems()) {
            pItem.remove();
        }
        getContainer().remove(budgetItem);
        getContainer().flush();
    }
    return this;
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Aggregations

PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)7 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)5 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 Action (org.apache.isis.applib.annotation.Action)2 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 Budget (org.estatio.module.budget.dom.budget.Budget)2 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)2 BudgetCalculationRun (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)2 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Contributed (org.apache.isis.applib.annotation.Contributed)1 Mixin (org.apache.isis.applib.annotation.Mixin)1 ParameterLayout (org.apache.isis.applib.annotation.ParameterLayout)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 SemanticsOf (org.apache.isis.applib.annotation.SemanticsOf)1 UserService (org.apache.isis.applib.services.user.UserService)1 Property (org.estatio.module.asset.dom.Property)1 EstatioRole (org.estatio.module.base.dom.EstatioRole)1 BudgetCalculation (org.estatio.module.budget.dom.budgetcalculation.BudgetCalculation)1