Package org.libreplan.business.advance.entities

Examples of org.libreplan.business.advance.entities.DirectAdvanceAssignment


        }
        if(orderElement.getAdvanceAssignmentByType(advanceType) != null){
                return false;
        }
        try {
            DirectAdvanceAssignment newAdvanceAssignment = DirectAdvanceAssignment
                    .create();
            newAdvanceAssignment.setAdvanceType(advanceType);
            orderElement.checkAncestorsNoOtherAssignmentWithSameAdvanceType(
                    orderElement.getParent(), newAdvanceAssignment);
        } catch (DuplicateAdvanceAssignmentForOrderElementException e) {
            return false;
        }
View Full Code Here


                createAdvancePercentageIfRequired(each);
            }
        }

        private void createAdvancePercentageIfRequired(OrderElement orderElement) {
            DirectAdvanceAssignment advancePercentage = orderElement
                    .getDirectAdvanceAssignmentByType(PredefinedAdvancedTypes.PERCENTAGE
                            .getType());

            if ((orderElement.isSchedulingPoint())
                    && (orderElement.getReportGlobalAdvanceAssignment() == null)
View Full Code Here

                createAdvancePercentage(orderElement);
            }
        }

        private void createAdvancePercentage(OrderElement orderElement) {
            DirectAdvanceAssignment newAdvance = DirectAdvanceAssignment
                    .create();
            newAdvance.setOrderElement(orderElement);

            AdvanceType type = PredefinedAdvancedTypes.PERCENTAGE.getType();
            newAdvance.setAdvanceType(type);
            newAdvance.setMaxValue(type.getDefaultMaxValue());
            newAdvance.setReportGlobalAdvance(true);

            try {
                orderElement.addAdvanceAssignment(newAdvance);
            } catch (DuplicateValueTrueReportGlobalAdvanceException e) {
                // This shouldn't happen
View Full Code Here

        return advanceMeasurement;
    }

    private DirectAdvanceAssignment createValidAdvanceAssignment(
            boolean reportGlobalAdvance) {
    DirectAdvanceAssignment advanceAssignment = DirectAdvanceAssignment
                .create(reportGlobalAdvance, BigDecimal.TEN);
        return advanceAssignment;
    }
View Full Code Here

        assertThat(found.getIndirectAdvanceAssignments().size(), equalTo(2));

        Set<DirectAdvanceAssignment> directAdvanceAssignments = found.getChildren().get(0).getDirectAdvanceAssignments();
        assertThat(directAdvanceAssignments.size(), equalTo(1));

        DirectAdvanceAssignment directAdvanceAssignment = directAdvanceAssignments
                .iterator().next();
        assertThat(directAdvanceAssignment.getMaxValue(),
                equalTo(new BigDecimal(1000)));

        SortedSet<AdvanceMeasurement> advanceMeasurements = directAdvanceAssignment.getAdvanceMeasurements();
        assertThat(advanceMeasurements.size(), equalTo(1));
        assertThat(advanceMeasurements.iterator().next().getValue(),
                equalTo(new BigDecimal(100)));
    }
View Full Code Here

        Order order = createValidOrder();
        OrderElement orderLine = createValidLeaf("OrderLineA", "1k1k1k1k");

        AdvanceType advanceType = createAndSaveType("tipoA");

        DirectAdvanceAssignment advanceAssignment = createValidAdvanceAssignment(true);
        assertTrue(orderLine.getDirectAdvanceAssignments().isEmpty());
        advanceAssignment.setAdvanceType(advanceType);

        order.add(orderLine);
        orderDao.save(order);

        orderLine.addAdvanceAssignment(advanceAssignment);

        orderDao.save(order);
        this.sessionFactory.getCurrentSession().flush();

        assertFalse(orderLine.getDirectAdvanceAssignments().isEmpty());
        assertTrue(advanceAssignmentDao.exists(advanceAssignment.getId()));

    }
View Full Code Here

        OrderLine orderLine = createValidLeaf("OrderLineA", "1111111");

        AdvanceType advanceTypeA = createAndSaveType("tipoA");
        AdvanceType advanceTypeB = createAndSaveType("tipoB");

        DirectAdvanceAssignment advanceAssignmentA = createValidAdvanceAssignment(true);
        advanceAssignmentA.setAdvanceType(advanceTypeA);

        order.add(orderLine);
        orderDao.save(order);

        orderLine.addAdvanceAssignment(advanceAssignmentA);

        DirectAdvanceAssignment advanceAssignmentB = createValidAdvanceAssignment(false);
        advanceAssignmentB.setAdvanceType(advanceTypeB);
        orderLine.addAdvanceAssignment(advanceAssignmentB);
    }
View Full Code Here

            DuplicateAdvanceAssignmentForOrderElementException {
        OrderLine orderLine = createValidLeaf("OrderLineA", "22222222");

        AdvanceType advanceTypeA = createAndSaveType("tipoA");

        DirectAdvanceAssignment advanceAssignmentA = createValidAdvanceAssignment(true);
        advanceAssignmentA.setAdvanceType(advanceTypeA);

        orderLine.addAdvanceAssignment(advanceAssignmentA);

        DirectAdvanceAssignment advanceAssignmentB = createValidAdvanceAssignment(false);
        advanceAssignmentB.setAdvanceType(advanceTypeA);

        try {
            orderLine.addAdvanceAssignment(advanceAssignmentB);
            fail("It should throw an exception");
        } catch (DuplicateAdvanceAssignmentForOrderElementException e) {
View Full Code Here

        OrderLine orderLine = createValidLeaf("OrderLineA", "101010101");

        AdvanceType advanceTypeA = createAndSaveType("tipoA");
        AdvanceType advanceTypeB = createAndSaveType("tipoB");

        DirectAdvanceAssignment advanceAssignmentA = createValidAdvanceAssignment(true);
        advanceAssignmentA.setAdvanceType(advanceTypeA);


        orderLine.addAdvanceAssignment(advanceAssignmentA);

        DirectAdvanceAssignment advanceAssignmentB = createValidAdvanceAssignment(true);
        advanceAssignmentB.setAdvanceType(advanceTypeB);
        try {
            orderLine.addAdvanceAssignment(advanceAssignmentB);
            fail("It should throw an exception  ");
        } catch (DuplicateValueTrueReportGlobalAdvanceException e) {
            // Ok
View Full Code Here

        AdvanceMeasurement advanceMeasurement = createValidAdvanceMeasurement();

        AdvanceType advanceTypeA = createAndSaveType("tipoA");
        AdvanceType advanceTypeB = createAndSaveType("tipoB");

        DirectAdvanceAssignment advanceAssignmentA = createValidAdvanceAssignment(true);
        advanceAssignmentA.setAdvanceType(advanceTypeA);

        DirectAdvanceAssignment advanceAssignmentB = createValidAdvanceAssignment(false);
        advanceAssignmentB.setAdvanceType(advanceTypeB);

        OrderElementTest
                .removeReportGlobalAdvanceFromChildrenAdvance(container);
        container.addAdvanceAssignment(advanceAssignmentA);
        son.addAdvanceAssignment(advanceAssignmentB);

        advanceAssignmentA.addAdvanceMeasurements(advanceMeasurement);
        advanceAssignmentB.addAdvanceMeasurements(advanceMeasurement);
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.advance.entities.DirectAdvanceAssignment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.