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);
}
}
}
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;
}
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;
}
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();
}
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;
}
Aggregations