OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 106 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 106 Rev 181
1
package org.openconcerto.modules.humanresources.travel.expense;
1
package org.openconcerto.modules.humanresources.travel.expense;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Collections;
4
import java.util.Collections;
5
import java.util.List;
5
import java.util.List;
6
import java.util.Set;
6
import java.util.Set;
7
 
7
 
8
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
8
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
9
import org.openconcerto.sql.element.GlobalMapper;
9
import org.openconcerto.sql.element.GlobalMapper;
10
import org.openconcerto.sql.element.SQLComponent;
10
import org.openconcerto.sql.element.SQLComponent;
11
import org.openconcerto.ui.group.Group;
11
import org.openconcerto.ui.group.Group;
12
import org.openconcerto.utils.ListMap;
12
import org.openconcerto.utils.ListMap;
13
 
13
 
14
public class ExpenseSQLElement extends ComptaSQLConfElement {
14
public class ExpenseSQLElement extends ComptaSQLConfElement {
15
    public static final String ELEMENT_CODE = "humanresources.travel.expense";
15
    public static final String ELEMENT_CODE = "humanresources.travel.expense";
16
 
16
 
17
    public ExpenseSQLElement() {
17
    public ExpenseSQLElement() {
18
        super(Module.TABLE_EXPENSE, "une note de frais", "notes de frais");
18
        super(Module.TABLE_EXPENSE, "une note de frais", "notes de frais");
19
    }
19
    }
20
 
20
 
21
    @Override
21
    @Override
22
    protected String createCode() {
22
    protected String createCode() {
23
        return ELEMENT_CODE;
23
        return ELEMENT_CODE;
24
    }
24
    }
25
 
25
 
26
    @Override
26
    @Override
27
    protected List<String> getListFields() {
27
    protected List<String> getListFields() {
28
        final List<String> l = new ArrayList<String>();
28
        final List<String> l = new ArrayList<String>();
29
        l.add("DATE");
29
        l.add("DATE");
30
        l.add("ID_USER_COMMON");
30
        l.add("ID_USER_COMMON");
31
        l.add("DESCRIPTION");
31
        l.add("DESCRIPTION");
32
        l.add("TRAVEL_AMOUNT");
32
        l.add("TRAVEL_AMOUNT");
33
        l.add("MISC_AMOUNT");
33
        l.add("MISC_AMOUNT");
34
        l.add("ID_EXPENSE_STATE");
34
        l.add("ID_EXPENSE_STATE");
35
        return l;
35
        return l;
36
    }
36
    }
37
 
37
 
38
    @Override
38
    @Override
39
    public Set<String> getReadOnlyFields() {
39
    public Set<String> getReadOnlyFields() {
40
        return Collections.singleton("TRAVEL_AMOUNT");
40
        return Collections.singleton("TRAVEL_AMOUNT");
41
    }
41
    }
42
 
42
 
43
    @Override
43
    @Override
44
    protected List<String> getComboFields() {
44
    protected List<String> getComboFields() {
45
        final List<String> l = new ArrayList<String>();
45
        final List<String> l = new ArrayList<String>();
46
        l.add("DATE");
46
        l.add("DATE");
47
        l.add("DESCRIPTION");
47
        l.add("DESCRIPTION");
48
        return l;
48
        return l;
49
    }
49
    }
50
 
50
 
51
    @Override
51
    @Override
52
    public ListMap<String, String> getShowAs() {
52
    public ListMap<String, String> getShowAs() {
53
        return ListMap.singleton(null, getComboFields());
53
        return ListMap.singleton(null, getComboFields());
54
    }
54
    }
55
 
55
 
56
    @Override
56
    @Override
57
    public SQLComponent createComponent() {
57
	public SQLComponent createComponent() {
58
        final String groupId = this.getCode() + ".default";
58
        final String groupId = this.getCode() + ".default";
59
        final Group group = GlobalMapper.getInstance().getGroup(groupId);
59
        final Group group = GlobalMapper.getInstance().getGroup(groupId);
60
        if (group == null) {
60
        if (group == null) {
61
            throw new IllegalStateException("No group found for id " + groupId);
61
            throw new IllegalStateException("No group found for id " + groupId);
62
        }
62
        }
63
        return new ExpenseSQLComponent(this, group);
63
        return new ExpenseSQLComponent(this, group);
64
    }
64
    }
65
 
65
 
66
}
66
}