OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 80 Rev 83
Line 26... Line 26...
26
import org.openconcerto.erp.core.sales.pos.model.Article;
26
import org.openconcerto.erp.core.sales.pos.model.Article;
27
import org.openconcerto.erp.core.sales.pos.model.Paiement;
27
import org.openconcerto.erp.core.sales.pos.model.Paiement;
28
import org.openconcerto.erp.core.sales.pos.model.ReceiptCode;
28
import org.openconcerto.erp.core.sales.pos.model.ReceiptCode;
29
import org.openconcerto.erp.core.sales.pos.model.Ticket;
29
import org.openconcerto.erp.core.sales.pos.model.Ticket;
30
import org.openconcerto.erp.core.sales.pos.model.TicketLine;
30
import org.openconcerto.erp.core.sales.pos.model.TicketLine;
31
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
31
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
-
 
32
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.Type;
32
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
33
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
33
import org.openconcerto.erp.generationEcritures.GenerationMvtTicketCaisse;
34
import org.openconcerto.erp.generationEcritures.GenerationMvtTicketCaisse;
34
import org.openconcerto.erp.generationEcritures.GenerationMvtVirement;
35
import org.openconcerto.erp.generationEcritures.GenerationMvtVirement;
35
import org.openconcerto.erp.generationEcritures.GenerationReglementVenteNG;
36
import org.openconcerto.erp.generationEcritures.GenerationReglementVenteNG;
36
import org.openconcerto.erp.model.PrixTTC;
37
import org.openconcerto.erp.model.PrixTTC;
37
import org.openconcerto.erp.preferences.DefaultNXProps;
38
import org.openconcerto.erp.preferences.DefaultNXProps;
38
import org.openconcerto.sql.Configuration;
39
import org.openconcerto.sql.Configuration;
39
import org.openconcerto.sql.element.SQLElement;
40
import org.openconcerto.sql.element.SQLElement;
40
import org.openconcerto.sql.model.SQLBase;
41
import org.openconcerto.sql.model.SQLBase;
41
import org.openconcerto.sql.model.SQLRow;
42
import org.openconcerto.sql.model.SQLRow;
-
 
43
import org.openconcerto.sql.model.SQLRowAccessor;
42
import org.openconcerto.sql.model.SQLRowListRSH;
44
import org.openconcerto.sql.model.SQLRowListRSH;
43
import org.openconcerto.sql.model.SQLRowValues;
45
import org.openconcerto.sql.model.SQLRowValues;
44
import org.openconcerto.sql.model.SQLSelect;
46
import org.openconcerto.sql.model.SQLSelect;
45
import org.openconcerto.sql.model.SQLTable;
47
import org.openconcerto.sql.model.SQLTable;
46
import org.openconcerto.sql.model.Where;
48
import org.openconcerto.sql.model.Where;
Line 121... Line 123...
121
        return getConfigFile(ComptaPropsConfiguration.APP_NAME, new File("."));
123
        return getConfigFile(ComptaPropsConfiguration.APP_NAME, new File("."));
122
    }
124
    }
123
 
125
 
