Package org.libreplan.business.expensesheet.entities

Examples of org.libreplan.business.expensesheet.entities.ExpenseSheetLine


        // order element empty
        OrderElement orderElement = null;

        // a expense sheet with valid value,date but without order element.
        ExpenseSheetLine line1 = ExpenseSheetLine.create(BigDecimal.ZERO, "concept",
                new LocalDate(), orderElement);

        line1.setExpenseSheet(expense);
        expense.add(line1);

        expenseSheetDAO.save(expense);
        expenseSheetDAO.flush();
        fail("it must throw a exception. The order element not specified");
View Full Code Here


        // order element empty
        OrderElement orderElement = this.givenOrderElement("order-element-2");

        // a expense sheet with valid date and order element, but invalid value.
        ExpenseSheetLine line1 = ExpenseSheetLine.create(null, "concept", new LocalDate(),
                orderElement);

        // add the line to the expense sheet
        line1.setExpenseSheet(expense);
        expense.add(line1);

        try {
            expenseSheetDAO.save(expense);
            fail("it must throw a exception. The value is not specified in the expense sheet line.");
        } catch (ValidationException e) {
        }

        line1.setValue(new BigDecimal(-3));

        try {
            expenseSheetDAO.save(expense);
            fail("it must throw a exception. The total is invalid because it is less than 0.");
        } catch (ValidationException e) {
        }

        ExpenseSheetLine line2 = ExpenseSheetLine.create(BigDecimal.TEN, "concept",
                new LocalDate(), orderElement);

        // add other line to the expense sheet
        line2.setExpenseSheet(expense);
        expense.add(line2);

        try {
            expenseSheetDAO.save(expense);
            fail("it must throw a exception. The value of the line 1 is invalid because it is less than 0.");
View Full Code Here

        // order element empty
        OrderElement orderElement = this.givenOrderElement("order-element-2");

        // a expense sheet with valid date and order element, but invalid value.
        ExpenseSheetLine line1 = ExpenseSheetLine.create(BigDecimal.ONE, "concept", null,
                orderElement);

        // add the line to the expense sheet
        line1.setExpenseSheet(expense);
        expense.add(line1);

        try {
            expenseSheetDAO.save(expense);
            fail("it must throw a exception. The date is not specified in the expense sheet line.");
        } catch (ValidationException e) {
        }

        LocalDate today = new LocalDate();
        line1.setDate(today);

        assertThat(expense.getFirstExpense(), equalTo(today));
        assertThat(expense.getLastExpense(), equalTo(today));

        // add other line with other date
        LocalDate tomorrow = new LocalDate().plusDays(1);
        ExpenseSheetLine line2 = ExpenseSheetLine.create(BigDecimal.ONE, "concept", tomorrow,
                orderElement);
        line2.setExpenseSheet(expense);
        expense.add(line2);

        assertThat(expense.getFirstExpense(), equalTo(today));
        assertThat(expense.getLastExpense(), equalTo(tomorrow));
View Full Code Here

        // check out the resource
        Worker worker = givenSavedValidWorker();

        // add line 1 with a resource
        LocalDate today = new LocalDate();
        ExpenseSheetLine line1 = ExpenseSheetLine.create(BigDecimal.ONE, "concept 1", today,
                orderElement);
        line1.setResource(worker);
        line1.setExpenseSheet(expense);
        expense.add(line1);

        // add line 2 without resource
        LocalDate tomorrow = new LocalDate().plusDays(1);
        ExpenseSheetLine line2 = ExpenseSheetLine.create(BigDecimal.ONE, "concept 2", tomorrow,
                orderElement);
        line2.setExpenseSheet(expense);
        expense.add(line2);

        try {
            expenseSheetDAO.save(expense);
            expenseSheetDAO.flush();

        } catch (ValidationException e) {
            fail("it must not throw a exception");
        }

        assertThat(expenseSheetDAO.getAll().size(), equalTo(previousExpenses + 1));

        // check out the expense sheet
        ExpenseSheet expenseSheet = expenseSheetDAO.getAll().get(previousExpenses);
        assertNotNull(expenseSheet.getCode());
        assertThat(expenseSheet.getCode(), equalTo("code-expense-sheet-1"));
        assertThat(expenseSheet.getTotal(), equalTo(new BigDecimal(2)));
        assertThat(expenseSheet.getFirstExpense(), equalTo(today));
        assertThat(expenseSheet.getLastExpense(), equalTo(tomorrow));
        assertThat(expenseSheet.getExpenseSheetLines().size(), equalTo(2));

        // check out the expense sheet lines
        ExpenseSheetLine savedLine1 = expenseSheet.getExpenseSheetLines().last();
        ExpenseSheetLine savedLine2 = expenseSheet.getExpenseSheetLines().first();

        assertThat(savedLine1.getConcept(), equalTo("concept 1"));
        assertThat(savedLine1.getDate(), equalTo(today));
        assertThat(savedLine1.getValue(), equalTo(BigDecimal.ONE));
        assertNotNull(savedLine1.getOrderElement());
        assertNotNull(savedLine1.getResource());
        assertNotNull(savedLine1.getCode());

        assertThat(savedLine2.getConcept(), equalTo("concept 2"));
        assertThat(savedLine2.getDate(), equalTo(tomorrow));
        assertThat(savedLine2.getValue(), equalTo(BigDecimal.ONE));
        assertNotNull(savedLine2.getOrderElement());
        assertNotNull(savedLine2.getCode());

    }
