Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
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
|
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
|
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.
|
9 |
* language governing permissions and limitations under the License.
|
Line 58... |
Line 58... |
58 |
import org.openconcerto.utils.BaseDirs;
|
58 |
import org.openconcerto.utils.BaseDirs;
|
59 |
import org.openconcerto.utils.DecimalUtils;
|
59 |
import org.openconcerto.utils.DecimalUtils;
|
60 |
import org.openconcerto.utils.ExceptionHandler;
|
60 |
import org.openconcerto.utils.ExceptionHandler;
|
61 |
import org.openconcerto.utils.i18n.TranslationManager;
|
61 |
import org.openconcerto.utils.i18n.TranslationManager;
|
62 |
|
62 |
|
- |
|
63 |
import java.awt.GraphicsDevice;
|
- |
|
64 |
import java.awt.GraphicsEnvironment;
|
63 |
import java.io.File;
|
65 |
import java.io.File;
|
64 |
import java.io.FileOutputStream;
|
66 |
import java.io.FileOutputStream;
|
65 |
import java.io.IOException;
|
67 |
import java.io.IOException;
|
66 |
import java.math.BigDecimal;
|
68 |
import java.math.BigDecimal;
|
67 |
import java.math.RoundingMode;
|
69 |
import java.math.RoundingMode;
|
Line 107... |
Line 109... |
107 |
private int screenWidth, screenHeight;
|
109 |
private int screenWidth, screenHeight;
|
108 |
private TicketPrinterConfiguration ticketPrinterConf1, ticketPrinterConf2;
|
110 |
private TicketPrinterConfiguration ticketPrinterConf1, ticketPrinterConf2;
|
109 |
private int userID = 2;
|
111 |
private int userID = 2;
|
110 |
private int companyID = 42;
|
112 |
private int companyID = 42;
|
111 |
private int posID = 2;
|
113 |
private int posID = 2;
|
- |
|
114 |
private int depotStockId = 2;
|
112 |
private int scanDelay = 80;
|
115 |
private int scanDelay = 80;
|
113 |
|
116 |
|
114 |
private List<TicketLine> headerLines = new ArrayList<TicketLine>();
|
117 |
private List<TicketLine> headerLines = new ArrayList<>();
|
115 |
private List<TicketLine> footerLines = new ArrayList<TicketLine>();
|
118 |
private List<TicketLine> footerLines = new ArrayList<>();
|
116 |
// Terminal CB
|
119 |
// Terminal CB
|
117 |
private String creditCardPort = "";
|
120 |
private String creditCardPort = "";
|
118 |
// LCD
|
121 |
// LCD
|
119 |
private String LCDType = "serial";
|
122 |
private String LCDType = "serial";
|
120 |
private String LCDPort = "";
|
123 |
private String LCDPort = "";
|
Line 168... |
Line 171... |
168 |
return file.exists();
|
171 |
return file.exists();
|
169 |
}
|
172 |
}
|
170 |
|
173 |
|
171 |
// Screen
|
174 |
// Screen
|
172 |
public int getScreenWidth() {
|
175 |
public int getScreenWidth() {
|
- |
|
176 |
if (screenWidth == 0) {
|
- |
|
177 |
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
- |
|
178 |
screenWidth = gd.getDisplayMode().getWidth();
|
- |
|
179 |
}
|
173 |
return screenWidth;
|
180 |
return screenWidth;
|
174 |
}
|
181 |
}
|
175 |
|
182 |
|
176 |
public int getScreenHeight() {
|
183 |
public int getScreenHeight() {
|
- |
|
184 |
if (screenHeight == 0) {
|
- |
|
185 |
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
- |
|
186 |
screenHeight = gd.getDisplayMode().getHeight();
|
- |
|
187 |
}
|
177 |
return screenHeight;
|
188 |
return screenHeight;
|
178 |
}
|
189 |
}
|
179 |
|
190 |
|
180 |
// Database connection
|
191 |
// Database connection
|
181 |
public int getUserID() {
|
192 |
public int getUserID() {
|
Line 200... |
Line 211... |
200 |
}
|
211 |
}
|
201 |
|
212 |
|
202 |
public void setPosID(int posID) {
|
213 |
public void setPosID(int posID) {
|
203 |
this.posID = posID;
|
214 |
this.posID = posID;
|
204 |
}
|
215 |
}
|
- |
|
216 |
// Depot stock
|
- |
|
217 |
|
- |
|
218 |
public void setDepotID(int depotStockId) {
|
- |
|
219 |
this.depotStockId = depotStockId;
|
- |
|
220 |
|
- |
|
221 |
}
|
- |
|
222 |
|
- |
|
223 |
public int getDepotID() {
|
- |
|
224 |
return depotStockId;
|
- |
|
225 |
}
|
205 |
|
226 |
|
206 |
public int getScanDelay() {
|
227 |
public int getScanDelay() {
|
207 |
return scanDelay;
|
228 |
return scanDelay;
|
208 |
}
|
229 |
}
|
209 |
|
230 |
|
Line 371... |
Line 392... |
371 |
int idClient = ticket.getClient().getId();
|
392 |
int idClient = ticket.getClient().getId();
|
372 |
if (idClient <= 0) {
|
393 |
if (idClient <= 0) {
|
373 |
idClient = defaultIDClient;
|
394 |
idClient = defaultIDClient;
|
374 |
}
|
395 |
}
|
375 |
|
396 |
|
- |
|
397 |
rowVals.put("ID_CLIENT", idClient);
|
- |
|
398 |
SQLRow rowClient = elt.getTable().getForeignTable("ID_CLIENT").getRow(idClient);
|
- |
|
399 |
SQLRowAccessor rowCat = rowClient.getNonEmptyForeign("ID_CATEGORIE_COMPTABLE");
|
- |
|
400 |
|
376 |
// TODO fusionner TotalCalculator avec Ticket.GetTotalCalcutor
|
401 |
// TODO fusionner TotalCalculator avec Ticket.GetTotalCalcutor
|
377 |
TotalCalculator calc = new TotalCalculator("T_PA_HT", "T_PV_HT", null, null);
|
402 |
TotalCalculator calc = new TotalCalculator("T_PA_HT", "T_PV_HT", null, rowCat);
|
378 |
|
403 |
|
379 |
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
|
404 |
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
|
380 |
Boolean bServiceActive = Boolean.valueOf(val);
|
405 |
Boolean bServiceActive = Boolean.valueOf(val);
|
381 |
calc.setServiceActive(bServiceActive != null && bServiceActive);
|
406 |
calc.setServiceActive(bServiceActive != null && bServiceActive);
|
382 |
|
407 |
|
383 |
// Articles
|
408 |
// Articles
|
384 |
for (TicketItem item : ticket.getItems()) {
|
409 |
for (TicketItem item : ticket.getItems()) {
|
385 |
SQLRowValues rowValsElt = new SQLRowValues(eltFact.getTable());
|
410 |
SQLRowValues rowValsElt = new SQLRowValues(eltFact.getTable());
|
386 |
final Article article = item.getArticle();
|
411 |
final Article article = item.getArticle();
|
387 |
final BigDecimal nb = item.getQty();
|
412 |
final BigDecimal nb = item.getQty();
|
- |
|
413 |
|
- |
|
414 |
rowValsElt.put("ID_DEPOT_STOCK", getDepotID());
|
- |
|
415 |
|
388 |
if (article.getSalesUnit() == null) {
|
416 |
if (article.getSalesUnit() == null) {
|
389 |
rowValsElt.put("QTE", nb.intValue());
|
417 |
rowValsElt.put("QTE", nb.intValue());
|
390 |
} else {
|
418 |
} else {
|
391 |
rowValsElt.put("QTE", 1);
|
419 |
rowValsElt.put("QTE", 1);
|
392 |
rowValsElt.put("QTE_UNITAIRE", nb);
|
420 |
rowValsElt.put("QTE_UNITAIRE", nb);
|
393 |
}
|
421 |
}
|
- |
|
422 |
|
394 |
rowValsElt.put("PV_HT", article.getPriceWithoutTax());
|
423 |
rowValsElt.put("PV_HT", article.getPriceWithoutTax(nb, false));
|
395 |
Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
|
424 |
Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
|
396 |
BigDecimal tauxTVA = BigDecimal.valueOf(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
|
425 |
BigDecimal tauxTVA = BigDecimal.valueOf(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
|
- |
|
426 |
final BigDecimal valueHT = article.getPriceWithoutTax(nb, true).multiply(nb, DecimalUtils.HIGH_PRECISION);
|
397 |
|
427 |
|
398 |
final BigDecimal valueHT = article.getPriceWithoutTax().multiply(nb, DecimalUtils.HIGH_PRECISION);
|
- |
|
399 |
if (article.getSalesUnit() != null) {
|
428 |
if (article.getSalesUnit() != null) {
|
400 |
rowValsElt.put("ID_UNITE_VENTE", mapUniteVenteName.get(article.getSalesUnit()));
|
429 |
rowValsElt.put("ID_UNITE_VENTE", mapUniteVenteName.get(article.getSalesUnit()));
|
401 |
}
|
430 |
}
|
402 |
rowValsElt.put("T_PV_HT", valueHT);
|
431 |
rowValsElt.put("T_PV_HT", valueHT);
|
403 |
rowValsElt.put("T_PV_TTC", valueHT.multiply(tauxTVA, DecimalUtils.HIGH_PRECISION));
|
432 |
rowValsElt.put("T_PV_TTC", valueHT.multiply(tauxTVA, DecimalUtils.HIGH_PRECISION));
|
404 |
rowValsElt.put("ID_TAXE", article.getIdTaxe());
|
433 |
rowValsElt.put("ID_TAXE", article.getIdTaxe());
|
405 |
rowValsElt.put("CODE", article.getCode());
|
434 |
rowValsElt.put("CODE", article.getCode());
|
- |
|
435 |
rowValsElt.put("POURCENT_REMISE", article.getDiscountPct().movePointRight(2));
|
- |
|
436 |
rowValsElt.put("ECO_CONTRIBUTION", article.getEcoTaxe());
|
- |
|
437 |
rowValsElt.put("T_ECO_CONTRIBUTION", article.getEcoTaxe().multiply(nb));
|
406 |
rowValsElt.put("NOM", article.getName());
|
438 |
rowValsElt.put("NOM", article.getName());
|
407 |
rowValsElt.put("ID_TICKET_CAISSE", rowVals);
|
439 |
rowValsElt.put("ID_TICKET_CAISSE", rowVals);
|
408 |
rowValsElt.put("ID_ARTICLE", article.getId());
|
440 |
rowValsElt.put("ID_ARTICLE", article.getId());
|
409 |
calc.addLine(rowValsElt, eltArticle.getTable().getRow(article.getId()), 0, false);
|
441 |
calc.addLine(rowValsElt, eltArticle.getTable().getRow(article.getId()), 0, false);
|
410 |
}
|
442 |
}
|
Line 500... |
Line 532... |
500 |
SQLSelect sel = new SQLSelect();
|
532 |
SQLSelect sel = new SQLSelect();
|
501 |
sel.addSelectStar(elt.getTable());
|
533 |
sel.addSelectStar(elt.getTable());
|
502 |
sel.setWhere(new Where(elt.getTable().getField("NOM"), "=", "Caisse OpenConcerto"));
|
534 |
sel.setWhere(new Where(elt.getTable().getField("NOM"), "=", "Caisse OpenConcerto"));
|
503 |
@SuppressWarnings("unchecked")
|
535 |
@SuppressWarnings("unchecked")
|
504 |
List<SQLRow> l = (List<SQLRow>) elt.getTable().getBase().getDataSource().execute(sel.asString(), new SQLSelectHandlerBuilder(sel).createHandler());
|
536 |
List<SQLRow> l = (List<SQLRow>) elt.getTable().getBase().getDataSource().execute(sel.asString(), new SQLSelectHandlerBuilder(sel).createHandler());
|
505 |
if (l.size() > 0) {
|
537 |
if (!l.isEmpty()) {
|
506 |
rowClient = l.get(0);
|
538 |
rowClient = l.get(0);
|
507 |
} else {
|
539 |
} else {
|
508 |
SQLRowValues rowValues = new SQLRowValues(elt.getTable());
|
540 |
SQLRowValues rowValues = new SQLRowValues(elt.getTable());
|
509 |
rowValues.put("NOM", "Caisse OpenConcerto");
|
541 |
rowValues.put("NOM", "Caisse OpenConcerto");
|
510 |
SQLRowValues rowValuesMode = new SQLRowValues(elt.getTable().getTable("MODE_REGLEMENT"));
|
542 |
SQLRowValues rowValuesMode = new SQLRowValues(elt.getTable().getTable("MODE_REGLEMENT"));
|
Line 584... |
Line 616... |
584 |
// config
|
616 |
// config
|
585 |
final Element rootElement = document.getRootElement();
|
617 |
final Element rootElement = document.getRootElement();
|
586 |
setUserID(Integer.valueOf(rootElement.getAttributeValue("userID", "2")));
|
618 |
setUserID(Integer.valueOf(rootElement.getAttributeValue("userID", "2")));
|
587 |
setCompanyID(Integer.valueOf(rootElement.getAttributeValue("societeID", "42")));
|
619 |
setCompanyID(Integer.valueOf(rootElement.getAttributeValue("societeID", "42")));
|
588 |
setPosID(Integer.valueOf(rootElement.getAttributeValue("caisseID", "2")));
|
620 |
setPosID(Integer.valueOf(rootElement.getAttributeValue("caisseID", "2")));
|
- |
|
621 |
setDepotID(Integer.valueOf(rootElement.getAttributeValue("depotID", "2")));
|
589 |
setScanDelay(Integer.valueOf(rootElement.getAttributeValue("scanDelay", "80")));
|
622 |
setScanDelay(Integer.valueOf(rootElement.getAttributeValue("scanDelay", "80")));
|
590 |
setAskPostalCode(rootElement.getAttributeValue("askPostalCode", "false").equals("true"));
|
623 |
setAskPostalCode(rootElement.getAttributeValue("askPostalCode", "false").equals("true"));
|
591 |
|
624 |
|
592 |
// screen
|
625 |
// screen
|
593 |
final List<Element> children = rootElement.getChildren("screen");
|
626 |
final List<Element> children = rootElement.getChildren("screen");
|
Line 670... |
Line 703... |
670 |
final Document doc = new Document();
|
703 |
final Document doc = new Document();
|
671 |
final Element configElement = new Element("config");
|
704 |
final Element configElement = new Element("config");
|
672 |
configElement.setAttribute("userID", String.valueOf(this.userID));
|
705 |
configElement.setAttribute("userID", String.valueOf(this.userID));
|
673 |
configElement.setAttribute("societeID", String.valueOf(this.companyID));
|
706 |
configElement.setAttribute("societeID", String.valueOf(this.companyID));
|
674 |
configElement.setAttribute("caisseID", String.valueOf(this.posID));
|
707 |
configElement.setAttribute("caisseID", String.valueOf(this.posID));
|
- |
|
708 |
configElement.setAttribute("depotID", String.valueOf(this.depotStockId));
|
675 |
configElement.setAttribute("scanDelay", String.valueOf(this.scanDelay));
|
709 |
configElement.setAttribute("scanDelay", String.valueOf(this.scanDelay));
|
676 |
configElement.setAttribute("askPostalCode", this.askPostalCode ? "true" : "false");
|
710 |
configElement.setAttribute("askPostalCode", this.askPostalCode ? "true" : "false");
|
677 |
doc.addContent(configElement);
|
711 |
doc.addContent(configElement);
|
678 |
// screen size
|
712 |
// screen size
|
679 |
final Element screenElement = new Element("screen");
|
713 |
final Element screenElement = new Element("screen");
|
Line 753... |
Line 787... |
753 |
}
|
787 |
}
|
754 |
}
|
788 |
}
|
755 |
}
|
789 |
}
|
756 |
|
790 |
|
757 |
public boolean isUsingJPos() {
|
791 |
public boolean isUsingJPos() {
|
758 |
// TODO Auto-generated method stub
|
- |
|
759 |
return false;
|
792 |
return false;
|
760 |
}
|
793 |
}
|
761 |
|
794 |
|
762 |
public List<String> getJPosDirectories() {// TODO Auto-generated method stub
|
795 |
public List<String> getJPosDirectories() {
|
763 |
final ArrayList<String> result = new ArrayList<String>();
|
796 |
final ArrayList<String> result = new ArrayList<String>();
|
764 |
return result;
|
797 |
return result;
|
765 |
}
|
798 |
}
|
766 |
|
799 |
|
767 |
public String getLCDPort() {
|
800 |
public String getLCDPort() {
|
Line 800... |
Line 833... |
800 |
List<Client> l = new ArrayList<Client>();
|
833 |
List<Client> l = new ArrayList<Client>();
|
801 |
|
834 |
|
802 |
for (SQLRowValues sqlRowValues : result) {
|
835 |
for (SQLRowValues sqlRowValues : result) {
|
803 |
Client c = new Client(sqlRowValues.getID(), sqlRowValues.getString("NOM"), sqlRowValues.getBigDecimal("SOLDE_COMPTE"));
|
836 |
Client c = new Client(sqlRowValues.getID(), sqlRowValues.getString("NOM"), sqlRowValues.getBigDecimal("SOLDE_COMPTE"));
|
804 |
final SQLRowAccessor foreign = sqlRowValues.getForeign("ID_ADRESSE");
|
837 |
final SQLRowAccessor foreign = sqlRowValues.getForeign("ID_ADRESSE");
|
805 |
c.setAdresse(foreign.getString("RUE") + " " + foreign.getString("VILLE"));
|
838 |
c.setAdresse(foreign.getString("RUE") + "\n" + foreign.getString("VILLE"));
|
806 |
l.add(c);
|
839 |
l.add(c);
|
807 |
}
|
840 |
}
|
808 |
Collections.sort(l, new Comparator<Client>() {
|
841 |
Collections.sort(l, new Comparator<Client>() {
|
809 |
|
842 |
|
810 |
@Override
|
843 |
@Override
|
Line 830... |
Line 863... |
830 |
}
|
863 |
}
|
831 |
|
864 |
|
832 |
public void setAskPostalCode(boolean askPostalCode) {
|
865 |
public void setAskPostalCode(boolean askPostalCode) {
|
833 |
this.askPostalCode = askPostalCode;
|
866 |
this.askPostalCode = askPostalCode;
|
834 |
}
|
867 |
}
|
- |
|
868 |
|
835 |
}
|
869 |
}
|