Package org.libreplan.business.advance.entities

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


    }

    @Override
    public SortedMap<LocalDate, BigDecimal> getAdvanceCost(Task task,
            LocalDate filterStartDate, LocalDate filterEndDate) {
        DirectAdvanceAssignment advanceAssignment = (task.getOrderElement() != null) ? task
                .getOrderElement().getReportGlobalAdvanceAssignment() : null;

        if (advanceAssignment == null) {
            return new TreeMap<LocalDate, BigDecimal>();
        }

        return calculateHoursPerDay(task.getHoursSpecifiedAtOrder(),
                advanceAssignment.getAdvanceMeasurements(),
                filterStartDate, filterEndDate);
    }
View Full Code Here


        boolean reportGlobalAdvance = false;
        if (getReportGlobalAdvanceAssignment() == null) {
            reportGlobalAdvance = true;
        }

        DirectAdvanceAssignment directAdvanceAssignment = DirectAdvanceAssignment
                .create(reportGlobalAdvance, new BigDecimal(100));
        directAdvanceAssignment
                .setAdvanceType(PredefinedAdvancedTypes.SUBCONTRACTOR.getType());

        addAdvanceAssignment(directAdvanceAssignment);
        return directAdvanceAssignment;
    }
View Full Code Here

    public void detachFromParent() {
        parent = null;
    }

    public AdvanceMeasurement getLastAdvanceMeasurement() {
        DirectAdvanceAssignment advanceAssignment = getReportGlobalAdvanceAssignment();
        if (advanceAssignment == null) {
            return null;
        }
        return advanceAssignment.getLastAdvanceMeasurement();
    }
View Full Code Here

            OrderElement orderElement, BigDecimal percentage,
            LocalDate latestWorkLogDate) {

        AdvanceType advanceType = PredefinedAdvancedTypes.PERCENTAGE.getType();

        DirectAdvanceAssignment directAdvanceAssignment = orderElement
                .getDirectAdvanceAssignmentByType(advanceType);
        if (directAdvanceAssignment == null) {
            directAdvanceAssignment = DirectAdvanceAssignment.create(false,
                    new BigDecimal(100).setScale(2));
            directAdvanceAssignment.setAdvanceType(advanceType);
            try {
                orderElement.addAdvanceAssignment(directAdvanceAssignment);
            } catch (DuplicateValueTrueReportGlobalAdvanceException e) {
                // This couldn't happen as it has just created the
                // directAdvanceAssignment with false as reportGlobalAdvance
                throw new RuntimeException(e);
            } catch (DuplicateAdvanceAssignmentForOrderElementException e) {
                // This could happen if a parent or child of the current
                // OrderElement has an advance of type PERCENTAGE
                synchronizationInfo
                        .addFailedReason(_(
                                "Duplicate value AdvanceAssignment for order element of \"{0}\"",
                                orderElement.getCode()));
                return;
            }
        }

        AdvanceMeasurement advanceMeasurement = directAdvanceAssignment
                .getAdvanceMeasurementAtExactDate(latestWorkLogDate);
        if (advanceMeasurement == null) {
            advanceMeasurement = AdvanceMeasurement.create();
            advanceMeasurement.setDate(latestWorkLogDate);
            directAdvanceAssignment.addAdvanceMeasurements(advanceMeasurement);
        }

        advanceMeasurement.setValue(percentage
                .setScale(2, RoundingMode.HALF_UP));

        DirectAdvanceAssignment spreadAdvanceAssignment = orderElement
                .getReportGlobalAdvanceAssignment();
        if (spreadAdvanceAssignment != null) {
            spreadAdvanceAssignment.setReportGlobalAdvance(false);
        }

        directAdvanceAssignment.setReportGlobalAdvance(true);
    }
