Search in sources :

Example 1 with Project

use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.

the class ProjectBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("reference", ec, String.class);
    checkParam("name", ec, String.class);
    final Project project = projectRepository.create(reference, name, startDate, endDate, atPath, parent);
    ec.addResult(this, reference, project);
    for (ItemSpec i : itemSpecs) {
        project.addItem(i.charge, i.description, i.budgetedAmount, i.startDate, i.endDate, i.property, i.tax);
    }
    object = project;
}
Also used : Project(org.estatio.module.capex.dom.project.Project)

Example 2 with Project

use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.

the class IncomingInvoice method getProjectSummary.

@Programmatic
public String getProjectSummary() {
    List<Project> distinctProjects = new ArrayList<>();
    for (InvoiceItem item : getItems()) {
        IncomingInvoiceItem iitem = (IncomingInvoiceItem) item;
        if (iitem.getProject() != null && !distinctProjects.contains(iitem.getProject())) {
            distinctProjects.add(iitem.getProject());
        }
    }
    StringBuffer summary = new StringBuffer();
    for (Project project : distinctProjects) {
        if (summary.length() > 0) {
            summary.append(" | ");
        }
        summary.append(project.getName());
    }
    return summary.toString();
}
Also used : Project(org.estatio.module.capex.dom.project.Project) InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) ArrayList(java.util.ArrayList) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 3 with Project

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

Example 4 with Project

use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.

the class OrderItemRepository_Test method upsert_works.

@Test
public void upsert_works() throws Exception {
    // given
    OrderItemRepository orderItemRepository = new OrderItemRepository() {

        @Override
        public OrderItem findByOrderAndCharge(final Order order, final Charge charge) {
            return orderItem;
        }
    };
    String description = new String("some description");
    BigDecimal netAmount = BigDecimal.ZERO;
    BigDecimal vatAmount = BigDecimal.ONE;
    BigDecimal grossAmount = BigDecimal.TEN;
    Tax tax = new Tax();
    LocalDate startDate = new LocalDate(2017, 1, 1);
    LocalDate endDate = new LocalDate(2017, 1, 2);
    Property property = new Property();
    Project project = new Project();
    BudgetItem budgetItem = new BudgetItem();
    assertThat(orderItem.getOrdr()).isNull();
    assertThat(orderItem.getCharge()).isNull();
    // when
    orderItemRepository.upsert(mockOrder, mockCharge, description, netAmount, vatAmount, grossAmount, tax, startDate, endDate, property, project, budgetItem);
    // then
    assertThat(orderItem.getOrdr()).isNull();
    assertThat(orderItem.getCharge()).isNull();
    assertThat(orderItem.getDescription()).isEqualTo(description);
    assertThat(orderItem.getNetAmount()).isEqualTo(netAmount);
    assertThat(orderItem.getVatAmount()).isEqualTo(vatAmount);
    assertThat(orderItem.getGrossAmount()).isEqualTo(grossAmount);
    assertThat(orderItem.getTax()).isEqualTo(tax);
    assertThat(orderItem.getStartDate()).isEqualTo(startDate);
    assertThat(orderItem.getEndDate()).isEqualTo(endDate);
    assertThat(orderItem.getProperty()).isEqualTo(property);
    assertThat(orderItem.getProject()).isEqualTo(project);
    assertThat(orderItem.getBudgetItem()).isEqualTo(budgetItem);
}
Also used : 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) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 5 with Project

use of org.estatio.module.capex.dom.project.Project in project estatio by estatio.

the class Project_IntegTest method parent_project_cannot_add_itself_as_a_child.

@Test
public void parent_project_cannot_add_itself_as_a_child() throws Exception {
    // given
    Project parent = Project_enum.KalProject1.findUsing(serviceRegistry);
    // expect
    expectedExceptions.expect(InvalidException.class);
    expectedExceptions.expectMessage("Reason: A project cannot have itself as a child.");
    // when
    wrap(parent).addChildProject(parent);
}
Also used : Project(org.estatio.module.capex.dom.project.Project) Test(org.junit.Test)

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