Package org.libreplan.business.advance.entities

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


        SortedSet<AdvanceMeasurement> newAdvanceMeasurements = new TreeSet<AdvanceMeasurement>(
                new AdvanceMeasurementComparator());
        for (LocalDate localDate : measurementDates) {
            BigDecimal value = getAdvancePercentageChildren(localDate)
                    .multiply(new BigDecimal(100));
            AdvanceMeasurement advanceMeasurement = AdvanceMeasurement.create(
                    localDate, value);
            advanceMeasurement.setAdvanceAssignment(newDirectAdvanceAssignment);
            newAdvanceMeasurements.add(advanceMeasurement);
        }
        newDirectAdvanceAssignment
                .setAdvanceMeasurements(newAdvanceMeasurements);
View Full Code Here


            List<AdvanceMeasurement> result) {

        Iterator<AdvanceMeasurement> iterator1 = list1.iterator();
        Iterator<AdvanceMeasurement> iterator2 = list2.iterator();

        AdvanceMeasurement next1;
        if (iterator1.hasNext()) {
            next1 = iterator1.next();
        } else {
            next1 = null;
        }
        AdvanceMeasurement next2;
        if (iterator2.hasNext()) {
            next2 = iterator2.next();
        } else {
            next2 = null;
        }

        BigDecimal previous1 = BigDecimal.ZERO;
        BigDecimal previous2 = BigDecimal.ZERO;
        BigDecimal previousResult = BigDecimal.ZERO;

        LocalDate date;
        BigDecimal add;
        Date communicationDate;

        BigDecimal totalHours = null;
        if (advanceAssignment.getAdvanceType().getPercentage()) {
            totalHours = new BigDecimal(advanceAssignment.getOrderElement()
                    .getWorkHours());
        }

        while ((next1 != null) && (next2 != null)) {
            if (next1.getDate().compareTo(next2.getDate()) < 0) {
                date = next1.getDate();
                add = next1.getValue().subtract(previous1);
                communicationDate = next1.getCommunicationDate();
                previous1 = next1.getValue();

                if (advanceAssignment.getAdvanceType().getPercentage()) {
                    BigDecimal orderElementHours = new BigDecimal(next1
                            .getAdvanceAssignment().getOrderElement()
                            .getWorkHours());
                    add = addMeasure(add, totalHours, orderElementHours);
                }

                if (iterator1.hasNext()) {
                    next1 = iterator1.next();
                } else {
                    next1 = null;
                }
            } else if (next1.getDate().compareTo(next2.getDate()) > 0) {
                date = next2.getDate();
                add = next2.getValue().subtract(previous2);
                communicationDate = next2.getCommunicationDate();
                previous2 = next2.getValue();

                if (advanceAssignment.getAdvanceType().getPercentage()) {
                    BigDecimal orderElementHours = new BigDecimal(next2
                            .getAdvanceAssignment().getOrderElement()
                            .getWorkHours());
                    add = addMeasure(add, totalHours, orderElementHours);
                }

                if (iterator2.hasNext()) {
                    next2 = iterator2.next();
                } else {
                    next2 = null;
                }
            } else {
                date = next1.getDate();
                BigDecimal add1 = next1.getValue().subtract(previous1);
                BigDecimal add2 = next2.getValue().subtract(previous2);
                add = add1.add(add2);
                communicationDate = getGreatestDate(next1
                        .getCommunicationDate(), next2.getCommunicationDate());
                previous1 = next1.getValue();
                previous2 = next2.getValue();

                if (advanceAssignment.getAdvanceType().getPercentage()) {
                    BigDecimal orderElementHours1 = new BigDecimal(next1
                            .getAdvanceAssignment().getOrderElement()
                            .getWorkHours());
                    add1 = addMeasure(add1, totalHours, orderElementHours1);

                    BigDecimal orderElementHours2 = new BigDecimal(next2
                            .getAdvanceAssignment().getOrderElement()
                            .getWorkHours());
                    add2 = addMeasure(add2, totalHours, orderElementHours2);
                    add = add1.add(add2);
                }

                if (iterator1.hasNext()) {
                    next1 = iterator1.next();
                } else {
                    next1 = null;
                }
                if (iterator2.hasNext()) {
                    next2 = iterator2.next();
                } else {
                    next2 = null;
                }
            }

            AdvanceMeasurement advanceMeasurement = AdvanceMeasurement.create();
            advanceMeasurement.setAdvanceAssignment(advanceAssignment);
            advanceMeasurement.setDate(date);
            previousResult = previousResult.add(add);
            checkAndSetValue(advanceMeasurement, previousResult);
            advanceMeasurement.setCommunicationDate(communicationDate);
            result.add(advanceMeasurement);
        }

        while (next1 != null) {
            date = next1.getDate();
            add = next1.getValue().subtract(previous1);
            communicationDate = next1.getCommunicationDate();
            previous1 = next1.getValue();

            if (advanceAssignment.getAdvanceType().getPercentage()) {
                BigDecimal orderElementHours = new BigDecimal(next1
                        .getAdvanceAssignment().getOrderElement()
                        .getWorkHours());
                add = addMeasure(add, totalHours, orderElementHours);
            }

            if (iterator1.hasNext()) {
                next1 = iterator1.next();
            } else {
                next1 = null;
            }

            AdvanceMeasurement advanceMeasurement = AdvanceMeasurement.create();
            advanceMeasurement.setAdvanceAssignment(advanceAssignment);
            advanceMeasurement.setDate(date);
            checkAndSetValue(advanceMeasurement, previousResult.add(add));
            previousResult = advanceMeasurement.getValue();
            advanceMeasurement.setCommunicationDate(communicationDate);
            result.add(advanceMeasurement);
        }

        while (next2 != null) {
            date = next2.getDate();
            add = next2.getValue().subtract(previous2);
            communicationDate = next2.getCommunicationDate();
            previous2 = next2.getValue();

            if (advanceAssignment.getAdvanceType().getPercentage()) {
                BigDecimal orderElementHours = new BigDecimal(next2
                        .getAdvanceAssignment().getOrderElement()
                        .getWorkHours());
                add = addMeasure(add, totalHours, orderElementHours);
            }

            if (iterator2.hasNext()) {
                next2 = iterator2.next();
            } else {
                next2 = null;
            }

            AdvanceMeasurement advanceMeasurement = AdvanceMeasurement.create();
            advanceMeasurement.setAdvanceAssignment(advanceAssignment);
            advanceMeasurement.setDate(date);
            checkAndSetValue(advanceMeasurement, previousResult.add(add));
            previousResult = advanceMeasurement.getValue();
            advanceMeasurement.setCommunicationDate(communicationDate);
            result.add(advanceMeasurement);
        }

    }
