OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 180
Line 20... Line 20...
20
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
20
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
21
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
21
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
22
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
22
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
23
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
23
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
24
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
24
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
-
 
25
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
-
 
26
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProvider;
-
 
27
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProviderManager;
25
import org.openconcerto.erp.model.PrixTTC;
28
import org.openconcerto.erp.model.PrixTTC;
26
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
29
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
27
import org.openconcerto.sql.Configuration;
30
import org.openconcerto.sql.Configuration;
28
import org.openconcerto.sql.element.SQLElement;
31
import org.openconcerto.sql.element.SQLElement;
29
import org.openconcerto.sql.model.SQLRow;
32
import org.openconcerto.sql.model.SQLRow;
Line 50... Line 53...
50
    private static final SQLTable tableEncaisseElt = base.getTable("ENCAISSER_MONTANT_ELEMENT");
53
    private static final SQLTable tableEncaisseElt = base.getTable("ENCAISSER_MONTANT_ELEMENT");
51
    private static final SQLTable tableSaisieVenteFacture = base.getTable("SAISIE_VENTE_FACTURE");
54
    private static final SQLTable tableSaisieVenteFacture = base.getTable("SAISIE_VENTE_FACTURE");
52
    private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
55
    private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
53
    private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
56
    private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
54
 
57
 
-
 
58
    public static final String ID = "accounting.records.invoice.sales.payment";
-
 
59
 
55
    public SQLRow ecrClient = null;
60
    public SQLRow ecrClient = null;
56
 
61
 
57
    public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource) throws SQLException {
62
    public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource) throws SQLException {
58
        this(label, rowClient, ttc, d, modeReglement, source, mvtSource, true);
63
        this(label, rowClient, ttc, d, modeReglement, source, mvtSource, true);
59
    }
64
    }
Line 79... Line 84...
79
        }
84
        }
80
 
85
 
81
        // TODO Nommage des ecritures
86
        // TODO Nommage des ecritures
82
 
87
 
83
        this.nom = label;
88
        this.nom = label;
-
 
89
        AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(ID);
-
 
90
        if (provider != null) {
-
 
91
            provider.putLabel(source, this.mEcritures);
-
 
92
        }
84
 
93
 
85
        this.putValue("DATE", this.date);
94
        this.putValue("DATE", this.date);
86
        this.putValue("NOM", this.nom);
95
        this.putValue("NOM", this.nom);
87
        fillJournalBanqueFromRow(modeReglement);
96
        fillJournalBanqueFromRow(modeReglement);
88
 
97
 
Line 234... Line 243...
234
 
243
 
235
                this.putValue("DEBIT", Long.valueOf(ttc.getLongValue()));
244
                this.putValue("DEBIT", Long.valueOf(ttc.getLongValue()));
236
                this.putValue("CREDIT", Long.valueOf(0));
245
                this.putValue("CREDIT", Long.valueOf(0));
237
                ajoutEcriture();
246
                ajoutEcriture();
238
 
247
 
-
 
248
                // FIXME remove getConf
-
 
249
                SQLRow rowSoc = ComptaPropsConfiguration.getInstanceCompta().getRowSociete();
-
 
250
                if (rowSoc.getTable().contains("TVA_ENCAISSEMENT") && rowSoc.getBoolean("TVA_ENCAISSEMENT")) {
-
 
251
                    SQLRow rowTaxe = TaxeCache.getCache().getFirstTaxe();
-
 
252
                    if (rowTaxe.contains("ID_COMPTE_PCE_COLLECTE_ENCAISSEMENT")) {
-
 
253
                        SQLRowAccessor rowCompteTvaEnc = rowTaxe.getNonEmptyForeign("ID_COMPTE_PCE_COLLECTE_ENCAISSEMENT");
-
 
254
                        SQLRowAccessor rowCompteTvaCol = rowTaxe.getNonEmptyForeign("ID_COMPTE_PCE_COLLECTE");
-
 
255
                        if (rowCompteTvaCol != null && rowCompteTvaEnc != null) {
-
 
256
                            Float taux = rowTaxe.getFloat("TAUX");
-
 
257
 
-
 
258
                            long tva = ttc.calculLongTVA(taux / 100.0);
-
 
259
                            this.putValue("ID_COMPTE_PCE", rowCompteTvaCol.getID());
-
 
260
                            this.putValue("DEBIT", Long.valueOf(tva));
-
 
261
                            this.putValue("CREDIT", Long.valueOf(0));
-
 
262
                            ajoutEcriture();
-
 
263
 
-
 
264
                            this.putValue("ID_COMPTE_PCE", rowCompteTvaEnc.getID());
-
 
265
                            this.putValue("DEBIT", Long.valueOf(0));
-
 
266
                            this.putValue("CREDIT", Long.valueOf(tva));
-
 
267
                            ajoutEcriture();
-
 
268
 
-
 
269
                        }
-
 
270
                    }
-
 
271
                }
-
 
272
 
239
                List<Integer> pieceIDs = new ArrayList<Integer>();
273
                List<Integer> pieceIDs = new ArrayList<Integer>();
240
                if (source.getTable().getName().equals("ENCAISSER_MONTANT")) {
274
                if (source.getTable().getName().equals("ENCAISSER_MONTANT")) {
241
                    List<SQLRow> l = source.getReferentRows(base.getTable("ENCAISSER_MONTANT_ELEMENT"));
275
                    List<SQLRow> l = source.getReferentRows(base.getTable("ENCAISSER_MONTANT_ELEMENT"));
242
                    for (SQLRow sqlRow : l) {
276
                    for (SQLRow sqlRow : l) {
243
                        pieceIDs.add(sqlRow.getForeign("ID_MOUVEMENT_ECHEANCE").getForeignID("ID_PIECE"));
277
                        pieceIDs.add(sqlRow.getForeign("ID_MOUVEMENT_ECHEANCE").getForeignID("ID_PIECE"));
Line 297... Line 331...
297
                // ajout de l'ecriture
331
                // ajout de l'ecriture
298
                SQLRow row = valEcheance.insert();
332
                SQLRow row = valEcheance.insert();
299
                SQLRowValues rowVals = new SQLRowValues(tableMouvement);
333
                SQLRowValues rowVals = new SQLRowValues(tableMouvement);
300
                rowVals.put("IDSOURCE", row.getID());
334
                rowVals.put("IDSOURCE", row.getID());
301
                rowVals.update(this.idMvt);
335
                rowVals.update(this.idMvt);
-
 
336
                if (source.getTable().getName().equalsIgnoreCase("ENCAISSER_MONTANT")) {
-
 
337
 
-
 
338
                    source.createEmptyUpdateRow().put("ID_MOUVEMENT", this.idMvt).commit();
-
 
339
                }
302
 
340
 
303
        }
341
        }
304
    }
342
    }
305
 
343
 
306
    private void setDateReglement(SQLRow source, Date d) throws SQLException {
344
    private void setDateReglement(SQLRow source, Date d) throws SQLException {
Line 458... Line 496...
458
 
496
 
459
            ajoutEcriture();
497
            ajoutEcriture();
460
        }
498
        }
461
 
499
 
462
    }
500
    }
-
 
501
 
463
}
502
}