Search in sources :

Example 11 with BudgetItem

use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.

the class Budget method removeAllBudgetItems.

@Action(restrictTo = RestrictTo.PROTOTYPING, semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout()
public Budget removeAllBudgetItems() {
    for (BudgetItem budgetItem : this.getItems()) {
        for (PartitionItem pItem : budgetItem.getPartitionItems()) {
            pItem.remove();
        }
        getContainer().remove(budgetItem);
        getContainer().flush();
    }
    return this;
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 12 with BudgetItem

use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.

the class BudgetCalculationRepository method findByBudget.

public List<BudgetCalculation> findByBudget(final Budget budget) {
    List<BudgetCalculation> result = new ArrayList<>();
    for (BudgetItem item : budget.getItems()) {
        result.addAll(findByBudgetItemAndCalculationType(item, BudgetCalculationType.ACTUAL));
        result.addAll(findByBudgetItemAndCalculationType(item, BudgetCalculationType.BUDGETED));
    }
    return result;
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) ArrayList(java.util.ArrayList)

Example 13 with BudgetItem

use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.

the class BudgetCalculationService method getAllCalculations.

public List<BudgetCalculationViewmodel> getAllCalculations(final Budget budget) {
    List<BudgetCalculationViewmodel> budgetCalculationViewmodels = new ArrayList<>();
    for (BudgetItem budgetItem : budget.getItems()) {
        budgetCalculationViewmodels.addAll(calculate(budgetItem, BudgetCalculationType.BUDGETED));
        budgetCalculationViewmodels.addAll(calculate(budgetItem, BudgetCalculationType.ACTUAL));
    }
    return budgetCalculationViewmodels;
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) ArrayList(java.util.ArrayList)

Example 14 with BudgetItem

use of org.estatio.module.budget.dom.budgetitem.BudgetItem 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 15 with BudgetItem

use of org.estatio.module.budget.dom.budgetitem.BudgetItem 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)

Aggregations

BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)22 Property (org.estatio.module.asset.dom.Property)11 Charge (org.estatio.module.charge.dom.Charge)9 LocalDate (org.joda.time.LocalDate)9 Test (org.junit.Test)9 BigDecimal (java.math.BigDecimal)8 Budget (org.estatio.module.budget.dom.budget.Budget)8 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)5 Project (org.estatio.module.capex.dom.project.Project)5 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 Tax (org.estatio.module.tax.dom.Tax)4 ArrayList (java.util.ArrayList)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 ApplicationException (org.apache.isis.applib.ApplicationException)2 Action (org.apache.isis.applib.annotation.Action)2 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 Partitioning (org.estatio.module.budget.dom.partioning.Partitioning)2 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)2 BudgetCalculationRun (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)2 Organisation (org.estatio.module.party.dom.Organisation)2