124
    public static void createConnexion() {
126
    public static void createConnexion() {
125
        final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create();
127
        final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create();
126
        conf.setupLogging("logs");
-
 
127
        TranslationManager.getInstance().addTranslationStreamFromClass(MainFrame.class);
128
        TranslationManager.getInstance().addTranslationStreamFromClass(MainFrame.class);
128
        TranslationManager.getInstance().setLocale(Locale.getDefault());
129
        TranslationManager.getInstance().setLocale(Locale.getDefault());
129
 
130
 
130
        Configuration.setInstance(conf);
131
        Configuration.setInstance(conf);
131
        try {
132
        try {
Line 349... Line 350...
349
 
350
 
350
    }
351
    }
351
 
352
 
352
    private static void updateStock(int id) throws SQLException {
353
    private static void updateStock(int id) throws SQLException {
353
 
354
 
354
        final SQLElement elt = Configuration.getInstance().getDirectory().getElement("TICKET_CAISSE");
355
        SQLRow row = getClientCaisse().getTable().getTable("TICKET_CAISSE").getRow(id);
355
        final SQLElement eltArticleFact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
-
 
356
        MouvementStockSQLElement mvtStock = (MouvementStockSQLElement) Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
-
 
357
        mvtStock.createMouvement(elt.getTable().getRow(id), eltArticleFact.getTable(), new StockLabel() {
356
        StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
358
            @Override
357
            @Override
359
            public String getLabel(SQLRow rowOrigin, SQLRow rowElt) {
358
            public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
360
                return "Ticket N°" + rowOrigin.getString("NUMERO");
359
                return "Ticket N°" + rowOrigin.getString("NUMERO");
361
            }
360
            }
-
 
361
        }, row, row.getReferentRows(getClientCaisse().getTable().getTable("SAISIE_VENTE_FACTURE_ELEMENT")), Type.REAL_DELIVER);
-
 
362
 
362
        }, false);
363
        stockUpdater.update();
-
 
364
 
363
    }
365
    }
364
 
366
 
365
    public static int getID() {
367
    public static int getID() {
366
        final Document d = getDocument();
368
        final Document d = getDocument();
367
        return Integer.valueOf(d.getRootElement().getAttributeValue("caisseID", "-1"));
369
        return Integer.valueOf(d.getRootElement().getAttributeValue("caisseID", "2"));
368
    }
370
    }
369
 
371
 
370
    public static void setID(int caisseId) {
372
    public static void setID(int caisseId) {
371
        final Document d = getDocument();
373
        final Document d = getDocument();
372
        d.getRootElement().setAttribute("caisseID", String.valueOf(caisseId));
374
        d.getRootElement().setAttribute("caisseID", String.valueOf(caisseId));
Line 383... Line 385...
383
        return l;
385
        return l;
384
    }
386
    }
385
 
387
 
386
    public static int getUserID() {
388
    public static int getUserID() {
387
        final Document d = getDocument();
389
        final Document d = getDocument();
388
        return Integer.valueOf(d.getRootElement().getAttributeValue("userID", "-1"));
390
        return Integer.valueOf(d.getRootElement().getAttributeValue("userID", "2"));
389
    }
391
    }
390
 
392
 
391
    public static void setUserID(int userId) {
393
    public static void setUserID(int userId) {
392
        final Document d = getDocument();
394
        final Document d = getDocument();
393
        d.getRootElement().setAttribute("userID", String.valueOf(userId));
395
        d.getRootElement().setAttribute("userID", String.valueOf(userId));
394
    }
396
    }
395
 
397
 
396
    public static int getSocieteID() {
398
    public static int getSocieteID() {
397
        final Document d = getDocument();
399
        final Document d = getDocument();
398
        return Integer.valueOf(d.getRootElement().getAttributeValue("societeID", "-1"));
400
        return Integer.valueOf(d.getRootElement().getAttributeValue("societeID", "42"));
399
    }
401
    }
400
 
402
 
401
    public static void setSocieteID(int societeId) {
403
    public static void setSocieteID(int societeId) {
402
        final Document d = getDocument();
404
        final Document d = getDocument();
403
        d.getRootElement().setAttribute("societeID", String.valueOf(societeId));
405
        d.getRootElement().setAttribute("societeID", String.valueOf(societeId));
404
    }
406
    }
405
 
407
 
-
 
408
    public static int getScanDelay() {
-
 
409
        final Document d = getDocument();
-
 
410
        return Integer.valueOf(d.getRootElement().getAttributeValue("scanDelay", "80"));
-
 
411
    }
-
 
412
 
-
 
413
    public static void setScanDelay(int scanDelay) {
-
 
414
        final Document d = getDocument();
-
 
415
        d.getRootElement().setAttribute("scanDelay", String.valueOf(scanDelay));
-
 
416
    }
