Package org.libreplan.business.advance.entities

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


        advanceTypeDAO.reattach(advanceType);
        AdvanceAssignment advanceAssignment = taskQualityForm.getOrderElement()
                .getDirectAdvanceAssignmentByType(advanceType);

        if (advanceAssignment == null) {
            DirectAdvanceAssignment newAdvanceAssignment = DirectAdvanceAssignment
                    .create(false, new BigDecimal(100));
            newAdvanceAssignment.setAdvanceType(advanceType);
            taskQualityForm.getOrderElement().addAdvanceAssignment(
                    newAdvanceAssignment);
            addAdvanceMeasurements(taskQualityForm, newAdvanceAssignment);
        }
    }
View Full Code Here


    @Override
    public void updateAdvancesIfNeeded() {
        if (orderElement != null) {
            for (TaskQualityForm taskQualityForm : getTaskQualityForms()) {
                if (taskQualityForm.isReportAdvance()) {
                    DirectAdvanceAssignment advanceAssignment = orderElement
                            .getAdvanceAssignmentByType(taskQualityForm
                                    .getQualityForm().getAdvanceType());
                    advanceAssignment.clearAdvanceMeasurements();
                    addAdvanceMeasurements(taskQualityForm, advanceAssignment);
                }
            }
        }
    }
View Full Code Here

            appendLabel(row, order.getCode());
            appendLabel(row, toString(order.getCustomerReference()));
            appendLabel(row, order.getName());

            DirectAdvanceAssignment directAdvanceAssignment = order
                    .getDirectAdvanceAssignmentOfTypeSubcontractor();

            // append the last advance measurement reported
            AdvanceMeasurement lastAdvanceMeasurementReported = reportAdvancesModel
                    .getLastAdvanceMeasurementReported(directAdvanceAssignment);
View Full Code Here

            lastEndDateCommunicationToCustomerReported.setCommunicationDate(new Date());
            endDateCommunicationToCustomerDTO = OrderElementConverter.toDTO(lastEndDateCommunicationToCustomerReported);
        }

        // create the progress
        DirectAdvanceAssignment directAdvanceAssignment = order
                .getDirectAdvanceAssignmentOfTypeSubcontractor();
        Set<AdvanceMeasurementDTO> advanceMeasurementDTOs = new HashSet<AdvanceMeasurementDTO>();

        if (directAdvanceAssignment != null) {
            for (AdvanceMeasurement advanceMeasurement : directAdvanceAssignment
                    .getAdvanceMeasurements()) {
                if (advanceMeasurement.getCommunicationDate() == null) {
                    AdvanceMeasurementDTO advanceMeasurementDTO = OrderElementConverter
                            .toDTO(advanceMeasurement);
                    advanceMeasurement.updateCommunicationDate(new Date());
View Full Code Here

        return xml.toString();
    }

    @Override
    public String getStatus(Order order) {
        DirectAdvanceAssignment directAdvanceAssignment = order
                .getDirectAdvanceAssignmentOfTypeSubcontractor();

        boolean advancesNotReported = isAnyAdvanceMeasurementNotReported(directAdvanceAssignment);
        boolean endDateNotReported = isAnyEndDateNotReported(order);
        if (advancesNotReported && endDateNotReported) {
View Full Code Here

        }
        return hoursGroups;
    }

    public BigDecimal getAdvancePercentage(AdvanceType advanceType, LocalDate date) {
        final DirectAdvanceAssignment directAdvanceAssignment = this.getAdvanceAssignmentByType(advanceType);
        if (directAdvanceAssignment != null) {
            return directAdvanceAssignment.getAdvancePercentage(date);
        }
        return null;
    }
View Full Code Here

                    if (date == null) {
                        return getAdvancePercentageChildren();
                    }
                    return getAdvancePercentageChildren(date);
                } else {
                    DirectAdvanceAssignment directAdvanceAssignment = calculateFakeDirectAdvanceAssignment(indirectAdvanceAssignment);
                    if (date == null) {
                        return directAdvanceAssignment.getAdvancePercentage();
                    }
                    return directAdvanceAssignment.getAdvancePercentage(date);
                }
            }
        }

        return BigDecimal.ZERO;
