OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 151 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 151 Rev 174
Line 177... Line 177...
177
        final SQLRowValuesListFetcher fetcher = new SQLRowValuesListFetcher(vals);
177
        final SQLRowValuesListFetcher fetcher = new SQLRowValuesListFetcher(vals);
178
        fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
178
        fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
179
            @Override
179
            @Override
180
            public SQLSelect transformChecked(SQLSelect sel) {
180
            public SQLSelect transformChecked(SQLSelect sel) {
181
 
181
 
182
                Where w = (new Where(tableEcriture.getField("DATE"), GrandLivreSheetXML.this.dateDu, GrandLivreSheetXML.this.dateAu));
-
 
183
 
-
 
184
                if (GrandLivreSheetXML.this.compteDeb.equals(GrandLivreSheetXML.this.compteEnd)) {
-
 
185
                    w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "=", GrandLivreSheetXML.this.compteDeb));
-
 
186
                } else {
-
 
187
                    w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), (Object) GrandLivreSheetXML.this.compteDeb, (Object) GrandLivreSheetXML.this.compteEnd));
-
 
188
                }
-
 
189
                w = w.and(new Where(tableEcriture.getField("ID_JOURNAL"), "!=", idJrnlExclude));
-
 
190
                w = w.and(new Where(tableEcriture.getField("ID_MOUVEMENT"), "=", tableMvt.getField("ID")));
-
 
191
 
-
 
192
                if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODELETTREE) {
-
 
193
                    Object o = null;
-
 
194
                    w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "<>", o));
-
 
195
                    w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "!=", ""));
-
 
196
                    w = w.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), "<=", GrandLivreSheetXML.this.dateAu));
-
 
197
                } else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_PERIODE) {
-
 
198
                    Object o = null;
-
 
199
                    Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
-
 
200
                    Where wSTTC = new Where(tableEcriture.getField("DATE_LETTRAGE"), "<>", o);
-
 
201
                    wSTTC = wSTTC.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), ">", GrandLivreSheetXML.this.dateAu));
-
 
202
 
-
 
203
                    w2 = w2.or(wSTTC);
-
 
204
                    w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
-
 
205
                } else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_ALL) {
-
 
206
                    Object o = null;
-
 
207
                    Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
-
 
208
                    w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
-
 
209
                }
-
 
210
 
-
 
211
                if (GrandLivreSheetXML.this.excludeCompteSolde) {
182
                Where w = getWhere(lCompteSolde);
212
                    System.err.println("Exclude compte");
-
 
213
 
-
 
214
                    w = w.and(new Where(tableEcriture.getField("ID_COMPTE_PCE"), lCompteSolde).not());
-
 
215
                }
-
 
216
                w = w.and(new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%"));
-
 
217
 
-
 
218
                if (!UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
-
 
219
                    // TODO Show Restricted acces in UI
-
 
220
                    w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "LIKE", "411%"));
-
 
221
                }
-
 
222
 
183
 
223
                sel.setWhere(w);
184
                sel.setWhere(w);
224
                sel.addFieldOrder(tableEcriture.getField("COMPTE_NUMERO"));
185
                sel.addFieldOrder(tableEcriture.getField("COMPTE_NUMERO"));
225
                sel.addFieldOrder(tableEcriture.getField("DATE"));
186
                sel.addFieldOrder(tableEcriture.getField("DATE"));
226
                sel.addFieldOrder(tableMvt.getField("NUMERO"));
187
                sel.addFieldOrder(tableMvt.getField("NUMERO"));
Line 565... Line 526...
565
 
526
 
566
        sel.addSelect(tableCompte.getField("ID"));
527
        sel.addSelect(tableCompte.getField("ID"));
567
        sel.addSelect(tableEcriture.getField("DEBIT"), "SUM");
528
        sel.addSelect(tableEcriture.getField("DEBIT"), "SUM");
568
        sel.addSelect(tableEcriture.getField("CREDIT"), "SUM");
529
        sel.addSelect(tableEcriture.getField("CREDIT"), "SUM");
569
 
530
 
570
        Where w;
-
 
571
        if (this.compteDeb.equals(this.compteEnd)) {
-
 
572
            w = new Where(tableCompte.getField("NUMERO"), "=", this.compteDeb);
-
 
573
        } else {
-
 
574
            w = new Where(tableCompte.getField("NUMERO"), (Object) this.compteDeb, (Object) this.compteEnd);
-
 
575
        }
-
 
576
 
-
 
577
        w = w.and(new Where(tableEcriture.getField("ID_COMPTE_PCE"), "=", tableCompte.getField("ID")));