-
 
417
 
406
    public static boolean isCopyActive() {
418
    public static boolean isCopyActive() {
407
        final Document d = getDocument();
419
        final Document d = getDocument();
408
        return Boolean.valueOf(d.getRootElement().getAttributeValue("copyTicket", "true"));
420
        return Boolean.valueOf(d.getRootElement().getAttributeValue("copyTicket", "true"));
409
    }
421
    }
410
 
422
 
Line 487... Line 499...
487
            d.getRootElement().addContent(e);
499
            d.getRootElement().addContent(e);
488
        }
500
        }
489
        e.setAttribute("port", port);
501
        e.setAttribute("port", port);
490
    }
502
    }
491
 
503
 
-
 
504
    public static String getCardPort() {
-
 
505
        final Document d = getDocument();
-
 
506
        final List<Element> children = d.getRootElement().getChildren("card");
-
 
507
        if (children != null) {
-
 
508
            for (Element e : children) {
-
 
509
                if (e.getAttribute("port") != null) {
-
 
510
                    return e.getAttributeValue("port", "COM1:");
-
 
511
                }
-
 
512
            }
-
 
513
        }
-
 
514
        return "";
-
 
515
    }
-
 
516
 
-
 
517
    public static void setCardPort(String port) {
-
 
518
        final Document d = getDocument();
-
 
519
        Element e = d.getRootElement().getChild("card");
-
 
520
        if (e == null) {
-
 
521
            e = new Element("card");
-
 
522
            d.getRootElement().addContent(e);
-
 
523
        }
-
 
524
        e.setAttribute("port", port);
-
 
525
    }
-
 
526
 
492
    public static String getJPosDirectory() {
527
    public static String getJPosDirectory() {
493
        final Document d = getDocument();
528
        final Document d = getDocument();
494
        final List<Element> children = d.getRootElement().getChildren("jpos");
529
        final List<Element> children = d.getRootElement().getChildren("jpos");
495
        if (children != null) {
530
        if (children != null) {
496
            for (Element e : children) {
531
            for (Element e : children) {
Line 582... Line 617...
582
            d.getRootElement().addContent(e);
617
            d.getRootElement().addContent(e);
583
        }
618
        }
584
        e.setAttribute("printWidth", w);
619
        e.setAttribute("printWidth", w);
585
    }
620
    }
586
 
621
 
-
 
622
    public static int getScreenWidth() {
-
 
623
        final Document d = getDocument();
-
 
624
        final List<Element> children = d.getRootElement().getChildren("screen");
-
 
625
        if (children != null) {
-
 
626
            for (Element e : children) {
-
 
627
                if (e.getAttribute("width") != null) {
-
 
628
                    return Integer.valueOf(e.getAttributeValue("width", "0"));
-
 
629
                }
-
 
630
            }
-
 
631
        }
-
 
632
        return 0;
-
 
633
    }
-
 
634
 
-
 
635
    public static int getScreenHeight() {
-
 
636
        final Document d = getDocument();
-
 
637
        final List<Element> children = d.getRootElement().getChildren("screen");
-
 
638
        if (children != null) {
-
 
639
            for (Element e : children) {
-
 
640
                if (e.getAttribute("height") != null) {
-
 
641
                    return Integer.valueOf(e.getAttributeValue("height", "0"));
-
 
642
                }
-
 
643
            }
-
 
644
        }
-
 
645
        return 0;
-
 
646
    }
-
 
647
 
587
    public static void saveConfiguration() {
648
    public static void saveConfiguration() {
588
        final File file = getConfigFile();
649
        final File file = getConfigFile();
589
        final XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
650
        final XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
590
        try {
651
        try {
591
            System.out.println("Saving:" + file.getAbsolutePath());
652
            System.out.println("Saving:" + file.getAbsolutePath());