OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
80 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.supplychain.order.element;
15
 
94 ilm 16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
151 ilm 17
import org.openconcerto.erp.core.edm.AttachmentAction;
94 ilm 18
import org.openconcerto.erp.core.supplychain.order.component.FactureFournisseurSQLComponent;
19
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet;
20
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
21
import org.openconcerto.sql.element.SQLComponent;
174 ilm 22
import org.openconcerto.sql.model.SQLRowAccessor;
23
import org.openconcerto.sql.view.EditFrame;
24
import org.openconcerto.sql.view.EditPanel;
25
import org.openconcerto.sql.view.list.IListe;
151 ilm 26
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
174 ilm 27
import org.openconcerto.sql.view.list.RowAction;
151 ilm 28
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
142 ilm 29
import org.openconcerto.utils.ListMap;
94 ilm 30
 
174 ilm 31
import java.awt.event.ActionEvent;
151 ilm 32
import java.util.ArrayList;
156 ilm 33
import java.util.HashSet;
151 ilm 34
import java.util.List;
156 ilm 35
import java.util.Set;
151 ilm 36
 
174 ilm 37
import javax.swing.AbstractAction;
38
 
80 ilm 39
public class FactureFournisseurSQLElement extends ComptaSQLConfElement {
40
 
41
    public FactureFournisseurSQLElement() {
42
        super("FACTURE_FOURNISSEUR", "une facture fournisseur", "factures fournisseur");
94 ilm 43
        MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(FactureFournisseurXmlSheet.class);
44
        mouseSheetXmlListeListener.setGenerateHeader(true);
45
        mouseSheetXmlListeListener.setShowHeader(true);
46
        getRowActions().addAll(mouseSheetXmlListeListener.getRowActions());
151 ilm 47
        if (getTable().contains("ATTACHMENTS")) {
48
            PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
49
            actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
50
            getRowActions().add(actionAttachment);
51
        }
174 ilm 52
        RowAction actionClone = new RowAction(new AbstractAction() {
53
            public void actionPerformed(ActionEvent e) {
54
 
55
                EditFrame editFrame = new EditFrame(FactureFournisseurSQLElement.this, EditPanel.CREATION);
56
 
57
                ((FactureFournisseurSQLComponent) editFrame.getSQLComponent()).loadFactureExistante(IListe.get(e).getSelectedId());
58
                editFrame.setVisible(true);
59
            }
60
        }, true, "supplychain.invoice.clone") {
61
            public boolean enabledFor(IListeEvent evt) {
62
                List<? extends SQLRowAccessor> l = evt.getSelectedRows();
63
                return (l != null && l.size() == 1);
64
            }
65
        };
66
        getRowActions().add(actionClone);
80 ilm 67
    }
68
 
156 ilm 69
    @Override
70
    public Set<String> getReadOnlyFields() {
71
        Set<String> s = new HashSet<>();
72
        s.add("NET_A_PAYER");
73
        return s;
74
    }
75
 
80 ilm 76
    protected List<String> getListFields() {
77
        final List<String> l = new ArrayList<String>();
78
        l.add("NUMERO");
79
        l.add("NOM");
80
        l.add("DATE");
81
        l.add("ID_FOURNISSEUR");
82
        l.add("T_HT");
83
        l.add("T_TTC");
84
        l.add("INFOS");
85
        return l;
86
    }
87
 
142 ilm 88
    @Override
89
    public ListMap<String, String> getShowAs() {
90
        ListMap<String, String> map = new ListMap<String, String>();
91
        map.putCollection(null, "NUMERO", "DATE");
92
        return map;
93
    }
94
 
80 ilm 95
    protected List<String> getComboFields() {
96
        final List<String> l = new ArrayList<String>();
97
        l.add("NUMERO");
98
        l.add("NOM");
99
        l.add("DATE");
100
        return l;
101
    }
102
 
103
    /*
104
     * (non-Javadoc)
105
     *
106
     * @see org.openconcerto.devis.SQLElement#getComponent()
107
     */
108
    public SQLComponent createComponent() {
109
        return new FactureFournisseurSQLComponent();
110
    }
111
 
112
    @Override
113
    protected String createCode() {
156 ilm 114
        return createCodeOfPackage() + ".invoice.purchase";
80 ilm 115
    }
116
}