use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class BudgetItemValueRepository_IntegTest method findUniqueTest.
@Test
public void findUniqueTest() {
// given
Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
Budget budget = budgetRepository.findByPropertyAndStartDate(property, new LocalDate(2015, 01, 01));
BudgetItem budgetItem = budget.getItems().first();
// when
BudgetItemValue result = budgetItemValueRepository.findUnique(budgetItem, new LocalDate(2015, 01, 01), BudgetCalculationType.BUDGETED);
// then
assertThat(result.getDate()).isEqualTo(new LocalDate(2015, 01, 01));
// and when
result = budgetItemValueRepository.findUnique(budgetItem, new LocalDate(2015, 01, 02), BudgetCalculationType.BUDGETED);
// then
assertThat(result).isNull();
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class BudgetItemValueRepository_IntegTest method updateOrCreateTest_Update.
@Test
public void updateOrCreateTest_Update() {
// given
LocalDate budgetStart = new LocalDate(2015, 01, 01);
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.BUDGETED);
// then
assertThat(budgetItem.getValues().size()).isEqualTo(1);
assertThat(result.getValue()).isEqualTo(new BigDecimal("33333.00"));
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem 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.budgetitem.BudgetItem in project estatio by estatio.
the class BudgetImportExport method findOrCreateBudgetAndBudgetItem.
private BudgetItem findOrCreateBudgetAndBudgetItem(final Charge incomingCharge) {
Property property = propertyRepository.findPropertyByReference(getPropertyReference());
if (property == null)
throw new ApplicationException(String.format("Property with reference [%s] not found.", getPropertyReference()));
Budget budget = budgetRepository.findOrCreateBudget(property, getBudgetStartDate(), getBudgetEndDate());
BudgetItem budgetItem = budget.findOrCreateBudgetItem(incomingCharge).updateOrCreateBudgetItemValue(getBudgetedValue(), getBudgetStartDate(), BudgetCalculationType.BUDGETED).updateOrCreateBudgetItemValue(getAuditedValue(), getBudgetEndDate(), BudgetCalculationType.ACTUAL);
return budgetItem;
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class IncomingInvoiceItemRepository_Test method upsert_works.
@Test
public void upsert_works() throws Exception {
// given
IncomingInvoiceItemRepository incomingInvoiceItemRepository = new IncomingInvoiceItemRepository() {
@Override
public IncomingInvoiceItem findByInvoiceAndChargeAndSequence(final IncomingInvoice invoice, final Charge charge, final BigInteger sequence) {
return invoiceItem;
}
};
BigInteger sequence = new BigInteger("1");
String description = "";
Tax tax = new Tax();
LocalDate dueDate = new LocalDate(2017, 1, 1);
LocalDate startDate = new LocalDate(2017, 1, 2);
LocalDate endDate = new LocalDate(2017, 1, 3);
Property property = new Property();
Project project = new Project();
BudgetItem budgetItem = new BudgetItem();
IncomingInvoiceType type = IncomingInvoiceType.CORPORATE_EXPENSES;
invoiceItem.setInvoice(mockInvoice);
assertThat(invoiceItem.getInvoice()).isEqualTo(mockInvoice);
assertThat(invoiceItem.getIncomingInvoiceType()).isNull();
assertThat(invoiceItem.getCharge()).isNull();
assertThat(invoiceItem.getSequence()).isNull();
assertThat(invoiceItem.getDescription()).isNull();
assertThat(invoiceItem.getNetAmount()).isNull();
assertThat(invoiceItem.getVatAmount()).isNull();
assertThat(invoiceItem.getGrossAmount()).isNull();
assertThat(invoiceItem.getTax()).isNull();
assertThat(invoiceItem.getDueDate()).isNull();
assertThat(invoiceItem.getStartDate()).isNull();
assertThat(invoiceItem.getEndDate()).isNull();
assertThat(invoiceItem.getFixedAsset()).isNull();
assertThat(invoiceItem.getProject()).isNull();
// when
incomingInvoiceItemRepository.upsert(sequence, mockInvoice, type, mockCharge, description, BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN, tax, dueDate, startDate, endDate, property, project, budgetItem);
// then
// should not updated
assertThat(invoiceItem.getInvoice()).isEqualTo(mockInvoice);
// should not updated
assertThat(invoiceItem.getCharge()).isNull();
// should not be updated
assertThat(invoiceItem.getIncomingInvoiceType()).isNull();
assertThat(invoiceItem.getSequence()).isEqualTo(sequence);
assertThat(invoiceItem.getDescription()).isEqualTo(description);
assertThat(invoiceItem.getNetAmount()).isEqualTo(BigDecimal.ZERO);
assertThat(invoiceItem.getVatAmount()).isEqualTo(BigDecimal.ONE);
assertThat(invoiceItem.getGrossAmount()).isEqualTo(BigDecimal.TEN);
assertThat(invoiceItem.getTax()).isEqualTo(tax);
assertThat(invoiceItem.getDueDate()).isEqualTo(dueDate);
assertThat(invoiceItem.getStartDate()).isEqualTo(startDate);
assertThat(invoiceItem.getEndDate()).isEqualTo(endDate);
assertThat(invoiceItem.getFixedAsset()).isEqualTo(property);
assertThat(invoiceItem.getProject()).isEqualTo(project);
}
Aggregations