-
 
578
 
-
 
579
        if (this.cumul) {
-
 
580
            w = w.and(new Where(tableEcriture.getField("DATE"), "<=", this.dateAu));
-
 
581
        } else {
-
 
582
            w = w.and(new Where(tableEcriture.getField("DATE"), this.dateDu, this.dateAu));
-
 
583
        }
-
 
584
        w = w.and(new Where(tableEcriture.getField("ID_JOURNAL"), "!=", idJrnlExclude));
-
 
585
        if (this.lettrage == GrandLivreSheet.MODELETTREE) {
-
 
586
            Object o = null;
531
        Where w = getWhere(null);
587
            w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "<>", o));
-
 
588
            w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "!=", ""));
-
 
589
        } else if (this.lettrage == GrandLivreSheet.MODENONLETTREE_ALL) {
-
 
590
            Object o = null;
-
 
591
            Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
-
 
592
            w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
-
 
593
 
-
 
594
        } else if (this.lettrage == GrandLivreSheet.MODENONLETTREE_PERIODE) {
-
 
595
            Object o = null;
-
 
596
            Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
-
 
597
            w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
-
 
598
        }
-
 
599
 
532
 
600
        sel.setWhere(w);
533
        sel.setWhere(w);
601
 
534
 
602
        String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\"";
535
        String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\"";
603
        System.err.println(req);
536
        System.err.println(req);
Line 621... Line 554...
621
            }
554
            }
622
        }
555
        }
623
        return list;
556
        return list;
624
    }
557
    }
625
 
558
 
-
 
559
    private Where getWhere(final List<Integer> lCompteSolde) {
-
 
560
        Where w = (new Where(tableEcriture.getField("DATE"), GrandLivreSheetXML.this.dateDu, GrandLivreSheetXML.this.dateAu));
-
 
561
 
-
 
562
        if (GrandLivreSheetXML.this.compteDeb.equals(GrandLivreSheetXML.this.compteEnd)) {
-
 
563
            w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "=", GrandLivreSheetXML.this.compteDeb));
-
 
564
        } else {
-
 
565
            w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), (Object) GrandLivreSheetXML.this.compteDeb, (Object) GrandLivreSheetXML.this.compteEnd));
-
 
566
        }
-
 
567
        w = w.and(new Where(tableEcriture.getField("ID_JOURNAL"), "!=", idJrnlExclude));
-
 
568
        w = w.and(new Where(tableEcriture.getField("ID_MOUVEMENT"), "=", tableMvt.getField("ID")));
-
 
569
 
-
 
570
        if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODELETTREE) {
-
 
571
            Object o = null;
-
 
572
            w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "<>", o));
-
 
573
            w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "!=", ""));
-
 
574
            w = w.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), "<=", GrandLivreSheetXML.this.dateAu));
-
 
575
        } else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_PERIODE) {
-
 
576
            Object o = null;
-
 
577
            Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
-
 
578
            Where wSTTC = new Where(tableEcriture.getField("DATE_LETTRAGE"), "<>", o);
-
 
579
            wSTTC = wSTTC.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), ">", GrandLivreSheetXML.this.dateAu));
-
 
580
 
-
 
581
            w2 = w2.or(wSTTC);
-
 
582
            w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
-
 
583
        } else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_ALL) {
-
 
584
            Object o = null;
-
 
585
            Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
-
 
586
            w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
-
 
587
        }
-
 
588
 
-
 
589
        if (GrandLivreSheetXML.this.excludeCompteSolde) {
-
 
590
            System.err.println("Exclude compte");
-
 
591
 
-
 
592
            if (lCompteSolde != null) {
-
 
593
                w = w.and(new Where(tableEcriture.getField("ID_COMPTE_PCE"), lCompteSolde).not());
-
 
594
            }
-
 
595
        }
-
 
596
        w = w.and(new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%"));
-
 
597
 
-
 
598
        if (!UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
-
 
599
            // TODO Show Restricted acces in UI
-
 
600
            w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "LIKE", "411%"));
-
 
601
        }
-
 
602
        return w;
-
 
603
    }
-
 
604
 
626
    /**
605
    /**
627
     * @param d date limite des cumuls
606
     * @param d date limite des cumuls
628
     * @return Map<Integer id compte, Long solde(debit-credit)>
607
     * @return Map<Integer id compte, Long solde(debit-credit)>
629
     */
608
     */
630
    private Map<Integer, Long> getCumulsAnterieur(Date d, List<Integer> listCompteSolde) {
609
    private Map<Integer, Long> getCumulsAnterieur(Date d, List<Integer> listCompteSolde) {