-
-
-
-
-
-
-
@@ -1457,24 +1518,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
@@ -1486,10 +1535,57 @@
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/caja.jar b/dist/caja.jar
index a7b5fe5..ac6be48 100644
Binary files a/dist/caja.jar and b/dist/caja.jar differ
diff --git a/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java b/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java
index 4280209..a9d1a6d 100644
--- a/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java
+++ b/src/danielcortes/xyz/models/informe/SQLiteInformeMensualContentDAO.java
@@ -25,6 +25,7 @@
package danielcortes.xyz.models.informe;
import danielcortes.xyz.data.SQLiteConnectionHolder;
+import danielcortes.xyz.utils.NaturalOrderComparator;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -34,9 +35,9 @@ import java.time.LocalDate;
import java.util.*;
public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
- HashMap map;
+ private HashMap map;
- public SQLiteInformeMensualContentDAO(){
+ public SQLiteInformeMensualContentDAO() {
this.map = new HashMap<>();
}
@@ -109,7 +110,8 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
}
}
- private void fillBoletasFromResultSet(ResultSet rs) throws SQLException{
+ private void fillBoletasFromResultSet(ResultSet rs) throws SQLException {
+ Comparator comparator = new NaturalOrderComparator();
while (rs.next()) {
InformeMensualContent informe = map.get(rs.getInt("caja"));
int tipoIngreso = rs.getInt("tipo_ingreso");
@@ -121,7 +123,7 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
String fiscalesZFinal = rs.getString("z_final");
if (informe.getFiscalesInicial() != null) {
- if (fiscalesInicial.compareTo(informe.getFiscalesInicial()) < 0) {
+ if (comparator.compare(fiscalesInicial, informe.getFiscalesInicial()) < 0) {
informe.setFiscalesInicial(fiscalesInicial);
}
} else {
@@ -129,7 +131,7 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
}
if (informe.getFiscalesFinal() != null) {
- if (fiscalesFinal.compareTo(informe.getFiscalesFinal()) > 0) {
+ if (comparator.compare(fiscalesFinal, informe.getFiscalesFinal()) > 0) {
informe.setFiscalesFinal(fiscalesFinal);
}
} else {
@@ -137,7 +139,7 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
}
if (informe.getFiscalesZInicial() != null) {
- if (fiscalesZInicial.compareTo(informe.getFiscalesZInicial()) < 0) {
+ if (comparator.compare(fiscalesZInicial, informe.getFiscalesZInicial()) < 0) {
informe.setFiscalesZInicial(fiscalesZInicial);
}
} else {
@@ -145,7 +147,7 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
}
if (informe.getFiscalesZFinal() != null) {
- if (fiscalesZFinal.compareTo(informe.getFiscalesZFinal()) > 0) {
+ if (comparator.compare(fiscalesZFinal, informe.getFiscalesZFinal()) > 0) {
informe.setFiscalesZFinal(fiscalesZFinal);
}
} else {
@@ -158,7 +160,7 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
String manualesFinal = rs.getString("final");
if (informe.getManualesInicial() != null) {
- if (manualesInicial.compareTo(informe.getManualesInicial()) < 0) {
+ if (comparator.compare(manualesInicial, informe.getManualesInicial()) < 0) {
informe.setManualesInicial(manualesInicial);
}
} else {
@@ -166,7 +168,7 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
}
if (informe.getManualesFinal() != null) {
- if (manualesFinal.compareTo(informe.getManualesFinal()) > 0) {
+ if (comparator.compare(manualesFinal, informe.getManualesFinal()) > 0) {
informe.setManualesFinal(manualesFinal);
}
} else {
@@ -179,14 +181,14 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
String facturasFinal = rs.getString("final");
if (informe.getFacturasInicial() != null) {
- if (facturasInicial.compareTo(informe.getFacturasInicial()) < 0) {
+ if (comparator.compare(facturasInicial, informe.getFacturasInicial()) < 0) {
informe.setFacturasInicial(facturasInicial);
}
} else {
informe.setFacturasInicial(facturasInicial);
}
if (informe.getFacturasFinal() != null) {
- if (facturasFinal.compareTo(informe.getFacturasFinal()) > 0) {
+ if (comparator.compare(facturasFinal, informe.getFacturasFinal()) > 0) {
informe.setFacturasFinal(facturasFinal);
}
} else {
@@ -199,14 +201,14 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
String guiasFinal = rs.getString("final");
if (informe.getGuiasInicial() != null) {
- if (guiasInicial.compareTo(informe.getGuiasInicial()) < 0) {
+ if (comparator.compare(guiasInicial, informe.getGuiasInicial()) < 0) {
informe.setGuiasInicial(guiasInicial);
}
} else {
informe.setGuiasInicial(guiasInicial);
}
if (informe.getGuiasFinal() != null) {
- if (guiasFinal.compareTo(informe.getGuiasFinal()) > 0) {
+ if (comparator.compare(guiasFinal, informe.getGuiasFinal()) > 0) {
informe.setGuiasFinal(guiasFinal);
}
} else {
@@ -218,14 +220,14 @@ public class SQLiteInformeMensualContentDAO extends InformeMensualContentDAO {
String exentasFinal = rs.getString("final");
if (informe.getExentasInicial() != null) {
- if (exentasInicial.compareTo(informe.getExentasInicial()) < 0) {
+ if (comparator.compare(exentasInicial, informe.getExentasInicial()) < 0) {
informe.setExentasInicial(exentasInicial);
}
} else {
informe.setExentasInicial(exentasInicial);
}
if (informe.getExentasFinal() != null) {
- if (exentasFinal.compareTo(informe.getExentasFinal()) > 0) {
+ if (comparator.compare(exentasFinal, informe.getExentasFinal()) > 0) {
informe.setExentasFinal(exentasFinal);
}
} else {
diff --git a/src/danielcortes/xyz/utils/NaturalOrderComparator.java b/src/danielcortes/xyz/utils/NaturalOrderComparator.java
new file mode 100644
index 0000000..d99e76a
--- /dev/null
+++ b/src/danielcortes/xyz/utils/NaturalOrderComparator.java
@@ -0,0 +1,128 @@
+/*
+ NaturalOrderComparator.java -- Perform 'natural order' comparisons of strings in Java.
+ Copyright (C) 2003 by Pierre-Luc Paour
+ Based on the C version by Martin Pool, of which this is more or less a straight conversion.
+ Copyright (C) 2000 by Martin Pool
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ This class was sightly modified by Daniel Cortes, removing the main method that it had
+ */
+
+package danielcortes.xyz.utils;
+
+import java.util.*;
+
+public class NaturalOrderComparator implements Comparator {
+ int compareRight(String a, String b) {
+ int bias = 0, ia = 0, ib = 0;
+
+ // The longest run of digits wins. That aside, the greatest
+ // value wins, but we can't know that it will until we've scanned
+ // both numbers to know that they have the same magnitude, so we
+ // remember it in BIAS.
+ for (; ; ia++, ib++) {
+ char ca = charAt(a, ia);
+ char cb = charAt(b, ib);
+
+ if (!Character.isDigit(ca) && !Character.isDigit(cb)) {
+ return bias;
+ }
+ if (!Character.isDigit(ca)) {
+ return -1;
+ }
+ if (!Character.isDigit(cb)) {
+ return +1;
+ }
+ if (ca == 0 && cb == 0) {
+ return bias;
+ }
+
+ if (bias == 0) {
+ if (ca < cb) {
+ bias = -1;
+ } else if (ca > cb) {
+ bias = +1;
+ }
+ }
+ }
+ }
+
+ public int compare(Object o1, Object o2) {
+ String a = o1.toString();
+ String b = o2.toString();
+
+ int ia = 0, ib = 0;
+ int nza = 0, nzb = 0;
+ char ca, cb;
+
+ while (true) {
+ // Only count the number of zeroes leading the last number compared
+ nza = nzb = 0;
+
+ ca = charAt(a, ia);
+ cb = charAt(b, ib);
+
+ // skip over leading spaces or zeros
+ while (Character.isSpaceChar(ca) || ca == '0') {
+ if (ca == '0') {
+ nza++;
+ } else {
+ // Only count consecutive zeroes
+ nza = 0;
+ }
+
+ ca = charAt(a, ++ia);
+ }
+
+ while (Character.isSpaceChar(cb) || cb == '0') {
+ if (cb == '0') {
+ nzb++;
+ } else {
+ // Only count consecutive zeroes
+ nzb = 0;
+ }
+
+ cb = charAt(b, ++ib);
+ }
+
+ // Process run of digits
+ if (Character.isDigit(ca) && Character.isDigit(cb)) {
+ int bias = compareRight(a.substring(ia), b.substring(ib));
+ if (bias != 0) {
+ return bias;
+ }
+ }
+
+ if (ca == 0 && cb == 0) {
+ // The strings compare the same. Perhaps the caller
+ // will want to call strcmp to break the tie.
+ return nza - nzb;
+ }
+ if (ca < cb) {
+ return -1;
+ }
+ if (ca > cb) {
+ return +1;
+ }
+
+ ++ia;
+ ++ib;
+ }
+ }
+
+ static char charAt(String s, int i) {
+ return i >= s.length() ? 0 : s.charAt(i);
+ }
+}
\ No newline at end of file