use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.
the class Order_Test method minimalRequiredDataToComplete_consitent_dimensions_for_project_budgetItem.
@Test
public void minimalRequiredDataToComplete_consitent_dimensions_for_project_budgetItem() throws Exception {
// given
Order order = new Order();
OrderItem item1 = new OrderItem();
order.getItems().add(item1);
order.setOrderNumber("123");
order.setBuyer(new Organisation());
order.setSeller(new Organisation());
item1.setNetAmount(new BigDecimal("100"));
item1.setDescription("blah");
item1.setGrossAmount(BigDecimal.ZERO);
item1.setCharge(new Charge());
item1.setStartDate(new LocalDate());
item1.setEndDate(new LocalDate());
item1.setProperty(new Property());
// when
item1.setBudgetItem(new BudgetItem());
item1.setProject(new Project());
String result = order.reasonIncomplete();
// then
assertThat(result).isEqualTo("(on item) either project or budget item - not both required");
}
use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.
the class Order_Test method splitItem_mixin_works.
@Test
public void splitItem_mixin_works() throws Exception {
// given
Order order = new Order();
order.orderItemRepository = mockOrderItemRepository;
String description = "some description";
Tax tax = new Tax();
Charge charge = new Charge();
Property property = new Property();
Project project = new Project();
BudgetItem budgetItem = new BudgetItem();
String period = "F2018";
OrderItem itemToSplit = new OrderItem();
BigDecimal newItemNetAmount = new BigDecimal("50.00");
BigDecimal newItemVatAmount = new BigDecimal("10");
BigDecimal newItemGrossAmount = new BigDecimal("60.00");
// expect
context.checking(new Expectations() {
{
oneOf(mockOrderItemRepository).upsert(order, charge, description, newItemNetAmount, newItemVatAmount, newItemGrossAmount, tax, PeriodUtil.yearFromPeriod(period).startDate(), PeriodUtil.yearFromPeriod(period).endDate(), property, project, budgetItem);
}
});
// when
order.splitItem(itemToSplit, description, newItemNetAmount, newItemVatAmount, tax, newItemGrossAmount, charge, property, project, budgetItem, period);
}
use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.
the class Project_CreateMissingItems method chargesLinkedNotOnItems.
private List<Charge> chargesLinkedNotOnItems() {
List<Charge> result = new ArrayList<>();
Project_OrderItemsNotOnProjectItem orderItemsMixin = new Project_OrderItemsNotOnProjectItem(project);
serviceRegistry2.injectServicesInto(orderItemsMixin);
for (Charge chargeCandidate : orderItemsMixin.orderItemsNotOnProjectItem().stream().filter(x -> x.getCharge() != null).map(x -> x.getCharge()).collect(Collectors.toList())) {
if (!result.contains(chargeCandidate)) {
result.add(chargeCandidate);
}
}
Project_InvoiceItemsNotOnProjectItem invoiceItemsMixin = new Project_InvoiceItemsNotOnProjectItem(project);
serviceRegistry2.injectServicesInto(invoiceItemsMixin);
for (Charge chargeCandidate : invoiceItemsMixin.invoiceItemsNotOnProjectItem().stream().filter(x -> x.getCharge() != null).map(x -> x.getCharge()).collect(Collectors.toList())) {
if (!result.contains(chargeCandidate)) {
result.add(chargeCandidate);
}
}
return result;
}
use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.
the class IncomingInvoice method copyWithLinks.
private IncomingInvoiceItem copyWithLinks(final IncomingInvoiceItem itemToReverse, final Sort sort) {
final IncomingInvoiceType type = itemToReverse.getIncomingInvoiceType();
final String description = itemToReverse.getDescription();
final Charge charge = itemToReverse.getCharge();
final BigDecimal netAmount = itemToReverse.getNetAmount();
final BigDecimal vatAmount = itemToReverse.getVatAmount();
final BigDecimal grossAmount = itemToReverse.getGrossAmount();
final Tax tax = itemToReverse.getTax();
final LocalDate dueDate = itemToReverse.getDueDate();
final String period = itemToReverse.getPeriod();
final FixedAsset fixedAsset = itemToReverse.getFixedAsset();
final Project project = itemToReverse.getProject();
final BudgetItem budgetItem = itemToReverse.getBudgetItem();
final IncomingInvoiceItem copyItem = addItemToThis(type, charge, sort.prefixTo(description), sort.adjust(netAmount), sort.adjust(vatAmount), sort.adjust(grossAmount), tax, dueDate, period, fixedAsset, project, budgetItem);
if (sort == Sort.REVERSAL) {
copyItem.setReversalOf(itemToReverse);
}
final Optional<OrderItemInvoiceItemLink> linkIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(itemToReverse);
linkIfAny.ifPresent(link -> {
orderItemInvoiceItemLinkRepository.createLink(link.getOrderItem(), copyItem, sort.adjust(link.getNetAmount()));
});
return copyItem;
}
use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.
the class PartyRoleMemberInferenceServiceForProjectRoleAndIncomingInvoice method doInferMembersOf.
@Override
protected List<Person> doInferMembersOf(final ProjectRoleTypeEnum roleType, final IncomingInvoice incomingInvoice) {
final Project project = inferProject(incomingInvoice);
if (project == null) {
// can't go any further
return null;
}
final List<ProjectRole> projectRoles = projectRoleRepository.findByProject(project);
return currentPersonsFor(projectRoles);
}
Aggregations