use of org.estatio.module.charge.dom.Charge 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.charge.dom.Charge in project estatio by estatio.
the class PartitionItemImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
Property property = propertyRepository.findPropertyByReference(propertyReference);
if (property == null)
throw new ApplicationException(String.format("Property with reference [%s] not found.", propertyReference));
final Budget budget = budgetRepository.findOrCreateBudget(property, startDate, endDate);
final KeyTable keyTable = keyTableRepository.findOrCreateBudgetKeyTable(budget, keyTableName, FoundationValueType.MANUAL, KeyValueMethod.PERCENT, 6);
findOrCreateBudgetKeyItem(keyTable, unitRepository.findUnitByReference(unitReference), keyValue, sourceValue);
final Charge charge = fetchCharge(budgetChargeReference);
final BudgetItem butgetItem = findOrCreateBudgetItem(budget, charge, budgetValue);
final Charge scheduleCharge = fetchCharge(invoiceChargeReference);
final Partitioning partitioning = findOrCreatePartitioning(budget);
findOrCreatePartitionItem(partitioning, scheduleCharge, butgetItem, keyTable, percentage);
return Lists.newArrayList();
}
use of org.estatio.module.charge.dom.Charge in project estatio by estatio.
the class ProjectImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
if (previousRow != null) {
// TODO: support sparse sheets ?
}
Project parent = null;
if (getParentReference() != null) {
parent = projectRepository.findByReference(getParentReference());
if (parent == null) {
throw new ApplicationException(String.format("Parent with reference %s not found.", getParentReference()));
}
if (!parent.getAtPath().equals(getAtPath())) {
throw new ApplicationException(String.format("AtPath parent %s does not match %s.", getParentReference(), getAtPath()));
}
if (!parent.getItems().isEmpty()) {
// TODO: (ECP-438) until we find out more about the process, prevent a the choice of a project having items
throw new ApplicationException(String.format("Parent with reference %s has items and cannot be a parent therefore.", getAtPath()));
}
}
Project project = findOrCreateProjectAndUpdateParent(getReference(), getName(), getStartDate(), getEndDate(), getAtPath(), parent);
if (getItemChargeReference() != null) {
Charge charge = chargeRepository.findByReference(getItemChargeReference());
Property property = propertyRepository.findPropertyByReference(getItemPropertyReference());
Tax tax = taxRepository.findByReference(getItemTaxReference());
wrapperFactory.wrap(project).addItem(charge, getItemDescription(), getItemBudgetedAmount(), getItemStartDate(), getItemEndDate(), property, tax);
}
return Lists.newArrayList(project);
}
use of org.estatio.module.charge.dom.Charge in project estatio by estatio.
the class BudgetOverride_IntegTest method findOrCreateValuesTest.
@Test
public void findOrCreateValuesTest() {
// given
Lease leaseTopModel = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
Charge invoiceCharge = Charge_enum.GbServiceCharge.findUsing(serviceRegistry);
BigDecimal overrideValue = new BigDecimal("1234.56");
String reason = "Some reason";
budgetOverrideForFixed = wrap(budgetOverrideRepository).newBudgetOverrideForFixed(overrideValue, leaseTopModel, null, null, invoiceCharge, null, null, reason);
assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(0);
// when
budgetOverrideForFixed.findOrCreateValues(new LocalDate(2015, 01, 01));
// then
assertThat(budgetOverrideForFixed.getValues().size()).isEqualTo(2);
assertThat(budgetOverrideForFixed.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
assertThat(budgetOverrideForFixed.getValues().last().getType()).isEqualTo(BudgetCalculationType.ACTUAL);
// and when again
budgetOverrideForFixed.findOrCreateValues(new LocalDate(2015, 01, 01));
// then still
assertThat(budgetOverrideForFixed.getValues().size()).isEqualTo(2);
}
use of org.estatio.module.charge.dom.Charge in project estatio by estatio.
the class OrderItemRepository_Test method orderItemsWithoutProjectItem_works.
@Test
public void orderItemsWithoutProjectItem_works() throws Exception {
// given
Project project = new Project();
ProjectItem item1 = new ProjectItem();
Charge chargeOnProjectItem = new Charge();
item1.setCharge(chargeOnProjectItem);
project.getItems().add(item1);
Charge chargeNOTOnProjectItem = new Charge();
OrderItem orderItemToBeFound = new OrderItem();
orderItemToBeFound.setCharge(chargeNOTOnProjectItem);
OrderItem orderItemNOTToBeFound = new OrderItem();
orderItemNOTToBeFound.setCharge(chargeOnProjectItem);
OrderItemRepository orderItemRepository = new OrderItemRepository() {
@Override
public List<OrderItem> findByProject(final Project project) {
return Arrays.asList(orderItemNOTToBeFound, orderItemToBeFound);
}
};
// when
List<OrderItem> result = orderItemRepository.orderItemsNotOnProjectItem(project);
// then
Assertions.assertThat(result.size()).isEqualTo(1);
Assertions.assertThat(result.get(0)).isEqualTo(orderItemToBeFound);
Assertions.assertThat(result.get(0).getCharge()).isEqualTo(chargeNOTOnProjectItem);
}
Aggregations