View Full Code Here

        }
    }

    private DirectAdvanceAssignment calculateFakeDirectAdvanceAssignmentChildren(
            IndirectAdvanceAssignment indirectAdvanceAssignment) {
        DirectAdvanceAssignment newDirectAdvanceAssignment = DirectAdvanceAssignment
                .create();
        newDirectAdvanceAssignment.setFake(true);
        newDirectAdvanceAssignment.setMaxValue(new BigDecimal(100));
        newDirectAdvanceAssignment.setAdvanceType(indirectAdvanceAssignment
                .getAdvanceType());
        newDirectAdvanceAssignment.setOrderElement(this);

        Set<DirectAdvanceAssignment> directAdvanceAssignments = new HashSet<DirectAdvanceAssignment>();
        for (OrderElement orderElement : children) {
            directAdvanceAssignments.addAll(orderElement
                    .getAllDirectAdvanceAssignmentsReportGlobal());
        }

        List<AdvanceMeasurement> advanceMeasurements = new ArrayList<AdvanceMeasurement>();
        for (DirectAdvanceAssignment directAdvanceAssignment : directAdvanceAssignments) {
            advanceMeasurements.addAll(directAdvanceAssignment
                    .getAdvanceMeasurements());
        }

        List<LocalDate> measurementDates = getMeasurementDates(advanceMeasurements);
        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);

        return newDirectAdvanceAssignment;
    }
View Full Code Here

        if (list.isEmpty()) {
            return null;
        }

        Iterator<DirectAdvanceAssignment> iterator = list.iterator();
        DirectAdvanceAssignment origAdvanceAssignment = iterator.next();
        DirectAdvanceAssignment directAdvanceAssignment = DirectAdvanceAssignment
                .create();
        directAdvanceAssignment.setFake(true);
        directAdvanceAssignment
                .setMaxValue(origAdvanceAssignment.getMaxValue());
        directAdvanceAssignment
                .setAdvanceType(origAdvanceAssignment.getAdvanceType());
        directAdvanceAssignment.setOrderElement(this);
        directAdvanceAssignment.setAdvanceMeasurements(origAdvanceAssignment
                .getAdvanceMeasurements());

        while (iterator.hasNext()) {
            DirectAdvanceAssignment tempAssignment = iterator.next();
            if (!directAdvanceAssignment.getAdvanceType().getPercentage()) {
                BigDecimal maxValue = tempAssignment.getMaxValue();
                maxValue = maxValue.add(directAdvanceAssignment.getMaxValue());
                directAdvanceAssignment.setMaxValue(maxValue);
            }

            SortedSet<AdvanceMeasurement> advanceMeasurements = new TreeSet<AdvanceMeasurement>(
                    new AdvanceMeasurementComparator());
            advanceMeasurements.addAll(mergeAdvanceMeasurements(
                    directAdvanceAssignment, new ArrayList<AdvanceMeasurement>(
                            directAdvanceAssignment.getAdvanceMeasurements()),
                    new ArrayList<AdvanceMeasurement>(tempAssignment
                            .getAdvanceMeasurements())));
            directAdvanceAssignment.setAdvanceMeasurements(advanceMeasurements);
        }

        return directAdvanceAssignment;
View Full Code Here

                    .createIndirectAdvanceFor(parent));
        }
    }

    public void removeIndirectAdvanceAssignment(AdvanceType advanceType) {
        DirectAdvanceAssignment tempAdavanceAssignmet = DirectAdvanceAssignment
                .create();
        tempAdavanceAssignmet.setAdvanceType(advanceType);

        try {
            checkChildrenNoOtherAssignmentWithSameAdvanceType(this,
                    tempAdavanceAssignmet);
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.