use of org.estatio.module.budget.dom.budget.Budget 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.budget.Budget in project estatio by estatio.
the class BudgetBuilder method execute.
@Override
protected void execute(ExecutionContext executionContext) {
checkParam("property", executionContext, Property.class);
checkParam("startDate", executionContext, LocalDate.class);
Budget budget = budgetRepository.newBudget(property, startDate, startDate.plusYears(1).minusDays(1));
for (ItemSpec itemSpec : itemSpecs) {
budget.newBudgetItem(itemSpec.value, itemSpec.charge);
}
executionContext.addResult(this, startDate.toString("yyyy-MM-dd"), budget);
object = budget;
}
use of org.estatio.module.budget.dom.budget.Budget in project estatio by estatio.
the class BudgetMenu method newBudget.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
public Budget newBudget(final Property property, final int year) {
Budget budget = budgetRepository.newBudget(property, new LocalDate(year, 01, 01), new LocalDate(year, 12, 31));
budget.findOrCreatePartitioningForBudgeting();
return budget;
}
use of org.estatio.module.budget.dom.budget.Budget in project estatio by estatio.
the class BudgetAssignmentService_Test method before.
@Before
public void before() throws Exception {
budgetAssignmentService = new BudgetAssignmentService();
o1 = new Occupancy();
leaseWith1ActiveOccupancy = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o1));
}
};
o2 = new Occupancy();
o3 = new Occupancy();
leaseWith2ActiveOccupancies = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o2, o3));
}
};
o4 = new Occupancy();
leaseWithNoActiveOccupancies = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o4));
}
};
o5 = new Occupancy();
leaseTerminated = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o5));
}
};
budget = new Budget();
LocalDate startDate = new LocalDate(2015, 01, 01);
LocalDate endDate = new LocalDate(2015, 12, 31);
budget.setStartDate(startDate);
budget.setEndDate(endDate);
LeaseRepository leaseRepository = new LeaseRepository() {
@Override
public List<Lease> findLeasesByProperty(final Property property) {
return Arrays.asList(leaseWith1ActiveOccupancy, leaseWith2ActiveOccupancies, leaseWithNoActiveOccupancies, leaseTerminated);
}
};
budgetAssignmentService.leaseRepository = leaseRepository;
}
use of org.estatio.module.budget.dom.budget.Budget in project estatio by estatio.
the class BudgetItemValueRepository_IntegTest method updateOrCreateTest_Create.
@Test
public void updateOrCreateTest_Create() {
// given
LocalDate budgetStart = new LocalDate(2015, 1, 1);
Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
Budget budget = budgetRepository.findByPropertyAndStartDate(property, budgetStart);
BudgetItem budgetItem = budget.getItems().first();
assertThat(budgetItem.getValues().size()).isEqualTo(1);
assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
assertThat(budgetItem.getValues().first().getValue()).isEqualTo(new BigDecimal("30000.55"));
// when
BudgetItemValue result = wrap(budgetItemValueRepository).updateOrCreateBudgetItemValue(new BigDecimal("33333.00"), budgetItem, budgetStart, BudgetCalculationType.ACTUAL);
transactionService.flushTransaction();
// then
assertThat(budgetItem.getValues().size()).isEqualTo(2);
assertThat(result.getValue()).isEqualTo(new BigDecimal("33333.00"));
assertThat(result.getType()).isEqualTo(BudgetCalculationType.ACTUAL);
}
Aggregations