View Full Code Here

        ExpenseSheet expense = ExpenseSheet.create();
        expense.setCode(code);

        // add line 1
        LocalDate today = new LocalDate();
        ExpenseSheetLine line1 = ExpenseSheetLine.create(BigDecimal.ONE, "concept 1", today,
                orderElement);
        line1.setExpenseSheet(expense);
        expense.add(line1);
        return expense;
    }
View Full Code Here

        // check out the resource
        Worker worker = givenSavedValidWorker();

        // add line 1 with a resource
        LocalDate today = new LocalDate();
        ExpenseSheetLine line1 = ExpenseSheetLine.create(BigDecimal.ONE, "concept 1", today,
                orderElement);
        line1.setResource(worker);
        line1.setExpenseSheet(expense);
        expense.add(line1);

        // add line 2 without resource
        LocalDate tomorrow = new LocalDate().plusDays(1);
        ExpenseSheetLine line2 = ExpenseSheetLine.create(BigDecimal.ONE, "concept 2", tomorrow,
                orderElement);
        line2.setCode("code-line-2");
        line2.setExpenseSheet(expense);
        expense.add(line2);

        try {
            expenseSheetDAO.save(expense);
            expenseSheetDAO.flush();
View Full Code Here

        return expenseSheet;
    }

    private ExpenseSheetLine createExpenseSheetLine(BigDecimal value, String concept,
            int indiceOrder) {
        ExpenseSheetLine expenseSheetLine = ExpenseSheetLine.create(value, concept,
                new LocalDate(), orderElements.get(indiceOrder));
        expenseSheetLine.setCode("default-expense-sheet-line-" + UUID.randomUUID());
        expenseSheetLine.setResource(resource);
        expenseSheetLine.setExpenseSheet(expenseSheet);
        expenseSheet.add(expenseSheetLine);
        return expenseSheetLine;
    }
View Full Code Here

        listES.add(createEmptyExpenseSheetDTO(order));
        return listES;
    }

    private CostExpenseSheetDTO createEmptyExpenseSheetDTO(OrderElement orderElement) {
        ExpenseSheetLine emptyBean = ExpenseSheetLine.create(BigDecimal.ZERO, "Expense concept",
                new LocalDate(), orderElement);
        CostExpenseSheetDTO emptyDTO = new CostExpenseSheetDTO(emptyBean);
        return emptyDTO;
    }
View Full Code Here

    }

    @Override
    public void addExpenseSheetLine() {
        if (expenseSheet != null) {
            ExpenseSheetLine line = this.getNewExpenseSheetLine();
            line.setExpenseSheet(expenseSheet);
            if (expenseSheet.isPersonal()) {
                line.setResource(resource);
            }
            expenseSheet.add(line);
        }
        this.createNewExpenseSheetLine();
    }
View Full Code Here

     */
    public class ExpenseSheetLineRenderer implements RowRenderer {

        @Override
        public void render(Row row, Object data) {
            ExpenseSheetLine expenseSheetLine = (ExpenseSheetLine) data;
            row.setValue(expenseSheetLine);

            appendOrderElementInLines(row);
            appendValueInLines(row);
            appendConceptInLines(row);
View Full Code Here

TOP

Related Classes of org.libreplan.business.expensesheet.entities.ExpenseSheetLine

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.