View Full Code Here

                                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) {
View Full Code Here

        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

                    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()));
                    }

                    int currentCommunications = subcontractorCommunicationDAO.getAll().size();
                    assertThat((previousCommunications + 1), equalTo(currentCommunications));
                } catch (InstanceNotFoundException e) {
View Full Code Here

                    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()));
                    }

                    int currentCommunications = subcontractorCommunicationDAO.getAll().size();
                    assertThat((previousCommunications + 2), equalTo(currentCommunications));
View Full Code Here

            showMessageNotAddMoreAdvances();
        }
    }

    public void goToCreateLineAdvanceMeasurement() {
        AdvanceMeasurement newMeasure = manageOrderElementAdvancesModel
                .addNewLineAdvaceMeasurement();
        if ((newMeasure != null)
                && (manageOrderElementAdvancesModel
                        .hasConsolidatedAdvances(newMeasure
                                .getAdvanceAssignment()))) {
            newMeasure.setDate(null);
        }
        reloadAdvances();
    }
View Full Code Here

    }

    private Listbox editAdvancesMeasurement;

    public void goToRemoveLineAdvanceMeasurement(Listitem listItem) {
        AdvanceMeasurement advance = (AdvanceMeasurement) listItem.getValue();
        if (manageOrderElementAdvancesModel.canRemoveOrChange(advance)) {
            manageOrderElementAdvancesModel
                    .removeLineAdvanceMeasurement(advance);
            reloadAdvances();
        } else {
View Full Code Here

                    .calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) advanceAssignment);
        } else {
            directAdvanceAssignment = (DirectAdvanceAssignment) advanceAssignment;
        }

        final AdvanceMeasurement advanceMeasurement = this.manageOrderElementAdvancesModel
                .getLastAdvanceMeasurement(directAdvanceAssignment);
        if (advanceMeasurement != null) {
            Util.bind(value, new Util.Getter<BigDecimal>() {
                @Override
                public BigDecimal get() {
                    return advanceMeasurement.getValue();
                }
            });
        }
        Listcell listCell = new Listcell();
        listCell.appendChild(value);
View Full Code Here

            directAdvanceAssignment = manageOrderElementAdvancesModel
                    .calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) advanceAssignment);
        } else {
            directAdvanceAssignment = (DirectAdvanceAssignment) advanceAssignment;
        }
        final AdvanceMeasurement advanceMeasurement = this.manageOrderElementAdvancesModel
                .getLastAdvanceMeasurement(directAdvanceAssignment);
        if (advanceMeasurement != null) {
            percentage
                    .setValue(this.manageOrderElementAdvancesModel
                    .getPercentageAdvanceMeasurement(advanceMeasurement)
View Full Code Here

TOP

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

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.