Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

working on productorders

  • Loading branch information...
commit a49a228ff5fa24f393ca75dc6a87493b86050930 1 parent 2588fbe
@anti43 authored
View
380 src/enoa/connection/NoaConnectionLocalServer.java
@@ -50,182 +50,184 @@
*/
public class NoaConnectionLocalServer extends NoaConnection {
- private static List<Process> ooProcesses = new ArrayList<Process>();
+ private static List<Process> ooProcesses = new ArrayList<Process>();
- /**
- * Creates a connection, depending on the current local config.
- *
- * @return
- */
- public synchronized static NoaConnection getConnection() {
- if (LocalSettings.hasProperty(LocalSettings.OFFICE_HOST)) {
- if (cachedConnection == null) {
- try {
- cachedConnection = new NoaConnectionLocalServer(LocalSettings.getProperty(LocalSettings.OFFICE_HOST), Long.valueOf(LocalSettings.getProperty(LocalSettings.OFFICE_PORT)));
- } catch (Exception ex) {
- mpv5.logging.Log.Debug(ex);//Logger.getLogger(NoaConnection.class.getName()).log(Level.SEVERE, null, ex);
- YabsViewProxy.instance().addMessage(Messages.OOCONNERROR + "\n" + ex, Color.RED);
- }
- YabsViewProxy.instance().showOfficeStatus(cachedConnection != null, "Local server");
+ /**
+ * Creates a connection, depending on the current local config.
+ *
+ * @return
+ */
+ public synchronized static NoaConnection getConnection() {
+ if (LocalSettings.hasProperty(LocalSettings.OFFICE_HOST)) {
+ if (cachedConnection == null) {
+ try {
+ cachedConnection = new NoaConnectionLocalServer(LocalSettings.getProperty(LocalSettings.OFFICE_HOST), Integer.valueOf(LocalSettings.getProperty(LocalSettings.OFFICE_PORT)));
+ } catch (Exception ex) {
+ mpv5.logging.Log.Debug(ex);//Logger.getLogger(NoaConnection.class.getName()).log(Level.SEVERE, null, ex);
+ YabsViewProxy.instance().addMessage(Messages.OOCONNERROR + "\n" + ex, Color.RED);
}
- return cachedConnection;
- } else {
- throw new UnsupportedOperationException("OpenOffice is not configured yet.");
- }
- }
+ YabsViewProxy.instance().showOfficeStatus(cachedConnection != null, "Local server");
+ }
+ return cachedConnection;
+ } else {
+ throw new UnsupportedOperationException("OpenOffice is not configured yet.");
+ }
+ }
- /**
- * clears the onnnetion for testing puproses
- */
- public static void clearConnection() {
- cachedConnection = null;
- }
+ /**
+ * clears the onnnetion for testing puproses
+ */
+ public static void clearConnection() {
+ cachedConnection = null;
+ }
- /**
- * New NoaConnection instance, connects to OO using the given parameters.
- *
- * @param connectionString The connection String. Can be a <b>Path<b/> or an
- * <b>IP<b/>
- * @param port The port to connect to. A port value of zero (0) indicates a
- * <b>local<b/> connection
- * @throws Exception If any Exception is thrown during the connection
- * attempt
- */
- public NoaConnectionLocalServer(String connectionString, Long port) throws Exception {
- Log.Debug(this, connectionString);
- if (connectionString != null && connectionString.length() > 1 && port > 0 && port < 9999) {
- createServerConnection(connectionString, port.intValue());
- } else {
- throw new Exception("Connection not possible with the given parameters: [" + connectionString + ":" + port + "]");
- }
- }
+ /**
+ * New NoaConnection instance, connects to OO using the given parameters.
+ *
+ * @param connectionString The connection String. Can be a <b>Path<b/> or an
+ * <b>IP<b/>
+ * @param port The port to connect to. A port value of zero (0) indicates a
+ * <b>local<b/> connection
+ * @throws Exception If any Exception is thrown during the connection attempt
+ */
+ public NoaConnectionLocalServer(String connectionString, int port) throws Exception {
+ Log.Debug(this, connectionString);
+ if (port == 0) {
+ port = 8100;
+ }
+ if (connectionString != null && connectionString.length() > 1 && port > 0 && port < 9999) {
+ createServerConnection(connectionString, port);
+ } else {
+ throw new Exception("Connection not possible with the given parameters: [" + connectionString + ":" + port + "]");
+ }
+ }
- /**
- * Creates a new connection
- *
- * @param host
- * @param port
- * @return
- * @throws OfficeApplicationException
- * @throws NOAException
- * @throws InvalidArgumentException
- */
- private synchronized boolean createServerConnection(String host, int port) throws OfficeApplicationException, NOAException, InvalidArgumentException {
- if (host != null && port > 0) {
- Map<String, String> configuration = new HashMap<String, String>();
- configuration.put(IOfficeApplication.APPLICATION_TYPE_KEY,
- IOfficeApplication.REMOTE_APPLICATION);
- configuration.put(IOfficeApplication.APPLICATION_HOST_KEY, host.replace("http://", ""));
- configuration.put(IOfficeApplication.APPLICATION_PORT_KEY, String.valueOf(port));
+ /**
+ * Creates a new connection
+ *
+ * @param host
+ * @param port
+ * @return
+ * @throws OfficeApplicationException
+ * @throws NOAException
+ * @throws InvalidArgumentException
+ */
+ private synchronized boolean createServerConnection(String host, int port) throws OfficeApplicationException, NOAException, InvalidArgumentException {
+ if (host != null && port > 0) {
+ Map<String, String> configuration = new HashMap<String, String>();
+ configuration.put(IOfficeApplication.APPLICATION_TYPE_KEY,
+ IOfficeApplication.REMOTE_APPLICATION);
+ configuration.put(IOfficeApplication.APPLICATION_HOST_KEY, host.replace("http://", ""));
+ configuration.put(IOfficeApplication.APPLICATION_PORT_KEY, String.valueOf(port));
- officeAplication =
- OfficeApplicationRuntime.getApplication(configuration);
- officeAplication.setConfiguration(configuration);
+ officeAplication =
+ OfficeApplicationRuntime.getApplication(configuration);
+ officeAplication.setConfiguration(configuration);
+ try {
+ officeAplication.activate(Notificator.getOfficeMonitor());
+ } catch (Throwable officeApplicationException) {
try {
- officeAplication.activate(Notificator.getOfficeMonitor());
- } catch (Throwable officeApplicationException) {
- try {
- Thread.sleep(6666);
- Notificator.raiseNotification(Messages.OO_WAITING, false);
- } catch (InterruptedException ex) {
- }
- try {
- officeAplication.activate(Notificator.getOfficeMonitor());
- } catch (Throwable officeApplicationException1) {
- Log.Debug(officeApplicationException1);
- Notificator.raiseNotification(officeApplicationException1, true);
- }
+ Thread.sleep(6666);
+ Notificator.raiseNotification(Messages.OO_WAITING, false);
+ } catch (InterruptedException ex) {
}
- if (officeAplication.isActive()) {
- documentService = officeAplication.getDocumentService();
- desktopService = officeAplication.getDesktopService();
- } else {
- throw new RuntimeException("Office " + officeAplication + " cannot get activated .. " + new ArrayList(configuration.values()));
+ try {
+ officeAplication.activate(Notificator.getOfficeMonitor());
+ } catch (Throwable officeApplicationException1) {
+ Log.Debug(officeApplicationException1);
+ Notificator.raiseNotification(officeApplicationException1, true);
}
- setType(TYPE_REMOTE);
- } else {
- throw new InvalidArgumentException("Host cannot be null and port must be > 0: " + host + ":" + port);
- }
+ }
+ if (officeAplication.isActive()) {
+ documentService = officeAplication.getDocumentService();
+ desktopService = officeAplication.getDesktopService();
+ } else {
+ throw new RuntimeException("Office " + officeAplication + " cannot get activated .. " + new ArrayList(configuration.values()));
+ }
+ setType(TYPE_REMOTE);
+ } else {
+ throw new InvalidArgumentException("Host cannot be null and port must be > 0: " + host + ":" + port);
+ }
- return true;
- }
+ return true;
+ }
- public static void killConnection() {
- try {
- YabsViewProxy.instance().setWaiting(true);
- YabsViewProxy.instance().setProgressRunning(true);
- try {
- if (cachedConnection != null) {
- cachedConnection.getDesktopService().terminate();
- }
- if (officeAplication != null) {
- officeAplication.deactivate();
- }
- } catch (Exception ex) {
- Log.Debug(NoaConnectionLocalServer.class, ex.getMessage());
- } finally {
- cachedConnection = null;
- officeAplication = null;
+ public static void killConnection() {
+ try {
+ YabsViewProxy.instance().setWaiting(true);
+ YabsViewProxy.instance().setProgressRunning(true);
+ try {
+ if (cachedConnection != null) {
+ cachedConnection.getDesktopService().terminate();
}
- } catch (Exception ex) {
- Logger.getLogger(NoaConnectionLocalServer.class.getName()).log(Level.SEVERE, null, ex);
- } finally {
- try {
- for (int i = 0; i < ooProcesses.size(); i++) {
- Process officeProcess = (Process) ooProcesses.get(i);
- if (officeProcess != null) {
- officeProcess.destroy();
- officeProcess.waitFor();
- }
- }
- } catch (Exception e) {
- Logger.getLogger(NoaConnectionLocalServer.class.getName()).log(Level.SEVERE, null, e);
+ if (officeAplication != null) {
+ officeAplication.deactivate();
}
- YabsViewProxy.instance().setWaiting(false);
- YabsViewProxy.instance().setProgressReset();
- YabsViewProxy.instance().showOfficeStatus(false, "");
- }
- }
+ } catch (Exception ex) {
+ Log.Debug(NoaConnectionLocalServer.class, ex.getMessage());
+ } finally {
+ cachedConnection = null;
+ officeAplication = null;
+ }
+ } catch (Exception ex) {
+ Logger.getLogger(NoaConnectionLocalServer.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ try {
+ for (int i = 0; i < ooProcesses.size(); i++) {
+ Process officeProcess = (Process) ooProcesses.get(i);
+ if (officeProcess != null) {
+ officeProcess.destroy();
+ officeProcess.waitFor();
+ }
+ }
+ } catch (Exception e) {
+ Logger.getLogger(NoaConnectionLocalServer.class.getName()).log(Level.SEVERE, null, e);
+ }
+ YabsViewProxy.instance().setWaiting(false);
+ YabsViewProxy.instance().setProgressReset();
+ YabsViewProxy.instance().showOfficeStatus(false, "");
+ }
+ }
- /**
- * -1 indicates no connection.
- *
- * @return the type
- */
- public synchronized int getType() {
- return type;
- }
+ /**
+ * -1 indicates no connection.
+ *
+ * @return the type
+ */
+ public synchronized int getType() {
+ return type;
+ }
- /**
- * @param type the type to set
- */
- private synchronized void setType(int type) {
- this.type = type;
- }
+ /**
+ * @param type the type to set
+ */
+ private synchronized void setType(int type) {
+ this.type = type;
+ }
- /**
- * @return the documentService
- */
- public synchronized IDocumentService getDocumentService() {
- return documentService;
- }
+ /**
+ * @return the documentService
+ */
+ public synchronized IDocumentService getDocumentService() {
+ return documentService;
+ }
- /**
- * @return the desktopService
- */
- public synchronized IDesktopService getDesktopService() {
- return desktopService;
- }
+ /**
+ * @return the desktopService
+ */
+ public synchronized IDesktopService getDesktopService() {
+ return desktopService;
+ }
- /**
- * Tries to start OO in headless server mode.
- * <code>Give it at least 3-4 seconds before attempting to use the server.</code>
- *
- * @param path The path where the OO installation resides
- * @param port The port the server shall listen to
- * @throws IOException
- */
- public synchronized static void startOOServerIfNotRunning(final String path, final int port) {
+ /**
+ * Tries to start OO in headless server mode.
+ * <code>Give it at least 3-4 seconds before attempting to use the server.</code>
+ *
+ * @param path The path where the OO installation resides
+ * @param port The port the server shall listen to
+ * @throws IOException
+ */
+ public synchronized static void startOOServerIfNotRunning(final String path, final int port) {
// final String command = path.replace("\\", "\\\\") + File.separator + LocalSettings.getProperty(LocalSettings.OFFICE_BINARY_FOLDER) + File.separator + "soffice" + " "
// + "-headless" + " "
@@ -237,40 +239,40 @@ public synchronized static void startOOServerIfNotRunning(final String path, fin
// + (Main.osIsWindows ? "-accept=socket,host=0.0.0.0,port=" + port + ";urp;StarOffice.Service"
// : "-accept='socket,host=0.0.0.0,port=" + port + ";urp;StarOffice.Service'");
- try {
- SocketAddress addr = new InetSocketAddress("127.0.0.1", port);
- Socket socket = new Socket();
- socket.connect(addr, 100);
- throw new UnsupportedOperationException("Port " + port + " is already in use :-/. Not going to start OO here.");
- } catch (IOException iOException) {
- //nothing is running here
- }
+ try {
+ SocketAddress addr = new InetSocketAddress("127.0.0.1", port);
+ Socket socket = new Socket();
+ socket.connect(addr, 100);
+ throw new UnsupportedOperationException("Port " + port + " is already in use :-/. Not going to start OO here.");
+ } catch (IOException iOException) {
+ //nothing is running here
+ }
- Runnable runnable = new Runnable() {
- public void run() {
- if (LocalSettings.hasProperty(LocalSettings.OFFICE_COMMAND)) {
- FileExecutor.run(LocalSettings.getProperty(LocalSettings.OFFICE_COMMAND));
- } else {
- FileExecutor.run(getOOArgs(path, port));
- }
+ Runnable runnable = new Runnable() {
+ public void run() {
+ if (LocalSettings.hasProperty(LocalSettings.OFFICE_COMMAND)) {
+ FileExecutor.run(LocalSettings.getProperty(LocalSettings.OFFICE_COMMAND));
+ } else {
+ FileExecutor.run(getOOArgs(path, port));
}
- };
+ }
+ };
- Thread t = new Thread(runnable);
- t.setDaemon(true);
- t.start();
+ Thread t = new Thread(runnable);
+ t.setDaemon(true);
+ t.start();
- }
+ }
- /**
- * Tries to start OO in headless server mode.
- * <code>Give it at least 3-4 seconds before attempting to use the server.</code>
- *
- * @param path The path where the OO installation resides
- * @param port The port the server shall listen to
- * @throws IOException
- */
- public synchronized static void startOOServer(String path, int port) throws IOException {
- FileExecutor.run(getOOArgs(path, port), ooProcesses);
- }
+ /**
+ * Tries to start OO in headless server mode.
+ * <code>Give it at least 3-4 seconds before attempting to use the server.</code>
+ *
+ * @param path The path where the OO installation resides
+ * @param port The port the server shall listen to
+ * @throws IOException
+ */
+ public synchronized static void startOOServer(String path, int port) throws IOException {
+ FileExecutor.run(getOOArgs(path, port), ooProcesses);
+ }
}
View
4,745 src/mpv5/db/common/DatabaseObject.java
2,374 additions, 2,371 deletions not shown
View
1,779 src/mpv5/db/objects/SubItem.java
@@ -45,918 +45,927 @@
/**
*
- *
+ *
*/
public final class SubItem extends DatabaseObject implements Triggerable {
- public static final int TYPE_TEXT = 1;
- public static final int TYPE_PRODUCT = 2;
- public static final int TYPE_NORMAL = 0;
- private static final long serialVersionUID = 1L;
-
- public static LinkedList<SubItem> saveModel(Item dataOwner, MPTableModel model, boolean deleteRemovedSubitems, boolean cloneSubitems) {
- List<Object[]> rowsl = model.getValidRows(new int[]{4});
- LinkedList<SubItem> items = new LinkedList<SubItem>();
- Log.Debug(SubItem.class, "Rows found: " + rowsl.size());
- for (int i = 0; i < rowsl.size(); i++) {
- Object[] row = rowsl.get(i);
- for (int j = 0; j < row.length; j++) {
- if (row[j] == null) {
- row[j] = "";
- }
+ public static final int TYPE_TEXT = 1;
+ public static final int TYPE_PRODUCT = 2;
+ public static final int TYPE_NORMAL = 0;
+ private static final long serialVersionUID = 1L;
+
+ public static LinkedList<SubItem> saveModel(Item dataOwner, MPTableModel model, boolean deleteRemovedSubitems, boolean cloneSubitems) {
+ List<Object[]> rowsl = model.getValidRows(new int[]{4});
+ LinkedList<SubItem> items = new LinkedList<SubItem>();
+ Log.Debug(SubItem.class, "Rows found: " + rowsl.size());
+ for (int i = 0; i < rowsl.size(); i++) {
+ Object[] row = rowsl.get(i);
+ for (int j = 0; j < row.length; j++) {
+ if (row[j] == null) {
+ row[j] = "";
+ }
+ }
+ SubItem it = new SubItem();
+ it.setOrdernr(i);
+ Log.Print(Arrays.asList(row));
+ try {
+ if (!cloneSubitems && row[0] != null && Integer.valueOf(row[0].toString()).intValue() > 0) {
+ it.setIDS(Integer.valueOf(row[0].toString()).intValue());
+ } else {
+ it.setIDS(-1);
}
- SubItem it = new SubItem();
- it.setOrdernr(i);
- Log.Print(Arrays.asList(row));
+ } catch (Exception e) {
+ Log.Debug(SubItem.class, e.getMessage());
+ }
+ it.setCname(row[14].toString());
+ it.setItemsids(dataOwner.__getIDS());
+ it.setCountvalue(new BigDecimal(row[1].toString()));
+ it.setDatedelivery(dataOwner.__getDatetodo());
+ it.setDescription(row[4].toString());
+ it.setExternalvalue(new BigDecimal(row[5].toString()));
+ it.setInternalvalue(new BigDecimal(row[5].toString()));//not supported yet
+ it.setMeasure(row[3].toString());
+
+ if (row[10] instanceof Product) {
try {
- if (!cloneSubitems && row[0] != null && Integer.valueOf(row[0].toString()).intValue() > 0) {
- it.setIDS(Integer.valueOf(row[0].toString()).intValue());
- } else {
- it.setIDS(-1);
- }
+ it.setOriginalproductsids(((Product) row[10]).__getIDS());
} catch (Exception e) {
- Log.Debug(SubItem.class, e.getMessage());
- }
- it.setCname(row[14].toString());
- it.setItemsids(dataOwner.__getIDS());
- it.setCountvalue(new BigDecimal(row[1].toString()));
- it.setDatedelivery(dataOwner.__getDatetodo());
- it.setDescription(row[4].toString());
- it.setExternalvalue(new BigDecimal(row[5].toString()));
- it.setInternalvalue(new BigDecimal(row[5].toString()));//not supported yet
- it.setMeasure(row[3].toString());
-
- if (row[10] instanceof Product) {
- try {
- it.setOriginalproductsids(((Product) row[10]).__getIDS());
- } catch (Exception e) {
- Log.Debug(e);
- }
- } else {
+ Log.Debug(e);
}
- it.setLinkurl((row[12 + 1].toString()));
- it.setQuantityvalue(new BigDecimal(row[2].toString()));
- it.setTaxpercentvalue(new BigDecimal(row[6].toString()));
+ } else {
+ }
+ it.setLinkurl((row[12 + 1].toString()));
+ it.setQuantityvalue(new BigDecimal(row[2].toString()));
+ it.setTaxpercentvalue(new BigDecimal(row[6].toString()));
+ if (row[15].toString().trim().length() > 0) {//maybe not set at all from prodctorders
it.setDiscount(new BigDecimal(row[15].toString()));
- calculate(it);
-
- if (!it.isExisting()) {
- it.setDateadded(new Date());
- it.setGroupsids(dataOwner.__getGroupsids());
- }
- it.save(true);
- items.add(it.getOrdernr(), it);
- }
-
- if (deleteRemovedSubitems) {
- for (int i = 0; i < deletionQueue.size(); i++) {
- try {
- QueryHandler.delete(SubItem.getObject(Context.getSubItem(), deletionQueue.get(i)));
- } catch (NodataFoundException ex) {
- Log.Debug(ex);
- }
+ }
+ calculate(it);
+
+ if (!it.isExisting()) {
+ it.setDateadded(new Date());
+ it.setGroupsids(dataOwner.__getGroupsids());
+ }
+ it.save(true);
+ items.add(it.getOrdernr(), it);
+ }
+
+ if (deleteRemovedSubitems) {
+ for (int i = 0; i < deletionQueue.size(); i++) {
+ try {
+ QueryHandler.delete(SubItem.getObject(Context.getSubItem(), deletionQueue.get(i)));
+ } catch (NodataFoundException ex) {
+ Log.Debug(ex);
}
- }
- deletionQueue.clear();
- return items;
-
- }
-
- /**
- * Save the model of SubItems
- * @param dataOwner
- * @param model
- * @param deleteRemovedSubitems
- * @return
- */
- public static List<SubItem> saveModel(Item dataOwner, MPTableModel model, boolean deleteRemovedSubitems) {
- return saveModel(dataOwner, model, deleteRemovedSubitems, false);
- }
-
- /**
- * Convert the model to a list of String arrays
- * @param dataOwner
- * @param model
- * @param t
- * @return
- */
- public static LinkedList<String[]> convertModel(Item dataOwner, MPTableModel model, Template t) {
- List<Object[]> rowsl = model.getValidRows(new int[]{4});
- LinkedList<String[]> rowsk = new LinkedList<String[]>();
- Log.Debug(SubItem.class, "Rows found: " + rowsl.size());
- for (int i = 0; i < rowsl.size(); i++) {
- Object[] row = rowsl.get(i);
-
- for (int j = 0; j < row.length; j++) {
- if (row[j] == null) {
- row[j] = "";
- }
+ }
+ }
+ deletionQueue.clear();
+ return items;
+
+ }
+
+ /**
+ * Save the model of SubItems
+ *
+ * @param dataOwner
+ * @param model
+ * @param deleteRemovedSubitems
+ * @return
+ */
+ public static List<SubItem> saveModel(Item dataOwner, MPTableModel model, boolean deleteRemovedSubitems) {
+ return saveModel(dataOwner, model, deleteRemovedSubitems, false);
+ }
+
+ /**
+ * Convert the model to a list of String arrays
+ *
+ * @param dataOwner
+ * @param model
+ * @param t
+ * @return
+ */
+ public static LinkedList<String[]> convertModel(Item dataOwner, MPTableModel model, Template t) {
+ List<Object[]> rowsl = model.getValidRows(new int[]{4});
+ LinkedList<String[]> rowsk = new LinkedList<String[]>();
+ Log.Debug(SubItem.class, "Rows found: " + rowsl.size());
+ for (int i = 0; i < rowsl.size(); i++) {
+ Object[] row = rowsl.get(i);
+
+ for (int j = 0; j < row.length; j++) {
+ if (row[j] == null) {
+ row[j] = "";
}
+ }
- final SubItem it = new SubItem();
- it.setOrdernr(i);
+ final SubItem it = new SubItem();
+ it.setOrdernr(i);
+ try {
+ if (row[0] != null && Integer.valueOf(row[0].toString()).intValue() > 0) {
+ it.setIDS(Integer.valueOf(row[0].toString()).intValue());
+ } else {
+ it.setIDS(-1);
+ }
+ } catch (Exception e) {
+ Log.Debug(SubItem.class, e.getMessage());
+ }
+ it.setCname(row[14].toString());
+ it.setItemsids(dataOwner.__getIDS());
+ it.setCountvalue(new BigDecimal(row[1].toString()));
+ it.setDatedelivery(dataOwner.__getDatetodo());
+ it.setDescription(row[4].toString());
+ it.setExternalvalue(new BigDecimal(row[5].toString()));
+ it.setInternalvalue(new BigDecimal(row[5].toString()));//not supported yet
+ it.setMeasure(row[3].toString());
+ it.setOriginalproductsids(Integer.valueOf(row[10].toString()));
+ if (row[10] instanceof Product) {
try {
- if (row[0] != null && Integer.valueOf(row[0].toString()).intValue() > 0) {
- it.setIDS(Integer.valueOf(row[0].toString()).intValue());
- } else {
- it.setIDS(-1);
- }
+ it.setOriginalproductsids(((Product) row[10]).__getIDS());
} catch (Exception e) {
- Log.Debug(SubItem.class, e.getMessage());
+ Log.Debug(e);
}
- it.setCname(row[14].toString());
- it.setItemsids(dataOwner.__getIDS());
- it.setCountvalue(new BigDecimal(row[1].toString()));
- it.setDatedelivery(dataOwner.__getDatetodo());
- it.setDescription(row[4].toString());
- it.setExternalvalue(new BigDecimal(row[5].toString()));
- it.setInternalvalue(new BigDecimal(row[5].toString()));//not supported yet
- it.setMeasure(row[3].toString());
- it.setOriginalproductsids(Integer.valueOf(row[10].toString()));
- if (row[10] instanceof Product) {
- try {
- it.setOriginalproductsids(((Product) row[10]).__getIDS());
- } catch (Exception e) {
- Log.Debug(e);
- }
- }
- it.setQuantityvalue(new BigDecimal(row[2].toString()));
- it.setTaxpercentvalue(new BigDecimal(row[6].toString()));
- it.setLinkurl((row[12 + 1].toString()));
- it.setDiscount(new BigDecimal(row[15].toString()));
+ }
+ it.setQuantityvalue(new BigDecimal(row[2].toString()));
+ it.setTaxpercentvalue(new BigDecimal(row[6].toString()));
+ it.setLinkurl((row[12 + 1].toString()));
+ it.setDiscount(new BigDecimal(row[15].toString()));
- calculate(it);
+ calculate(it);
- if (!it.isExisting()) {
- it.setDateadded(new Date());
- it.setGroupsids(dataOwner.__getGroupsids());
- }
+ if (!it.isExisting()) {
+ it.setDateadded(new Date());
+ it.setGroupsids(dataOwner.__getGroupsids());
+ }
// it.save();
- rowsk.add(it.getOrdernr(), it.toStringArray());
- }
-
- return rowsk;
- }
- private static List<Integer> deletionQueue = new ArrayList<Integer>();
-
- /**
- * Mark a subitem for deletion
- * @param valueAt INT or Entity
- */
- public static void addToDeletionQueue(Object valueAt) {
- Log.Debug(SubItem.class, "Adding to deletionqueue: " + valueAt);
- if (valueAt != null) {
- try {
- Integer isd = Integer.valueOf(valueAt.toString());
- deletionQueue.add(isd);
- } catch (NumberFormatException numberFormatException) {
- Integer isd = ((Entity) valueAt).getValue();
- deletionQueue.add(isd);
- }
- }
- }
-
- /**
- * UN-Mark a subitem for deletion
- * @param valueAt INT or Entity
- */
- public static void removeFromDeletionQueue(Object valueAt) {
- Log.Debug(SubItem.class, "Removing from deletionqueue: " + valueAt);
- if (valueAt != null) {
- try {
- Integer isd = Integer.valueOf(valueAt.toString());
- deletionQueue.remove(isd);
- } catch (NumberFormatException numberFormatException) {
- Integer isd = ((Entity) valueAt).getValue();
- deletionQueue.add(isd);
- }
- }
- }
- private int itemsids;
- private int ordernr;
- private int inttype;
- private int originalproductsids;
- private BigDecimal countvalue = BigDecimal.ZERO;
- private BigDecimal quantityvalue = BigDecimal.ZERO;
- private String measure = "";
- private String description = "";
- private String linkurl = "";
- private BigDecimal internalvalue = BigDecimal.ZERO;
- private BigDecimal externalvalue = BigDecimal.ZERO;
- private BigDecimal taxpercentvalue = BigDecimal.ZERO;
- private BigDecimal totalnetvalue = BigDecimal.ZERO;
- private BigDecimal totalbrutvalue = BigDecimal.ZERO;
- private Date datedelivery;
- private BigDecimal totaltaxvalue = BigDecimal.ZERO;
- private BigDecimal discount = BigDecimal.ZERO;
- private BigDecimal discvalue = BigDecimal.ZERO;
-
- public SubItem() {
- setContext(Context.getSubItem());
- }
-
- /**
- *
- * @return
- */
- public static SubItem getDefaultItem() {
- SubItem i = new SubItem();
-
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defunit")) {
- String defunit = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defunit");
- i.setMeasure(defunit);
- }
- BigDecimal deftax = BigDecimal.ZERO;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("deftax")) {
- int taxid = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("deftax", new Integer(0));
- deftax = Tax.getTaxValue(taxid);
- }
- i.setTaxpercentvalue(deftax);
-
- BigDecimal defdiscount = BigDecimal.ZERO;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defdiscount")) {
- defdiscount = new BigDecimal(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defdiscount"));
- }
- i.setDiscount(defdiscount);
-
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defcount")) {
- Double defcount = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defcount", 0d);
- i.setQuantityvalue(new BigDecimal(defcount.toString()));
- } else {
- i.setQuantityvalue(BigDecimal.ONE);
- }
-
- return i;
- }
-
- /**
- *
- * @param product
- */
- public SubItem(Product product) {
- this();
- setCname(product.__getCname());
- setDateadded(new Date());
- setDatedelivery(new Date());
+ rowsk.add(it.getOrdernr(), it.toStringArray());
+ }
+
+ return rowsk;
+ }
+ private static List<Integer> deletionQueue = new ArrayList<Integer>();
+
+ /**
+ * Mark a subitem for deletion
+ *
+ * @param valueAt INT or Entity
+ */
+ public static void addToDeletionQueue(Object valueAt) {
+ Log.Debug(SubItem.class, "Adding to deletionqueue: " + valueAt);
+ if (valueAt != null) {
+ try {
+ Integer isd = Integer.valueOf(valueAt.toString());
+ deletionQueue.add(isd);
+ } catch (NumberFormatException numberFormatException) {
+ Integer isd = ((Entity) valueAt).getValue();
+ deletionQueue.add(isd);
+ }
+ }
+ }
+
+ /**
+ * UN-Mark a subitem for deletion
+ *
+ * @param valueAt INT or Entity
+ */
+ public static void removeFromDeletionQueue(Object valueAt) {
+ Log.Debug(SubItem.class, "Removing from deletionqueue: " + valueAt);
+ if (valueAt != null) {
+ try {
+ Integer isd = Integer.valueOf(valueAt.toString());
+ deletionQueue.remove(isd);
+ } catch (NumberFormatException numberFormatException) {
+ Integer isd = ((Entity) valueAt).getValue();
+ deletionQueue.add(isd);
+ }
+ }
+ }
+ private int itemsids;
+ private int ordernr;
+ private int inttype;
+ private int originalproductsids;
+ private BigDecimal countvalue = BigDecimal.ZERO;
+ private BigDecimal quantityvalue = BigDecimal.ZERO;
+ private String measure = "";
+ private String description = "";
+ private String linkurl = "";
+ private BigDecimal internalvalue = BigDecimal.ZERO;
+ private BigDecimal externalvalue = BigDecimal.ZERO;
+ private BigDecimal taxpercentvalue = BigDecimal.ZERO;
+ private BigDecimal totalnetvalue = BigDecimal.ZERO;
+ private BigDecimal totalbrutvalue = BigDecimal.ZERO;
+ private Date datedelivery;
+ private BigDecimal totaltaxvalue = BigDecimal.ZERO;
+ private BigDecimal discount = BigDecimal.ZERO;
+ private BigDecimal discvalue = BigDecimal.ZERO;
+
+ public SubItem() {
+ setContext(Context.getSubItem());
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static SubItem getDefaultItem() {
+ SubItem i = new SubItem();
+
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defunit")) {
+ String defunit = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defunit");
+ i.setMeasure(defunit);
+ }
+ BigDecimal deftax = BigDecimal.ZERO;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("deftax")) {
+ int taxid = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("deftax", new Integer(0));
+ deftax = Tax.getTaxValue(taxid);
+ }
+ i.setTaxpercentvalue(deftax);
+
+ BigDecimal defdiscount = BigDecimal.ZERO;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defdiscount")) {
+ defdiscount = new BigDecimal(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defdiscount"));
+ }
+ i.setDiscount(defdiscount);
+
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defcount")) {
+ Double defcount = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defcount", 0d);
+ i.setQuantityvalue(new BigDecimal(defcount.toString()));
+ } else {
+ i.setQuantityvalue(BigDecimal.ONE);
+ }
+
+ return i;
+ }
+
+ /**
+ *
+ * @param product
+ */
+ public SubItem(Product product) {
+ this();
+ setCname(product.__getCname());
+ setDateadded(new Date());
+ setDatedelivery(new Date());
////////////////format///////////////////////////////////////////////////////////
- Context contextl = product.getContext();
- String params = "cname";
- String vars = null;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty(contextl + mpv5.ui.beans.LightMPComboBox.VALUE_SEARCHFIELDS)
- && mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(contextl + mpv5.ui.beans.LightMPComboBox.VALUE_SEARCHFIELDS).contains("_$")) {
- try {
- params = "ids";
- vars = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(contextl + mpv5.ui.beans.LightMPComboBox.VALUE_SEARCHFIELDS);
- String[] vaars = vars.split("_\\$");
-
- for (int i = 0; i < vaars.length; i++) {
- try {
- if (vaars[i] != null && vaars[i].contains("$_")) {
- params += "," + vaars[i].split("\\$_")[0].replace(",", "").replace("'", "`");
- }
- } catch (Exception e) {
- Log.Debug(e);
- }
- }
-
- QueryCriteria qc = new QueryCriteria("ids", product.__getIDS());
- Object[][] result = QueryHandler.instanceOf().clone(Context.getProduct()).select(params, qc);
-
- String formatString = vars;
- if (formatString != null) {
- vaars = formatString.split("_\\$");
- Log.Debug(MPComboBoxModelItem.class, "Length of var string: " + vaars.length);
- }
- String x = "";
- String format = formatString;
- for (int j = 1; j < result[0].length; j++) {
- String k = String.valueOf(result[0][j]);
- if (format == null) {
- x += k;
- } else {
- try {
- format = format.replaceFirst("_\\$(.*?)\\$_", k);
- } catch (Exception e) {
- Log.Debug(e);
- }
- x = format;
- }
- }
-
- setDescription(VariablesHandler.parse(x, product));
- } catch (NodataFoundException nodataFoundException) {
- setDescription(VariablesHandler.parse(product.__getCname(), product));
+ Context contextl = product.getContext();
+ String params = "cname";
+ String vars = null;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty(contextl + mpv5.ui.beans.LightMPComboBox.VALUE_SEARCHFIELDS)
+ && mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(contextl + mpv5.ui.beans.LightMPComboBox.VALUE_SEARCHFIELDS).contains("_$")) {
+ try {
+ params = "ids";
+ vars = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(contextl + mpv5.ui.beans.LightMPComboBox.VALUE_SEARCHFIELDS);
+ String[] vaars = vars.split("_\\$");
+
+ for (int i = 0; i < vaars.length; i++) {
+ try {
+ if (vaars[i] != null && vaars[i].contains("$_")) {
+ params += "," + vaars[i].split("\\$_")[0].replace(",", "").replace("'", "`");
+ }
+ } catch (Exception e) {
+ Log.Debug(e);
+ }
}
- } else {
- Log.Debug(SubItem.class, "No format defined..");
- setDescription(VariablesHandler.parse(product.__getCname(), product));
- }
-///////////////end format////////////////////////////////////////////////////////
- setExternalvalue(product.findPriceFor(1d));
- setGroupsids(mpv5.db.objects.User.getCurrentUser().__getGroupsids());
- setIntaddedby(mpv5.db.objects.User.getCurrentUser().__getIDS());
- setInternalvalue(product.__getInternalnetvalue());
- setMeasure(product.__getMeasure());
- setOriginalproductsids(product.__getIDS());
- setQuantityvalue(BigDecimal.ONE);
- setTaxpercentvalue(Tax.getTaxValue(product.__getTaxids()));
- setLinkurl(product.__getUrl());
- calculate(this);
- }
-
- /**
- * Generates a SubItem with useless sample data
- * @return
- */
- public static SubItem getRandomItem() {
- SubItem i = new SubItem();
- i.fillSampleData();
- i.setGroupsids(1);
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defunit")) {
- String defunit = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defunit");
- i.setMeasure(defunit);
- }
- BigDecimal deftax = BigDecimal.ZERO;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("deftax")) {
- int taxid = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("deftax", 0);
- deftax = Tax.getTaxValue(taxid);
- i.setTaxpercentvalue(deftax);
- }
- Double defcount = 1d;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defcount")) {
- defcount = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defcount", 0d);
- i.setQuantityvalue(new BigDecimal(defcount.toString()));
- }
- return i;
- }
-
- /**
- * Generates a String array out of this SubItem
- * @return
- */
- public synchronized String[] toStringArray() {
- calculate(this);
-
- List<String> all = new LinkedList<String>();
-
- String[] possibleCols = new String[]{
- ////////////////// The exported columns///////////////////////////////////////
- getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatInteger(this.__getCountvalue())) : "",
- getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatDezimal(this.__getQuantityvalue())) : "",
- getInttype() != TYPE_TEXT ? __getMeasure() : "",
- __getDescription(),
- getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.__getExternalvalue())) : "",
- getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.__getTotalnetvalue())) : "",
- getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatPercent(this.__getTaxpercentvalue())) : "",
- getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.getTotalTaxValue())) : "",
- getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.__getTotalbrutvalue())) : "",
- __getLinkurl(),
- __getCname()
- ///////////////////////////////////////////////////////////////////////////////
- };
- List<String> l = Arrays.asList(possibleCols);
- all.addAll(l);
-
- if (GlobalSettings.getBooleanProperty("org.openyabs.exportproperty.productsresolved", false) && __getOriginalproductsids() > 0) {
- try {
- Product p = (Product) DatabaseObject.getObject(Context.getProduct(), __getOriginalproductsids());
- List<String[]> vals = p.getValues3();
- Collections.sort(vals, new Comparator<String[]>() {
-
- public int compare(String[] o1, String[] o2) {
- return o1[0].compareTo(o2[0]);
- }
- });
- for (int i = 0; i < vals.size(); i++) {
- String[] v = vals.get(i);
- all.add(v[1]);
- if (Log.getLoglevel() == Log.LOGLEVEL_DEBUG) {
- Log.Debug(this, (12 + i) + ": " + v[0] + " ");
- }
- }
- } catch (Exception ex) {
- Log.Debug(ex);
- }
- }
-
- return all.toArray(new String[0]);
- }
-
-
- /**
- * @return the itemsids
- */
- public int __getItemsids() {
- return itemsids;
- }
-
- /**
- * @param itemsids the itemsids to set
- */
- public void setItemsids(int itemsids) {
- this.itemsids = itemsids;
- }
-
- /**
- * @return the originalproductsids
- */
- public int __getOriginalproductsids() {
- return originalproductsids;
- }
-
- /**
- * @param originalproductsids the originalproductsids to set
- */
- public void setOriginalproductsids(int originalproductsids) {
- this.originalproductsids = originalproductsids;
- if (originalproductsids > 0) {
- setInttype(TYPE_PRODUCT);
- } else {
- setInttype(TYPE_NORMAL);
- }
- }
-
- /**
- * @return the count
- */
- public BigDecimal __getCountvalue() {
- return countvalue;
- }
-
- /**
- * @param count the count to set
- */
- public void setCountvalue(BigDecimal count) {
- this.countvalue = count;
- }
-
- /**
- * @return the quantity
- */
- public BigDecimal __getQuantityvalue() {
- return quantityvalue;
- }
-
- /**
- * @param quantity the quantity to set
- */
- public void setQuantityvalue(BigDecimal quantity) {
- this.quantityvalue = quantity;
- if (quantity.compareTo(BigDecimal.ZERO) == 0) {
- setInttype(TYPE_TEXT);
- }
- }
-
- /**
- * @return the measure
- */
- public String __getMeasure() {
- return measure;
- }
-
- /**
- * @param measure the measure to set
- */
- public void setMeasure(String measure) {
- this.measure = measure;
- }
-
- /**
- * @return the description
- */
- public String __getDescription() {
- return description;
- }
-
- /**
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the taxpercent
- */
- public BigDecimal __getTaxpercentvalue() {
- return taxpercentvalue;
- }
-
- /**
- * @param taxpercent the taxpercent to set
- */
- public void setTaxpercentvalue(BigDecimal taxpercent) {
- this.taxpercentvalue = taxpercent;
- }
-
- /**
- * @return the datedelivery
- */
- public Date __getDatedelivery() {
- return datedelivery;
- }
-
- /**
- * @param datedelivery the datedelivery to set
- */
- public void setDatedelivery(Date datedelivery) {
- this.datedelivery = datedelivery;
- }
-
- /**
- *
- * @return
- */
- public BigDecimal __getDiscount() {
- return discount;
- }
-
- /**
- *
- * @param discount
- */
- public void setDiscount(BigDecimal discount) {
- this.discount = discount;
- }
-
- public BigDecimal getDiscvalue() {
- return discvalue;
- }
-
- public void defDiscvalue(BigDecimal discvalue) {
- this.discvalue = discvalue;
- }
-
- @Override
- public JComponent getView() {
- try {
- Item dos = (Item) DatabaseObject.getObject(Context.getItem(), __getItemsids());
- ItemPanel ip = new ItemPanel(Context.getItem(), dos.__getInttype());
- return ip;
- } catch (NodataFoundException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- @Override
- public mpv5.utils.images.MPIcon getIcon() {
- return null;
- }
-
- /**
- * Generates a table model out of the given SubItems
- * @param items
- * @return
- */
- public static MPTableModel toModel(SubItem[] items) {
- return toModel(items, false);
- }
- /**
- * The ADD button index
- */
- public static int COLUMNINDEX_ADD = 11;
- /**
- * The CLEAR button index
- */
- public static int COLUMNINDEX_REMOVE = 12;
- /**
- * Compares by ordernr
- */
- public static Comparator<SubItem> ORDER_COMPARATOR = new Comparator<SubItem>() {
-
- @Override
- public int compare(SubItem o1, SubItem o2) {
- return (o1.getOrdernr() > o2.getOrdernr()) ? 1 : -1;
- }
- };
-
- /**
- * Generates a table model out of the given SubItems
- * @param items
- * @param removeSubitemIds
- * @return
- */
- public static MPTableModel toModel(SubItem[] items, boolean removeSubitemIds) {
- //"Internal ID", "ID", "Count", "Measure", "Description", "Netto Price", "Tax Value", "Total Price"
- Object[][] data = new Object[items.length][];
- List<SubItem> tlist = new LinkedList<SubItem>();
- tlist.addAll(Arrays.asList(items));
- Collections.sort(tlist, SubItem.ORDER_COMPARATOR);
-
- for (int i = 0; i < tlist.size(); i++) {
- SubItem subItem = tlist.get(i);
- if (subItem != null) {
- data[i] = subItem.getRowData(i + 1);
- } else {
- data[i] = getDefaultItem().getRowData(i + 1);
- }
- if (removeSubitemIds) {
- data[i][0] = -1;
+
+ QueryCriteria qc = new QueryCriteria("ids", product.__getIDS());
+ Object[][] result = QueryHandler.instanceOf().clone(Context.getProduct()).select(params, qc);
+
+ String formatString = vars;
+ if (formatString != null) {
+ vaars = formatString.split("_\\$");
+ Log.Debug(MPComboBoxModelItem.class, "Length of var string: " + vaars.length);
}
- }
-
-
- MPTableModel model = new MPTableModel(
- new Class[]{
- Integer.class, Integer.class, BigDecimal.class, String.class, Object.class, BigDecimal.class, BigDecimal.class, BigDecimal.class,
- BigDecimal.class, BigDecimal.class, Product.class, JButton.class, JButton.class, String.class, String.class, BigDecimal.class, BigDecimal.class},
- new boolean[]{false, false, true, true, true, true, true, false, false, false, false, true, true, true, true, true, true, true},
- data,
- Headers.SUBITEMS.getValue());
-
- model.setContext(Context.getSubItem());
- String defunit = null;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defunit")) {
- defunit = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defunit");
- }
- BigDecimal deftax = BigDecimal.ZERO;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("deftax")) {
- int taxid = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("deftax", 0);
- deftax = Tax.getTaxValue(taxid);
- }
- Double defcount = 1d;
- if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defcount")) {
- defcount = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defcount", 0d);
- }
- model.defineRow(new Object[]{0, 0, defcount, defunit, null, 0.0, deftax, 0.0, 0.0, 0.0, null, "A", "C", "", "", 0.0, 0.0});
- model.setAutoCountColumn(1);
-
- return model;
- }
-
- /**
- * Turn this SubItem into table row data
- * @param row
- * @return
- */
- public synchronized Object[] getRowData(int row) {
- Object[] data = new Object[17];
- for (int i = 0; i < data.length; i++) {
- data[0] = __getIDS();
- data[1] = Integer.valueOf(row);
- data[2] = __getQuantityvalue();
- data[3] = __getMeasure();
- data[4] = __getDescription();
- data[5] = __getExternalvalue();
- data[6] = __getTaxpercentvalue();
- data[7] = __getQuantityvalue().multiply(__getExternalvalue().multiply(((__getTaxpercentvalue().divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP).add(BigDecimal.ONE)))));
- data[8] = 0.0;
- data[9] = 0.0;
- if (__getOriginalproductsids() > 0) {
- try {
- data[10] = Product.getObject(Context.getProduct(), __getOriginalproductsids());
- } catch (NodataFoundException ex) {
- Log.Debug(ex);
- }
+ String x = "";
+ String format = formatString;
+ for (int j = 1; j < result[0].length; j++) {
+ String k = String.valueOf(result[0][j]);
+ if (format == null) {
+ x += k;
+ } else {
+ try {
+ format = format.replaceFirst("_\\$(.*?)\\$_", k);
+ } catch (Exception e) {
+ Log.Debug(e);
+ }
+ x = format;
+ }
}
- data[11] = "A";
- data[12] = "C";
- data[12 + 1] = __getLinkurl();
- data[14] = __getCname();
- data[15] = __getDiscount();
- data[16] = 0.0;
- }
- return data;
- }
-
- /**
- * Turn this SubItem into table row data
- * @param row
- * @return
- */
- public static synchronized SubItem getFromModel(MPTableModel m, int row) {
- SubItem t = new SubItem();
-
- if (m.getValueAt(row, 0) != null) {
- t.setIDS(Integer.valueOf(m.getValueAt(row, 0).toString()));
- }
- if (m.getValueAt(row, 1) != null) {
- t.setCountvalue(new BigDecimal(m.getValueAt(row, 1).toString()));
- }
- if (m.getValueAt(row, 2) != null) {
- t.setQuantityvalue(new BigDecimal(m.getValueAt(row, 2).toString()));
- }
- if (m.getValueAt(row, 3) != null) {
- t.setMeasure(m.getValueAt(row, 3).toString());
- }
- if (m.getValueAt(row, 4) != null) {
- t.setDescription(m.getValueAt(row, 4).toString());
- }
- if (m.getValueAt(row, 5) != null) {
- t.setExternalvalue(new BigDecimal(m.getValueAt(row, 5).toString()));
- }
- if (m.getValueAt(row, 6) != null) {
- t.setTaxpercentvalue(new BigDecimal(m.getValueAt(row, 6).toString()));
- }
- if (m.getValueAt(row, 10) != null) {
- try {
- t.setOriginalproductsids(((Product) m.getValueAt(row, 10)).__getIDS());
- } catch (Exception e) {
- Log.Debug(e);
+
+ setDescription(VariablesHandler.parse(x, product));
+ } catch (NodataFoundException nodataFoundException) {
+ setDescription(VariablesHandler.parse(product.__getCname(), product));
+ }
+ } else {
+ Log.Debug(SubItem.class, "No format defined..");
+ setDescription(VariablesHandler.parse(product.__getCname(), product));
+ }
+///////////////end format////////////////////////////////////////////////////////
+ setExternalvalue(product.findPriceFor(1d));
+ setGroupsids(mpv5.db.objects.User.getCurrentUser().__getGroupsids());
+ setIntaddedby(mpv5.db.objects.User.getCurrentUser().__getIDS());
+ setInternalvalue(product.__getInternalnetvalue());
+ setMeasure(product.__getMeasure());
+ setOriginalproductsids(product.__getIDS());
+ setQuantityvalue(BigDecimal.ONE);
+ setTaxpercentvalue(Tax.getTaxValue(product.__getTaxids()));
+ setLinkurl(product.__getUrl());
+ calculate(this);
+ }
+
+ /**
+ * Generates a SubItem with useless sample data
+ *
+ * @return
+ */
+ public static SubItem getRandomItem() {
+ SubItem i = new SubItem();
+ i.fillSampleData();
+ i.setGroupsids(1);
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defunit")) {
+ String defunit = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defunit");
+ i.setMeasure(defunit);
+ }
+ BigDecimal deftax = BigDecimal.ZERO;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("deftax")) {
+ int taxid = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("deftax", 0);
+ deftax = Tax.getTaxValue(taxid);
+ i.setTaxpercentvalue(deftax);
+ }
+ Double defcount = 1d;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defcount")) {
+ defcount = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defcount", 0d);
+ i.setQuantityvalue(new BigDecimal(defcount.toString()));
+ }
+ return i;
+ }
+
+ /**
+ * Generates a String array out of this SubItem
+ *
+ * @return
+ */
+ public synchronized String[] toStringArray() {
+ calculate(this);
+
+ List<String> all = new LinkedList<String>();
+
+ String[] possibleCols = new String[]{
+ ////////////////// The exported columns///////////////////////////////////////
+ getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatInteger(this.__getCountvalue())) : "",
+ getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatDezimal(this.__getQuantityvalue())) : "",
+ getInttype() != TYPE_TEXT ? __getMeasure() : "",
+ __getDescription(),
+ getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.__getExternalvalue())) : "",
+ getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.__getTotalnetvalue())) : "",
+ getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatPercent(this.__getTaxpercentvalue())) : "",
+ getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.getTotalTaxValue())) : "",
+ getInttype() != TYPE_TEXT ? String.valueOf(FormatNumber.formatLokalCurrency(this.__getTotalbrutvalue())) : "",
+ __getLinkurl(),
+ __getCname()
+ ///////////////////////////////////////////////////////////////////////////////
+ };
+ List<String> l = Arrays.asList(possibleCols);
+ all.addAll(l);
+
+ if (GlobalSettings.getBooleanProperty("org.openyabs.exportproperty.productsresolved", false) && __getOriginalproductsids() > 0) {
+ try {
+ Product p = (Product) DatabaseObject.getObject(Context.getProduct(), __getOriginalproductsids());
+ List<String[]> vals = p.getValues3();
+ Collections.sort(vals, new Comparator<String[]>() {
+ public int compare(String[] o1, String[] o2) {
+ return o1[0].compareTo(o2[0]);
+ }
+ });
+ for (int i = 0; i < vals.size(); i++) {
+ String[] v = vals.get(i);
+ all.add(v[1]);
+ if (Log.getLoglevel() == Log.LOGLEVEL_DEBUG) {
+ Log.Debug(this, (12 + i) + ": " + v[0] + " ");
+ }
}
- }
- if (m.getValueAt(row, 13) != null) {
- t.setLinkurl(m.getValueAt(row, 13).toString());
- }
- if (m.getValueAt(row, 14) != null) {
- t.setCname(m.getValueAt(row, 14).toString());
- }
- if (m.getValueAt(row, 15) != null) {
- t.setDiscount(new BigDecimal(m.getValueAt(row, 15).toString()));
- }
-
- return t;
- }
-
- /**
- * @return the internalvalue
- */
- public BigDecimal __getInternalvalue() {
- return internalvalue;
- }
-
- /**
- * @param internalvalue the internalvalue to set
- */
- public void setInternalvalue(BigDecimal internalvalue) {
- this.internalvalue = internalvalue;
- }
-
- /**
- * @return the externalvalue
- */
- public BigDecimal __getExternalvalue() {
- return externalvalue;
- }
-
- /**
- * @param externalvalue the externalvalue to set
- */
- public void setExternalvalue(BigDecimal externalvalue) {
- this.externalvalue = externalvalue;
- }
-
- @Override
- public HashMap<String, Object> resolveReferences(HashMap<String, Object> map) {
-
- if (map.containsKey("originalproductsids")) {
+ } catch (Exception ex) {
+ Log.Debug(ex);
+ }
+ }
+
+ return all.toArray(new String[0]);
+ }
+
+ /**
+ * @return the itemsids
+ */
+ public int __getItemsids() {
+ return itemsids;
+ }
+
+ /**
+ * @param itemsids the itemsids to set
+ */
+ public void setItemsids(int itemsids) {
+ this.itemsids = itemsids;
+ }
+
+ /**
+ * @return the originalproductsids
+ */
+ public int __getOriginalproductsids() {
+ return originalproductsids;
+ }
+
+ /**
+ * @param originalproductsids the originalproductsids to set
+ */
+ public void setOriginalproductsids(int originalproductsids) {
+ this.originalproductsids = originalproductsids;
+ if (originalproductsids > 0) {
+ setInttype(TYPE_PRODUCT);
+ } else {
+ setInttype(TYPE_NORMAL);
+ }
+ }
+
+ /**
+ * @return the count
+ */
+ public BigDecimal __getCountvalue() {
+ return countvalue;
+ }
+
+ /**
+ * @param count the count to set
+ */
+ public void setCountvalue(BigDecimal count) {
+ this.countvalue = count;
+ }
+
+ /**
+ * @return the quantity
+ */
+ public BigDecimal __getQuantityvalue() {
+ return quantityvalue;
+ }
+
+ /**
+ * @param quantity the quantity to set
+ */
+ public void setQuantityvalue(BigDecimal quantity) {
+ this.quantityvalue = quantity;
+ if (quantity.compareTo(BigDecimal.ZERO) == 0) {
+ setInttype(TYPE_TEXT);
+ }
+ }
+
+ /**
+ * @return the measure
+ */
+ public String __getMeasure() {
+ return measure;
+ }
+
+ /**
+ * @param measure the measure to set
+ */
+ public void setMeasure(String measure) {
+ this.measure = measure;
+ }
+
+ /**
+ * @return the description
+ */
+ public String __getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the taxpercent
+ */
+ public BigDecimal __getTaxpercentvalue() {
+ return taxpercentvalue;
+ }
+
+ /**
+ * @param taxpercent the taxpercent to set
+ */
+ public void setTaxpercentvalue(BigDecimal taxpercent) {
+ this.taxpercentvalue = taxpercent;
+ }
+
+ /**
+ * @return the datedelivery
+ */
+ public Date __getDatedelivery() {
+ return datedelivery;
+ }
+
+ /**
+ * @param datedelivery the datedelivery to set
+ */
+ public void setDatedelivery(Date datedelivery) {
+ this.datedelivery = datedelivery;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public BigDecimal __getDiscount() {
+ return discount;
+ }
+
+ /**
+ *
+ * @param discount
+ */
+ public void setDiscount(BigDecimal discount) {
+ this.discount = discount;
+ }
+
+ public BigDecimal getDiscvalue() {
+ return discvalue;
+ }
+
+ public void defDiscvalue(BigDecimal discvalue) {
+ this.discvalue = discvalue;
+ }
+
+ @Override
+ public JComponent getView() {
+ try {
+ Item dos = (Item) DatabaseObject.getObject(Context.getItem(), __getItemsids());
+ ItemPanel ip = new ItemPanel(Context.getItem(), dos.__getInttype());
+ return ip;
+ } catch (NodataFoundException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ @Override
+ public mpv5.utils.images.MPIcon getIcon() {
+ return null;
+ }
+
+ /**
+ * Generates a table model out of the given SubItems
+ *
+ * @param items
+ * @return
+ */
+ public static MPTableModel toModel(SubItem[] items) {
+ return toModel(items, false);
+ }
+ /**
+ * The ADD button index
+ */
+ public static int COLUMNINDEX_ADD = 11;
+ /**
+ * The CLEAR button index
+ */
+ public static int COLUMNINDEX_REMOVE = 12;
+ /**
+ * Compares by ordernr
+ */
+ public static Comparator<SubItem> ORDER_COMPARATOR = new Comparator<SubItem>() {
+ @Override
+ public int compare(SubItem o1, SubItem o2) {
+ return (o1.getOrdernr() > o2.getOrdernr()) ? 1 : -1;
+ }
+ };
+
+ /**
+ * Generates a table model out of the given SubItems
+ *
+ * @param items
+ * @param removeSubitemIds
+ * @return
+ */
+ public static MPTableModel toModel(SubItem[] items, boolean removeSubitemIds) {
+ //"Internal ID", "ID", "Count", "Measure", "Description", "Netto Price", "Tax Value", "Total Price"
+ Object[][] data = new Object[items.length][];
+ List<SubItem> tlist = new LinkedList<SubItem>();
+ tlist.addAll(Arrays.asList(items));
+ Collections.sort(tlist, SubItem.ORDER_COMPARATOR);
+
+ for (int i = 0; i < tlist.size(); i++) {
+ SubItem subItem = tlist.get(i);
+ if (subItem != null) {
+ data[i] = subItem.getRowData(i + 1);
+ } else {
+ data[i] = getDefaultItem().getRowData(i + 1);
+ }
+ if (removeSubitemIds) {
+ data[i][0] = -1;
+ }
+ }
+
+
+ MPTableModel model = new MPTableModel(
+ new Class[]{
+ Integer.class, Integer.class, BigDecimal.class, String.class, Object.class, BigDecimal.class, BigDecimal.class, BigDecimal.class,
+ BigDecimal.class, BigDecimal.class, Product.class, JButton.class, JButton.class, String.class, String.class, BigDecimal.class, BigDecimal.class},
+ new boolean[]{false, false, true, true, true, true, true, false, false, false, false, true, true, true, true, true, true, true},
+ data,
+ Headers.SUBITEMS.getValue());
+
+ model.setContext(Context.getSubItem());
+ String defunit = null;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defunit")) {
+ defunit = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defunit");
+ }
+ BigDecimal deftax = BigDecimal.ZERO;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("deftax")) {
+ int taxid = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("deftax", 0);
+ deftax = Tax.getTaxValue(taxid);
+ }
+ Double defcount = 1d;
+ if (mpv5.db.objects.User.getCurrentUser().getProperties().hasProperty("defcount")) {
+ defcount = mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("defcount", 0d);
+ }
+ model.defineRow(new Object[]{0, 0, defcount, defunit, null, 0.0, deftax, 0.0, 0.0, 0.0, null, "A", "C", "", "", 0.0, 0.0});
+ model.setAutoCountColumn(1);
+
+ return model;
+ }
+
+ /**
+ * Turn this SubItem into table row data
+ *
+ * @param row
+ * @return
+ */
+ public synchronized Object[] getRowData(int row) {
+ Object[] data = new Object[17];
+ for (int i = 0; i < data.length; i++) {
+ data[0] = __getIDS();
+ data[1] = Integer.valueOf(row);
+ data[2] = __getQuantityvalue();
+ data[3] = __getMeasure();
+ data[4] = __getDescription();
+ data[5] = __getExternalvalue();
+ data[6] = __getTaxpercentvalue();
+ data[7] = __getQuantityvalue().multiply(__getExternalvalue().multiply(((__getTaxpercentvalue().divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP).add(BigDecimal.ONE)))));
+ data[8] = 0.0;
+ data[9] = 0.0;
+ if (__getOriginalproductsids() > 0) {
try {
- try {
- map.put("originalproduct", DatabaseObject.getObject(Context.getProduct(), Integer.valueOf(map.get("originalproductsids").toString())));
- map.remove("originalproductsids");
- } catch (NodataFoundException ex) {
- map.put("originalproduct", null);
- }
- } catch (NumberFormatException numberFormatException) {
- //already resolved?
+ data[10] = Product.getObject(Context.getProduct(), __getOriginalproductsids());
+ } catch (NodataFoundException ex) {
+ Log.Debug(ex);
}
- }
-
- return super.resolveReferences(map);
- }
-
- /**
- * @return the totalnetvalue
- */
- public BigDecimal __getTotalnetvalue() {
- return totalnetvalue;
- }
-
- /**
- * @param totalnetvalue the totalnetvalue to set
- */
- public void setTotalnetvalue(BigDecimal totalnetvalue) {
- this.totalnetvalue = totalnetvalue;
- }
-
- /**
- * @return the totalbrutvalue
- */
- public BigDecimal __getTotalbrutvalue() {
- return totalbrutvalue;
- }
-
- /**
- * @param totalbrutvalue the totalbrutvalue to set
- */
- public void setTotalbrutvalue(BigDecimal totalbrutvalue) {
- this.totalbrutvalue = totalbrutvalue;
- }
-
- static void calculate(SubItem s) {
- BigDecimal disc = s.__getDiscount().divide(BD100, 9, BigDecimal.ROUND_HALF_UP);
- s.setTotalbrutvalue(s.quantityvalue.multiply(s.externalvalue.multiply(((s.taxpercentvalue.divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP)).add(BigDecimal.ONE)))));
- s.setTotalbrutvalue(s.totalbrutvalue.subtract(s.totalbrutvalue.multiply(disc)));
- s.defTotaltaxvalue(s.quantityvalue.multiply(s.externalvalue.multiply((s.taxpercentvalue.divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP)))));
- s.defTotaltaxvalue(s.totaltaxvalue.subtract(s.totaltaxvalue.multiply(disc)));
- s.setTotalnetvalue(s.quantityvalue.multiply(s.externalvalue));
- s.defDiscvalue(s.totalnetvalue.multiply(disc));
- }
-
- @Override
- public boolean save() {
- calculate(this);
- return super.save();
- }
-
- private void defTotaltaxvalue(BigDecimal value) {
- totaltaxvalue = value;
- }
-
- /**
- *
- * @return
- */
- public BigDecimal getTotalTaxValue() {
- return totaltaxvalue;
- }
-
- /**
- * @return the linkurl
- */
- public String __getLinkurl() {
- return linkurl;
- }
-
- /**
- * @param linkurl the linkurl to set
- */
- public void setLinkurl(String linkurl) {
- this.linkurl = linkurl;
- }
-
- @Override
- public boolean save(boolean b) {
- if (getCname().length() == 0) {
- setCname(" ");
- }
- return super.save(b);
- }
-
- @Override
- public void triggerOnCreate() {
- if (__getOriginalproductsids() > 0) {
+ }
+ data[11] = "A";
+ data[12] = "C";
+ data[12 + 1] = __getLinkurl();
+ data[14] = __getCname();
+ data[15] = __getDiscount();
+ data[16] = 0.0;
+ }
+ return data;
+ }
+
+ /**
+ * Turn this SubItem into table row data
+ *
+ * @param row
+ * @return
+ */
+ public static synchronized SubItem getFromModel(MPTableModel m, int row) {
+ SubItem t = new SubItem();
+
+ if (m.getValueAt(row, 0) != null) {
+ t.setIDS(Integer.valueOf(m.getValueAt(row, 0).toString()));
+ }
+ if (m.getValueAt(row, 1) != null) {
+ t.setCountvalue(new BigDecimal(m.getValueAt(row, 1).toString()));
+ }
+ if (m.getValueAt(row, 2) != null) {
+ t.setQuantityvalue(new BigDecimal(m.getValueAt(row, 2).toString()));
+ }
+ if (m.getValueAt(row, 3) != null) {
+ t.setMeasure(m.getValueAt(row, 3).toString());
+ }
+ if (m.getValueAt(row, 4) != null) {
+ t.setDescription(m.getValueAt(row, 4).toString());
+ }
+ if (m.getValueAt(row, 5) != null) {
+ t.setExternalvalue(new BigDecimal(m.getValueAt(row, 5).toString()));
+ }
+ if (m.getValueAt(row, 6) != null) {
+ t.setTaxpercentvalue(new BigDecimal(m.getValueAt(row, 6).toString()));
+ }
+ if (m.getValueAt(row, 10) != null) {
+ try {
+ t.setOriginalproductsids(((Product) m.getValueAt(row, 10)).__getIDS());
+ } catch (Exception e) {
+ Log.Debug(e);
+ }
+ }
+ if (m.getValueAt(row, 13) != null) {
+ t.setLinkurl(m.getValueAt(row, 13).toString());
+ }
+ if (m.getValueAt(row, 14) != null) {
+ t.setCname(m.getValueAt(row, 14).toString());
+ }
+ if (m.getValueAt(row, 15) != null) {
+ t.setDiscount(new BigDecimal(m.getValueAt(row, 15).toString()));
+ }
+
+ return t;
+ }
+
+ /**
+ * @return the internalvalue
+ */
+ public BigDecimal __getInternalvalue() {
+ return internalvalue;
+ }
+
+ /**
+ * @param internalvalue the internalvalue to set
+ */
+ public void setInternalvalue(BigDecimal internalvalue) {
+ this.internalvalue = internalvalue;
+ }
+
+ /**
+ * @return the externalvalue
+ */
+ public BigDecimal __getExternalvalue() {
+ return externalvalue;
+ }
+
+ /**
+ * @param externalvalue the externalvalue to set
+ */
+ public void setExternalvalue(BigDecimal externalvalue) {
+ this.externalvalue = externalvalue;
+ }
+
+ @Override
+ public HashMap<String, Object> resolveReferences(HashMap<String, Object> map) {
+
+ if (map.containsKey("originalproductsids")) {
+ try {
try {
- Product p = (Product) DatabaseObject.getObject(Context.getProduct(), originalproductsids);
- if (p.__getIntinventorytype() == 1) {
- p.setStockvalue(p.__getStockvalue().subtract(__getQuantityvalue()));
- p.save(true);
- }
+ map.put("originalproduct", DatabaseObject.getObject(Context.getProduct(), Integer.valueOf(map.get("originalproductsids").toString())));
+ map.remove("originalproductsids");
} catch (NodataFoundException ex) {
- Log.Debug(this, ex.getMessage());//jemand hats gelöscht:-/
- originalproductsids = -1;
- save(true);
+ map.put("originalproduct", null);
+ }
+ } catch (NumberFormatException numberFormatException) {
+ //already resolved?
+ }
+ }
+
+ return super.resolveReferences(map);
+ }
+
+ /**
+ * @return the totalnetvalue
+ */
+ public BigDecimal __getTotalnetvalue() {
+ return totalnetvalue;
+ }
+
+ /**
+ * @param totalnetvalue the totalnetvalue to set
+ */
+ public void setTotalnetvalue(BigDecimal totalnetvalue) {
+ this.totalnetvalue = totalnetvalue;
+ }
+
+ /**
+ * @return the totalbrutvalue
+ */
+ public BigDecimal __getTotalbrutvalue() {
+ return totalbrutvalue;
+ }
+
+ /**
+ * @param totalbrutvalue the totalbrutvalue to set
+ */
+ public void setTotalbrutvalue(BigDecimal totalbrutvalue) {
+ this.totalbrutvalue = totalbrutvalue;
+ }
+
+ static void calculate(SubItem s) {
+ BigDecimal disc = s.__getDiscount().divide(BD100, 9, BigDecimal.ROUND_HALF_UP);
+ s.setTotalbrutvalue(s.quantityvalue.multiply(s.externalvalue.multiply(((s.taxpercentvalue.divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP)).add(BigDecimal.ONE)))));
+ s.setTotalbrutvalue(s.totalbrutvalue.subtract(s.totalbrutvalue.multiply(disc)));
+ s.defTotaltaxvalue(s.quantityvalue.multiply(s.externalvalue.multiply((s.taxpercentvalue.divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP)))));
+ s.defTotaltaxvalue(s.totaltaxvalue.subtract(s.totaltaxvalue.multiply(disc)));
+ s.setTotalnetvalue(s.quantityvalue.multiply(s.externalvalue));
+ s.defDiscvalue(s.totalnetvalue.multiply(disc));
+ }
+
+ @Override
+ public boolean save() {
+ calculate(this);
+ return super.save();
+ }
+
+ private void defTotaltaxvalue(BigDecimal value) {
+ totaltaxvalue = value;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public BigDecimal getTotalTaxValue() {
+ return totaltaxvalue;
+ }
+
+ /**
+ * @return the linkurl
+ */
+ public String __getLinkurl() {
+ return linkurl;
+ }
+
+ /**
+ * @param linkurl the linkurl to set
+ */
+ public void setLinkurl(String linkurl) {
+ this.linkurl = linkurl;
+ }
+
+ @Override
+ public boolean save(boolean b) {
+ if (getCname().length() == 0) {
+ setCname(" ");
+ }
+ return super.save(b);
+ }
+
+ @Override
+ public void triggerOnCreate() {
+ if (__getOriginalproductsids() > 0) {
+ try {
+ Product p = (Product) DatabaseObject.getObject(Context.getProduct(), originalproductsids);
+ if (p.__getIntinventorytype() == 1) {
+ p.setStockvalue(p.__getStockvalue().subtract(__getQuantityvalue()));
+ p.save(true);
}
- }
- }
-
- @Override
- public void triggerOnUpdate() {
- }
-
- @Override
- public void triggerOnDelete() {
- // Log.Debug(this, "Deleting... " + IDENTITY);
- }
-
- @Override
- public String toString() {
- if (description != null && description.length() > 15) {
- return description.substring(0, 14);
- } else {
- return description;
- }
- }
-
- /**
- * @return the order
- */
- @Persistable(true)
- public int getOrdernr() {
- return ordernr;
- }
-
- /**
- * @param ordernr the order to set
- */
- public void setOrdernr(int ordernr) {
- this.ordernr = ordernr;
- }
-
- /**
- * @return the inttype
- */
- @Persistable(true)
- public int getInttype() {
- return inttype;
- }
-
- /**
- * @param inttype the inttype to set
- */
- public void setInttype(int inttype) {
- this.inttype = inttype;
- }
+ } catch (NodataFoundException ex) {
+ Log.Debug(this, ex.getMessage());//jemand hats gelöscht:-/
+ originalproductsids = -1;
+ save(true);
+ }
+ }
+ }
+
+ @Override
+ public void triggerOnUpdate() {
+ }
+
+ @Override
+ public void triggerOnDelete() {
+ // Log.Debug(this, "Deleting... " + IDENTITY);
+ }
+
+ @Override
+ public String toString() {
+ if (description != null && description.length() > 15) {
+ return description.substring(0, 14);
+ } else {
+ return description;
+ }
+ }
+
+ /**
+ * @return the order
+ */
+ @Persistable(true)
+ public int getOrdernr() {
+ return ordernr;
+ }
+
+ /**
+ * @param ordernr the order to set
+ */
+ public void setOrdernr(int ordernr) {
+ this.ordernr = ordernr;
+ }
+
+ /**
+ * @return the inttype
+ */
+ @Persistable(true)
+ public int getInttype() {
+ return inttype;
+ }
+
+ /**
+ * @param inttype the inttype to set
+ */
+ public void setInttype(int inttype) {
+ this.inttype = inttype;
+ }
}
View
633 src/mpv5/logging/Log.java
@@ -36,6 +36,7 @@
import javax.swing.table.TableModel;
import mpv5.Main;
import mpv5.bugtracker.ExceptionHandler;
+import mpv5.db.objects.Contact;
import mpv5.globals.Messages;
import mpv5.utils.files.FileReaderWriter;
@@ -45,326 +46,330 @@
*/
public class Log {
- static {
-
- Logger globalLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
- globalLogger.addHandler(new LogHandler(new Formatter() {
- @Override
- public String format(LogRecord record) {
- if (record != null) {
- return record.getMessage();
- } else {
- return "null";
- }
- }
- }) {
- @Override
- public void publish(LogRecord record) {
- Log.Debug(this, record);
- }
+ static {
- @Override
- public void flush() {
- }
-
- @Override
- public void close() throws SecurityException {
- }
- });
-
- Logger.getLogger(Log.class.getName()).log(Level.INFO, "Yabs Logger set!");
- }
- /**
- *
- * Set the logging to NONE
- */
- public static final int LOGLEVEL_NONE = 0;
- /**
- *
- * Gives basic messages
- */
- public static final int LOGLEVEL_NORMAL = 1;
- /**
- *
- * Produces a huge amount of messages, and error stack traces
- */
- public static final int LOGLEVEL_DEBUG = 2;
- private static int loglevel = 1;
- private static List<LogConsole> loggers = Collections.synchronizedList(new ArrayList<LogConsole>(Arrays.asList(new LogConsole[]{(LogConsole) new YConsole()})));
-
- /**
- * Print out a text file
- *
- * @param file
- */
- public static void Debug(File file) {
- PrintArray(new FileReaderWriter(file).readLines());
- }
-
- /**
- *
- * @param source
- * @param message
- * @param alwaysToKonsole
- * @deprecated Replaced * with <code>Debug(Object source, Object message)</code>
- */
- public static void Debug(Object source, Object message, boolean alwaysToKonsole) {
- Debug(source, message);
- }
-
- /**
- * The main debug method. Logs the given message depending on the current
- * Log level.<br/><br/> <li>LOGLEVEL_NONE = no logging</li>
- * <li>LOGLEVEL_HIGH = basic logging</li> <li>LOGLEVEL_DEBUG = verbose
- * logging</li>
- *
- * @param source
- * @param message
- */
- public static synchronized void Debug(Object source, Object message) {
- String sourcen;
- if (source instanceof Class) {
- sourcen = ((Class) source).getName();