OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
174 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.customerrelationship.customer.report;
15
 
16
import java.math.BigDecimal;
17
import java.util.Collection;
18
import java.util.Date;
19
import java.util.HashMap;
20
import java.util.Map;
21
 
22
public class ReportingCommercial {
23
 
24
    private String commercial;
25
    private Date debut;
26
    private Date fin;
27
    private Map<String, ReportingCommercialItem> items = new HashMap<>();
28
 
29
    public ReportingCommercial(String commercial, Date debut, Date fin) {
30
        this.commercial = commercial;
31
        this.debut = debut;
32
        this.fin = fin;
33
    }
34
 
35
    public BigDecimal getTotal() {
36
        BigDecimal total = BigDecimal.ZERO;
37
        for (ReportingCommercialItem item : this.items.values()) {
38
            total = total.add(item.getCa());
39
        }
40
        return total;
41
    }
42
 
43
    public void add(ReportingCommercialItem item) {
44
        this.items.put(item.getClient(), item);
45
    }
46
 
47
    public void add(String client, BigDecimal ht) {
48
        if (this.items.containsKey(client)) {
49
            this.items.get(client).addCA(ht);
50
        } else {
51
            ReportingCommercialItem reportingCommercialItem = new ReportingCommercialItem(client);
52
            reportingCommercialItem.addCA(ht);
53
            this.items.put(client, reportingCommercialItem);
54
        }
55
    }
56
 
57
    public Collection<ReportingCommercialItem> getItems() {
58
        return this.items.values();
59
    }
60
 
61
    public String getCommercial() {
62
        return this.commercial;
63
    }
64
 
65
    public Date getDebut() {
66
        return this.debut;
67
    }
68
 
69
    public Date getFin() {
70
        return this.fin;
71
    }
72
 
73
}