View Full Code Here

    private void addDirectAdvanceAssignment(OrderElement orderElement,
            boolean spread)
            throws DuplicateValueTrueReportGlobalAdvanceException,
            DuplicateAdvanceAssignmentForOrderElementException {
        DirectAdvanceAssignment directAdvanceAssignment = DirectAdvanceAssignment
                .create(spread, HUNDRED);
        advanceType = PredefinedAdvancedTypes.PERCENTAGE.getType();
        directAdvanceAssignment.setAdvanceType(advanceType);
        orderElement.addAdvanceAssignment(directAdvanceAssignment);
    }
View Full Code Here

    }

    private void addAnotherDirectAdvanceAssignment(OrderElement orderElement)
            throws DuplicateValueTrueReportGlobalAdvanceException,
            DuplicateAdvanceAssignmentForOrderElementException {
        DirectAdvanceAssignment directAdvanceAssignment = DirectAdvanceAssignment
                .create(false, HUNDRED);
        advanceType2 = PredefinedAdvancedTypes.UNITS.getType();
        directAdvanceAssignment.setAdvanceType(advanceType2);
        orderElement.addAdvanceAssignment(directAdvanceAssignment);
    }
View Full Code Here

    private void addAnotherDifferentDirectAdvanceAssignment(
            OrderElement orderElement)
            throws DuplicateValueTrueReportGlobalAdvanceException,
            DuplicateAdvanceAssignmentForOrderElementException {
        DirectAdvanceAssignment directAdvanceAssignment = DirectAdvanceAssignment
                .create(false, HUNDRED);
        advanceType3 = PredefinedAdvancedTypes.SUBCONTRACTOR.getType();
        directAdvanceAssignment.setAdvanceType(advanceType3);
        orderElement.addAdvanceAssignment(directAdvanceAssignment);
    }
View Full Code Here

        assertThat(foundOrder.getChildren().size(), equalTo(1));

        OrderElement orderElement = foundOrder.getChildren().get(0);
        assertNotNull(orderElement);

        DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                .getDirectAdvanceAssignmentSubcontractor();
        assertNotNull(directAdvanceAssignmentSubcontractor);
        assertTrue(directAdvanceAssignmentSubcontractor.getReportGlobalAdvance());
        assertThat(directAdvanceAssignmentSubcontractor.getAdvanceMeasurements().size(), equalTo(1));

        for (Entry<LocalDate, BigDecimal> entry : values.entrySet()) {
            AdvanceMeasurement advanceMeasurement = directAdvanceAssignmentSubcontractor
                    .getAdvanceMeasurements().first();
            assertThat(advanceMeasurement.getDate(), equalTo(entry.getKey()));
            assertThat(advanceMeasurement.getValue(), equalTo(entry.getValue()));
        }
    }
View Full Code Here

            public Void execute() {

                OrderElement orderElement;
                try {
                    orderElement = orderElementDAO.findByCode(orderElementCode);
                    DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                            .getDirectAdvanceAssignmentSubcontractor();
                    assertNotNull(directAdvanceAssignmentSubcontractor);
                    assertTrue(directAdvanceAssignmentSubcontractor.getReportGlobalAdvance());
                    assertThat(
                            directAdvanceAssignmentSubcontractor.getAdvanceMeasurements().size(),
                            equalTo(1));

                    for (Entry<LocalDate, BigDecimal> entry : values.entrySet()) {
                        AdvanceMeasurement advanceMeasurement = directAdvanceAssignmentSubcontractor
                                .getAdvanceMeasurements().first();
                        assertThat(advanceMeasurement.getDate(), equalTo(entry.getKey()));
                        assertThat(advanceMeasurement.getValue(), equalTo(entry.getValue()));
                    }
View Full Code Here

                OrderElement orderElement;
                try {
                    orderElement = orderElementDAO.findByCode(orderElementCode);

                assertNotNull(orderElement);
                DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                        .getDirectAdvanceAssignmentSubcontractor();
                assertNull(directAdvanceAssignmentSubcontractor);

                int currentCommunications = subcontractorCommunicationDAO.getAll().size();
                assertThat((previousCommunications + 1), equalTo(currentCommunications));
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.