Package org.libreplan.business.advance.entities

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


            @Override
            public Void execute() {
                try {
                    OrderElement orderElement = orderElementDAO.findByCode(orderElementCode);
                    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


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

                assertThat(directAdvanceAssignmentSubcontractor.getAdvanceMeasurements().size(),
                        equalTo(values.size()));

                for (AdvanceMeasurement measure : directAdvanceAssignmentSubcontractor
                        .getAdvanceMeasurements()) {
                    assertTrue(values.containsKey(measure.getDate()));
                    assertTrue(values.containsValue(measure.getValue()));
                    assertThat(values.get(measure.getDate()), equalTo(measure.getValue()));
                }
View Full Code Here

                            throw new RuntimeException(e);
                        }
                    }
                });
        assertNotNull(orderElement);
        DirectAdvanceAssignment advanceAssignment = orderElement
                .getDirectAdvanceAssignmentSubcontractor();
        assertNotNull(advanceAssignment);
        assertThat(advanceAssignment.getAdvanceMeasurements().size(),
                equalTo(1));
    }
View Full Code Here

                            throw new RuntimeException(e);
                        }
                    }
                });
        assertNotNull(orderElement);
        DirectAdvanceAssignment advanceAssignment = orderElement
                .getDirectAdvanceAssignmentSubcontractor();
        assertNotNull(advanceAssignment);
        assertThat(advanceAssignment.getAdvanceMeasurements().size(),
                equalTo(1));

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                orderElementDAO.flush();
                sessionFactory.getCurrentSession().evict(orderElement);
                return null;
            }
        });

        AdvanceMeasurementDTO advanceMeasurementDTO2 = new AdvanceMeasurementDTO(
                DateConverter.toXMLGregorianCalendar(date.plusWeeks(1)),
                new BigDecimal(20));
        orderDTO.advanceMeasurements.add(advanceMeasurementDTO2);

        orderListDTO = createOrderListDTO(orderDTO);
        instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;

        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        final OrderElement orderElement2 = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            OrderElement element = orderElementDAO
                                    .findUniqueByCode(code);
                            for (AdvanceMeasurement measurement : element
                                    .getDirectAdvanceAssignmentSubcontractor()
                                    .getAdvanceMeasurements()) {
                                measurement.getDate();
                            }
                            return element;
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });
        assertNotNull(orderElement2);
        advanceAssignment = orderElement2
                .getDirectAdvanceAssignmentSubcontractor();
        assertNotNull(advanceAssignment);
        SortedSet<AdvanceMeasurement> advanceMeasurements = advanceAssignment
                .getAdvanceMeasurements();
        assertThat(advanceMeasurements.size(), equalTo(2));
        for (AdvanceMeasurement advanceMeasurement : advanceMeasurements) {
            assertThat(advanceMeasurement.getDate(), anyOf(equalTo(date),
                    equalTo(date.plusWeeks(1))));
View Full Code Here

    }

    private static void addAdvanceMeasurements(OrderElement orderElement,
            OrderElementDTO orderElementDTO) {
        if (!orderElementDTO.advanceMeasurements.isEmpty()) {
            DirectAdvanceAssignment directAdvanceAssignment = getDirectAdvanceAssignmentSubcontractor(orderElement);

            for (AdvanceMeasurementDTO advanceMeasurementDTO : orderElementDTO.advanceMeasurements) {
                AdvanceMeasurement advanceMeasurement = null;
                LocalDate date = null;
                if (advanceMeasurementDTO.date != null) {
                    date = new LocalDate(DateConverter
                            .toLocalDate(advanceMeasurementDTO.date));
                    advanceMeasurement = directAdvanceAssignment
                            .getAdvanceMeasurementAtExactDate(date);
                }

                if (advanceMeasurement == null) {
                    advanceMeasurement = AdvanceMeasurement.create(date,
                            advanceMeasurementDTO.value);
                    directAdvanceAssignment
                            .addAdvanceMeasurements(advanceMeasurement);
                } else {
                    advanceMeasurement.setValue(advanceMeasurementDTO.value);
                }
            }
View Full Code Here

            appendOperations(listItem, readOnlyAdvance);
        }
    }

    private void appendComboboxAdvanceType(final Listitem listItem) {
        final DirectAdvanceAssignment advance = (DirectAdvanceAssignment) listItem
                .getValue();
        final Combobox comboAdvanceTypes = new Combobox();
        final List<AdvanceType> listAdvanceType = manageOrderElementAdvancesModel
                .getPossibleAdvanceTypes(advance);

        for(AdvanceType advanceType : listAdvanceType){
            if (!advanceType.getUnitName().equals(
                    PredefinedAdvancedTypes.CHILDREN.getTypeName())
                    && !advanceType.isQualityForm()
                    && !advanceType.isReadOnly()) {
                Comboitem comboItem = new Comboitem();
                comboItem.setValue(advanceType);
                comboItem.setLabel(advanceType.getUnitName());
                comboItem.setParent(comboAdvanceTypes);

                if ((advance.getAdvanceType() != null)
                    && (advance.getAdvanceType().getId().equals(advanceType
                                .getId()))) {
                    comboAdvanceTypes.setSelectedItem(comboItem);
                }
            }
        }

        comboAdvanceTypes.addEventListener(Events.ON_SELECT,
                new EventListener() {
                    @Override
                    public void onEvent(Event event) {
                        setMaxValue(listItem, comboAdvanceTypes);
                        cleanFields(advance);
                        setPercentage();
                        reloadAdvances();
                    }
        });

        Util.bind(comboAdvanceTypes,
                    new Util.Getter<Comboitem>() {
                        @Override
                        public Comboitem get(){
                                return comboAdvanceTypes.getSelectedItem();
                        }
                    }, new Util.Setter<Comboitem>() {
                @Override
            public void set(Comboitem comboItem) {
                            if(((comboItem!=null))&&(comboItem.getValue() != null)&&
                                    (comboItem.getValue() instanceof AdvanceType)){
                                AdvanceType advanceType = (AdvanceType)comboItem.getValue();
                                advance.setAdvanceType(advanceType);
                    advance.setMaxValue(manageOrderElementAdvancesModel
                            .getMaxValue(advanceType));
                            }
                        }

                    });
View Full Code Here

        }
    }

    private static DirectAdvanceAssignment getDirectAdvanceAssignmentSubcontractor(
            OrderElement orderElement) {
        DirectAdvanceAssignment directAdvanceAssignment = orderElement
                .getDirectAdvanceAssignmentSubcontractor();
        if (directAdvanceAssignment == null) {
            try {
                directAdvanceAssignment = orderElement
                        .addSubcontractorAdvanceAssignment();
View Full Code Here

        final AdvanceAssignment advanceAssignment = (AdvanceAssignment) listItem
                .getValue();
        final Decimalbox maxValue = new Decimalbox();
        maxValue.setScale(2);

        final DirectAdvanceAssignment directAdvanceAssignment;
        if ((advanceAssignment instanceof IndirectAdvanceAssignment)
                || isQualityFormOrReadOnly
                || (advanceAssignment.getAdvanceType() != null && advanceAssignment
                        .getAdvanceType().getPercentage())
                || manageOrderElementAdvancesModel
                        .hasConsolidatedAdvances(advanceAssignment)) {
            maxValue.setDisabled(true);
        }
        if (advanceAssignment instanceof IndirectAdvanceAssignment) {
            directAdvanceAssignment = manageOrderElementAdvancesModel
                    .calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) advanceAssignment);
        } else {
            directAdvanceAssignment = (DirectAdvanceAssignment) advanceAssignment;
        }

        Util.bind(maxValue, new Util.Getter<BigDecimal>() {
            @Override
            public BigDecimal get() {
                return directAdvanceAssignment.getMaxValue();
            }
        }, new Util.Setter<BigDecimal>() {

            @Override
            public void set(BigDecimal value) {
                if (!manageOrderElementAdvancesModel
                        .hasConsolidatedAdvances(advanceAssignment)) {
                    directAdvanceAssignment.setMaxValue(value);
                }
            }
        });
        maxValue.addEventListener(Events.ON_CHANGE,
                new EventListener() {
View Full Code Here

                .getValue();
        Decimalbox value = new Decimalbox();
        value.setScale(2);
        value.setDisabled(true);

        DirectAdvanceAssignment directAdvanceAssignment;
        if (advanceAssignment instanceof IndirectAdvanceAssignment) {
            directAdvanceAssignment = manageOrderElementAdvancesModel
                    .calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) advanceAssignment);
        } else {
            directAdvanceAssignment = (DirectAdvanceAssignment) advanceAssignment;
View Full Code Here

    private void appendLabelPercentage(final Listitem listItem){
        final AdvanceAssignment advanceAssignment = (AdvanceAssignment) listItem
                .getValue();
        Label percentage = new Label();

        DirectAdvanceAssignment directAdvanceAssignment;
        if (advanceAssignment instanceof IndirectAdvanceAssignment) {
            directAdvanceAssignment = manageOrderElementAdvancesModel
                    .calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) advanceAssignment);
        } else {
            directAdvanceAssignment = (DirectAdvanceAssignment) advanceAssignment;
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.