Search in sources :

Example 11 with Project

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");
}
Also used : Project(org.estatio.module.capex.dom.project.Project) Organisation(org.estatio.module.party.dom.Organisation) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 12 with Project

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);
}
Also used : Expectations(org.jmock.Expectations) Project(org.estatio.module.capex.dom.project.Project) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 13 with Project

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;
}
Also used : Action(org.apache.isis.applib.annotation.Action) Project(org.estatio.module.capex.dom.project.Project) ServiceRegistry2(org.apache.isis.applib.services.registry.ServiceRegistry2) Project_InvoiceItemsNotOnProjectItem(org.estatio.module.capex.dom.invoice.contributions.Project_InvoiceItemsNotOnProjectItem) Charge(org.estatio.module.charge.dom.Charge) EstatioRole(org.estatio.module.base.dom.EstatioRole) Property(org.estatio.module.asset.dom.Property) Collectors(java.util.stream.Collectors) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) List(java.util.List) Project_OrderItemsNotOnProjectItem(org.estatio.module.capex.dom.order.contributions.Project_OrderItemsNotOnProjectItem) UserService(org.apache.isis.applib.services.user.UserService) Project_InvoiceItemsNotOnProjectItem(org.estatio.module.capex.dom.invoice.contributions.Project_InvoiceItemsNotOnProjectItem) Charge(org.estatio.module.charge.dom.Charge) ArrayList(java.util.ArrayList) Project_OrderItemsNotOnProjectItem(org.estatio.module.capex.dom.order.contributions.Project_OrderItemsNotOnProjectItem)

Example 14 with Project

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;
}
Also used : Project(org.estatio.module.capex.dom.project.Project) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) FixedAsset(org.estatio.module.asset.dom.FixedAsset) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal)

Example 15 with Project

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);
}
Also used : Project(org.estatio.module.capex.dom.project.Project) ProjectRole(org.estatio.module.capex.dom.project.ProjectRole)

Aggregations

Project (org.estatio.module.capex.dom.project.Project)18 Test (org.junit.Test)11 Charge (org.estatio.module.charge.dom.Charge)9 BigDecimal (java.math.BigDecimal)6 Property (org.estatio.module.asset.dom.Property)6 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)5 Tax (org.estatio.module.tax.dom.Tax)5 LocalDate (org.joda.time.LocalDate)5 ArrayList (java.util.ArrayList)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)2 OrderItemInvoiceItemLink (org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink)2 Organisation (org.estatio.module.party.dom.Organisation)2 Expectations (org.jmock.Expectations)2 BigInteger (java.math.BigInteger)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 ApplicationException (org.apache.isis.applib.ApplicationException)1 Action (org.apache.isis.applib.annotation.Action)1