From cade3b10ad3d964c53fc2afff5b9958a995511cb Mon Sep 17 00:00:00 2001 From: Hugh Date: Mon, 29 Dec 2025 15:40:07 +0000 Subject: [PATCH] wip --- pom.xml | 4 +- .../com/unicenta/pos/admin/PeopleView.form | 140 +- .../com/unicenta/pos/admin/PeopleView.java | 295 +- .../pos/customers/CustomersPayment.java | 1307 ++-- .../unicenta/pos/forms/DataLogicSales.java | 5354 ++++++++--------- .../unicenta/pos/sales/DataLogicReceipts.java | 654 +- .../com/unicenta/pos/sales/JPanelTicket.java | 1031 ++-- .../restaurant/JTicketsBagRestaurantMap.java | 2006 +++--- .../unicenta/pos/ticket/TicketLineInfo.java | 890 +-- test.jpg | Bin 0 -> 12606 bytes 10 files changed, 5714 insertions(+), 5967 deletions(-) create mode 100644 test.jpg diff --git a/pom.xml b/pom.xml index 18698e6..b0ebc46 100644 --- a/pom.xml +++ b/pom.xml @@ -8,8 +8,8 @@ jar UTF-8 - 1.8 - 1.8 + 11 + 11 10.14.2.0 diff --git a/src/main/java/com/unicenta/pos/admin/PeopleView.form b/src/main/java/com/unicenta/pos/admin/PeopleView.form index dbc2f17..d1efe63 100644 --- a/src/main/java/com/unicenta/pos/admin/PeopleView.form +++ b/src/main/java/com/unicenta/pos/admin/PeopleView.form @@ -19,93 +19,10 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -121,10 +38,10 @@ - + - + @@ -134,7 +51,7 @@ - + @@ -144,7 +61,7 @@ - + @@ -157,7 +74,7 @@ - + @@ -170,7 +87,7 @@ - + @@ -210,7 +127,7 @@ - + @@ -223,7 +140,7 @@ - + @@ -233,7 +150,7 @@ - + @@ -246,33 +163,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -285,5 +176,12 @@ + + + + + + + diff --git a/src/main/java/com/unicenta/pos/admin/PeopleView.java b/src/main/java/com/unicenta/pos/admin/PeopleView.java index 3053bee..33473d4 100644 --- a/src/main/java/com/unicenta/pos/admin/PeopleView.java +++ b/src/main/java/com/unicenta/pos/admin/PeopleView.java @@ -64,11 +64,11 @@ public class PeopleView extends JPanel implements EditorRecord { m_RoleModel = new ComboBoxValModel(); m_Dirty = dirty; - m_jName.getDocument().addDocumentListener(dirty); + nameTextField.getDocument().addDocumentListener(dirty); m_jRole.addActionListener(dirty); - m_jVisible.addActionListener(dirty); - m_jImage.addPropertyChangeListener("image", dirty); - m_jcard.getDocument().addDocumentListener(dirty); + isVisible.addActionListener(dirty); + imageEditor.addPropertyChangeListener("image", dirty); + cardIdTextField.getDocument().addDocumentListener(dirty); m_ReasonModel = new ComboBoxValModel(); m_ReasonModel.add(AppLocal.getIntString("cboption.generate")); @@ -86,17 +86,17 @@ public class PeopleView extends JPanel implements EditorRecord { @Override public void writeValueEOF() { m_oId = null; - m_jName.setText(null); + nameTextField.setText(null); m_sPassword = null; m_RoleModel.setSelectedKey(null); - m_jVisible.setSelected(false); - m_jcard.setText(null); - m_jImage.setImage(null); - m_jName.setEnabled(false); + isVisible.setSelected(false); + cardIdTextField.setText(null); + imageEditor.setImage(null); + nameTextField.setEnabled(false); m_jRole.setEnabled(false); - m_jVisible.setEnabled(false); - m_jcard.setEnabled(false); - m_jImage.setEnabled(false); + isVisible.setEnabled(false); + cardIdTextField.setEnabled(false); + imageEditor.setEnabled(false); jButton1.setEnabled(false); webCBSecurity.setEnabled(false); } @@ -107,17 +107,17 @@ public class PeopleView extends JPanel implements EditorRecord { @Override public void writeValueInsert() { m_oId = null; - m_jName.setText(null); + nameTextField.setText(null); m_sPassword = null; m_RoleModel.setSelectedKey(null); - m_jVisible.setSelected(true); - m_jcard.setText(null); - m_jImage.setImage(null); - m_jName.setEnabled(true); + isVisible.setSelected(true); + cardIdTextField.setText(null); + imageEditor.setImage(null); + nameTextField.setEnabled(true); m_jRole.setEnabled(true); - m_jVisible.setEnabled(true); - m_jcard.setEnabled(true); - m_jImage.setEnabled(true); + isVisible.setEnabled(true); + cardIdTextField.setEnabled(true); + imageEditor.setEnabled(true); jButton1.setEnabled(true); webCBSecurity.setEnabled(true); } @@ -130,18 +130,18 @@ public class PeopleView extends JPanel implements EditorRecord { public void writeValueDelete(Object value) { Object[] people = (Object[]) value; m_oId = people[0]; - m_jName.setText(Formats.STRING.formatValue(people[1])); + nameTextField.setText(Formats.STRING.formatValue(people[1])); m_sPassword = Formats.STRING.formatValue(people[2]); m_RoleModel.setSelectedKey(people[3]); - m_jVisible.setSelected(((Boolean) people[4]).booleanValue()); - m_jcard.setText(Formats.STRING.formatValue(people[5])); - m_jImage.setImage((BufferedImage) people[6]); + isVisible.setSelected(((Boolean) people[4]).booleanValue()); + cardIdTextField.setText(Formats.STRING.formatValue(people[5])); + imageEditor.setImage((BufferedImage) people[6]); - m_jName.setEnabled(false); + nameTextField.setEnabled(false); m_jRole.setEnabled(false); - m_jVisible.setEnabled(false); - m_jcard.setEnabled(false); - m_jImage.setEnabled(false); + isVisible.setEnabled(false); + cardIdTextField.setEnabled(false); + imageEditor.setEnabled(false); jButton1.setEnabled(false); webCBSecurity.setEnabled(false); } @@ -154,25 +154,25 @@ public class PeopleView extends JPanel implements EditorRecord { public void writeValueEdit(Object value) { Object[] people = (Object[]) value; m_oId = people[0]; - m_jName.setText(Formats.STRING.formatValue(people[1])); + nameTextField.setText(Formats.STRING.formatValue(people[1])); m_sPassword = Formats.STRING.formatValue(people[2]); m_RoleModel.setSelectedKey(people[3]); - m_jVisible.setSelected(((Boolean) people[4]).booleanValue()); - m_jcard.setText(Formats.STRING.formatValue(people[5])); - m_jImage.setImage((BufferedImage) people[6]); + isVisible.setSelected(((Boolean) people[4]).booleanValue()); + cardIdTextField.setText(Formats.STRING.formatValue(people[5])); + imageEditor.setImage((BufferedImage) people[6]); - if (m_jcard.getText().length() == 16) { - jLblCardID.setText(AppLocal.getIntString("label.ibutton")); + if (cardIdTextField.getText().length() == 16) { + cardIdLabel.setText(AppLocal.getIntString("label.ibutton")); } else { - jLblCardID.setText(AppLocal.getIntString("label.card")); + cardIdLabel.setText(AppLocal.getIntString("label.card")); } - System.out.println(m_jcard.getText().length()); + System.out.println(cardIdTextField.getText().length()); - m_jName.setEnabled(true); + nameTextField.setEnabled(true); m_jRole.setEnabled(true); - m_jVisible.setEnabled(true); - m_jcard.setEnabled(true); - m_jImage.setEnabled(true); + isVisible.setEnabled(true); + cardIdTextField.setEnabled(true); + imageEditor.setEnabled(true); jButton1.setEnabled(true); webCBSecurity.setEnabled(true); } @@ -186,12 +186,12 @@ public class PeopleView extends JPanel implements EditorRecord { public Object createValue() throws BasicException { Object[] people = new Object[7]; people[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; - people[1] = Formats.STRING.parseValue(m_jName.getText()); + people[1] = Formats.STRING.parseValue(nameTextField.getText()); people[2] = Formats.STRING.parseValue(m_sPassword); people[3] = m_RoleModel.getSelectedKey(); - people[4] = m_jVisible.isSelected(); - people[5] = Formats.STRING.parseValue(m_jcard.getText()); - people[6] = m_jImage.getImage(); + people[4] = isVisible.isSelected(); + people[5] = Formats.STRING.parseValue(cardIdTextField.getText()); + people[6] = imageEditor.getImage(); return people; } @@ -230,49 +230,56 @@ public class PeopleView extends JPanel implements EditorRecord { // //GEN-BEGIN:initComponents private void initComponents() { - jLabel1 = new javax.swing.JLabel(); - m_jName = new javax.swing.JTextField(); - m_jVisible = new javax.swing.JCheckBox(); - jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); - m_jImage = new com.unicenta.data.gui.JImageEditor(); + nameLabel = new javax.swing.JLabel(); + nameTextField = new javax.swing.JTextField(); + isVisible = new javax.swing.JCheckBox(); + visiableLabel = new javax.swing.JLabel(); + imageLabel = new javax.swing.JLabel(); + imageEditor = new com.unicenta.data.gui.JImageEditor(); jButton1 = new javax.swing.JButton(); m_jRole = new javax.swing.JComboBox(); - jLabel2 = new javax.swing.JLabel(); - m_jcard = new javax.swing.JTextField(); - jLblCardID = new javax.swing.JLabel(); - webCBSecurity = new com.alee.laf.combobox.WebComboBox(); - jLabel6 = new javax.swing.JLabel(); + roleLabel = new javax.swing.JLabel(); + cardIdTextField = new javax.swing.JTextField(); + cardIdLabel = new javax.swing.JLabel(); + passwordLabel = new javax.swing.JLabel(); + taxIdLabel = new javax.swing.JLabel(); + taxIdTextField = new javax.swing.JTextField(); setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N setPreferredSize(new java.awt.Dimension(500, 500)); - jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N - jLabel1.setText(AppLocal.getIntString("label.peoplenamem")); // NOI18N - jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); - jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { + nameLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + nameLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + nameLabel.setText(AppLocal.getIntString("label.peoplenamem")); // NOI18N + nameLabel.setPreferredSize(new java.awt.Dimension(110, 30)); + nameLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { - jLabel1MouseClicked(evt); + nameLabelMouseClicked(evt); } }); + add(nameLabel); - m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - m_jName.setPreferredSize(new java.awt.Dimension(0, 30)); + nameTextField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + nameTextField.setPreferredSize(new java.awt.Dimension(0, 30)); + add(nameTextField); - m_jVisible.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - m_jVisible.setPreferredSize(new java.awt.Dimension(0, 30)); + isVisible.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + isVisible.setPreferredSize(new java.awt.Dimension(0, 30)); + add(isVisible); - jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel3.setText(AppLocal.getIntString("label.peoplevisible")); // NOI18N - jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + visiableLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + visiableLabel.setText(AppLocal.getIntString("label.peoplevisible")); // NOI18N + visiableLabel.setPreferredSize(new java.awt.Dimension(110, 30)); + add(visiableLabel); - jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel4.setText(AppLocal.getIntString("label.peopleimage")); // NOI18N - jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + imageLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + imageLabel.setText(AppLocal.getIntString("label.peopleimage")); // NOI18N + imageLabel.setPreferredSize(new java.awt.Dimension(110, 30)); + add(imageLabel); - m_jImage.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - m_jImage.setPreferredSize(new java.awt.Dimension(300, 250)); + imageEditor.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + imageEditor.setPreferredSize(new java.awt.Dimension(300, 250)); + add(imageEditor); jButton1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/password.png"))); // NOI18N @@ -284,101 +291,34 @@ public class PeopleView extends JPanel implements EditorRecord { jButton1ActionPerformed(evt); } }); + add(jButton1); m_jRole.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N m_jRole.setPreferredSize(new java.awt.Dimension(0, 30)); + add(m_jRole); - jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel2.setText(AppLocal.getIntString("label.rolem")); // NOI18N - jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + roleLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + roleLabel.setText(AppLocal.getIntString("label.rolem")); // NOI18N + roleLabel.setPreferredSize(new java.awt.Dimension(110, 30)); + add(roleLabel); - m_jcard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - m_jcard.setPreferredSize(new java.awt.Dimension(0, 30)); + cardIdTextField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + cardIdTextField.setPreferredSize(new java.awt.Dimension(0, 30)); + add(cardIdTextField); - jLblCardID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLblCardID.setText(AppLocal.getIntString("label.card")); // NOI18N - jLblCardID.setPreferredSize(new java.awt.Dimension(110, 30)); + cardIdLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + cardIdLabel.setText(AppLocal.getIntString("label.card")); // NOI18N + cardIdLabel.setPreferredSize(new java.awt.Dimension(110, 30)); + add(cardIdLabel); - webCBSecurity.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Generate new key", "Delete exisitng key", "Use iButton ID" })); - webCBSecurity.setSelectedIndex(0); - webCBSecurity.setToolTipText(AppLocal.getIntString("tooltip.peoplesecurity")); // NOI18N - webCBSecurity.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - webCBSecurity.setPreferredSize(new java.awt.Dimension(140, 45)); - webCBSecurity.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - webCBSecurityActionPerformed(evt); - } - }); + passwordLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + passwordLabel.setText(AppLocal.getIntString("label.Password")); // NOI18N + passwordLabel.setPreferredSize(new java.awt.Dimension(110, 30)); + add(passwordLabel); - jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel6.setText(AppLocal.getIntString("label.Password")); // NOI18N - jLabel6.setPreferredSize(new java.awt.Dimension(110, 30)); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(m_jRole, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLblCardID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(m_jcard, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(webCBSecurity, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLblCardID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(m_jcard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(webCBSecurity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(m_jRole, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(15, 15, 15) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); + taxIdLabel.setText("Tax ID"); + add(taxIdLabel); + add(taxIdTextField); }// //GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed @@ -401,7 +341,7 @@ public class PeopleView extends JPanel implements EditorRecord { JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { - m_jcard.setText("C" + StringUtils.getCardNumber()); + cardIdTextField.setText("C" + StringUtils.getCardNumber()); m_Dirty.setDirty(true); } } @@ -413,7 +353,7 @@ public class PeopleView extends JPanel implements EditorRecord { JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { - m_jcard.setText(null); + cardIdTextField.setText(null); m_Dirty.setDirty(true); } } @@ -426,8 +366,8 @@ public class PeopleView extends JPanel implements EditorRecord { JOptionPane.INFORMATION_MESSAGE) == JOptionPane.OK_OPTION) { - m_jcard.setText( uOWWatch.getibuttonid() ); - jLblCardID.setText(AppLocal.getIntString("label.ibutton")); + cardIdTextField.setText( uOWWatch.getibuttonid() ); + cardIdLabel.setText(AppLocal.getIntString("label.ibutton")); m_Dirty.setDirty(true); } @@ -435,7 +375,7 @@ public class PeopleView extends JPanel implements EditorRecord { }//GEN-LAST:event_webCBSecurityActionPerformed - private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked + private void nameLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nameLabelMouseClicked if (evt.getClickCount() == 2) { String uuidString = m_oId.toString(); StringSelection stringSelection = new StringSelection(uuidString); @@ -445,23 +385,24 @@ public class PeopleView extends JPanel implements EditorRecord { JOptionPane.showMessageDialog(null, AppLocal.getIntString("message.uuidcopy")); } - }//GEN-LAST:event_jLabel1MouseClicked + }//GEN-LAST:event_nameLabelMouseClicked // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel cardIdLabel; + private javax.swing.JTextField cardIdTextField; + private com.unicenta.data.gui.JImageEditor imageEditor; + private javax.swing.JLabel imageLabel; + private javax.swing.JCheckBox isVisible; private javax.swing.JButton jButton1; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLblCardID; - private com.unicenta.data.gui.JImageEditor m_jImage; - private javax.swing.JTextField m_jName; private javax.swing.JComboBox m_jRole; - private javax.swing.JCheckBox m_jVisible; - private javax.swing.JTextField m_jcard; - private com.alee.laf.combobox.WebComboBox webCBSecurity; + private javax.swing.JLabel nameLabel; + private javax.swing.JTextField nameTextField; + private javax.swing.JLabel passwordLabel; + private javax.swing.JLabel roleLabel; + private javax.swing.JLabel taxIdLabel; + private javax.swing.JTextField taxIdTextField; + private javax.swing.JLabel visiableLabel; // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/com/unicenta/pos/customers/CustomersPayment.java b/src/main/java/com/unicenta/pos/customers/CustomersPayment.java index 4c100b5..eec9f1c 100644 --- a/src/main/java/com/unicenta/pos/customers/CustomersPayment.java +++ b/src/main/java/com/unicenta/pos/customers/CustomersPayment.java @@ -42,752 +42,789 @@ import javax.swing.JOptionPane; /** * - * @author adrianromero + * @author adrianromero */ public class CustomersPayment extends javax.swing.JPanel implements JPanelView, BeanFactoryApp { - private AppView app; - private DataLogicCustomers dlcustomers; - private DataLogicSales dlsales; - private DataLogicSystem dlsystem; - private TicketParser ttp; - private JPaymentSelect paymentdialog; - - private CustomerInfoExt customerext; - private DirtyManager dirty; + private AppView app; + private DataLogicCustomers dlcustomers; + private DataLogicSales dlsales; + private DataLogicSystem dlsystem; + private TicketParser ttp; + private JPaymentSelect paymentdialog; - /** Creates new form CustomersPayment */ - public CustomersPayment() { + private CustomerInfoExt customerext; + private DirtyManager dirty; - initComponents(); - - editorcard.addEditorKeys(m_jKeys); - txtNotes.addEditorKeys(m_jKeys); - txtPrePay.addEditorKeys(m_jKeys); + /** Creates new form CustomersPayment */ + public CustomersPayment() { - dirty = new DirtyManager(); - txtNotes.addPropertyChangeListener("Text", dirty); - txtPrePay.addPropertyChangeListener("Number", dirty); + initComponents(); + + editorcard.addEditorKeys(m_jKeys); + txtNotes.addEditorKeys(m_jKeys); + txtPrePay.addEditorKeys(m_jKeys); + + dirty = new DirtyManager(); + txtNotes.addPropertyChangeListener("Text", dirty); + txtPrePay.addPropertyChangeListener("Number", dirty); + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + this.app = app; + dlcustomers = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + dlsales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlsystem = (DataLogicSystem) app.getBean("com.unicenta.pos.forms.DataLogicSystem"); + ttp = new TicketParser(app.getDeviceTicket(), dlsystem); + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CustomersPayment"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + paymentdialog = JPaymentSelectCustomer.getDialog(this); + paymentdialog.init(app); + + resetCustomer(); + + editorcard.reset(); + editorcard.activate(); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + if (dirty.isDirty()) { + int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannasave"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + save(); + return true; + } else { + return res == JOptionPane.NO_OPTION; + } + } else { + return true; + } + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + private void editCustomer(CustomerInfoExt customer) { + + customerext = customer; + + txtTaxId.setText(customer.getTaxid()); + txtName.setText(customer.getName()); + txtCard.setText(customer.getCard()); + txtNotes.reset(); + txtNotes.setText(customer.getNotes()); + txtMaxdebt.setText(Formats.CURRENCY.formatValue(customer.getMaxdebt())); + txtCurdebt.setText(Formats.CURRENCY.formatValue(customer.getAccdebt())); + txtCurdate.setText(Formats.DATE.formatValue(customer.getCurdate())); + txtPrePay.setText(null); + + txtNotes.setEnabled(true); + txtPrePay.setEnabled(true); + + dirty.setDirty(false); + + btnSave.setEnabled(true); + btnPay.setEnabled(true); + btnPrePay.setEnabled(true); + + // btnPay.setEnabled(customer.getCurdebt() != null && + // customer.getCurdebt().doubleValue() > 0.0); + + } + + private void resetCustomer() { + + customerext = null; + + txtTaxId.setText(null); + txtName.setText(null); + txtCard.setText(null); + txtNotes.reset(); + txtMaxdebt.setText(null); + txtCurdebt.setText(null); + txtCurdate.setText(null); + txtPrePay.setText(null); + + txtNotes.setEnabled(false); + txtPrePay.setEnabled(false); + + dirty.setDirty(false); + + btnSave.setEnabled(false); + btnPay.setEnabled(false); + btnPrePay.setEnabled(false); + + } + + private void readCustomer() { + + try { + CustomerInfoExt customer = dlsales.findCustomerExt(editorcard.getText()); + if (customer == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(customer); + } + + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); + msg.show(this); } - /** - * - * @param app - * @throws BeanFactoryException - */ - @Override - public void init(AppView app) throws BeanFactoryException { + editorcard.reset(); + editorcard.activate(); + } - this.app = app; - dlcustomers = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); - dlsales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); - dlsystem = (DataLogicSystem) app.getBean("com.unicenta.pos.forms.DataLogicSystem"); - ttp = new TicketParser(app.getDeviceTicket(), dlsystem); + private void save() { + + customerext.setNotes(txtNotes.getText()); + customerext.setPrePay(txtPrePay.getText()); + + try { + dlcustomers.updateCustomerExt(customerext); + editCustomer(customerext); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosave"), e); + msg.show(this); } - /** - * - * @return - */ - @Override - public Object getBean() { - return this; + } + + private void printTicket(String resname, TicketInfo ticket, CustomerInfoExt customer) { + + String resource = dlsystem.getResourceAsXML(resname); + if (resource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket")); + msg.show(this); + } else { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticket", ticket); + script.put("customer", customer); + ttp.printTicket(script.eval(resource).toString()); + // JG 6 May use multicatch + } catch (ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(this); + } } + } - /** - * - * @return - */ - @Override - public String getTitle() { - return AppLocal.getIntString("Menu.CustomersPayment"); - } + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; - /** - * - * @throws BasicException - */ - @Override - public void activate() throws BasicException { + jPanel2 = new javax.swing.JPanel(); + jPanel6 = new javax.swing.JPanel(); + btnCustomer = new javax.swing.JButton(); + btnSave = new javax.swing.JButton(); + jSeparator1 = new javax.swing.JSeparator(); + btnPay = new javax.swing.JButton(); + btnPrePay = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel5 = new javax.swing.JPanel(); + editorcard = new com.unicenta.editor.JEditorString(); + jButton1 = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + txtCard = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + txtCurdebt = new javax.swing.JTextField(); + txtCurdate = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + txtName = new javax.swing.JTextField(); + txtMaxdebt = new javax.swing.JTextField(); + txtPrePay = new com.unicenta.editor.JEditorString(); + txtTaxId = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + txtNotes = new com.unicenta.editor.JEditorString(); - paymentdialog = JPaymentSelectCustomer.getDialog(this); - paymentdialog.init(app); + setLayout(new java.awt.BorderLayout()); - resetCustomer(); + jPanel2.setLayout(new java.awt.BorderLayout()); - editorcard.reset(); - editorcard.activate(); - } + btnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + btnCustomer.setToolTipText(bundle.getString("tooltip.customerpay.customer")); // NOI18N + btnCustomer.setFocusPainted(false); + btnCustomer.setFocusable(false); + btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnCustomer.setPreferredSize(new java.awt.Dimension(110, 45)); + btnCustomer.setRequestFocusEnabled(false); + btnCustomer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCustomerActionPerformed(evt); + } + }); + jPanel6.add(btnCustomer); - /** - * - * @return - */ - @Override - public boolean deactivate() { - if (dirty.isDirty()) { - int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannasave"), - AppLocal.getIntString("title.editor"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - - if (res == JOptionPane.YES_OPTION) { - save(); - return true; - } else { - return res == JOptionPane.NO_OPTION; - } - } else { - return true; - } - } + btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + btnSave.setToolTipText(bundle.getString("tootltip.save")); // NOI18N + btnSave.setFocusPainted(false); + btnSave.setFocusable(false); + btnSave.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnSave.setPreferredSize(new java.awt.Dimension(110, 45)); + btnSave.setRequestFocusEnabled(false); + btnSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSaveActionPerformed(evt); + } + }); + jPanel6.add(btnSave); + jPanel6.add(jSeparator1); - /** - * - * @return - */ - @Override - public JComponent getComponent() { - return this; - } + btnPay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + btnPay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/pay.png"))); // NOI18N + btnPay.setText(AppLocal.getIntString("button.pay")); // NOI18N + btnPay.setToolTipText(bundle.getString("tooltip.customerpay.pay")); // NOI18N + btnPay.setFocusPainted(false); + btnPay.setFocusable(false); + btnPay.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnPay.setMaximumSize(new java.awt.Dimension(110, 44)); + btnPay.setMinimumSize(new java.awt.Dimension(110, 44)); + btnPay.setPreferredSize(new java.awt.Dimension(110, 45)); + btnPay.setRequestFocusEnabled(false); + btnPay.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPayActionPerformed(evt); + } + }); + jPanel6.add(btnPay); - private void editCustomer(CustomerInfoExt customer) { + btnPrePay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + btnPrePay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_add_sml.png"))); // NOI18N + btnPrePay.setText(AppLocal.getIntString("button.prepay")); // NOI18N + btnPrePay.setToolTipText(bundle.getString("tooltip.prepay")); // NOI18N + btnPrePay.setFocusPainted(false); + btnPrePay.setFocusable(false); + btnPrePay.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnPrePay.setMaximumSize(new java.awt.Dimension(110, 44)); + btnPrePay.setMinimumSize(new java.awt.Dimension(110, 44)); + btnPrePay.setPreferredSize(new java.awt.Dimension(110, 45)); + btnPrePay.setRequestFocusEnabled(false); + btnPrePay.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPrePayActionPerformed(evt); + } + }); + jPanel6.add(btnPrePay); - customerext = customer; + jPanel2.add(jPanel6, java.awt.BorderLayout.LINE_START); - txtTaxId.setText(customer.getTaxid()); - txtName.setText(customer.getName()); - txtCard.setText(customer.getCard()); - txtNotes.reset(); - txtNotes.setText(customer.getNotes()); - txtMaxdebt.setText(Formats.CURRENCY.formatValue(customer.getMaxdebt())); - txtCurdebt.setText(Formats.CURRENCY.formatValue(customer.getAccdebt())); - txtCurdate.setText(Formats.DATE.formatValue(customer.getCurdate())); - txtPrePay.setText(null); - - txtNotes.setEnabled(true); - txtPrePay.setEnabled(true); + add(jPanel2, java.awt.BorderLayout.PAGE_START); - dirty.setDirty(false); + jPanel3.setLayout(new java.awt.BorderLayout()); - btnSave.setEnabled(true); - btnPay.setEnabled(true); - btnPrePay.setEnabled(true); - -// btnPay.setEnabled(customer.getCurdebt() != null && customer.getCurdebt().doubleValue() > 0.0); - - } + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); - private void resetCustomer() { + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel4.add(m_jKeys); - customerext = null; + jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel5.setLayout(new java.awt.GridBagLayout()); - txtTaxId.setText(null); - txtName.setText(null); - txtCard.setText(null); - txtNotes.reset(); - txtMaxdebt.setText(null); - txtCurdebt.setText(null); - txtCurdate.setText(null); - txtPrePay.setText(null); + editorcard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + editorcard.setPreferredSize(new java.awt.Dimension(200, 30)); + jPanel5.add(editorcard, new java.awt.GridBagConstraints()); - txtNotes.setEnabled(false); - txtPrePay.setEnabled(false); + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jButton1.setFocusPainted(false); + jButton1.setFocusable(false); + jButton1.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jButton1.setPreferredSize(new java.awt.Dimension(110, 45)); + jButton1.setRequestFocusEnabled(false); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + jPanel5.add(jButton1, gridBagConstraints); - dirty.setDirty(false); + jPanel4.add(jPanel5); - btnSave.setEnabled(false); - btnPay.setEnabled(false); - btnPrePay.setEnabled(false); + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); - } + add(jPanel3, java.awt.BorderLayout.LINE_END); - private void readCustomer() { + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); - try { - CustomerInfoExt customer = dlsales.findCustomerExt(editorcard.getText()); - if (customer == null) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); - msg.show(this); - } else { - editCustomer(customer); - } + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(AppLocal.getIntString("label.notes")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(150, 30)); - } catch (BasicException ex) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); - msg.show(this); - } + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.card")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); - editorcard.reset(); - editorcard.activate(); - } + txtCard.setEditable(false); + txtCard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCard.setFocusable(false); + txtCard.setPreferredSize(new java.awt.Dimension(0, 30)); + txtCard.setRequestFocusEnabled(false); - private void save() { + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(120, 30)); - customerext.setNotes(txtNotes.getText()); - customerext.setPrePay(txtPrePay.getText()); - - try { - dlcustomers.updateCustomerExt(customerext); - editCustomer(customerext); - } catch (BasicException e) { - MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosave"), e); - msg.show(this); - } + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setText(AppLocal.getIntString("label.curdebt")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(120, 30)); - } + txtCurdebt.setEditable(false); + txtCurdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtCurdebt.setFocusable(false); + txtCurdebt.setPreferredSize(new java.awt.Dimension(120, 30)); + txtCurdebt.setRequestFocusEnabled(false); - private void printTicket(String resname, TicketInfo ticket, CustomerInfoExt customer) { + txtCurdate.setEditable(false); + txtCurdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdate.setHorizontalAlignment(javax.swing.JTextField.CENTER); + txtCurdate.setFocusable(false); + txtCurdate.setPreferredSize(new java.awt.Dimension(120, 30)); + txtCurdate.setRequestFocusEnabled(false); - String resource = dlsystem.getResourceAsXML(resname); - if (resource == null) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket")); - msg.show(this); - } else { - try { - ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); - script.put("ticket", ticket); - script.put("customer", customer); - ttp.printTicket(script.eval(resource).toString()); -// JG 6 May use multicatch - } catch ( ScriptException | TicketPrinterException e) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); - msg.show(this); - } - } - } + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel6.setText(AppLocal.getIntString("label.curdate")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(120, 30)); - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { - java.awt.GridBagConstraints gridBagConstraints; + txtName.setEditable(false); + txtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtName.setFocusable(false); + txtName.setPreferredSize(new java.awt.Dimension(0, 30)); + txtName.setRequestFocusEnabled(false); - jPanel2 = new javax.swing.JPanel(); - jPanel6 = new javax.swing.JPanel(); - btnCustomer = new javax.swing.JButton(); - btnSave = new javax.swing.JButton(); - jSeparator1 = new javax.swing.JSeparator(); - btnPay = new javax.swing.JButton(); - btnPrePay = new javax.swing.JButton(); - jPanel3 = new javax.swing.JPanel(); - jPanel4 = new javax.swing.JPanel(); - m_jKeys = new com.unicenta.editor.JEditorKeys(); - jPanel5 = new javax.swing.JPanel(); - editorcard = new com.unicenta.editor.JEditorString(); - jButton1 = new javax.swing.JButton(); - jPanel1 = new javax.swing.JPanel(); - jLabel3 = new javax.swing.JLabel(); - jLabel12 = new javax.swing.JLabel(); - jLabel5 = new javax.swing.JLabel(); - txtCard = new javax.swing.JTextField(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - txtCurdebt = new javax.swing.JTextField(); - txtCurdate = new javax.swing.JTextField(); - jLabel6 = new javax.swing.JLabel(); - txtName = new javax.swing.JTextField(); - txtMaxdebt = new javax.swing.JTextField(); - txtPrePay = new com.unicenta.editor.JEditorString(); - txtTaxId = new javax.swing.JTextField(); - jLabel7 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); - txtNotes = new com.unicenta.editor.JEditorString(); + txtMaxdebt.setEditable(false); + txtMaxdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtMaxdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtMaxdebt.setFocusable(false); + txtMaxdebt.setPreferredSize(new java.awt.Dimension(120, 30)); + txtMaxdebt.setRequestFocusEnabled(false); - setLayout(new java.awt.BorderLayout()); + txtPrePay.setForeground(new java.awt.Color(0, 204, 255)); + txtPrePay.setToolTipText(bundle.getString("tooltip.customerpay.prepay")); // NOI18N + txtPrePay.setEnabled(false); + txtPrePay.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + txtPrePay.setPreferredSize(new java.awt.Dimension(200, 30)); - jPanel2.setLayout(new java.awt.BorderLayout()); + txtTaxId.setEditable(false); + txtTaxId.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtTaxId.setFocusable(false); + txtTaxId.setPreferredSize(new java.awt.Dimension(150, 30)); + txtTaxId.setRequestFocusEnabled(false); - btnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N - java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N - btnCustomer.setToolTipText(bundle.getString("tooltip.customerpay.customer")); // NOI18N - btnCustomer.setFocusPainted(false); - btnCustomer.setFocusable(false); - btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14)); - btnCustomer.setPreferredSize(new java.awt.Dimension(110, 45)); - btnCustomer.setRequestFocusEnabled(false); - btnCustomer.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCustomerActionPerformed(evt); - } - }); - jPanel6.add(btnCustomer); + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.taxid")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); - btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N - btnSave.setToolTipText(bundle.getString("tootltip.save")); // NOI18N - btnSave.setFocusPainted(false); - btnSave.setFocusable(false); - btnSave.setMargin(new java.awt.Insets(8, 14, 8, 14)); - btnSave.setPreferredSize(new java.awt.Dimension(110, 45)); - btnSave.setRequestFocusEnabled(false); - btnSave.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnSaveActionPerformed(evt); - } - }); - jPanel6.add(btnSave); - jPanel6.add(jSeparator1); + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prepay")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(120, 30)); - btnPay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - btnPay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/pay.png"))); // NOI18N - btnPay.setText(AppLocal.getIntString("button.pay")); // NOI18N - btnPay.setToolTipText(bundle.getString("tooltip.customerpay.pay")); // NOI18N - btnPay.setFocusPainted(false); - btnPay.setFocusable(false); - btnPay.setMargin(new java.awt.Insets(8, 14, 8, 14)); - btnPay.setMaximumSize(new java.awt.Dimension(110, 44)); - btnPay.setMinimumSize(new java.awt.Dimension(110, 44)); - btnPay.setPreferredSize(new java.awt.Dimension(110, 45)); - btnPay.setRequestFocusEnabled(false); - btnPay.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnPayActionPerformed(evt); - } - }); - jPanel6.add(btnPay); + txtNotes.setToolTipText(bundle.getString("tooltip.customerpay.notes")); // NOI18N + txtNotes.setEnabled(false); + txtNotes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtNotes.setPreferredSize(new java.awt.Dimension(250, 100)); - btnPrePay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - btnPrePay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_add_sml.png"))); // NOI18N - btnPrePay.setText(AppLocal.getIntString("button.prepay")); // NOI18N - btnPrePay.setToolTipText(bundle.getString("tooltip.prepay")); // NOI18N - btnPrePay.setFocusPainted(false); - btnPrePay.setFocusable(false); - btnPrePay.setMargin(new java.awt.Insets(8, 14, 8, 14)); - btnPrePay.setMaximumSize(new java.awt.Dimension(110, 44)); - btnPrePay.setMinimumSize(new java.awt.Dimension(110, 44)); - btnPrePay.setPreferredSize(new java.awt.Dimension(110, 45)); - btnPrePay.setRequestFocusEnabled(false); - btnPrePay.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnPrePayActionPerformed(evt); - } - }); - jPanel6.add(btnPrePay); - - jPanel2.add(jPanel6, java.awt.BorderLayout.LINE_START); - - add(jPanel2, java.awt.BorderLayout.PAGE_START); - - jPanel3.setLayout(new java.awt.BorderLayout()); - - jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); - - m_jKeys.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - m_jKeysActionPerformed(evt); - } - }); - jPanel4.add(m_jKeys); - - jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); - jPanel5.setLayout(new java.awt.GridBagLayout()); - - editorcard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - editorcard.setPreferredSize(new java.awt.Dimension(200, 30)); - jPanel5.add(editorcard, new java.awt.GridBagConstraints()); - - jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N - jButton1.setFocusPainted(false); - jButton1.setFocusable(false); - jButton1.setMargin(new java.awt.Insets(8, 14, 8, 14)); - jButton1.setPreferredSize(new java.awt.Dimension(110, 45)); - jButton1.setRequestFocusEnabled(false); - jButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton1ActionPerformed(evt); - } - }); - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 1.0; - gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); - jPanel5.add(jButton1, gridBagConstraints); - - jPanel4.add(jPanel5); - - jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); - - add(jPanel3, java.awt.BorderLayout.LINE_END); - - jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel3.setText(AppLocal.getIntString("label.name")); // NOI18N - jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); - - jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel12.setText(AppLocal.getIntString("label.notes")); // NOI18N - jLabel12.setPreferredSize(new java.awt.Dimension(150, 30)); - - jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel5.setText(AppLocal.getIntString("label.card")); // NOI18N - jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); - - txtCard.setEditable(false); - txtCard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - txtCard.setFocusable(false); - txtCard.setPreferredSize(new java.awt.Dimension(0, 30)); - txtCard.setRequestFocusEnabled(false); - - jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel1.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N - jLabel1.setPreferredSize(new java.awt.Dimension(120, 30)); - - jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel2.setText(AppLocal.getIntString("label.curdebt")); // NOI18N - jLabel2.setPreferredSize(new java.awt.Dimension(120, 30)); - - txtCurdebt.setEditable(false); - txtCurdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - txtCurdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); - txtCurdebt.setFocusable(false); - txtCurdebt.setPreferredSize(new java.awt.Dimension(120, 30)); - txtCurdebt.setRequestFocusEnabled(false); - - txtCurdate.setEditable(false); - txtCurdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - txtCurdate.setHorizontalAlignment(javax.swing.JTextField.CENTER); - txtCurdate.setFocusable(false); - txtCurdate.setPreferredSize(new java.awt.Dimension(120, 30)); - txtCurdate.setRequestFocusEnabled(false); - - jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel6.setText(AppLocal.getIntString("label.curdate")); // NOI18N - jLabel6.setPreferredSize(new java.awt.Dimension(120, 30)); - - txtName.setEditable(false); - txtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - txtName.setFocusable(false); - txtName.setPreferredSize(new java.awt.Dimension(0, 30)); - txtName.setRequestFocusEnabled(false); - - txtMaxdebt.setEditable(false); - txtMaxdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - txtMaxdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); - txtMaxdebt.setFocusable(false); - txtMaxdebt.setPreferredSize(new java.awt.Dimension(120, 30)); - txtMaxdebt.setRequestFocusEnabled(false); - - txtPrePay.setForeground(new java.awt.Color(0, 204, 255)); - txtPrePay.setToolTipText(bundle.getString("tooltip.customerpay.prepay")); // NOI18N - txtPrePay.setEnabled(false); - txtPrePay.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N - txtPrePay.setPreferredSize(new java.awt.Dimension(200, 30)); - - txtTaxId.setEditable(false); - txtTaxId.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - txtTaxId.setFocusable(false); - txtTaxId.setPreferredSize(new java.awt.Dimension(150, 30)); - txtTaxId.setRequestFocusEnabled(false); - - jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel7.setText(AppLocal.getIntString("label.taxid")); // NOI18N - jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); - - jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jLabel4.setText(AppLocal.getIntString("label.prepay")); // NOI18N - jLabel4.setPreferredSize(new java.awt.Dimension(120, 30)); - - txtNotes.setToolTipText(bundle.getString("tooltip.customerpay.notes")); // NOI18N - txtNotes.setEnabled(false); - txtNotes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - txtNotes.setPreferredSize(new java.awt.Dimension(250, 100)); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, + javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 240, + javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 140, + javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(txtCard, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(txtCard, javax.swing.GroupLayout.PREFERRED_SIZE, 240, + javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 140, + javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(txtTaxId, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(txtTaxId, javax.swing.GroupLayout.PREFERRED_SIZE, 240, + javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 140, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(txtPrePay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtNotes, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(txtPrePay, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtNotes, javax.swing.GroupLayout.PREFERRED_SIZE, 250, + javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtTaxId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtTaxId, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtNotes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtNotes, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtPrePay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPrePay, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(30, 30, 30) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); - add(jPanel1, java.awt.BorderLayout.CENTER); - }// //GEN-END:initComponents - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + add(jPanel1, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents - readCustomer(); - - }//GEN-LAST:event_jButton1ActionPerformed + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed - private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + readCustomer(); - readCustomer(); - - }//GEN-LAST:event_m_jKeysActionPerformed + }// GEN-LAST:event_jButton1ActionPerformed - private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerActionPerformed + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jKeysActionPerformed - JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlcustomers); - finder.search(null); - finder.setVisible(true); - CustomerInfo customer = finder.getSelectedCustomer(); - if (customer != null) { - try { - CustomerInfoExt c = dlsales.loadCustomerExt(customer.getId()); - if (c == null) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); - msg.show(this); - } else { - editCustomer(c); - } - } catch (BasicException ex) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); - msg.show(this); - } - } - editorcard.reset(); - editorcard.activate(); - -}//GEN-LAST:event_btnCustomerActionPerformed + readCustomer(); - private void btnPayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPayActionPerformed + }// GEN-LAST:event_m_jKeysActionPerformed - paymentdialog.setPrintSelected(true); - - if (paymentdialog.showDialog(customerext.getAccdebt(), null)) { + private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnCustomerActionPerformed - // Save the ticket - TicketInfo ticket = new TicketInfo(); - ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); - - List payments = paymentdialog.getSelectedPayments(); - - double total = 0.0; - for (PaymentInfo p : payments) { - total += p.getTotal(); - } - - payments.add(new PaymentInfoTicket(-total, "debtpaid")); - - ticket.setPayments(payments); - - ticket.setUser(app.getAppUserView().getUser().getUserInfo()); - ticket.setActiveCash(app.getActiveCashIndex()); - ticket.setDate(new Date()); - ticket.setCustomer(customerext); - - try { - dlsales.saveTicket(ticket, app.getInventoryLocation()); - } catch (BasicException eData) { - MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); - msg.show(this); - } - - - // reload customer - CustomerInfoExt c; - try { - c = dlsales.loadCustomerExt(customerext.getId()); - if (c == null) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); - msg.show(this); - } else { - editCustomer(c); - } - } catch (BasicException ex) { - c = null; - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); - msg.show(this); - } - - printTicket(paymentdialog.isPrintSelected() - ? "Printer.CustomerPaid" - : "Printer.CustomerPaid2", - ticket, c); + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlcustomers); + finder.search(null); + finder.setVisible(true); + CustomerInfo customer = finder.getSelectedCustomer(); + if (customer != null) { + try { + CustomerInfoExt c = dlsales.loadCustomerExt(customer.getId()); + if (c == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(c); } - - editorcard.reset(); - editorcard.activate(); - -}//GEN-LAST:event_btnPayActionPerformed + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), + ex); + msg.show(this); + } + } + editorcard.reset(); + editorcard.activate(); - private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed + }// GEN-LAST:event_btnCustomerActionPerformed - if (dirty.isDirty()) { - save(); + private void btnPayActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnPayActionPerformed - editorcard.reset(); - editorcard.activate(); + paymentdialog.setPrintSelected(true); + + if (paymentdialog.showDialog(customerext.getAccdebt(), null)) { + + // Save the ticket + TicketInfo ticket = new TicketInfo(); + ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); + + List payments = paymentdialog.getSelectedPayments(); + + double total = 0.0; + for (PaymentInfo p : payments) { + total += p.getTotal(); + } + + payments.add(new PaymentInfoTicket(-total, "debtpaid")); + + ticket.setPayments(payments); + + ticket.setUserInfo(app.getAppUserView().getUser().getUserInfo()); + ticket.setActiveCash(app.getActiveCashIndex()); + ticket.setDate(new Date()); + ticket.setCustomer(customerext); + + try { + dlsales.saveTicket(ticket, app.getInventoryLocation()); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); + msg.show(this); + } + + // reload customer + CustomerInfoExt c; + try { + c = dlsales.loadCustomerExt(customerext.getId()); + if (c == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(c); } - -}//GEN-LAST:event_btnSaveActionPerformed + } catch (BasicException ex) { + c = null; + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), + ex); + msg.show(this); + } - private void btnPrePayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrePayActionPerformed + printTicket(paymentdialog.isPrintSelected() + ? "Printer.CustomerPaid" + : "Printer.CustomerPaid2", + ticket, c); + } - txtPrePay.setFocusable(true); - txtPrePay.requestFocusInWindow(); + editorcard.reset(); + editorcard.activate(); - if (txtPrePay.getText() != null) { - double prepay = Double.parseDouble(txtPrePay.getText()); - Formats.CURRENCY.formatValue(RoundUtils.getValue(prepay)); - paymentdialog.setPrintSelected(true); - - if (paymentdialog.showDialog(prepay, null)) { - - TicketInfo ticket = new TicketInfo(); - ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); - List payments = paymentdialog.getSelectedPayments(); + }// GEN-LAST:event_btnPayActionPerformed - double total = 0.0; - for (PaymentInfo p : payments) { - total += p.getTotal(); - } - - total = Double.parseDouble(txtPrePay.getText()); + private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnSaveActionPerformed - payments.add(new PaymentInfoTicket(-total, "debtpaid")); + if (dirty.isDirty()) { + save(); - ticket.setPayments(payments); + editorcard.reset(); + editorcard.activate(); + } - ticket.setUser(app.getAppUserView().getUser().getUserInfo()); - ticket.setActiveCash(app.getActiveCashIndex()); - ticket.setDate(new Date()); - ticket.setCustomer(customerext); + }// GEN-LAST:event_btnSaveActionPerformed - try { - dlsales.saveTicket(ticket, app.getInventoryLocation()); - } catch (BasicException eData) { - MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); - msg.show(this); - } + private void btnPrePayActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnPrePayActionPerformed - CustomerInfoExt c; - try { - c = dlsales.loadCustomerExt(customerext.getId()); - if (c == null) { - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); - msg.show(this); - } else { - editCustomer(c); - } - } catch (BasicException ex) { - c = null; - MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); - msg.show(this); - } + txtPrePay.setFocusable(true); + txtPrePay.requestFocusInWindow(); - printTicket(paymentdialog.isPrintSelected() - ? "Printer.CustomerPaid" - : "Printer.CustomerPaid2", - ticket, c); - } - - editorcard.reset(); - editorcard.activate(); + if (txtPrePay.getText() != null) { + double prepay = Double.parseDouble(txtPrePay.getText()); + Formats.CURRENCY.formatValue(RoundUtils.getValue(prepay)); + paymentdialog.setPrintSelected(true); + + if (paymentdialog.showDialog(prepay, null)) { + + TicketInfo ticket = new TicketInfo(); + ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); + List payments = paymentdialog.getSelectedPayments(); + + double total = 0.0; + for (PaymentInfo p : payments) { + total += p.getTotal(); } - }//GEN-LAST:event_btnPrePayActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton btnCustomer; - private javax.swing.JButton btnPay; - private javax.swing.JButton btnPrePay; - private javax.swing.JButton btnSave; - private com.unicenta.editor.JEditorString editorcard; - private javax.swing.JButton jButton1; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel12; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JPanel jPanel3; - private javax.swing.JPanel jPanel4; - private javax.swing.JPanel jPanel5; - private javax.swing.JPanel jPanel6; - private javax.swing.JSeparator jSeparator1; - private com.unicenta.editor.JEditorKeys m_jKeys; - private javax.swing.JTextField txtCard; - private javax.swing.JTextField txtCurdate; - private javax.swing.JTextField txtCurdebt; - private javax.swing.JTextField txtMaxdebt; - private javax.swing.JTextField txtName; - private com.unicenta.editor.JEditorString txtNotes; - private com.unicenta.editor.JEditorString txtPrePay; - private javax.swing.JTextField txtTaxId; - // End of variables declaration//GEN-END:variables + total = Double.parseDouble(txtPrePay.getText()); + + payments.add(new PaymentInfoTicket(-total, "debtpaid")); + + ticket.setPayments(payments); + + ticket.setUserInfo(app.getAppUserView().getUser().getUserInfo()); + ticket.setActiveCash(app.getActiveCashIndex()); + ticket.setDate(new Date()); + ticket.setCustomer(customerext); + + try { + dlsales.saveTicket(ticket, app.getInventoryLocation()); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); + msg.show(this); + } + + CustomerInfoExt c; + try { + c = dlsales.loadCustomerExt(customerext.getId()); + if (c == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(c); + } + } catch (BasicException ex) { + c = null; + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), + ex); + msg.show(this); + } + + printTicket(paymentdialog.isPrintSelected() + ? "Printer.CustomerPaid" + : "Printer.CustomerPaid2", + ticket, c); + } + + editorcard.reset(); + editorcard.activate(); + } + }// GEN-LAST:event_btnPrePayActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCustomer; + private javax.swing.JButton btnPay; + private javax.swing.JButton btnPrePay; + private javax.swing.JButton btnSave; + private com.unicenta.editor.JEditorString editorcard; + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JSeparator jSeparator1; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JTextField txtCard; + private javax.swing.JTextField txtCurdate; + private javax.swing.JTextField txtCurdebt; + private javax.swing.JTextField txtMaxdebt; + private javax.swing.JTextField txtName; + private com.unicenta.editor.JEditorString txtNotes; + private com.unicenta.editor.JEditorString txtPrePay; + private javax.swing.JTextField txtTaxId; + // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/com/unicenta/pos/forms/DataLogicSales.java b/src/main/java/com/unicenta/pos/forms/DataLogicSales.java index d76e94c..0ffa9d3 100644 --- a/src/main/java/com/unicenta/pos/forms/DataLogicSales.java +++ b/src/main/java/com/unicenta/pos/forms/DataLogicSales.java @@ -52,2793 +52,2645 @@ import java.io.File; */ public class DataLogicSales extends BeanFactoryDataSingle { - protected Session s; + protected Session s; - protected Datas[] auxiliarDatas; - protected Datas[] stockdiaryDatas; - protected Datas[] paymenttabledatas; - protected Datas[] stockdatas; - protected Datas[] stockAdjustDatas; + protected Datas[] auxiliarDatas; + protected Datas[] stockdiaryDatas; + protected Datas[] paymenttabledatas; + protected Datas[] stockdatas; + protected Datas[] stockAdjustDatas; - protected Row productsRow; - protected Row customersRow; + protected Row productsRow; + protected Row customersRow; - private String pName; - private Double getTotal; - private Double getTendered; - private String getRetMsg; - private String getVoucher; + private String pName; + private Double getTotal; + private Double getTendered; + private String getRetMsg; + private String getVoucher; - public static final String DEBT = "debt"; - public static final String DEBT_PAID = "debtpaid"; - protected static final String PREPAY = "prepay"; - private static final Logger logger = Logger.getLogger("com.unicenta.pos.forms.DataLogicSales"); + public static final String DEBT = "debt"; + public static final String DEBT_PAID = "debtpaid"; + protected static final String PREPAY = "prepay"; + private static final Logger logger = Logger.getLogger("com.unicenta.pos.forms.DataLogicSales"); - private String getCardName; - protected SentenceExec m_createCat; - protected SentenceExec m_createSupp; + private String getCardName; + protected SentenceExec m_createCat; + protected SentenceExec m_createSupp; - protected AppView m_App; + protected AppView m_App; - private AppConfig m_config; + private AppConfig m_config; - public DataLogicSales() { - AppView app = null; - m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); - m_config.load(); - m_App = app; + public DataLogicSales() { + AppView app = null; + m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + m_App = app; - stockdiaryDatas = new Datas[] { - Datas.STRING, Datas.TIMESTAMP, Datas.INT, Datas.STRING, - Datas.STRING, Datas.STRING, Datas.DOUBLE, Datas.DOUBLE, - Datas.STRING, Datas.STRING, Datas.STRING}; + stockdiaryDatas = new Datas[] { + Datas.STRING, Datas.TIMESTAMP, Datas.INT, Datas.STRING, + Datas.STRING, Datas.STRING, Datas.DOUBLE, Datas.DOUBLE, + Datas.STRING, Datas.STRING, Datas.STRING }; - paymenttabledatas = new Datas[] { - Datas.STRING, Datas.STRING, Datas.TIMESTAMP, - Datas.STRING, Datas.STRING, Datas.DOUBLE, - Datas.STRING}; + paymenttabledatas = new Datas[] { + Datas.STRING, Datas.STRING, Datas.TIMESTAMP, + Datas.STRING, Datas.STRING, Datas.DOUBLE, + Datas.STRING }; - stockdatas = new Datas[] { - Datas.STRING, Datas.STRING, Datas.STRING, - Datas.DOUBLE, Datas.DOUBLE, Datas.DOUBLE}; + stockdatas = new Datas[] { + Datas.STRING, Datas.STRING, Datas.STRING, + Datas.DOUBLE, Datas.DOUBLE, Datas.DOUBLE }; - stockAdjustDatas = new Datas[] { - Datas.STRING, - Datas.STRING, - Datas.STRING, - Datas.DOUBLE}; + stockAdjustDatas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.DOUBLE }; - auxiliarDatas = new Datas[] { - Datas.STRING, Datas.STRING, Datas.STRING, - Datas.STRING, Datas.STRING, Datas.STRING}; + auxiliarDatas = new Datas[] { + Datas.STRING, Datas.STRING, Datas.STRING, + Datas.STRING, Datas.STRING, Datas.STRING }; - productsRow = new Row( - new Field("ID", Datas.STRING, Formats.STRING), - new Field(AppLocal.getIntString("label.prodref"), Datas.STRING, Formats.STRING, true, true, true), - new Field(AppLocal.getIntString("label.prodbarcode"), Datas.STRING, Formats.STRING, false, true, true), - new Field(AppLocal.getIntString("label.prodbarcodetype"), Datas.STRING, Formats.STRING, false, true, true), - new Field(AppLocal.getIntString("label.prodname"), Datas.STRING, Formats.STRING, true, true, true), - new Field(AppLocal.getIntString("label.prodpricebuy"), Datas.DOUBLE, Formats.CURRENCY, false, true, true), - new Field(AppLocal.getIntString("label.prodpricesell"), Datas.DOUBLE, Formats.CURRENCY, false, true, true), - new Field(AppLocal.getIntString("label.prodcategory"), Datas.STRING, Formats.STRING, false, false, true), - new Field(AppLocal.getIntString("label.taxcategory"), Datas.STRING, Formats.STRING, false, false, true), - new Field(AppLocal.getIntString("label.attributeset"), Datas.STRING, Formats.STRING, false, false, true), - new Field("STOCKCOST", Datas.DOUBLE, Formats.CURRENCY), - new Field("STOCKVOLUME", Datas.DOUBLE, Formats.DOUBLE), - new Field("IMAGE", Datas.IMAGE, Formats.NULL), - new Field("ISCOM", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("ISSCALE", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("ISCONSTANT", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("PRINTKB", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("SENDSTATUS", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("ISSERVICE", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("PROPERTIES", Datas.BYTES, Formats.NULL), - new Field(AppLocal.getIntString("label.display"), Datas.STRING, Formats.STRING, false, true, true), - new Field("ISVPRICE", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("ISVERPATRIB", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("TEXTTIP", Datas.STRING, Formats.STRING), - new Field("WARRANTY", Datas.BOOLEAN, Formats.BOOLEAN), - new Field(AppLocal.getIntString("label.stockunits"), Datas.DOUBLE, Formats.DOUBLE), - new Field("PRINTTO", Datas.STRING, Formats.STRING), - new Field(AppLocal.getIntString("label.prodsupplier"), Datas.STRING, Formats.STRING, false, false, true), - new Field(AppLocal.getIntString("label.UOM"), Datas.STRING, Formats.STRING), - new Field("MEMODATE", Datas.TIMESTAMP, Formats.DATE), + productsRow = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.prodref"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.prodbarcode"), Datas.STRING, Formats.STRING, false, true, true), + new Field(AppLocal.getIntString("label.prodbarcodetype"), Datas.STRING, Formats.STRING, false, true, true), + new Field(AppLocal.getIntString("label.prodname"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.prodpricebuy"), Datas.DOUBLE, Formats.CURRENCY, false, true, true), + new Field(AppLocal.getIntString("label.prodpricesell"), Datas.DOUBLE, Formats.CURRENCY, false, true, true), + new Field(AppLocal.getIntString("label.prodcategory"), Datas.STRING, Formats.STRING, false, false, true), + new Field(AppLocal.getIntString("label.taxcategory"), Datas.STRING, Formats.STRING, false, false, true), + new Field(AppLocal.getIntString("label.attributeset"), Datas.STRING, Formats.STRING, false, false, true), + new Field("STOCKCOST", Datas.DOUBLE, Formats.CURRENCY), + new Field("STOCKVOLUME", Datas.DOUBLE, Formats.DOUBLE), + new Field("IMAGE", Datas.IMAGE, Formats.NULL), + new Field("ISCOM", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISSCALE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISCONSTANT", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("PRINTKB", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("SENDSTATUS", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISSERVICE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("PROPERTIES", Datas.BYTES, Formats.NULL), + new Field(AppLocal.getIntString("label.display"), Datas.STRING, Formats.STRING, false, true, true), + new Field("ISVPRICE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISVERPATRIB", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("TEXTTIP", Datas.STRING, Formats.STRING), + new Field("WARRANTY", Datas.BOOLEAN, Formats.BOOLEAN), + new Field(AppLocal.getIntString("label.stockunits"), Datas.DOUBLE, Formats.DOUBLE), + new Field("PRINTTO", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.prodsupplier"), Datas.STRING, Formats.STRING, false, false, true), + new Field(AppLocal.getIntString("label.UOM"), Datas.STRING, Formats.STRING), + new Field("MEMODATE", Datas.TIMESTAMP, Formats.DATE), - new Field("ISCATALOG", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("CATORDER", Datas.INT, Formats.INT) - ); + new Field("ISCATALOG", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("CATORDER", Datas.INT, Formats.INT)); -// creating customers object here for now for future global reuse -// LOYALTY, MEMBERSHIP & etc as will be more system centric than customer + // creating customers object here for now for future global reuse + // LOYALTY, MEMBERSHIP & etc as will be more system centric than customer - customersRow = new Row( - new Field("ID", Datas.STRING, Formats.STRING), - new Field("SEARCHKEY", Datas.STRING, Formats.STRING), - new Field("TAXID", Datas.STRING, Formats.STRING), - new Field("NAME", Datas.STRING, Formats.STRING), - new Field("TAXCATEGORY", Datas.STRING, Formats.STRING), - new Field("CARD", Datas.STRING, Formats.STRING), - new Field("MAXDEBT", Datas.DOUBLE, Formats.CURRENCY), - new Field("ADDRESS", Datas.STRING, Formats.STRING), - new Field("ADDRESS2", Datas.STRING, Formats.STRING), - new Field("POSTAL", Datas.STRING, Formats.STRING), - new Field("CITY", Datas.STRING, Formats.STRING), - new Field("REGION", Datas.STRING, Formats.STRING), - new Field("COUNTRY", Datas.STRING, Formats.STRING), - new Field("FIRSTNAME", Datas.STRING, Formats.STRING), - new Field("LASTNAME", Datas.STRING, Formats.STRING), - new Field("EMAIL", Datas.STRING, Formats.STRING), - new Field("PHONE", Datas.STRING, Formats.STRING), - new Field("PHONE2", Datas.STRING, Formats.STRING), - new Field("FAX", Datas.STRING, Formats.STRING), - new Field("NOTES", Datas.STRING, Formats.STRING), - new Field("VISIBLE", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("CURDATE", Datas.STRING, Formats.TIMESTAMP), - new Field("CURDEBT", Datas.DOUBLE, Formats.CURRENCY), - new Field("IMAGE", Datas.BYTES, Formats.NULL), - new Field("ISVIP", Datas.BOOLEAN, Formats.BOOLEAN), - new Field("DISCOUNT", Datas.DOUBLE, Formats.CURRENCY), - new Field("MEMODATE", Datas.STRING, Formats.TIMESTAMP) - ); + customersRow = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field("SEARCHKEY", Datas.STRING, Formats.STRING), + new Field("TAXID", Datas.STRING, Formats.STRING), + new Field("NAME", Datas.STRING, Formats.STRING), + new Field("TAXCATEGORY", Datas.STRING, Formats.STRING), + new Field("CARD", Datas.STRING, Formats.STRING), + new Field("MAXDEBT", Datas.DOUBLE, Formats.CURRENCY), + new Field("ADDRESS", Datas.STRING, Formats.STRING), + new Field("ADDRESS2", Datas.STRING, Formats.STRING), + new Field("POSTAL", Datas.STRING, Formats.STRING), + new Field("CITY", Datas.STRING, Formats.STRING), + new Field("REGION", Datas.STRING, Formats.STRING), + new Field("COUNTRY", Datas.STRING, Formats.STRING), + new Field("FIRSTNAME", Datas.STRING, Formats.STRING), + new Field("LASTNAME", Datas.STRING, Formats.STRING), + new Field("EMAIL", Datas.STRING, Formats.STRING), + new Field("PHONE", Datas.STRING, Formats.STRING), + new Field("PHONE2", Datas.STRING, Formats.STRING), + new Field("FAX", Datas.STRING, Formats.STRING), + new Field("NOTES", Datas.STRING, Formats.STRING), + new Field("VISIBLE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("CURDATE", Datas.STRING, Formats.TIMESTAMP), + new Field("CURDEBT", Datas.DOUBLE, Formats.CURRENCY), + new Field("IMAGE", Datas.BYTES, Formats.NULL), + new Field("ISVIP", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("DISCOUNT", Datas.DOUBLE, Formats.CURRENCY), + new Field("MEMODATE", Datas.STRING, Formats.TIMESTAMP)); + } + + /** + * + * @param s + */ + @Override + public void init(Session s) { + this.s = s; + + m_createCat = new StaticSentence(s, + "INSERT INTO categories ( ID, NAME, CATSHOWNAME ) " + + "VALUES (?, ?, ?)", + new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.INT })); + + m_createSupp = new StaticSentence(s, + "INSERT INTO suppliers ( ID, NAME, SEARCHKEY, VISIBLE ) " + + "VALUES (?, ?, ?, ?)", + new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.BOOLEAN })); + } + + // Import Creates + public final void createCategory(Object[] category) throws BasicException { + m_createCat.exec(category); + } + + public final void createSupplier(Object[] supplier) throws BasicException { + m_createSupp.exec(supplier); + } + // End Import Creates + + public final Row getProductsRow() { + return productsRow; + } + + public final Row getCustomersRow() { + return customersRow; + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final ProductInfoExt getProductInfo(String id) throws BasicException { + return (ProductInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products WHERE ID = ?", SerializerWriteString.INSTANCE, ProductInfoExt.getSerializerRead()).find(id); + } + + public final ProductInfoExt getProductInfoByCode(String sCode) throws BasicException { + // if (sCode.length() == 13 && (sCode.startsWith("2") || + // sCode.startsWith("02"))) + // return getProductInfoByShortCode(sCode); + // else { + return (ProductInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products WHERE CODE = ?", SerializerWriteString.INSTANCE, ProductInfoExt.getSerializerRead()) + .find(sCode); + // } + } + + public final ProductInfoExt getProductInfoByShortCode(String sCode) throws BasicException { + + return (ProductInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE SUBSTRING( CODE, 3, 6 ) = ?", SerializerWriteString.INSTANCE, ProductInfoExt.getSerializerRead()) + .find(sCode.substring(2, 8)); + } + + /* + * Important Note: + * Deliberately extracted from other code to force strict UPC-A (full 12 digits) + * Why? Because other manf' or in-store codes may exist and we just need a + * single + * record returned. Also, handling things this way will allow use (future) of a + * COUPON code (5 or 9 normally used) in-store + * + */ + public final ProductInfoExt getProductInfoByUShortCode(String sCode) throws BasicException { + + return (ProductInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE LEFT( CODE, 7 ) = ? AND CODETYPE = 'UPC-A' " + // selection of 7 digits ie: 2123456 specific to allow for other 12 digit + // codes that may be in use at positions 234567 + // last digit (position 7) can be used to identify COUPON (5 or 9) - FUTURE + , SerializerWriteString.INSTANCE, ProductInfoExt.getSerializerRead()) + .find(sCode.substring(0, 7)); + } + + /** + * + * @param sReference + * @return + * @throws BasicException + */ + public final ProductInfoExt getProductInfoByReference(String sReference) throws BasicException { + return (ProductInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products WHERE REFERENCE = ?", SerializerWriteString.INSTANCE, ProductInfoExt.getSerializerRead()) + .find(sReference); + } + + /** + * + * @return + * @throws BasicException + */ + public final List getRootCategories() throws BasicException { + return new PreparedSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "WHERE PARENTID IS NULL AND CATSHOWNAME = " + s.DB.TRUE() + " " + + "ORDER BY CATORDER, NAME", null, CategoryInfo.getSerializerRead()).list(); + } + + /** + * + * @param category + * @return + * @throws BasicException + */ + public final List getSubcategories(String category) throws BasicException { + return new PreparedSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories WHERE PARENTID = ? " + + "ORDER BY CATORDER, NAME", SerializerWriteString.INSTANCE, CategoryInfo.getSerializerRead()).list(category); + } + + /** + * + * @param category + * @return + * @throws BasicException + */ + public List getProductCatalog(String category) throws BasicException { + return new PreparedSentence(s, "SELECT " + + "P.ID, " + + "P.REFERENCE, " + + "P.CODE, " + + "P.CODETYPE, " + + "P.NAME, " + + "P.PRICEBUY, " + + "P.PRICESELL, " + + "P.CATEGORY, " + + "P.TAXCAT, " + + "P.ATTRIBUTESET_ID, " + + "P.STOCKCOST, " + + "P.STOCKVOLUME, " + + "P.IMAGE, " + + "P.ISCOM, " + + "P.ISSCALE, " + + "P.ISCONSTANT, " + + "P.PRINTKB, " + + "P.SENDSTATUS, " + + "P.ISSERVICE, " + + "P.ATTRIBUTES, " + + "P.DISPLAY, " + + "P.ISVPRICE, " + + "P.ISVERPATRIB, " + + "P.TEXTTIP, " + + "P.WARRANTY, " + + "P.STOCKUNITS, " + + "P.PRINTTO, " + + "P.SUPPLIER, " + + "P.UOM, " + + "P.MEMODATE " + + "FROM products P, products_cat O " + + "WHERE P.ID = O.PRODUCT AND P.CATEGORY = ? " + + "ORDER BY O.CATORDER, P.NAME ", SerializerWriteString.INSTANCE, ProductInfoExt.getSerializerRead()) + .list(category); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public List getProductComments(String id) throws BasicException { + return new PreparedSentence(s, "SELECT " + + "P.ID, " + + "P.REFERENCE, " + + "P.CODE, " + + "P.CODETYPE, " + + "P.NAME, " + + "P.PRICEBUY, " + + "P.PRICESELL, " + + "P.CATEGORY, " + + "P.TAXCAT, " + + "P.ATTRIBUTESET_ID, " + + "P.STOCKCOST, " + + "P.STOCKVOLUME, " + + "P.IMAGE, " + + "P.ISCOM, " + + "P.ISSCALE, " + + "P.ISCONSTANT, " + + "P.PRINTKB, " + + "P.SENDSTATUS, " + + "P.ISSERVICE, " + + "P.ATTRIBUTES, " + + "P.DISPLAY, " + + "P.ISVPRICE, " + + "P.ISVERPATRIB, " + + "P.TEXTTIP, " + + "P.WARRANTY, " + + "P.STOCKUNITS, " + + "P.PRINTTO, " + + "P.SUPPLIER, " + + "P.UOM, " + + "P.MEMODATE " + + "FROM products P, " + + "products_cat O, products_com M " + + "WHERE P.ID = O.PRODUCT AND P.ID = M.PRODUCT2 AND M.PRODUCT = ? " + + "AND P.ISCOM = " + s.DB.TRUE() + " " + + "ORDER BY O.CATORDER, P.NAME", SerializerWriteString.INSTANCE, ProductInfoExt.getSerializerRead()).list(id); + } + + // JG uniCenta June 2014 includes StockUnits + /** + * + * @return + * @throws BasicException + */ + public List getProductConstant() throws BasicException { + return new PreparedSentence(s, "SELECT " + + "products.ID, " + + "products.REFERENCE, " + + "products.CODE, " + + "products.CODETYPE, " + + "products.NAME, " + + "products.PRICEBUY, " + + "products.PRICESELL, " + + "products.CATEGORY, " + + "products.TAXCAT, " + + "products.ATTRIBUTESET_ID, " + + "products.STOCKCOST, " + + "products.STOCKVOLUME, " + + "products.IMAGE, " + + "products.ISCOM, " + + "products.ISSCALE, " + + "products.ISCONSTANT, " + + "products.PRINTKB, " + + "products.SENDSTATUS, " + + "products.ISSERVICE, " + + "products.ATTRIBUTES, " + + "products.DISPLAY, " + + "products.ISVPRICE, " + + "products.ISVERPATRIB, " + + "products.TEXTTIP, " + + "products.WARRANTY, " + + "products.STOCKUNITS, " + + "products.PRINTTO, " + + "products.SUPPLIER, " + + "products.UOM, " + + "products.MEMODATE " + + "FROM categories INNER JOIN products ON (products.CATEGORY = categories.ID) " + + "WHERE products.ISCONSTANT = " + s.DB.TRUE() + " " + + "ORDER BY categories.NAME, products.NAME", + null, + ProductInfoExt.getSerializerRead()).list(); + + } + + public final CategoryInfo getCategoryInfoByName(String name) throws BasicException { + return (CategoryInfo) new PreparedSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "WHERE NAME = ? " + + "ORDER BY CATORDER, NAME", SerializerWriteString.INSTANCE, CategoryInfo.getSerializerRead()).find(name); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final CategoryInfo getCategoryInfo(String id) throws BasicException { + return (CategoryInfo) new PreparedSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "WHERE ID = ? " + + "ORDER BY CATORDER, NAME", SerializerWriteString.INSTANCE, CategoryInfo.getSerializerRead()).find(id); + } + + /** + * JG Dec 2017 + * + * @param pId + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List getCategorysProductList(String pId) throws BasicException { + return new PreparedSentence(s, + "SELECT products.ID, " + + "products.NAME AS Name, " + + "products.CODE AS Barcode, " + + "categories.ID AS Category " + + "FROM products products " + + "INNER JOIN categories categories ON (products.CATEGORY = categories.ID) " + + "WHERE products.category = ? " + + "ORDER BY products.NAME ASC", + SerializerWriteString.INSTANCE, + CategoryStock.getSerializerRead()).list(pId); + } + + /** + * + * @return + */ + + public final SentenceList getProductList() { + return new StaticSentence(s, new QBFBuilder( + "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY REFERENCE", + new String[] { "NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE" }), + new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING }), + ProductInfoExt.getSerializerRead()); + } + + /** + * + * @return + */ + public SentenceList getProductListNormal() { + return new StaticSentence(s, new QBFBuilder( + "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE ISCOM = " + s.DB.FALSE() + " AND ?(QBF_FILTER) ORDER BY REFERENCE", + new String[] { "NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE" }), + new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING }), + ProductInfoExt.getSerializerRead()); + } + + /** + * + * @return + */ + public SentenceList getProductsList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "ORDER BY NAME", null, ProductInfo.getSerializerRead()); + } + + public SentenceList getProductList2() { + return new StaticSentence(s, new QBFBuilder( + "SELECT " + + "products.id, " + + "products.name, " + + "stockcurrent.units, " + + "locations.name, " + + "products.pricesell, " + + "taxes.rate, " + + "products.pricesell + (products.pricesell * taxes.rate) AS SellIncTax " + + " FROM (((stockcurrent stockcurrent " + + "INNER JOIN locations locations " + + "ON (stockcurrent.location = locations.id)) " + + "INNER JOIN products products " + + "ON (stockcurrent.product = products.id)) " + + "INNER JOIN taxcategories taxcategories " + + "ON (products.taxcat = taxcategories.id)) " + + "INNER JOIN taxes taxes " + + "ON (taxes.category = taxcategories.id) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY products.name ", + new String[] { "NAME", "UNITS", "SellIncTax", "LOCATION", }), + new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING }), + ProductInfoExt.getSerializerRead()); + } + + /** + * + * @return + */ + public SentenceList getProductListAuxiliar() { + return new StaticSentence(s, new QBFBuilder( + "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE ISCOM = " + s.DB.TRUE() + " AND ?(QBF_FILTER) " + + "ORDER BY REFERENCE", + new String[] { "NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE" }), + new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING }), + ProductInfoExt.getSerializerRead()); + } + + /** + * + * @param productId The product id to look for bundle + * @return List of products part of the searched product + * @throws BasicException + */ + public final List getProductsBundle(String productId) throws BasicException { + return new PreparedSentence(s, "SELECT " + + "ID, " + + "PRODUCT, " + + "PRODUCT_BUNDLE, " + + "QUANTITY " + + "FROM products_bundle WHERE PRODUCT = ?", SerializerWriteString.INSTANCE, + ProductsBundleInfo.getSerializerRead()).list(productId); + } + + /** + * JG Oct 2016 + * Called from JPanelTicket + * + * @param pId + * @param location + * @return + * @throws BasicException + */ + public final ProductStock getProductStockState(String pId, String location) throws BasicException { + + PreparedSentence preparedSentence = new PreparedSentence(s, + "SELECT " + + "MIN(products.id), " + + "locations.id as Location, " + + "MIN(stockcurrent.units), " + + "MIN(stocklevel.stocksecurity) AS Minimum, " + + "MIN(stocklevel.stockmaximum) AS Maximum, " + + "MIN(products.pricebuy), " + + "MIN(products.pricesell), " + + "MIN(products.memodate) " + + "FROM locations " + + "INNER JOIN ((products " + + "INNER JOIN stockcurrent " + + "ON products.id = stockcurrent.product) " + + "LEFT JOIN stocklevel ON products.id = stocklevel.product) " + + "ON locations.id = stockcurrent.location " + + "WHERE products.id = ? " + + "AND locations.id = ?", + SerializerWriteString.INSTANCE, ProductStock.getSerializerRead()); + + ProductStock productStock = (ProductStock) preparedSentence.find(pId, location); + + return productStock; + } + + /** + * JG May 2016 + * Called from StockManagement + * + * @param pId + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List getProductStockList(String pId) throws BasicException { + return new PreparedSentence(s, + "SELECT MIN(products.id), " + + "MIN(locations.name) AS Location, " + + "MIN(stockcurrent.units) AS stockcurrent, " + + "MIN(stocklevel.stocksecurity) AS Minimum, " + + "MIN(stocklevel.stockmaximum) AS Maximum, " + + "MIN(products.pricebuy) AS PriceBuy, " + + "(MIN(products.pricesell) * MIN(taxes.rate)) + MIN(products.pricesell) AS PriceSell, " + + "MIN(products.memodate) " + + "FROM ((((taxcategories TC " + + "INNER JOIN taxes taxes " + + "ON (TC.id = taxes.category)) " + + "RIGHT OUTER JOIN products products " + + "ON (products.TAXCAT = TC.id)) " + + "LEFT OUTER JOIN stocklevel stocklevel " + + "ON (stocklevel.product = products.ID)) " + + "LEFT OUTER JOIN stockcurrent stockcurrent " + + "ON (products.ID = stockcurrent.product)) " + + "INNER JOIN locations locations " + + "ON (stockcurrent.location = locations.id) " + + "WHERE products.id= ? " + + "GROUP BY locations.name", + SerializerWriteString.INSTANCE, + ProductStock.getSerializerRead()).list(pId); + } + + /** + * JG Sept 2017 + * + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List getReprintTicketList() throws BasicException { + + // payment queries + List ticketInfoList = (List) new StaticSentence(s, "SELECT " + + "T.TICKETID, " + + "T.TICKETTYPE, " + + "R.DATENEW, " + + "P.NAME, " + + "C.NAME, " + + "SUM(PM.TOTAL), " + + "T.STATUS " + + "FROM receipts " + + "R JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " + + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " + + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "GROUP BY " + + "T.ID, " + + "T.TICKETID, " + + "T.TICKETTYPE, " + + "R.DATENEW, " + + "P.NAME, " + + "C.NAME " + + "ORDER BY R.DATENEW DESC, T.TICKETID " + + "LIMIT 10 ", null, new SerializerReadClass(ReprintTicketInfo.class)).list(); + + return ticketInfoList; + } + + /** + * + * @param Id + * @return + * @throws BasicException + */ + public final TicketInfo getReprintTicket(String Id) throws BasicException { + + // payment queries + + if (Id == null) { + return null; + } else { + Object[] record = (Object[]) new StaticSentence(s, "SELECT " + + "T.TICKETID, " + + "SUM(PM.TOTAL), " + + "R.DATENEW, " + + "P.NAME, " + + "T.TICKETTYPE, " + + "C.NAME, " + + "T.STATUS " + + "FROM receipts R " + + "JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " + + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " + + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "WHERE T.TICKETID = ?", SerializerWriteString.INSTANCE, + new SerializerReadBasic(new Datas[] { Datas.SERIALIZABLE })).find(Id); + return record == null ? null : (TicketInfo) record[0]; } + } + + // Tickets and Receipt list + + // Payment queries + public SentenceList getTicketsList() { + + StaticSentence staticSentence = new StaticSentence(s, new QBFBuilder( + "SELECT " + + "T.TICKETID, " + + "T.TICKETTYPE, " + + "R.DATENEW, " + + "P.NAME, " + + "C.NAME, " + + "SUM(PM.TOTAL), " + + "SUM(T.STATUS), " + + "PM.notes " + + "FROM receipts R " + + "JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " + + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " + + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY T.ID, T.TICKETID, T.TICKETTYPE, R.DATENEW, P.NAME, C.NAME, PM.notes " + + "ORDER BY R.DATENEW DESC, T.TICKETID", + new String[] { + "T.TICKETID", "T.TICKETTYPE", "PM.TOTAL", "R.DATENEW", "R.DATENEW", "P.NAME", "C.NAME", "PM.NOTES" }), + new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.INT, + Datas.OBJECT, Datas.INT, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.TIMESTAMP, + Datas.OBJECT, Datas.TIMESTAMP, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING }), + new SerializerReadClass(FindTicketsInfo.class)); + + return staticSentence; + } + + // User list + + /** + * + * @return + */ + public final SentenceList getUserList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME " + + "FROM people " + + "ORDER BY NAME", null, + (DataRead dr) -> new TaxCategoryInfo( + dr.getString(1), + dr.getString(2))); + } + + /** + * + * @return + */ + public final SentenceList getTaxList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "CATEGORY, " + + "CUSTCATEGORY, " + + "PARENTID, " + + "RATE, " + + "RATECASCADE, " + + "RATEORDER " + + "FROM taxes " + + "ORDER BY NAME", null, + (DataRead dr) -> new TaxInfo( + dr.getString(1), + dr.getString(2), + dr.getString(3), + dr.getString(4), + dr.getString(5), + dr.getDouble(6), + dr.getBoolean(7), + dr.getInt(8))); + } + + /** + * + * @return + */ + public final SentenceList getCategoriesList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "ORDER BY NAME", null, CategoryInfo.getSerializerRead()); + } + + /** + * JG Feb 2017 + * Returns all PARENT categories + * + * @return + */ + public final SentenceList getCategoriesList_1() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "WHERE PARENTID IS NULL " + + "ORDER BY NAME", null, CategoryInfo.getSerializerRead()); + } + + /** + * + * @return + */ + public final SentenceList getSuppList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "SEARCHKEY, " + + "NAME " + + "FROM suppliers " + + "ORDER BY NAME", null, + (DataRead dr) -> new SupplierInfo( + dr.getString(1), + dr.getString(2), + dr.getString(3))); + } + + /** + * + * @return + */ + public final SentenceList getTaxCustCategoriesList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME " + + "FROM taxcustcategories " + + "ORDER BY NAME", null, + (DataRead dr) -> new TaxCustCategoryInfo( + dr.getString(1), + dr.getString(2))); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final CustomerInfoExt getCustomerInfo(String id) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers WHERE ID = ?", SerializerWriteString.INSTANCE, new CustomerExtRead()).find(id); + } + + /** + * JG Apr 2017 - Revised to return Customer Id - cId param + * + * @param cId + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List getCustomersTransactionList(String cId) throws BasicException { + + return new PreparedSentence(s, + "SELECT tickets.TICKETID, " + + "products.NAME AS PNAME, " + + "SUM(ticketlines.UNITS) AS UNITS, " + + "SUM(ticketlines.UNITS * ticketlines.PRICE) AS AMOUNT, " + + "SUM(ticketlines.UNITS * ticketlines.PRICE * (1.0 + taxes.RATE)) AS TOTAL, " + + "receipts.DATENEW, " + + "customers.ID AS CID " + + "FROM ((((ticketlines ticketlines " + + "CROSS JOIN taxes taxes ON (ticketlines.TAXID = taxes.ID)) " + + "INNER JOIN tickets tickets ON (tickets.ID = ticketlines.TICKET)) " + + "INNER JOIN customers customers ON (customers.ID = tickets.CUSTOMER)) " + + "INNER JOIN receipts receipts ON (tickets.ID = receipts.ID)) " + + "LEFT OUTER JOIN products products ON (ticketlines.PRODUCT = products.ID) " + + "WHERE tickets.CUSTOMER = ? " + + "GROUP BY customers.ID, receipts.DATENEW, tickets.TICKETID, " + + "products.NAME, tickets.TICKETTYPE " + + "ORDER BY receipts.DATENEW DESC", + SerializerWriteString.INSTANCE, + CustomerTransaction.getSerializerRead()).list(cId); + } + + /** + * + * @return + */ + public final SentenceList getTaxCategoriesList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME " + + "FROM taxcategories " + + "ORDER BY NAME", null, (DataRead dr) -> new TaxCategoryInfo(dr.getString(1), dr.getString(2))); + } + + /** + * + * @return + */ + public final SentenceList getAttributeSetList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME " + + "FROM attributeset " + + "ORDER BY NAME", null, (DataRead dr) -> new AttributeSetInfo(dr.getString(1), dr.getString(2))); + } + + /** + * + * @return + */ + public final SentenceList getLocationsList() { + return new StaticSentence(s, "SELECT " + + "ID, " + + "NAME, " + + "ADDRESS FROM locations " + + "ORDER BY NAME", null, new SerializerReadClass(LocationInfo.class)); + } + + /** + * + * @return + */ + public final SentenceList getFloorsList() { + return new StaticSentence(s, "SELECT ID, NAME FROM floors ORDER BY NAME", null, + new SerializerReadClass(FloorsInfo.class)); + } + + /** + * + * @return + */ + public final SentenceList getFloorTablesList() { + return new StaticSentence(s, "SELECT ID, NAME, SEATS, width, height FROM places ORDER BY NAME", null, + new SerializerReadClass(FloorsInfo.class)); + } + + /** + * + * @param card + * @return + * @throws BasicException + */ + public CustomerInfoExt findCustomerExt(String card) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "TAXID, " + + "SEARCHKEY, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers " + + "WHERE CARD = ? AND VISIBLE = " + s.DB.TRUE() + " " + + "ORDER BY NAME", SerializerWriteString.INSTANCE, new CustomerExtRead()).find(card); + } + + /** + * + * @param name + * @return + * @throws BasicException + */ + public CustomerInfoExt findCustomerName(String name) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers " + + "WHERE NAME = ? AND VISIBLE = " + s.DB.TRUE() + " " + + "ORDER BY NAME", SerializerWriteString.INSTANCE, new CustomerExtRead()).find(name); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public CustomerInfoExt loadCustomerExt(String id) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers WHERE ID = ?", SerializerWriteString.INSTANCE, new CustomerExtRead()).find(id); + } + + /** + * Quick Customer create + * + * @param id + * @return + * @throws BasicException + */ + public CustomerInfoExt qCustomerExt(String id) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "MAXDEBT, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "ISVIP, " + + "DISCOUNT " + + "FROM customers WHERE ID = ?", SerializerWriteString.INSTANCE, new CustomerExtRead()).find(id); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final boolean isCashActive(String id) throws BasicException { + + return new PreparedSentence(s, + "SELECT MONEY FROM closedcash WHERE DATEEND IS NULL AND MONEY = ?", + SerializerWriteString.INSTANCE, + SerializerReadString.INSTANCE).find(id) != null; + } + + /** + * + * @param tickettype + * @param ticketid + * @return + * @throws BasicException + */ + public final TicketInfo loadTicket(final int tickettype, final int ticketid) throws BasicException { + TicketInfo ticket = (TicketInfo) new PreparedSentence(s, "SELECT " + + "T.ID, " + + "T.TICKETTYPE, " + + "T.TICKETID, " + + "R.DATENEW, " + + "R.MONEY, " + + "R.ATTRIBUTES, " + + "P.ID, " + + "P.NAME, " + + "T.CUSTOMER, " + + "T.STATUS " + + "FROM receipts R " + + "JOIN tickets T ON R.ID = T.ID " + + "LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "WHERE T.TICKETTYPE = ? AND T.TICKETID = ? " + + "ORDER BY R.DATENEW DESC", SerializerWriteParams.INSTANCE, new SerializerReadClass(TicketInfo.class)) + .find(new DataParams() { + @Override + public void writeValues() throws BasicException { + setInt(1, tickettype); + setInt(2, ticketid); + } + }); + + if (ticket != null) { + + String customerid = ticket.getCustomerId(); + ticket.setCustomer(customerid == null + ? null + : loadCustomerExt(customerid)); + + ticket.setLines(new PreparedSentence(s, "SELECT L.TICKET, L.LINE, L.PRODUCT, L.ATTRIBUTESETINSTANCE_ID, " + + "L.UNITS, L.PRICE, T.ID, T.NAME, T.CATEGORY, T.CUSTCATEGORY, " + + "T.PARENTID, T.RATE, T.RATECASCADE, T.RATEORDER, L.ATTRIBUTES " + + "FROM ticketlines L, taxes T " + + "WHERE L.TAXID = T.ID AND L.TICKET = ? ORDER BY L.LINE", SerializerWriteString.INSTANCE, + new SerializerReadClass(TicketLineInfo.class)).list(ticket.getId())); + + ticket.setPayments( + new PreparedSentence(s, "SELECT PAYMENT, TOTAL, TRANSID, TENDERED, CARDNAME FROM payments WHERE RECEIPT = ?", + SerializerWriteString.INSTANCE, new SerializerReadClass(PaymentInfoTicket.class)).list(ticket.getId())); + } + return ticket; + } + + /** + * + * @param ticket + * @param location + * @throws BasicException + */ + public final void saveTicket(final TicketInfo ticket, final String location) throws BasicException { + + Transaction t; + t = new Transaction(s) { + @Override + public Object transact() throws BasicException { + + // Set Receipt Id + if (ticket.getTicketId() == 0) { + switch (ticket.getTicketType()) { + case TicketInfo.RECEIPT_NORMAL: + ticket.setTicketId(getNextTicketIndex()); + break; + case TicketInfo.RECEIPT_REFUND: + ticket.setTicketId(getNextTicketRefundIndex()); + break; + case TicketInfo.RECEIPT_PAYMENT: + ticket.setTicketId(getNextTicketPaymentIndex()); + break; + case TicketInfo.RECEIPT_NOSALE: + ticket.setTicketId(getNextTicketPaymentIndex()); + break; + default: + throw new BasicException(); + } + } + + new PreparedSentence(s, "INSERT INTO receipts (ID, MONEY, DATENEW, ATTRIBUTES, PERSON) VALUES (?, ?, ?, ?, ?)", + SerializerWriteParams.INSTANCE) + .exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setString(1, ticket.getId()); + setString(2, ticket.getActiveCash()); + setTimestamp(3, ticket.getDate()); + + try { + ByteArrayOutputStream o = new ByteArrayOutputStream(); + ticket.getProperties().storeToXML(o, AppLocal.APP_NAME, "UTF-8"); + setBytes(4, o.toByteArray()); + } catch (IOException e) { + setBytes(4, null); + } + setString(5, ticket.getProperty("person")); + } + }); + + // new ticket + new PreparedSentence(s, "INSERT INTO tickets (ID, TICKETTYPE, TICKETID, PERSON, CUSTOMER, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?)", SerializerWriteParams.INSTANCE) + .exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setString(1, ticket.getId()); + setInt(2, ticket.getTicketType()); + setInt(3, ticket.getTicketId()); + setString(4, ticket.getUserInfo().getId()); + setString(5, ticket.getCustomerId()); + setInt(6, ticket.getTicketStatus()); + } + }); + + // update status of existing ticket + new PreparedSentence(s, "UPDATE tickets SET STATUS = ? " + + "WHERE TICKETTYPE = 0 AND TICKETID = ?", SerializerWriteParams.INSTANCE) + .exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setInt(1, ticket.getTicketId()); + setInt(2, ticket.getTicketStatus()); + } + }); + + SentenceExec ticketlineinsert = new PreparedSentence(s, "INSERT INTO ticketlines (TICKET, LINE, " + + "PRODUCT, ATTRIBUTESETINSTANCE_ID, " + + "UNITS, PRICE, TAXID, ATTRIBUTES) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)", SerializerWriteBuilder.INSTANCE); + + for (TicketLineInfo l : ticket.getLines()) { + ticketlineinsert.exec(l); + + if (l.getProductID() != null && l.isProductService() != true) { + getStockDiaryInsert().exec(new Object[] { + UUID.randomUUID().toString(), + ticket.getDate(), + l.getMultiply() < 0.0 + ? MovementReason.IN_REFUND.getKey() + : MovementReason.OUT_SALE.getKey(), + location, + l.getProductID(), + l.getProductAttSetInstId(), -l.getMultiply(), l.getPrice(), + ticket.getUserInfo().getName() + }); + } + } + + final Payments payments = new Payments(); + SentenceExec paymentinsert = new PreparedSentence(s, + "INSERT INTO payments (ID, RECEIPT, PAYMENT, TOTAL, TRANSID, RETURNMSG, " + + "TENDERED, CARDNAME, VOUCHER, NOTES) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + SerializerWriteParams.INSTANCE); + + ticket.getPayments().forEach((p) -> { + if (p instanceof PaymentInfoMagcard) { + payments.addPayment(p.getName(), p.getTotal(), p.getPaid(), ticket.getReturnMessage(), p.getVoucher(), + ((PaymentInfoMagcard) p).getLastFourDigits()); + } else { + payments.addPayment(p.getName(), p.getTotal(), p.getPaid(), ticket.getReturnMessage(), p.getVoucher(), + null); + } + + }); + while (payments.getSize() >= 1) { + paymentinsert.exec(new DataParams() { + @Override + public void writeValues() throws BasicException { + pName = payments.getFirstElement(); + getTotal = payments.getPaidAmount(pName); + getTendered = payments.getTendered(pName); + getRetMsg = payments.getRtnMessage(pName); + + if (pName.contains("voucher")) { + getVoucher = payments.getVoucher(pName); + } + payments.removeFirst(pName); + + setString(1, UUID.randomUUID().toString()); + setString(2, ticket.getId()); + setString(3, pName); + setDouble(4, getTotal); + setString(5, ticket.getTransactionID()); + setBytes(6, (byte[]) Formats.BYTEA.parseValue(getRetMsg)); + setDouble(7, getTendered); + setString(8, getCardName); + setString(9, getVoucher); + setString(10, payments.getNote(pName)); + payments.removeFirst(pName); + } + }); + + if (pName.contains("voucher")) { + getVoucherNonActive().exec(payments.getVoucher(pName)); + } + + if ("debt".equals(pName) || "debtpaid".equals(pName)) { + ticket.getCustomer().updateCurDebt(getTotal, ticket.getDate()); + getDebtUpdate().exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setDouble(1, ticket.getCustomer().getAccdebt()); + setTimestamp(2, ticket.getCustomer().getCurdate()); + setString(3, ticket.getCustomer().getId()); + } + }); + } + } + + SentenceExec taxlinesinsert = new PreparedSentence(s, + "INSERT INTO taxlines (ID, RECEIPT, TAXID, BASE, AMOUNT) " + + "VALUES (?, ?, ?, ?, ?)", + SerializerWriteParams.INSTANCE); + + if (ticket.getTaxes() != null) { + for (final TicketTaxInfo tickettax : ticket.getTaxes()) { + taxlinesinsert.exec(new DataParams() { + @Override + public void writeValues() throws BasicException { + setString(1, UUID.randomUUID().toString()); + setString(2, ticket.getId()); + setString(3, tickettax.getTaxInfo().getId()); + setDouble(4, tickettax.getSubTotal()); + setDouble(5, tickettax.getTax()); + } + }); + } + } + return null; + } + }; + + t.execute(); + } + + /** + * + * @param ticket + * @param location + * @throws BasicException + */ + public final void deleteTicket(final TicketInfo ticket, final String location) throws BasicException { + + Transaction t; + t = new Transaction(s) { + @Override + public Object transact() throws BasicException { + + // update the inventory + Date d = new Date(); + for (int i = 0; i < ticket.getLinesCount(); i++) { + if (ticket.getLine(i).getProductID() != null) { + // Hay que actualizar el stock si el hay producto + getStockDiaryInsert().exec(new Object[] { + UUID.randomUUID().toString(), + d, + ticket.getLine(i).getMultiply() >= 0.0 + ? MovementReason.IN_REFUND.getKey() + : MovementReason.OUT_SALE.getKey(), + location, + ticket.getLine(i).getProductID(), + ticket.getLine(i).getProductAttSetInstId(), ticket.getLine(i).getMultiply(), + ticket.getLine(i).getPrice(), + ticket.getUserInfo().getName() + }); + } + // For productBundle + List bundle = getProductsBundle((String) ticket.getLine(i).getProductID()); + + if (bundle.size() > 0) { + for (ProductsBundleInfo bundleComponent : bundle) { + ProductInfoExt bundleProduct = getProductInfo(bundleComponent.getProductBundleId()); + + getStockDiaryInsert().exec(new Object[] { + UUID.randomUUID().toString(), + d, + ticket.getLine(i).getMultiply() * bundleComponent.getQuantity() >= 0.0 + ? MovementReason.IN_REFUND.getKey() + : MovementReason.OUT_SALE.getKey(), + location, + bundleComponent.getProductBundleId(), + null, ticket.getLine(i).getMultiply() * bundleComponent.getQuantity(), bundleProduct.getPriceSell(), + ticket.getUserInfo().getName() }); + } + } + } + + // update customer debts + for (PaymentInfo p : ticket.getPayments()) { + if ("debt".equals(p.getName()) || "debtpaid".equals(p.getName())) { + + // udate customer fields... + ticket.getCustomer().updateCurDebt(-p.getTotal(), ticket.getDate()); + + // save customer fields... + getDebtUpdate().exec(new DataParams() { + @Override + public void writeValues() throws BasicException { + setDouble(1, ticket.getCustomer().getAccdebt()); + setTimestamp(2, ticket.getCustomer().getCurdate()); + setString(3, ticket.getCustomer().getId()); + } + }); + } + } + + // and delete the receipt + new StaticSentence(s, "DELETE FROM taxlines WHERE RECEIPT = ?", SerializerWriteString.INSTANCE) + .exec(ticket.getId()); + new StaticSentence(s, "DELETE FROM payments WHERE RECEIPT = ?", SerializerWriteString.INSTANCE) + .exec(ticket.getId()); + new StaticSentence(s, "DELETE FROM ticketlines WHERE TICKET = ?", SerializerWriteString.INSTANCE) + .exec(ticket.getId()); + new StaticSentence(s, "DELETE FROM tickets WHERE ID = ?", SerializerWriteString.INSTANCE).exec(ticket.getId()); + new StaticSentence(s, "DELETE FROM receipts WHERE ID = ?", SerializerWriteString.INSTANCE).exec(ticket.getId()); + return null; + } + }; + t.execute(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextPickupIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "pickup_number").find(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextTicketIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "ticketsnum").find(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextTicketRefundIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "ticketsnum_refund").find(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextTicketPaymentIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "ticketsnum_payment").find(); + } + + // JG 3 Feb 16 - Product load speedup + public final SentenceFind getProductImage() { + return new PreparedSentence(s, + "SELECT IMAGE FROM products WHERE ID = ?", + SerializerWriteString.INSTANCE, (DataRead dr) -> ImageUtils.readImage(dr.getBytes(1))); + } + + /** + * Loads on ProductsEditor + * + * @return + */ + public final SentenceList getProductCatQBF() { + return new StaticSentence(s, new QBFBuilder( + "SELECT " + + "P.ID, " + + "P.REFERENCE, " + + "P.CODE, " + + "P.CODETYPE, " + + "P.NAME, " + + "P.PRICEBUY, " + + "P.PRICESELL, " + + "P.CATEGORY, " + + "P.TAXCAT, " + + "P.ATTRIBUTESET_ID, " + + "P.STOCKCOST, " + + "P.STOCKVOLUME, " + // JG 3 feb 16 speedup + "P.IMAGE, " + + s.DB.CHAR_NULL() + "," + + "P.ISCOM, " + + "P.ISSCALE, " + + "P.ISCONSTANT, " + + "P.PRINTKB, " + + "P.SENDSTATUS, " + + "P.ISSERVICE, " + + "P.ATTRIBUTES, " + + "P.DISPLAY, " + + "P.ISVPRICE, " + + "P.ISVERPATRIB, " + + "P.TEXTTIP, " + + "P.WARRANTY, " + + "P.STOCKUNITS, " + + "P.PRINTTO, " + + "P.SUPPLIER, " + + "P.UOM, " + + "P.MEMODATE, " + + "CASE WHEN " + + "C.PRODUCT IS NULL " + + "THEN " + s.DB.FALSE() + + " ELSE " + s.DB.TRUE() + + " END, " + + "C.CATORDER " + + "FROM products P LEFT OUTER JOIN products_cat C " + + "ON P.ID = C.PRODUCT " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY P.REFERENCE", + new String[] { + "P.NAME", "P.PRICEBUY", "P.PRICESELL", "P.CATEGORY", "P.CODE" }), + new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING }), + productsRow.getSerializerRead()); + } + + /** + * + * @return + */ + + public final SentenceExec getProductCatInsert() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s, "INSERT INTO products (" + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE ) " + + "VALUES (" + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?)", + new SerializerWriteBasicExt(productsRow.getDatas(), + new int[] { 0, + 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29 })) + + .exec(params); + + if (i > 0 && ((Boolean) values[30])) { + return new PreparedSentence(s, "INSERT INTO products_cat (PRODUCT, CATORDER) VALUES (?, ?)", + new SerializerWriteBasicExt(productsRow.getDatas(), new int[] { 0, 31 })) + + .exec(params); + } else { + return i; + } + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getProductCatUpdate() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s, "UPDATE products SET " + + "ID = ?, " + + "REFERENCE = ?, " + + "CODE = ?, " + + "CODETYPE = ?, " + + "NAME = ?, " + + "PRICEBUY = ?, " + + "PRICESELL = ?, " + + "CATEGORY = ?, " + + "TAXCAT = ?, " + + "ATTRIBUTESET_ID = ?, " + + "STOCKCOST = ?, " + + "STOCKVOLUME = ?, " + + "IMAGE = ?, " + + "ISCOM = ?, " + + "ISSCALE = ?, " + + "ISCONSTANT = ?, " + + "PRINTKB = ?, " + + "SENDSTATUS = ?, " + + "ISSERVICE = ?, " + + "ATTRIBUTES = ?," + + "DISPLAY = ?, " + + "ISVPRICE = ?, " + + "ISVERPATRIB = ?, " + + "TEXTTIP = ?, " + + "WARRANTY = ?, " + + "STOCKUNITS = ?, " + + "PRINTTO = ?, " + + "SUPPLIER = ?, " + + "UOM = ?, " + + "MEMODATE = ? " + + "WHERE ID = ?", + new SerializerWriteBasicExt(productsRow.getDatas(), + new int[] { 0, + 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, + 26, 27, 28, 29, 0 })) + .exec(params); + if (i > 0) { + if (((Boolean) values[30])) { + if (new PreparedSentence(s, "UPDATE products_cat SET CATORDER = ? WHERE PRODUCT = ?", + new SerializerWriteBasicExt(productsRow.getDatas(), new int[] { 31, 0 })).exec(params) == 0) { + new PreparedSentence(s, "INSERT INTO products_cat (PRODUCT, CATORDER) VALUES (?, ?)", + new SerializerWriteBasicExt(productsRow.getDatas(), new int[] { 0, 31 })).exec(params); + } + } else { + new PreparedSentence(s, "DELETE FROM products_cat WHERE PRODUCT = ?", + new SerializerWriteBasicExt(productsRow.getDatas(), new int[] { 0 })).exec(params); + } + } + return i; + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getProductCatDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + new PreparedSentence(s, "DELETE FROM products_cat WHERE PRODUCT = ?", + new SerializerWriteBasicExt(productsRow.getDatas(), new int[] { 0 })).exec(params); + return new PreparedSentence(s, "DELETE FROM products WHERE ID = ?", + new SerializerWriteBasicExt(productsRow.getDatas(), new int[] { 0 })).exec(params); + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getDebtUpdate() { + + return new PreparedSentence(s, "UPDATE customers SET CURDEBT = ?, CURDATE = ? WHERE ID = ?", + SerializerWriteParams.INSTANCE); + } + + /** + * ProductBundle version + * + * @return + */ + public final SentenceExec getStockDiaryInsert() { + return new SentenceExecTransaction(s) { + @Override + /** + * @param params[0] String STOCKDIARY.ID + * @param params[1] Date Timestamp + * @param params[2] Integer Reason + * @param params[3] String Location + * @param params[4] String Product ID + * @param params[5] String Attribute instance ID + * @param params[6] Double Units + * @param params[7] Double Price + * @param params[8] String Application User + */ + public int execInTransaction(Object params) throws BasicException { + + Object[] adjustParams = new Object[4]; + Object[] paramsArray = (Object[]) params; + adjustParams[0] = paramsArray[4]; // product ->Location + adjustParams[1] = paramsArray[3]; // location -> Product + adjustParams[2] = paramsArray[5]; // attributesetinstance + adjustParams[3] = paramsArray[6]; // units + adjustStock(adjustParams); + + return new PreparedSentence(s, "INSERT INTO stockdiary (ID, DATENEW, REASON, LOCATION, " + + "PRODUCT, ATTRIBUTESETINSTANCE_ID, " + + "UNITS, PRICE, AppUser) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", + new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 })) + .exec(params); + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getStockDiaryInsert1() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + + int updateresult = ((Object[]) params)[5] == null + ? new PreparedSentence(s, "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID IS NULL", + new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 6, 3, 4 })).exec(params) + : new PreparedSentence(s, "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID = ?", + new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 6, 3, 4, 5 })).exec(params); + + if (updateresult == 0) { + new PreparedSentence(s, "INSERT INTO stockcurrent (LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS) " + + "VALUES (?, ?, ?, ?)", new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 3, 4, 5, 6 })) + .exec(params); + } + return new PreparedSentence(s, "INSERT INTO stockdiary (ID, DATENEW, REASON, LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS, PRICE, AppUser, " + + "SUPPLIER, SUPPLIERDOC) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + new SerializerWriteBasicExt(stockdiaryDatas, + new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })) + .exec(params); + + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getStockDiaryDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + int updateresult = ((Object[]) params)[5] == null // if ATTRIBUTESETINSTANCE_ID is null + ? new PreparedSentence(s, "UPDATE stockcurrent SET UNITS = (UNITS - ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID IS NULL", + new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 6, 3, 4 })).exec(params) + : new PreparedSentence(s, "UPDATE stockcurrent SET UNITS = (UNITS - ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID = ?", + new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 6, 3, 4, 5 })).exec(params); + + if (updateresult == 0) { + new PreparedSentence(s, "INSERT INTO stockcurrent (LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS) " + + "VALUES (?, ?, ?, -(?))", new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 3, 4, 5, 6 })) + .exec(params); + } + return new PreparedSentence(s, "DELETE FROM stockdiary WHERE ID = ?", + new SerializerWriteBasicExt(stockdiaryDatas, new int[] { 0 })).exec(params); + } + }; + } + + private void adjustStock(Object params) throws BasicException { + + List bundle = getProductsBundle((String) ((Object[]) params)[0]); + + if (bundle.size() > 0) { + + for (ProductsBundleInfo component : bundle) { + Object[] adjustParams = new Object[4]; + adjustParams[0] = component.getProductBundleId(); + adjustParams[1] = ((Object[]) params)[1]; + adjustParams[2] = ((Object[]) params)[2]; + adjustParams[3] = ((Double) ((Object[]) params)[3]) * component.getQuantity(); + adjustStock(adjustParams); + } + } else { + + int updateresult = ((Object[]) params)[2] == null + ? new PreparedSentence(s, "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID IS NULL", + new SerializerWriteBasicExt(stockAdjustDatas, new int[] { 3, 1, 0 })) + .exec(params) + : new PreparedSentence(s, "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID = ?", + new SerializerWriteBasicExt(stockAdjustDatas, new int[] { 3, 1, 0, 2 })) + .exec(params); + + if (updateresult == 0) { + + new PreparedSentence(s, "INSERT INTO stockcurrent (LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS) " + + "VALUES (?, ?, ?, ?)", new SerializerWriteBasicExt(stockAdjustDatas, new int[] { 1, 0, 2, 3 })) + .exec(params); + } + } + } + + /** + * + * @return + */ + public final SentenceExec getPaymentMovementInsert() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + new PreparedSentence(s, "INSERT INTO receipts (ID, MONEY, DATENEW) " + + "VALUES (?, ?, ?)", + new SerializerWriteBasicExt(paymenttabledatas, + new int[] { 0, 1, 2 })) + .exec(params); + return new PreparedSentence(s, "INSERT INTO payments (ID, RECEIPT, PAYMENT, TOTAL, NOTES) " + + "VALUES (?, ?, ?, ?, ?)", + new SerializerWriteBasicExt(paymenttabledatas, + new int[] { 3, 0, 4, 5, 6 })) + .exec(params); + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getPaymentMovementDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + new PreparedSentence(s, "DELETE FROM payments WHERE ID = ?", + new SerializerWriteBasicExt(paymenttabledatas, new int[] { 3 })).exec(params); + return new PreparedSentence(s, "DELETE FROM receipts WHERE ID = ?", + new SerializerWriteBasicExt(paymenttabledatas, new int[] { 0 })).exec(params); + } + }; + } + + /** + * + * @param warehouse + * @param id + * @param attsetinstid + * @return + * @throws BasicException + */ + public final double findProductStock(String warehouse, String id, String attsetinstid) throws BasicException { + + PreparedSentence p = attsetinstid == null + ? new PreparedSentence(s, "SELECT UNITS FROM stockcurrent " + + "WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID IS NULL", + new SerializerWriteBasic(Datas.STRING, Datas.STRING), SerializerReadDouble.INSTANCE) + : new PreparedSentence(s, "SELECT UNITS FROM stockcurrent " + + "WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID = ?", + new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING), SerializerReadDouble.INSTANCE); + + Double d = (Double) p.find(warehouse, id, attsetinstid); + return d == null ? 0.0 : d; + } + + /** + * + * @return + */ + public final SentenceExec getCatalogCategoryAdd() { + return new StaticSentence(s, "INSERT INTO products_cat(PRODUCT, CATORDER) SELECT ID, " + s.DB.INTEGER_NULL() + + " FROM products WHERE CATEGORY = ?", SerializerWriteString.INSTANCE); + } + + /** + * + * @return + */ + public final SentenceExec getCatalogCategoryDel() { + return new StaticSentence(s, "DELETE FROM products_cat WHERE PRODUCT = ANY (SELECT ID " + + "FROM products WHERE CATEGORY = ?)", SerializerWriteString.INSTANCE); + } + + /** + * + * @return + */ + public final TableDefinition getTableCategories() { + return new TableDefinition(s, + "categories", new String[] { "ID", "NAME", "PARENTID", "IMAGE", "TEXTTIP", "CATSHOWNAME", "CATORDER" }, + new String[] { "ID", AppLocal.getIntString("label.name"), "", AppLocal.getIntString("label.image") }, + new Datas[] { Datas.STRING, Datas.STRING, Datas.STRING, + Datas.IMAGE, Datas.STRING, Datas.BOOLEAN, Datas.STRING }, + new Formats[] { Formats.STRING, Formats.STRING, Formats.STRING, + Formats.NULL, Formats.STRING, Formats.BOOLEAN, Formats.STRING }, + new int[] { 0 }); + } + + /** + * + * @return + */ + public final TableDefinition getTableTaxes() { + return new TableDefinition(s, + "taxes", + new String[] { "ID", "NAME", "CATEGORY", "CUSTCATEGORY", "PARENTID", "RATE", "RATECASCADE", "RATEORDER" }, + new String[] { "ID", AppLocal.getIntString("label.name"), AppLocal.getIntString("label.taxcategory"), + AppLocal.getIntString("label.custtaxcategory"), AppLocal.getIntString("label.taxparent"), + AppLocal.getIntString("label.dutyrate"), AppLocal.getIntString("label.cascade"), + AppLocal.getIntString("label.order") }, + new Datas[] { Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, Datas.DOUBLE, Datas.BOOLEAN, + Datas.INT }, + new Formats[] { Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, Formats.PERCENT, + Formats.BOOLEAN, Formats.INT }, + new int[] { 0 }); + } + + /** + * + * @return + */ + public final TableDefinition getTableTaxCustCategories() { + return new TableDefinition(s, + "taxcustcategories", new String[] { "ID", "NAME" }, new String[] { "ID", AppLocal.getIntString("label.name") }, + new Datas[] { Datas.STRING, Datas.STRING }, new Formats[] { Formats.STRING, Formats.STRING }, new int[] { 0 }); + } + + /** + * + * @return + */ + public final TableDefinition getTableTaxCategories() { + return new TableDefinition(s, + "taxcategories", new String[] { "ID", "NAME" }, new String[] { "ID", AppLocal.getIntString("label.name") }, + new Datas[] { Datas.STRING, Datas.STRING }, new Formats[] { Formats.STRING, Formats.STRING }, new int[] { 0 }); + } + + /** + * + * @return + */ + public final TableDefinition getTableLocations() { + return new TableDefinition(s, + "locations", new String[] { "ID", "NAME", "ADDRESS" }, + new String[] { "ID", AppLocal.getIntString("label.locationname"), + AppLocal.getIntString("label.locationaddress") }, + new Datas[] { Datas.STRING, Datas.STRING, Datas.STRING }, + new Formats[] { Formats.STRING, Formats.STRING, Formats.STRING }, new int[] { 0 }); + } + + /** + * + */ + protected static class CustomerExtRead implements SerializerRead { /** * - * @param s + * @param dr + * @return + * @throws BasicException */ @Override - public void init(Session s){ - this.s = s; + public Object readValues(DataRead dr) throws BasicException { + CustomerInfoExt c = new CustomerInfoExt(dr.getString(1)); + c.setSearchkey(dr.getString(2)); + c.setTaxid(dr.getString(3)); + c.setTaxCustomerID(dr.getString(3)); + c.setName(dr.getString(4)); + c.setTaxCustCategoryID(dr.getString(5)); + c.setCard(dr.getString(6)); + c.setMaxdebt(dr.getDouble(7)); + c.setAddress(dr.getString(8)); + c.setAddress2(dr.getString(9)); + c.setPcode(dr.getString(10)); + c.setCity(dr.getString(11)); + c.setRegion(dr.getString(12)); + c.setCountry(dr.getString(13)); + c.setFirstname(dr.getString(14)); + c.setLastname(dr.getString(15)); + c.setCemail(dr.getString(16)); + c.setPhone1(dr.getString(17)); + c.setPhone2(dr.getString(18)); + c.setFax(dr.getString(19)); + c.setNotes(dr.getString(20)); + c.setVisible(dr.getBoolean(21)); + c.setCurdate(dr.getTimestamp(22)); + c.setAccdebt(dr.getDouble(23)); + c.setImage(ImageUtils.readImage(dr.getString(24))); + c.setisVIP(dr.getBoolean(25)); + c.setDiscount(dr.getDouble(26)); + c.setMemoDate(dr.getString(27)); - m_createCat = new StaticSentence(s, - "INSERT INTO categories ( ID, NAME, CATSHOWNAME ) " - + "VALUES (?, ?, ?)" - , new SerializerWriteBasic(new Datas[]{ - Datas.STRING, - Datas.STRING, - Datas.INT}) - ); - - m_createSupp = new StaticSentence(s, - "INSERT INTO suppliers ( ID, NAME, SEARCHKEY, VISIBLE ) " - + "VALUES (?, ?, ?, ?)" - , new SerializerWriteBasic(new Datas[]{ - Datas.STRING, - Datas.STRING, - Datas.STRING, - Datas.BOOLEAN}) - ); + return c; } + } - // Import Creates - public final void createCategory(Object[] category) throws BasicException { - m_createCat.exec(category); - } + public final UomInfo getUomInfoById(String id) throws BasicException { + return (UomInfo) new PreparedSentence(s, + "SELECT " + + "id, name " + + "FROM uom " + + "WHERE id = ?", + SerializerWriteString.INSTANCE, UomInfo.getSerializerRead()).find(id); + } - public final void createSupplier(Object[] supplier) throws BasicException { - m_createSupp.exec(supplier); - } -// End Import Creates + public final TableDefinition getTableUom() { + return new TableDefinition(s, + "uom", + new String[] { "id", "name" }, + new String[] { "id", + AppLocal.getIntString("Label.Name") }, + new Datas[] { + Datas.STRING, Datas.STRING }, + new Formats[] { + Formats.STRING, Formats.STRING }, + new int[] { 0 }); + } - public final Row getProductsRow() { - return productsRow; - } + public final SentenceList getUomList() { + return new StaticSentence(s, "SELECT ID, NAME FROM uom ORDER BY NAME", null, UomInfo.getSerializerRead()); + } - public final Row getCustomersRow() { - return customersRow; - } + /* + * public final SentenceList getVoucherList() { + * return new StaticSentence(s, + * "SELECT " + + * "vouchers.ID,vouchers.VOUCHER_NUMBER,vouchers.CUSTOMER, " + + * "customers.NAME,AMOUNT, STATUS " + + * "FROM vouchers " + + * "JOIN customers ON customers.id = vouchers.CUSTOMER " + + * "WHERE STATUS='A' " + + * "ORDER BY vouchers.VOUCHER_NUMBER ASC" + * , null, VoucherInfo.getSerializerRead()); + * } + */ + + public final SentenceList getVoucherList() { + return new StaticSentence(s, + "SELECT " + + "vouchers.ID,vouchers.VOUCHER_NUMBER,vouchers.CUSTOMER, " + + "vouchers.AMOUNT, vouchers.STATUS " + + "FROM vouchers " + + "WHERE STATUS='A' " + + "ORDER BY vouchers.VOUCHER_NUMBER ASC", + null, VoucherInfo.getSerializerRead()); + } + + public final SentenceExec getVoucherNonActive() { + return new PreparedSentence(s, + "UPDATE vouchers SET STATUS = 'D' " + + "WHERE VOUCHER_NUMBER = ?", + SerializerWriteString.INSTANCE); + } + + public final SentenceExec setVoucherPending() { + return new PreparedSentence(s, + "UPDATE vouchers SET STATUS = 'P' " + + "WHERE VOUCHER_NUMBER = ?", + SerializerWriteString.INSTANCE); + } + + public final SentenceExec resetPickupId() { + + return new PreparedSentence(s, + "UPDATE pickup_number SET ID=1 ", SerializerWriteString.INSTANCE); + + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public SupplierInfoExt loadSupplierExt(String id) throws BasicException { + return (SupplierInfoExt) new PreparedSentence(s, "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "VATID " + + "FROM suppliers WHERE ID = ?", SerializerWriteString.INSTANCE, new SupplierExtRead()).find(id); + } + + /** + * + */ + protected static class SupplierExtRead implements SerializerRead { /** * - * @param id + * @param dr * @return * @throws BasicException */ - public final ProductInfoExt getProductInfo(String id) throws BasicException { - return (ProductInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products WHERE ID = ?" - , SerializerWriteString.INSTANCE - , ProductInfoExt.getSerializerRead()).find(id); - } - - public final ProductInfoExt getProductInfoByCode(String sCode) throws BasicException { -// if (sCode.length() == 13 && (sCode.startsWith("2") || sCode.startsWith("02"))) -// return getProductInfoByShortCode(sCode); -// else { - return (ProductInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products WHERE CODE = ?" - , SerializerWriteString.INSTANCE - , ProductInfoExt.getSerializerRead()).find(sCode); -// } - } - - public final ProductInfoExt getProductInfoByShortCode(String sCode) throws BasicException { - - return (ProductInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products " - + "WHERE SUBSTRING( CODE, 3, 6 ) = ?" - , SerializerWriteString.INSTANCE - , ProductInfoExt.getSerializerRead()).find(sCode.substring(2, 8)); - } - - /* - * Important Note: - * Deliberately extracted from other code to force strict UPC-A (full 12 digits) - * Why? Because other manf' or in-store codes may exist and we just need a single - * record returned. Also, handling things this way will allow use (future) of a - * COUPON code (5 or 9 normally used) in-store - * - */ - public final ProductInfoExt getProductInfoByUShortCode(String sCode) throws BasicException { - - return (ProductInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products " - + "WHERE LEFT( CODE, 7 ) = ? AND CODETYPE = 'UPC-A' " -// selection of 7 digits ie: 2123456 specific to allow for other 12 digit -// codes that may be in use at positions 234567 -// last digit (position 7) can be used to identify COUPON (5 or 9) - FUTURE - , SerializerWriteString.INSTANCE - , ProductInfoExt.getSerializerRead()) - .find(sCode.substring(0, 7)); - } - - /** - * - * @param sReference - * @return - * @throws BasicException - */ - public final ProductInfoExt getProductInfoByReference(String sReference) throws BasicException { - return (ProductInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products WHERE REFERENCE = ?" - , SerializerWriteString.INSTANCE - , ProductInfoExt.getSerializerRead()).find(sReference); - } - - /** - * - * @return - * @throws BasicException - */ - public final List getRootCategories() throws BasicException { - return new PreparedSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "IMAGE, " - + "TEXTTIP, " - + "CATSHOWNAME, " - + "CATORDER " - + "FROM categories " - + "WHERE PARENTID IS NULL AND CATSHOWNAME = " + s.DB.TRUE() + " " - + "ORDER BY CATORDER, NAME" - , null - , CategoryInfo.getSerializerRead()).list(); - } - - /** - * - * @param category - * @return - * @throws BasicException - */ - public final List getSubcategories(String category) throws BasicException { - return new PreparedSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "IMAGE, " - + "TEXTTIP, " - + "CATSHOWNAME, " - + "CATORDER " - + "FROM categories WHERE PARENTID = ? " - + "ORDER BY CATORDER, NAME" - , SerializerWriteString.INSTANCE - , CategoryInfo.getSerializerRead()).list(category); - } - - /** - * - * @param category - * @return - * @throws BasicException - */ - public List getProductCatalog(String category) throws BasicException { - return new PreparedSentence(s - , "SELECT " - + "P.ID, " - + "P.REFERENCE, " - + "P.CODE, " - + "P.CODETYPE, " - + "P.NAME, " - + "P.PRICEBUY, " - + "P.PRICESELL, " - + "P.CATEGORY, " - + "P.TAXCAT, " - + "P.ATTRIBUTESET_ID, " - + "P.STOCKCOST, " - + "P.STOCKVOLUME, " - + "P.IMAGE, " - + "P.ISCOM, " - + "P.ISSCALE, " - + "P.ISCONSTANT, " - + "P.PRINTKB, " - + "P.SENDSTATUS, " - + "P.ISSERVICE, " - + "P.ATTRIBUTES, " - + "P.DISPLAY, " - + "P.ISVPRICE, " - + "P.ISVERPATRIB, " - + "P.TEXTTIP, " - + "P.WARRANTY, " - + "P.STOCKUNITS, " - + "P.PRINTTO, " - + "P.SUPPLIER, " - + "P.UOM, " - + "P.MEMODATE " - + "FROM products P, products_cat O " - + "WHERE P.ID = O.PRODUCT AND P.CATEGORY = ? " - + "ORDER BY O.CATORDER, P.NAME " - , SerializerWriteString.INSTANCE - , ProductInfoExt.getSerializerRead()).list(category); - } - - /** - * - * @param id - * @return - * @throws BasicException - */ - public List getProductComments(String id) throws BasicException { - return new PreparedSentence(s - , "SELECT " - + "P.ID, " - + "P.REFERENCE, " - + "P.CODE, " - + "P.CODETYPE, " - + "P.NAME, " - + "P.PRICEBUY, " - + "P.PRICESELL, " - + "P.CATEGORY, " - + "P.TAXCAT, " - + "P.ATTRIBUTESET_ID, " - + "P.STOCKCOST, " - + "P.STOCKVOLUME, " - + "P.IMAGE, " - + "P.ISCOM, " - + "P.ISSCALE, " - + "P.ISCONSTANT, " - + "P.PRINTKB, " - + "P.SENDSTATUS, " - + "P.ISSERVICE, " - + "P.ATTRIBUTES, " - + "P.DISPLAY, " - + "P.ISVPRICE, " - + "P.ISVERPATRIB, " - + "P.TEXTTIP, " - + "P.WARRANTY, " - + "P.STOCKUNITS, " - + "P.PRINTTO, " - + "P.SUPPLIER, " - + "P.UOM, " - + "P.MEMODATE " - + "FROM products P, " - + "products_cat O, products_com M " - + "WHERE P.ID = O.PRODUCT AND P.ID = M.PRODUCT2 AND M.PRODUCT = ? " - + "AND P.ISCOM = " + s.DB.TRUE() + " " + - "ORDER BY O.CATORDER, P.NAME" - , SerializerWriteString.INSTANCE - , ProductInfoExt.getSerializerRead()).list(id); - } - - // JG uniCenta June 2014 includes StockUnits - /** - * - * @return - * @throws BasicException - */ - public List getProductConstant() throws BasicException { - return new PreparedSentence(s - , "SELECT " - + "products.ID, " - + "products.REFERENCE, " - + "products.CODE, " - + "products.CODETYPE, " - + "products.NAME, " - + "products.PRICEBUY, " - + "products.PRICESELL, " - + "products.CATEGORY, " - + "products.TAXCAT, " - + "products.ATTRIBUTESET_ID, " - + "products.STOCKCOST, " - + "products.STOCKVOLUME, " - + "products.IMAGE, " - + "products.ISCOM, " - + "products.ISSCALE, " - + "products.ISCONSTANT, " - + "products.PRINTKB, " - + "products.SENDSTATUS, " - + "products.ISSERVICE, " - + "products.ATTRIBUTES, " - + "products.DISPLAY, " - + "products.ISVPRICE, " - + "products.ISVERPATRIB, " - + "products.TEXTTIP, " - + "products.WARRANTY, " - + "products.STOCKUNITS, " - + "products.PRINTTO, " - + "products.SUPPLIER, " - + "products.UOM, " - + "products.MEMODATE " - + "FROM categories INNER JOIN products ON (products.CATEGORY = categories.ID) " - + "WHERE products.ISCONSTANT = " +s.DB.TRUE()+ " " - + "ORDER BY categories.NAME, products.NAME", - null, - ProductInfoExt.getSerializerRead()).list(); - - - } - - public final CategoryInfo getCategoryInfoByName(String name) throws BasicException { - return (CategoryInfo) new PreparedSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "IMAGE, " - + "TEXTTIP, " - + "CATSHOWNAME, " - + "CATORDER " - + "FROM categories " - + "WHERE NAME = ? " - + "ORDER BY CATORDER, NAME" - , SerializerWriteString.INSTANCE - , CategoryInfo.getSerializerRead()).find(name); - } - - /** - * - * @param id - * @return - * @throws BasicException - */ - public final CategoryInfo getCategoryInfo(String id) throws BasicException { - return (CategoryInfo) new PreparedSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "IMAGE, " - + "TEXTTIP, " - + "CATSHOWNAME, " - + "CATORDER " - + "FROM categories " - + "WHERE ID = ? " - + "ORDER BY CATORDER, NAME" - , SerializerWriteString.INSTANCE - , CategoryInfo.getSerializerRead()).find(id); - } - - /** - * JG Dec 2017 - * @param pId - * @return - * @throws BasicException - */ - @SuppressWarnings("unchecked") - public final List getCategorysProductList(String pId) throws BasicException { - return new PreparedSentence(s, - "SELECT products.ID, " + - "products.NAME AS Name, " + - "products.CODE AS Barcode, " + - "categories.ID AS Category " + - "FROM products products " + - "INNER JOIN categories categories ON (products.CATEGORY = categories.ID) " + - "WHERE products.category = ? " + - "ORDER BY products.NAME ASC", - SerializerWriteString.INSTANCE, - CategoryStock.getSerializerRead()).list(pId); - } - - /** - * - * @return - */ - - public final SentenceList getProductList() { - return new StaticSentence(s - , new QBFBuilder( - "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products " - + "WHERE ?(QBF_FILTER) " - + "ORDER BY REFERENCE", - new String[] {"NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE"}) - , new SerializerWriteBasic(new Datas[] { - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.STRING}) - , ProductInfoExt.getSerializerRead()); - } - - /** - * - * @return - */ - public SentenceList getProductListNormal() { - return new StaticSentence(s - , new QBFBuilder( - "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products " - + "WHERE ISCOM = " + s.DB.FALSE() + " AND ?(QBF_FILTER) ORDER BY REFERENCE", - new String[] {"NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE"}) - , new SerializerWriteBasic(new Datas[] { - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.STRING}) - , ProductInfoExt.getSerializerRead()); - } - - /** - * - * @return - */ - public SentenceList getProductsList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products " - + "ORDER BY NAME" - , null - , ProductInfo.getSerializerRead()); - } - - public SentenceList getProductList2() { - return new StaticSentence(s - , new QBFBuilder( - "SELECT " - + "products.id, " - + "products.name, " - + "stockcurrent.units, " - + "locations.name, " - + "products.pricesell, " - + "taxes.rate, " - + "products.pricesell + (products.pricesell * taxes.rate) AS SellIncTax " - + " FROM (((stockcurrent stockcurrent " - + "INNER JOIN locations locations " - + "ON (stockcurrent.location = locations.id)) " - + "INNER JOIN products products " - + "ON (stockcurrent.product = products.id)) " - + "INNER JOIN taxcategories taxcategories " - + "ON (products.taxcat = taxcategories.id)) " - + "INNER JOIN taxes taxes " - + "ON (taxes.category = taxcategories.id) " - + "WHERE ?(QBF_FILTER) " - + "GROUP BY products.name ", - new String[] {"NAME", "UNITS", "SellIncTax", "LOCATION",}) - , new SerializerWriteBasic(new Datas[] { - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.STRING}) - , ProductInfoExt.getSerializerRead()); - } - - /** - * - * @return - */ - public SentenceList getProductListAuxiliar() { - return new StaticSentence(s - , new QBFBuilder( - "SELECT " - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE " - + "FROM products " - + "WHERE ISCOM = " + s.DB.TRUE() + " AND ?(QBF_FILTER) " - + "ORDER BY REFERENCE", new String[] {"NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE"}) - , new SerializerWriteBasic(new Datas[] { - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.STRING}) - , ProductInfoExt.getSerializerRead()); - } - - /** - * - * @param productId The product id to look for bundle - * @return List of products part of the searched product - * @throws BasicException - */ - public final List getProductsBundle(String productId) throws BasicException { - return new PreparedSentence(s - , "SELECT " - + "ID, " - + "PRODUCT, " - + "PRODUCT_BUNDLE, " - + "QUANTITY " - + "FROM products_bundle WHERE PRODUCT = ?" - , SerializerWriteString.INSTANCE - , ProductsBundleInfo.getSerializerRead()).list(productId); - } - - /** - * JG Oct 2016 - * Called from JPanelTicket - * @param pId - * @param location - * @return - * @throws BasicException - */ - public final ProductStock getProductStockState(String pId, String location) throws BasicException { - - PreparedSentence preparedSentence = new PreparedSentence(s, - "SELECT " + - "MIN(products.id), " + - "locations.id as Location, " + - "MIN(stockcurrent.units), " + - "MIN(stocklevel.stocksecurity) AS Minimum, " + - "MIN(stocklevel.stockmaximum) AS Maximum, " + - "MIN(products.pricebuy), " + - "MIN(products.pricesell), " + - "MIN(products.memodate) " + - "FROM locations " + - "INNER JOIN ((products " + - "INNER JOIN stockcurrent " + - "ON products.id = stockcurrent.product) " + - "LEFT JOIN stocklevel ON products.id = stocklevel.product) " + - "ON locations.id = stockcurrent.location " + - "WHERE products.id = ? " + - "AND locations.id = ?" - , SerializerWriteString.INSTANCE - , ProductStock.getSerializerRead()); - - ProductStock productStock = (ProductStock) preparedSentence.find(pId, location); - - return productStock; - } - - /** - * JG May 2016 - * Called from StockManagement - * @param pId - * @return - * @throws BasicException - */ - @SuppressWarnings("unchecked") - public final List getProductStockList(String pId) throws BasicException { - return new PreparedSentence(s, - "SELECT MIN(products.id), " + - "MIN(locations.name) AS Location, " + - "MIN(stockcurrent.units) AS stockcurrent, " + - "MIN(stocklevel.stocksecurity) AS Minimum, " + - "MIN(stocklevel.stockmaximum) AS Maximum, " + - "MIN(products.pricebuy) AS PriceBuy, " + - "(MIN(products.pricesell) * MIN(taxes.rate)) + MIN(products.pricesell) AS PriceSell, " + - "MIN(products.memodate) " + - "FROM ((((taxcategories TC " + - "INNER JOIN taxes taxes " + - "ON (TC.id = taxes.category)) " + - "RIGHT OUTER JOIN products products " + - "ON (products.TAXCAT = TC.id)) " + - "LEFT OUTER JOIN stocklevel stocklevel " + - "ON (stocklevel.product = products.ID)) " + - "LEFT OUTER JOIN stockcurrent stockcurrent " + - "ON (products.ID = stockcurrent.product)) " + - "INNER JOIN locations locations " + - "ON (stockcurrent.location = locations.id) " + - "WHERE products.id= ? " + - "GROUP BY locations.name", - SerializerWriteString.INSTANCE, - ProductStock.getSerializerRead()).list(pId); - } - - /** - * JG Sept 2017 - * @return - * @throws BasicException - */ - @SuppressWarnings("unchecked") - public final List getReprintTicketList() throws BasicException { - - //payment queries - List ticketInfoList = (List) new StaticSentence(s - , "SELECT " - + "T.TICKETID, " - + "T.TICKETTYPE, " - + "R.DATENEW, " - + "P.NAME, " - + "C.NAME, " - + "SUM(PM.TOTAL), " - + "T.STATUS " - + "FROM receipts " - + "R JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " - + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " - + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " - + "GROUP BY " - + "T.ID, " - + "T.TICKETID, " - + "T.TICKETTYPE, " - + "R.DATENEW, " - + "P.NAME, " - + "C.NAME " - + "ORDER BY R.DATENEW DESC, T.TICKETID " - + "LIMIT 10 " - , null - , new SerializerReadClass(ReprintTicketInfo.class)).list(); - - return ticketInfoList; - } - - /** - * - * @param Id - * @return - * @throws BasicException - */ - public final TicketInfo getReprintTicket(String Id) throws BasicException { - - //payment queries - - if (Id == null) { - return null; - } else { - Object[]record = (Object[]) new StaticSentence(s - , "SELECT " - + "T.TICKETID, " - + "SUM(PM.TOTAL), " - + "R.DATENEW, " - + "P.NAME, " - + "T.TICKETTYPE, " - + "C.NAME, " - + "T.STATUS " - + "FROM receipts R " - + "JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " - + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " - + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " - + "WHERE T.TICKETID = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadBasic(new Datas[] {Datas.SERIALIZABLE})).find(Id); - return record == null ? null : (TicketInfo) record[0]; - } - } - - //Tickets and Receipt list - - // Payment queries - public SentenceList getTicketsList() { - - - StaticSentence staticSentence = new StaticSentence(s - , new QBFBuilder( - "SELECT " - + "T.TICKETID, " - + "T.TICKETTYPE, " - + "R.DATENEW, " - + "P.NAME, " - + "C.NAME, " - + "SUM(PM.TOTAL), " - + "SUM(T.STATUS), " - + "PM.notes " - + "FROM receipts R " - + "JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " - + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " - + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " - + "WHERE ?(QBF_FILTER) " - + "GROUP BY T.ID, T.TICKETID, T.TICKETTYPE, R.DATENEW, P.NAME, C.NAME, PM.notes " - + "ORDER BY R.DATENEW DESC, T.TICKETID", - new String[]{ - "T.TICKETID", "T.TICKETTYPE", "PM.TOTAL", "R.DATENEW", "R.DATENEW", "P.NAME", "C.NAME", "PM.NOTES"}) - , new SerializerWriteBasic(new Datas[]{ - Datas.OBJECT, Datas.INT, - Datas.OBJECT, Datas.INT, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.TIMESTAMP, - Datas.OBJECT, Datas.TIMESTAMP, - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.STRING}) - , new SerializerReadClass(FindTicketsInfo.class)); - - return staticSentence; - } - - //User list - - /** - * - * @return - */ - public final SentenceList getUserList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME " - + "FROM people " - + "ORDER BY NAME" - , null - , (DataRead dr) -> new TaxCategoryInfo( - dr.getString(1), - dr.getString(2))); - } - - /** - * - * @return - */ - public final SentenceList getTaxList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "CATEGORY, " - + "CUSTCATEGORY, " - + "PARENTID, " - + "RATE, " - + "RATECASCADE, " - + "RATEORDER " - + "FROM taxes " - + "ORDER BY NAME" - , null - , (DataRead dr) -> new TaxInfo( - dr.getString(1), - dr.getString(2), - dr.getString(3), - dr.getString(4), - dr.getString(5), - dr.getDouble(6), - dr.getBoolean(7), - dr.getInt(8))); - } - - /** - * - * @return - */ - public final SentenceList getCategoriesList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "IMAGE, " - + "TEXTTIP, " - + "CATSHOWNAME, " - + "CATORDER " - + "FROM categories " - + "ORDER BY NAME" - , null - , CategoryInfo.getSerializerRead()); - } - /** - * JG Feb 2017 - * Returns all PARENT categories - * @return - */ - public final SentenceList getCategoriesList_1() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "IMAGE, " - + "TEXTTIP, " - + "CATSHOWNAME, " - + "CATORDER " - + "FROM categories " - + "WHERE PARENTID IS NULL " - + "ORDER BY NAME" - , null - , CategoryInfo.getSerializerRead()); - } - /** - * - * @return - */ - public final SentenceList getSuppList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "SEARCHKEY, " - + "NAME " - + "FROM suppliers " - + "ORDER BY NAME" - , null - , (DataRead dr) -> new SupplierInfo( - dr.getString(1), - dr.getString(2), - dr.getString(3))); - } - - /** - * - * @return - */ - public final SentenceList getTaxCustCategoriesList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME " - + "FROM taxcustcategories " - + "ORDER BY NAME" - , null - , (DataRead dr) -> new TaxCustCategoryInfo( - dr.getString(1), - dr.getString(2))); - } - - /** - * - * @param id - * @return - * @throws BasicException - */ - public final CustomerInfoExt getCustomerInfo(String id) throws BasicException { - return (CustomerInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "SEARCHKEY, " - + "TAXID, " - + "NAME, " - + "TAXCATEGORY, " - + "CARD, " - + "MAXDEBT, " - + "ADDRESS, " - + "ADDRESS2, " - + "POSTAL, " - + "CITY, " - + "REGION, " - + "COUNTRY, " - + "FIRSTNAME, " - + "LASTNAME, " - + "EMAIL, " - + "PHONE, " - + "PHONE2, " - + "FAX, " - + "NOTES, " - + "VISIBLE, " - + "CURDATE, " - + "CURDEBT, " - + "IMAGE, " - + "ISVIP, " - + "DISCOUNT, " - + "MEMODATE " - + "FROM customers WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new CustomerExtRead()).find(id); - } - - /** - * JG Apr 2017 - Revised to return Customer Id - cId param - * @param cId - * @return - * @throws BasicException - */ - @SuppressWarnings("unchecked") - public final List getCustomersTransactionList(String cId) throws BasicException { - - return new PreparedSentence(s, - "SELECT tickets.TICKETID, " + - "products.NAME AS PNAME, " + - "SUM(ticketlines.UNITS) AS UNITS, " + - "SUM(ticketlines.UNITS * ticketlines.PRICE) AS AMOUNT, " + - "SUM(ticketlines.UNITS * ticketlines.PRICE * (1.0 + taxes.RATE)) AS TOTAL, " + - "receipts.DATENEW, " + - "customers.ID AS CID " + - "FROM ((((ticketlines ticketlines " + - "CROSS JOIN taxes taxes ON (ticketlines.TAXID = taxes.ID)) " + - "INNER JOIN tickets tickets ON (tickets.ID = ticketlines.TICKET)) " + - "INNER JOIN customers customers ON (customers.ID = tickets.CUSTOMER)) " + - "INNER JOIN receipts receipts ON (tickets.ID = receipts.ID)) " + - "LEFT OUTER JOIN products products ON (ticketlines.PRODUCT = products.ID) " + - "WHERE tickets.CUSTOMER = ? " + - "GROUP BY customers.ID, receipts.DATENEW, tickets.TICKETID, " + - "products.NAME, tickets.TICKETTYPE " + - "ORDER BY receipts.DATENEW DESC", - SerializerWriteString.INSTANCE, - CustomerTransaction.getSerializerRead()).list(cId); - } - - /** - * - * @return - */ - public final SentenceList getTaxCategoriesList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME " - + "FROM taxcategories " - + "ORDER BY NAME" - , null - , (DataRead dr) -> new TaxCategoryInfo(dr.getString(1), dr.getString(2))); - } - - /** - * - * @return - */ - public final SentenceList getAttributeSetList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME " - + "FROM attributeset " - + "ORDER BY NAME" - , null - , (DataRead dr) -> new AttributeSetInfo(dr.getString(1), dr.getString(2))); - } - - /** - * - * @return - */ - public final SentenceList getLocationsList() { - return new StaticSentence(s - , "SELECT " - + "ID, " - + "NAME, " - + "ADDRESS FROM locations " - + "ORDER BY NAME" - , null - , new SerializerReadClass(LocationInfo.class)); - } - - /** - * - * @return - */ - public final SentenceList getFloorsList() { - return new StaticSentence(s - , "SELECT ID, NAME FROM floors ORDER BY NAME" - , null - , new SerializerReadClass(FloorsInfo.class)); - } - /** - * - * @return - */ - public final SentenceList getFloorTablesList() { - return new StaticSentence(s - , "SELECT ID, NAME, SEATS, width, height FROM places ORDER BY NAME" - , null - , new SerializerReadClass(FloorsInfo.class)); - } - - - /** - * - * @param card - * @return - * @throws BasicException - */ - public CustomerInfoExt findCustomerExt(String card) throws BasicException { - return (CustomerInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "TAXID, " - + "SEARCHKEY, " - + "NAME, " - + "TAXCATEGORY, " - + "CARD, " - + "MAXDEBT, " - + "ADDRESS, " - + "ADDRESS2, " - + "POSTAL, " - + "CITY, " - + "REGION, " - + "COUNTRY, " - + "FIRSTNAME, " - + "LASTNAME, " - + "EMAIL, " - + "PHONE, " - + "PHONE2, " - + "FAX, " - + "NOTES, " - + "VISIBLE, " - + "CURDATE, " - + "CURDEBT, " - + "IMAGE, " - + "ISVIP, " - + "DISCOUNT, " - + "MEMODATE " - + "FROM customers " - + "WHERE CARD = ? AND VISIBLE = " + s.DB.TRUE() + " " - + "ORDER BY NAME" - , SerializerWriteString.INSTANCE - , new CustomerExtRead()).find(card); - } - /** - * - * @param name - * @return - * @throws BasicException - */ - public CustomerInfoExt findCustomerName(String name) throws BasicException { - return (CustomerInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "SEARCHKEY, " - + "TAXID, " - + "NAME, " - + "TAXCATEGORY, " - + "CARD, " - + "MAXDEBT, " - + "ADDRESS, " - + "ADDRESS2, " - + "POSTAL, " - + "CITY, " - + "REGION, " - + "COUNTRY, " - + "FIRSTNAME, " - + "LASTNAME, " - + "EMAIL, " - + "PHONE, " - + "PHONE2, " - + "FAX, " - + "NOTES, " - + "VISIBLE, " - + "CURDATE, " - + "CURDEBT, " - + "IMAGE, " - + "ISVIP, " - + "DISCOUNT, " - + "MEMODATE " - + "FROM customers " - + "WHERE NAME = ? AND VISIBLE = " + s.DB.TRUE() + " " - + "ORDER BY NAME" - , SerializerWriteString.INSTANCE - , new CustomerExtRead()).find(name); - } - - /** - * - * @param id - * @return - * @throws BasicException - */ - public CustomerInfoExt loadCustomerExt(String id) throws BasicException { - return (CustomerInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "SEARCHKEY, " - + "TAXID, " - + "NAME, " - + "TAXCATEGORY, " - + "CARD, " - + "MAXDEBT, " - + "ADDRESS, " - + "ADDRESS2, " - + "POSTAL, " - + "CITY, " - + "REGION, " - + "COUNTRY, " - + "FIRSTNAME, " - + "LASTNAME, " - + "EMAIL, " - + "PHONE, " - + "PHONE2, " - + "FAX, " - + "NOTES, " - + "VISIBLE, " - + "CURDATE, " - + "CURDEBT, " - + "IMAGE, " - + "ISVIP, " - + "DISCOUNT, " - + "MEMODATE " - + "FROM customers WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new CustomerExtRead()).find(id); - } - - /** - * Quick Customer create - * @param id - * @return - * @throws BasicException - */ - public CustomerInfoExt qCustomerExt(String id) throws BasicException { - return (CustomerInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "SEARCHKEY, " - + "TAXID, " - + "NAME, " - + "TAXCATEGORY, " - + "MAXDEBT, " - + "FIRSTNAME, " - + "LASTNAME, " - + "EMAIL, " - + "PHONE, " - + "PHONE2, " - + "ISVIP, " - + "DISCOUNT " - + "FROM customers WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new CustomerExtRead()).find(id); - } - - /** - * - * @param id - * @return - * @throws BasicException - */ - public final boolean isCashActive(String id) throws BasicException { - - return new PreparedSentence(s, - "SELECT MONEY FROM closedcash WHERE DATEEND IS NULL AND MONEY = ?", - SerializerWriteString.INSTANCE, - SerializerReadString.INSTANCE).find(id) - != null; - } - - /** - * - * @param tickettype - * @param ticketid - * @return - * @throws BasicException - */ - public final TicketInfo loadTicket(final int tickettype, final int ticketid) throws BasicException { - TicketInfo ticket = (TicketInfo) new PreparedSentence(s - , "SELECT " - + "T.ID, " - + "T.TICKETTYPE, " - + "T.TICKETID, " - + "R.DATENEW, " - + "R.MONEY, " - + "R.ATTRIBUTES, " - + "P.ID, " - + "P.NAME, " - + "T.CUSTOMER, " - + "T.STATUS " - + "FROM receipts R " - + "JOIN tickets T ON R.ID = T.ID " - + "LEFT OUTER JOIN people P ON T.PERSON = P.ID " - + "WHERE T.TICKETTYPE = ? AND T.TICKETID = ? " - + "ORDER BY R.DATENEW DESC" - , SerializerWriteParams.INSTANCE - , new SerializerReadClass(TicketInfo.class)) - .find(new DataParams() { - @Override - public void writeValues() throws BasicException { - setInt(1, tickettype); - setInt(2, ticketid); - }}); - - if (ticket != null) { - - String customerid = ticket.getCustomerId(); - ticket.setCustomer(customerid == null - ? null - : loadCustomerExt(customerid)); - - ticket.setLines(new PreparedSentence(s - , "SELECT L.TICKET, L.LINE, L.PRODUCT, L.ATTRIBUTESETINSTANCE_ID, " + - "L.UNITS, L.PRICE, T.ID, T.NAME, T.CATEGORY, T.CUSTCATEGORY, " + - "T.PARENTID, T.RATE, T.RATECASCADE, T.RATEORDER, L.ATTRIBUTES " + - "FROM ticketlines L, taxes T " + - "WHERE L.TAXID = T.ID AND L.TICKET = ? ORDER BY L.LINE" - , SerializerWriteString.INSTANCE - , new SerializerReadClass(TicketLineInfo.class)).list(ticket.getId())); - - ticket.setPayments(new PreparedSentence(s - , "SELECT PAYMENT, TOTAL, TRANSID, TENDERED, CARDNAME FROM payments WHERE RECEIPT = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadClass(PaymentInfoTicket.class)).list(ticket.getId())); - } - return ticket; - } - - /** - * - * @param ticket - * @param location - * @throws BasicException - */ - public final void saveTicket(final TicketInfo ticket, final String location) throws BasicException { - - Transaction t; - t = new Transaction(s) { - @Override - public Object transact() throws BasicException { - - // Set Receipt Id - if (ticket.getTicketId() == 0) { - switch (ticket.getTicketType()) { - case TicketInfo.RECEIPT_NORMAL: - ticket.setTicketId(getNextTicketIndex()); - break; - case TicketInfo.RECEIPT_REFUND: - ticket.setTicketId(getNextTicketRefundIndex()); - break; - case TicketInfo.RECEIPT_PAYMENT: - ticket.setTicketId(getNextTicketPaymentIndex()); - break; - case TicketInfo.RECEIPT_NOSALE: - ticket.setTicketId(getNextTicketPaymentIndex()); - break; - default: - throw new BasicException(); - } - } - - new PreparedSentence(s - , "INSERT INTO receipts (ID, MONEY, DATENEW, ATTRIBUTES, PERSON) VALUES (?, ?, ?, ?, ?)" - , SerializerWriteParams.INSTANCE ) - .exec(new DataParams() { - - @Override - public void writeValues() throws BasicException { - setString(1, ticket.getId()); - setString(2, ticket.getActiveCash()); - setTimestamp(3, ticket.getDate()); - - try { - ByteArrayOutputStream o = new ByteArrayOutputStream(); - ticket.getProperties().storeToXML(o, AppLocal.APP_NAME, "UTF-8"); - setBytes(4, o.toByteArray()); - } catch (IOException e) { - setBytes(4, null); - } - setString(5, ticket.getProperty("person")); - } - }); - - // new ticket - new PreparedSentence(s - , "INSERT INTO tickets (ID, TICKETTYPE, TICKETID, PERSON, CUSTOMER, STATUS) " - + "VALUES (?, ?, ?, ?, ?, ?)" - , SerializerWriteParams.INSTANCE ) - .exec(new DataParams() { - - @Override - public void writeValues() throws BasicException { - setString(1, ticket.getId()); - setInt(2, ticket.getTicketType()); - setInt(3, ticket.getTicketId()); - setString(4, ticket.getUser().getId()); - setString(5, ticket.getCustomerId()); - setInt(6, ticket.getTicketStatus()); - } - }); - - // update status of existing ticket - new PreparedSentence(s - , "UPDATE tickets SET STATUS = ? " - + "WHERE TICKETTYPE = 0 AND TICKETID = ?" - , SerializerWriteParams.INSTANCE ) - .exec(new DataParams() { - - @Override - public void writeValues() throws BasicException { - setInt(1, ticket.getTicketId()); - setInt(2, ticket.getTicketStatus()); - } - }); - - SentenceExec ticketlineinsert = new PreparedSentence(s - , "INSERT INTO ticketlines (TICKET, LINE, " - + "PRODUCT, ATTRIBUTESETINSTANCE_ID, " - + "UNITS, PRICE, TAXID, ATTRIBUTES) " - + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)" - , SerializerWriteBuilder.INSTANCE); - - for (TicketLineInfo l : ticket.getLines()) { - ticketlineinsert.exec(l); - - if (l.getProductID() != null && l.isProductService() != true) { - getStockDiaryInsert().exec(new Object[] { - UUID.randomUUID().toString(), - ticket.getDate(), - l.getMultiply() < 0.0 - ? MovementReason.IN_REFUND.getKey() - : MovementReason.OUT_SALE.getKey(), - location, - l.getProductID(), - l.getProductAttSetInstId(), -l.getMultiply(), l.getPrice(), - ticket.getUser().getName() - }); - } - } - - final Payments payments = new Payments(); - SentenceExec paymentinsert = new PreparedSentence(s - , "INSERT INTO payments (ID, RECEIPT, PAYMENT, TOTAL, TRANSID, RETURNMSG, " - + "TENDERED, CARDNAME, VOUCHER, NOTES) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" - , SerializerWriteParams.INSTANCE); - - ticket.getPayments().forEach((p) -> { - if (p instanceof PaymentInfoMagcard) { - payments.addPayment(p.getName(),p.getTotal(), p.getPaid(),ticket.getReturnMessage(), p.getVoucher(), ((PaymentInfoMagcard) p).getLastFourDigits()); - }else { - payments.addPayment(p.getName(),p.getTotal(), p.getPaid(),ticket.getReturnMessage(), p.getVoucher(), null); - } - - }); - while (payments.getSize()>=1){ - paymentinsert.exec(new DataParams() { - @Override - public void writeValues() throws BasicException { - pName = payments.getFirstElement(); - getTotal = payments.getPaidAmount(pName); - getTendered = payments.getTendered(pName); - getRetMsg = payments.getRtnMessage(pName); - - if (pName.contains("voucher")) { - getVoucher = payments.getVoucher(pName); - } - payments.removeFirst(pName); - - setString(1, UUID.randomUUID().toString()); - setString(2, ticket.getId()); - setString(3, pName); - setDouble(4, getTotal); - setString(5, ticket.getTransactionID()); - setBytes(6, (byte[]) Formats.BYTEA.parseValue(getRetMsg)); - setDouble(7, getTendered); - setString(8, getCardName); - setString(9, getVoucher); - setString(10, payments.getNote(pName)); - payments.removeFirst(pName); - } - }); - - if (pName.contains("voucher")) { - getVoucherNonActive().exec(payments.getVoucher(pName)); - } - - if ("debt".equals(pName) || "debtpaid".equals(pName)) { - ticket.getCustomer().updateCurDebt(getTotal, ticket.getDate()); - getDebtUpdate().exec(new DataParams() { - - @Override - public void writeValues() throws BasicException { - setDouble(1, ticket.getCustomer().getAccdebt()); - setTimestamp(2, ticket.getCustomer().getCurdate()); - setString(3, ticket.getCustomer().getId()); - } - }); - } - } - - SentenceExec taxlinesinsert = new PreparedSentence(s - , "INSERT INTO taxlines (ID, RECEIPT, TAXID, BASE, AMOUNT) " - + "VALUES (?, ?, ?, ?, ?)" - , SerializerWriteParams.INSTANCE); - - if (ticket.getTaxes() != null) { - for (final TicketTaxInfo tickettax: ticket.getTaxes()) { - taxlinesinsert.exec(new DataParams() { - @Override - public void writeValues() throws BasicException { - setString(1, UUID.randomUUID().toString()); - setString(2, ticket.getId()); - setString(3, tickettax.getTaxInfo().getId()); - setDouble(4, tickettax.getSubTotal()); - setDouble(5, tickettax.getTax()); - } - }); - } - } - return null; - } - }; - - t.execute(); - } - - /** - * - * @param ticket - * @param location - * @throws BasicException - */ - public final void deleteTicket(final TicketInfo ticket, final String location) throws BasicException { - - Transaction t; - t = new Transaction(s) { - @Override - public Object transact() throws BasicException { - - // update the inventory - Date d = new Date(); - for (int i = 0; i < ticket.getLinesCount(); i++) { - if (ticket.getLine(i).getProductID() != null) { - // Hay que actualizar el stock si el hay producto - getStockDiaryInsert().exec( new Object[] { - UUID.randomUUID().toString(), - d, - ticket.getLine(i).getMultiply() >= 0.0 - ? MovementReason.IN_REFUND.getKey() - : MovementReason.OUT_SALE.getKey(), - location, - ticket.getLine(i).getProductID(), - ticket.getLine(i).getProductAttSetInstId(), ticket.getLine(i).getMultiply(), ticket.getLine(i).getPrice(), - ticket.getUser().getName() - }); - } -// For productBundle - List bundle = getProductsBundle((String)ticket.getLine(i).getProductID()); - - if (bundle.size() > 0) { - for (ProductsBundleInfo bundleComponent : bundle) { - ProductInfoExt bundleProduct = getProductInfo(bundleComponent.getProductBundleId()); - - getStockDiaryInsert().exec(new Object[]{ - UUID.randomUUID().toString(), - d, - ticket.getLine(i).getMultiply() * bundleComponent.getQuantity() >= 0.0 - ? MovementReason.IN_REFUND.getKey() - : MovementReason.OUT_SALE.getKey(), - location, - bundleComponent.getProductBundleId(), - null, ticket.getLine(i).getMultiply() * bundleComponent.getQuantity() - , bundleProduct.getPriceSell(), - ticket.getUser().getName()}); - } - } - } - - // update customer debts - for (PaymentInfo p : ticket.getPayments()) { - if ("debt".equals(p.getName()) || "debtpaid".equals(p.getName())) { - - // udate customer fields... - ticket.getCustomer().updateCurDebt(-p.getTotal(), ticket.getDate()); - - // save customer fields... - getDebtUpdate().exec(new DataParams() { - @Override - public void writeValues() throws BasicException { - setDouble(1, ticket.getCustomer().getAccdebt()); - setTimestamp(2, ticket.getCustomer().getCurdate()); - setString(3, ticket.getCustomer().getId()); - }}); - } - } - - // and delete the receipt - new StaticSentence(s - , "DELETE FROM taxlines WHERE RECEIPT = ?" - , SerializerWriteString.INSTANCE).exec(ticket.getId()); - new StaticSentence(s - , "DELETE FROM payments WHERE RECEIPT = ?" - , SerializerWriteString.INSTANCE).exec(ticket.getId()); - new StaticSentence(s - , "DELETE FROM ticketlines WHERE TICKET = ?" - , SerializerWriteString.INSTANCE).exec(ticket.getId()); - new StaticSentence(s - , "DELETE FROM tickets WHERE ID = ?" - , SerializerWriteString.INSTANCE).exec(ticket.getId()); - new StaticSentence(s - , "DELETE FROM receipts WHERE ID = ?" - , SerializerWriteString.INSTANCE).exec(ticket.getId()); - return null; - } - }; - t.execute(); - } - - /** - * - * @return - * @throws BasicException - */ - public final Integer getNextPickupIndex() throws BasicException { - return (Integer) s.DB.getSequenceSentence(s, "pickup_number").find(); - } - - /** - * - * @return - * @throws BasicException - */ - public final Integer getNextTicketIndex() throws BasicException { - return (Integer) s.DB.getSequenceSentence(s, "ticketsnum").find(); - } - - /** - * - * @return - * @throws BasicException - */ - public final Integer getNextTicketRefundIndex() throws BasicException { - return (Integer) s.DB.getSequenceSentence(s, "ticketsnum_refund").find(); - } - - /** - * - * @return - * @throws BasicException - */ - public final Integer getNextTicketPaymentIndex() throws BasicException { - return (Integer) s.DB.getSequenceSentence(s, "ticketsnum_payment").find(); - } - - // JG 3 Feb 16 - Product load speedup - public final SentenceFind getProductImage() { - return new PreparedSentence(s, - "SELECT IMAGE FROM products WHERE ID = ?", - SerializerWriteString.INSTANCE - , (DataRead dr) -> ImageUtils.readImage(dr.getBytes(1))); - } - - /** - * Loads on ProductsEditor - * @return - */ - public final SentenceList getProductCatQBF() { - return new StaticSentence(s - , new QBFBuilder( - "SELECT " - + "P.ID, " - + "P.REFERENCE, " - + "P.CODE, " - + "P.CODETYPE, " - + "P.NAME, " - + "P.PRICEBUY, " - + "P.PRICESELL, " - + "P.CATEGORY, " - + "P.TAXCAT, " - + "P.ATTRIBUTESET_ID, " - + "P.STOCKCOST, " - + "P.STOCKVOLUME, " -// JG 3 feb 16 speedup + "P.IMAGE, " - + s.DB.CHAR_NULL() + "," - + "P.ISCOM, " - + "P.ISSCALE, " - + "P.ISCONSTANT, " - + "P.PRINTKB, " - + "P.SENDSTATUS, " - + "P.ISSERVICE, " - + "P.ATTRIBUTES, " - + "P.DISPLAY, " - + "P.ISVPRICE, " - + "P.ISVERPATRIB, " - + "P.TEXTTIP, " - + "P.WARRANTY, " - + "P.STOCKUNITS, " - + "P.PRINTTO, " - + "P.SUPPLIER, " - + "P.UOM, " - + "P.MEMODATE, " - + "CASE WHEN " - + "C.PRODUCT IS NULL " - + "THEN " + s.DB.FALSE() - + " ELSE " + s.DB.TRUE() - + " END, " - + "C.CATORDER " - + "FROM products P LEFT OUTER JOIN products_cat C " - + "ON P.ID = C.PRODUCT " - + "WHERE ?(QBF_FILTER) " - + "ORDER BY P.REFERENCE", - new String[] { - "P.NAME", "P.PRICEBUY", "P.PRICESELL", "P.CATEGORY", "P.CODE"}) - , new SerializerWriteBasic(new Datas[] { - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.DOUBLE, - Datas.OBJECT, Datas.STRING, - Datas.OBJECT, Datas.STRING}) - , productsRow.getSerializerRead()); - } - - /** - * - * @return - */ - - public final SentenceExec getProductCatInsert() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - Object[] values = (Object[]) params; - int i = new PreparedSentence(s - , "INSERT INTO products (" - + "ID, " - + "REFERENCE, " - + "CODE, " - + "CODETYPE, " - + "NAME, " - + "PRICEBUY, " - + "PRICESELL, " - + "CATEGORY, " - + "TAXCAT, " - + "ATTRIBUTESET_ID, " - + "STOCKCOST, " - + "STOCKVOLUME, " - + "IMAGE, " - + "ISCOM, " - + "ISSCALE, " - + "ISCONSTANT, " - + "PRINTKB, " - + "SENDSTATUS, " - + "ISSERVICE, " - + "ATTRIBUTES, " - + "DISPLAY, " - + "ISVPRICE, " - + "ISVERPATRIB, " - + "TEXTTIP, " - + "WARRANTY, " - + "STOCKUNITS, " - + "PRINTTO, " - + "SUPPLIER, " - + "UOM, " - + "MEMODATE ) " - + "VALUES (" - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?, ?, ?, ?)" - , new SerializerWriteBasicExt(productsRow.getDatas(), - new int[]{0, - 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29})) - - .exec(params); - - if (i > 0 && ((Boolean)values[30])) { - return new PreparedSentence(s - , "INSERT INTO products_cat (PRODUCT, CATORDER) VALUES (?, ?)" - , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0, 31})) - - .exec(params); - } else { - return i; - } - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getProductCatUpdate() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - Object[] values = (Object[]) params; - int i = new PreparedSentence(s - , "UPDATE products SET " - + "ID = ?, " - + "REFERENCE = ?, " - + "CODE = ?, " - + "CODETYPE = ?, " - + "NAME = ?, " - + "PRICEBUY = ?, " - + "PRICESELL = ?, " - + "CATEGORY = ?, " - + "TAXCAT = ?, " - + "ATTRIBUTESET_ID = ?, " - + "STOCKCOST = ?, " - + "STOCKVOLUME = ?, " - + "IMAGE = ?, " - + "ISCOM = ?, " - + "ISSCALE = ?, " - + "ISCONSTANT = ?, " - + "PRINTKB = ?, " - + "SENDSTATUS = ?, " - + "ISSERVICE = ?, " - + "ATTRIBUTES = ?," - + "DISPLAY = ?, " - + "ISVPRICE = ?, " - + "ISVERPATRIB = ?, " - + "TEXTTIP = ?, " - + "WARRANTY = ?, " - + "STOCKUNITS = ?, " - + "PRINTTO = ?, " - + "SUPPLIER = ?, " - + "UOM = ?, " - + "MEMODATE = ? " - + "WHERE ID = ?" - , new SerializerWriteBasicExt(productsRow.getDatas(), - new int[]{0, - 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, - 26, 27, 28, 29, 0})) - .exec(params); - if (i > 0) { - if (((Boolean)values[30])) { - if (new PreparedSentence(s - , "UPDATE products_cat SET CATORDER = ? WHERE PRODUCT = ?" - , new SerializerWriteBasicExt(productsRow.getDatas() - , new int[] {31, 0})).exec(params) == 0) { - new PreparedSentence(s - , "INSERT INTO products_cat (PRODUCT, CATORDER) VALUES (?, ?)" - , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0, 31})).exec(params); - } - } else { - new PreparedSentence(s - , "DELETE FROM products_cat WHERE PRODUCT = ?" - , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0})).exec(params); - } - } - return i; - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getProductCatDelete() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - new PreparedSentence(s - , "DELETE FROM products_cat WHERE PRODUCT = ?" - , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0})).exec(params); - return new PreparedSentence(s - , "DELETE FROM products WHERE ID = ?" - , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0})).exec(params); - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getDebtUpdate() { - - return new PreparedSentence(s - , "UPDATE customers SET CURDEBT = ?, CURDATE = ? WHERE ID = ?" - , SerializerWriteParams.INSTANCE); - } - - /** - * ProductBundle version - * @return - */ - public final SentenceExec getStockDiaryInsert() { - return new SentenceExecTransaction(s) { - @Override - /** - * @param params[0] String STOCKDIARY.ID - * @param params[1] Date Timestamp - * @param params[2] Integer Reason - * @param params[3] String Location - * @param params[4] String Product ID - * @param params[5] String Attribute instance ID - * @param params[6] Double Units - * @param params[7] Double Price - * @param params[8] String Application User - */ - public int execInTransaction(Object params) throws BasicException { - - Object[] adjustParams = new Object[4]; - Object[] paramsArray = (Object[]) params; - adjustParams[0] = paramsArray[4]; //product ->Location - adjustParams[1] = paramsArray[3]; //location -> Product - adjustParams[2] = paramsArray[5]; //attributesetinstance - adjustParams[3] = paramsArray[6]; //units - adjustStock(adjustParams); - - return new PreparedSentence(s - , "INSERT INTO stockdiary (ID, DATENEW, REASON, LOCATION, " - + "PRODUCT, ATTRIBUTESETINSTANCE_ID, " - + "UNITS, PRICE, AppUser) " - + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" - , new SerializerWriteBasicExt(stockdiaryDatas - , new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8})) - .exec(params); - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getStockDiaryInsert1() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - - int updateresult = ((Object[]) params)[5] == null - ? new PreparedSentence(s - , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " - + "WHERE LOCATION = ? AND PRODUCT = ? " - + "AND ATTRIBUTESETINSTANCE_ID IS NULL" - , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4})).exec(params) - : new PreparedSentence(s - , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " - + "WHERE LOCATION = ? AND PRODUCT = ? " - + "AND ATTRIBUTESETINSTANCE_ID = ?" - , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4, 5})).exec(params); - - if (updateresult == 0) { - new PreparedSentence(s - , "INSERT INTO stockcurrent (LOCATION, PRODUCT, " - + "ATTRIBUTESETINSTANCE_ID, UNITS) " - + "VALUES (?, ?, ?, ?)" - , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {3, 4, 5, 6})).exec(params); - } - return new PreparedSentence(s - , "INSERT INTO stockdiary (ID, DATENEW, REASON, LOCATION, PRODUCT, " - + "ATTRIBUTESETINSTANCE_ID, UNITS, PRICE, AppUser, " - + "SUPPLIER, SUPPLIERDOC) " - + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" - , new SerializerWriteBasicExt(stockdiaryDatas, - new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10})).exec(params); - - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getStockDiaryDelete() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - int updateresult = ((Object[]) params)[5] == null // if ATTRIBUTESETINSTANCE_ID is null - ? new PreparedSentence(s - , "UPDATE stockcurrent SET UNITS = (UNITS - ?) " - + "WHERE LOCATION = ? AND PRODUCT = ? " - + "AND ATTRIBUTESETINSTANCE_ID IS NULL" - , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4})).exec(params) - : new PreparedSentence(s - , "UPDATE stockcurrent SET UNITS = (UNITS - ?) " - + "WHERE LOCATION = ? AND PRODUCT = ? " - + "AND ATTRIBUTESETINSTANCE_ID = ?" - , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4, 5})).exec(params); - - if (updateresult == 0) { - new PreparedSentence(s - , "INSERT INTO stockcurrent (LOCATION, PRODUCT, " - + "ATTRIBUTESETINSTANCE_ID, UNITS) " - + "VALUES (?, ?, ?, -(?))" - , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {3, 4, 5, 6})).exec(params); - } - return new PreparedSentence(s - , "DELETE FROM stockdiary WHERE ID = ?" - , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {0})).exec(params); - } - }; - } - - - private void adjustStock(Object params) throws BasicException { - - List bundle = getProductsBundle((String) ((Object[])params)[0]); - - if (bundle.size() > 0) { - - for (ProductsBundleInfo component : bundle) { - Object[] adjustParams = new Object[4]; - adjustParams[0] = component.getProductBundleId(); - adjustParams[1] = ((Object[])params)[1]; - adjustParams[2] = ((Object[])params)[2]; - adjustParams[3] = ((Double)((Object[])params)[3]) * component.getQuantity(); - adjustStock(adjustParams); - } - } else { - - int updateresult = ((Object[]) params)[2] == null - ? new PreparedSentence(s - , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " - + "WHERE LOCATION = ? AND PRODUCT = ? " - + "AND ATTRIBUTESETINSTANCE_ID IS NULL" - , new SerializerWriteBasicExt(stockAdjustDatas - , new int[] {3, 1, 0})) - .exec(params) - : new PreparedSentence(s - , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " - + "WHERE LOCATION = ? AND PRODUCT = ? " - + "AND ATTRIBUTESETINSTANCE_ID = ?" - , new SerializerWriteBasicExt(stockAdjustDatas - , new int[] {3, 1, 0, 2})) - .exec(params); - - if (updateresult == 0) { - - new PreparedSentence(s - , "INSERT INTO stockcurrent (LOCATION, PRODUCT, " - + "ATTRIBUTESETINSTANCE_ID, UNITS) " - + "VALUES (?, ?, ?, ?)" - , new SerializerWriteBasicExt(stockAdjustDatas - , new int[] {1, 0, 2, 3})) - .exec(params); - } - } - } - - /** - * - * @return - */ - public final SentenceExec getPaymentMovementInsert() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - new PreparedSentence(s - , "INSERT INTO receipts (ID, MONEY, DATENEW) " - + "VALUES (?, ?, ?)" - , new SerializerWriteBasicExt(paymenttabledatas, - new int[] {0, 1, 2})).exec(params); - return new PreparedSentence(s - , "INSERT INTO payments (ID, RECEIPT, PAYMENT, TOTAL, NOTES) " - + "VALUES (?, ?, ?, ?, ?)" - , new SerializerWriteBasicExt(paymenttabledatas, - new int[] {3, 0, 4, 5, 6})).exec(params); - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getPaymentMovementDelete() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - new PreparedSentence(s - , "DELETE FROM payments WHERE ID = ?" - , new SerializerWriteBasicExt(paymenttabledatas, new int[] {3})).exec(params); - return new PreparedSentence(s - , "DELETE FROM receipts WHERE ID = ?" - , new SerializerWriteBasicExt(paymenttabledatas, new int[] {0})).exec(params); - } - }; - } - - /** - * - * @param warehouse - * @param id - * @param attsetinstid - * @return - * @throws BasicException - */ - public final double findProductStock(String warehouse, String id, String attsetinstid) throws BasicException { - - PreparedSentence p = attsetinstid == null - ? new PreparedSentence(s, "SELECT UNITS FROM stockcurrent " - + "WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID IS NULL" - , new SerializerWriteBasic(Datas.STRING, Datas.STRING) - , SerializerReadDouble.INSTANCE) - : new PreparedSentence(s, "SELECT UNITS FROM stockcurrent " - + "WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID = ?" - , new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING) - , SerializerReadDouble.INSTANCE); - - Double d = (Double) p.find(warehouse, id, attsetinstid); - return d == null ? 0.0 : d; - } - - /** - * - * @return - */ - public final SentenceExec getCatalogCategoryAdd() { - return new StaticSentence(s - , "INSERT INTO products_cat(PRODUCT, CATORDER) SELECT ID, " + s.DB.INTEGER_NULL() + " FROM products WHERE CATEGORY = ?" - , SerializerWriteString.INSTANCE); - } - - /** - * - * @return - */ - public final SentenceExec getCatalogCategoryDel() { - return new StaticSentence(s - , "DELETE FROM products_cat WHERE PRODUCT = ANY (SELECT ID " - + "FROM products WHERE CATEGORY = ?)" - , SerializerWriteString.INSTANCE); - } - - /** - * - * @return - */ - public final TableDefinition getTableCategories() { - return new TableDefinition(s, - "categories" - , new String[] {"ID", "NAME", "PARENTID", "IMAGE", "TEXTTIP", "CATSHOWNAME", "CATORDER"} - , new String[] {"ID", AppLocal.getIntString("label.name"), "", AppLocal.getIntString("label.image")} - , new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING, - Datas.IMAGE, Datas.STRING, Datas.BOOLEAN, Datas.STRING} - , new Formats[] {Formats.STRING, Formats.STRING, Formats.STRING, - Formats.NULL, Formats.STRING, Formats.BOOLEAN, Formats.STRING} - , new int[] {0} - ); - } - - /** - * - * @return - */ - public final TableDefinition getTableTaxes() { - return new TableDefinition(s, - "taxes" - , new String[] {"ID", "NAME", "CATEGORY", "CUSTCATEGORY", "PARENTID", "RATE", "RATECASCADE", "RATEORDER"} - , new String[] {"ID", AppLocal.getIntString("label.name"), AppLocal.getIntString("label.taxcategory"), AppLocal.getIntString("label.custtaxcategory"), AppLocal.getIntString("label.taxparent"), AppLocal.getIntString("label.dutyrate"), AppLocal.getIntString("label.cascade"), AppLocal.getIntString("label.order")} - , new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, Datas.DOUBLE, Datas.BOOLEAN, Datas.INT} - , new Formats[] {Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, Formats.PERCENT, Formats.BOOLEAN, Formats.INT} - , new int[] {0} - ); - } - - /** - * - * @return - */ - public final TableDefinition getTableTaxCustCategories() { - return new TableDefinition(s, - "taxcustcategories" - , new String[] {"ID", "NAME"} - , new String[] {"ID", AppLocal.getIntString("label.name")} - , new Datas[] {Datas.STRING, Datas.STRING} - , new Formats[] {Formats.STRING, Formats.STRING} - , new int[] {0} - ); - } - - /** - * - * @return - */ - public final TableDefinition getTableTaxCategories() { - return new TableDefinition(s, - "taxcategories" - , new String[] {"ID", "NAME"} - , new String[] {"ID", AppLocal.getIntString("label.name")} - , new Datas[] {Datas.STRING, Datas.STRING} - , new Formats[] {Formats.STRING, Formats.STRING} - , new int[] {0} - ); - } - - /** - * - * @return - */ - public final TableDefinition getTableLocations() { - return new TableDefinition(s, - "locations" - , new String[] {"ID", "NAME", "ADDRESS"} - , new String[] {"ID", AppLocal.getIntString("label.locationname"), - AppLocal.getIntString("label.locationaddress")} - , new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING} - , new Formats[] {Formats.STRING, Formats.STRING, Formats.STRING} - , new int[] {0} - ); - } - - - /** - * - */ - protected static class CustomerExtRead implements SerializerRead { - - /** - * - * @param dr - * @return - * @throws BasicException + @Override + public Object readValues(DataRead dr) throws BasicException { + SupplierInfoExt s = new SupplierInfoExt(dr.getString(1)); + s.setSearchkey(dr.getString(2)); + s.setTaxid(dr.getString(3)); + s.setName(dr.getString(4)); + s.setMaxdebt(dr.getDouble(5)); + s.setAddress(dr.getString(6)); + s.setAddress2(dr.getString(7)); + s.setPostal(dr.getString(8)); + s.setCity(dr.getString(9)); + s.setRegion(dr.getString(10)); + s.setCountry(dr.getString(11)); + s.setFirstname(dr.getString(12)); + s.setLastname(dr.getString(13)); + s.setEmail(dr.getString(14)); + s.setPhone(dr.getString(15)); + s.setPhone2(dr.getString(16)); + s.setFax(dr.getString(17)); + s.setNotes(dr.getString(18)); + s.setVisible(dr.getBoolean(19)); + s.setCurdate(dr.getTimestamp(20)); + s.setCurdebt(dr.getDouble(21)); + s.setSupplierVATID(dr.getString(22)); + + return s; + } + } + + /** + * + * @return + */ + + public final SentenceExec getCustomerInsert() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s, "INSERT INTO customers (" + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE ) " + + "VALUES (" + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?)", + new SerializerWriteBasicExt(customersRow.getDatas(), + new int[] { 0, + 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, + 25, 26 })) + + .exec(params); + return i; + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getCustomerUpdate() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s, "UPDATE customers SET " + + "ID = ?, " + + "SEARCHKEY = ?, " + + "TAXID = ?, " + + "NAME = ?, " + + "TAXCATEGORY = ?, " + + "CARD = ?, " + + "MAXDEBT = ?, " + + "ADDRESS = ?, " + + "ADDRESS2 = ?, " + + "POSTAL = ?, " + + "CITY = ?, " + + "REGION = ?, " + + "COUNTRY = ?, " + + "FIRSTNAME = ?, " + + "LASTNAME = ?, " + + "EMAIL = ?, " + + "PHONE = ?, " + + "PHONE2 = ?, " + + "FAX = ?, " + + "NOTES = ?," + + "VISIBLE = ?, " + + "CURDATE = ?, " + + "CURDEBT = ?, " + + "IMAGE = ?, " + + "ISVIP = ?, " + + "DISCOUNT = ?, " + + "MEMODATE = ? " + + "WHERE ID = ?", + new SerializerWriteBasicExt(customersRow.getDatas(), + new int[] { 0, + 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, + 26, 0 })) + .exec(params); + + /* + * Use this block workflow as template to pump LOYALTY, MEMBERSHIP & etc + * updates to internal or external DB table + * if (i > 0) { + * if (((Boolean)values[n0])) { + * if (new PreparedSentence(s + * , "UPDATE tablename SET FIELD = ? WHERE CUSTOMER = ?" + * , new SerializerWriteBasicExt(customersRow.getDatas() + * , new int[] {n1, 0})).exec(params) == 0) { + * new PreparedSentence(s + * , "INSERT INTO other_tablename (CUSTOMER, FIELD) VALUES (?, ?)" + * , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0, + * n1})).exec(params); + * } + * } else { + * new PreparedSentence(s + * , "DELETE FROM FIELD WHERE CUSTOMER = ?" + * , new SerializerWriteBasicExt(customersRow.getDatas(), new int[] + * {0})).exec(params); + * } + * } */ - @Override - public Object readValues(DataRead dr) throws BasicException { - CustomerInfoExt c = new CustomerInfoExt(dr.getString(1)); - c.setSearchkey(dr.getString(2)); - c.setTaxid(dr.getString(3)); - c.setTaxCustomerID(dr.getString(3)); - c.setName(dr.getString(4)); - c.setTaxCustCategoryID(dr.getString(5)); - c.setCard(dr.getString(6)); - c.setMaxdebt(dr.getDouble(7)); - c.setAddress(dr.getString(8)); - c.setAddress2(dr.getString(9)); - c.setPcode(dr.getString(10)); - c.setCity(dr.getString(11)); - c.setRegion(dr.getString(12)); - c.setCountry(dr.getString(13)); - c.setFirstname(dr.getString(14)); - c.setLastname(dr.getString(15)); - c.setCemail(dr.getString(16)); - c.setPhone1(dr.getString(17)); - c.setPhone2(dr.getString(18)); - c.setFax(dr.getString(19)); - c.setNotes(dr.getString(20)); - c.setVisible(dr.getBoolean(21)); - c.setCurdate(dr.getTimestamp(22)); - c.setAccdebt(dr.getDouble(23)); - c.setImage(ImageUtils.readImage(dr.getString(24))); - c.setisVIP(dr.getBoolean(25)); - c.setDiscount(dr.getDouble(26)); - c.setMemoDate(dr.getString(27)); + return i; + } + }; + } - return c; - } - } + /** + * + * @return + */ + public final SentenceExec getCustomerDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + return new PreparedSentence(s, "DELETE FROM customers WHERE ID = ?", + new SerializerWriteBasicExt(customersRow.getDatas(), + new int[] { 0 })) + .exec(params); + } + }; + } - public final UomInfo getUomInfoById(String id) throws BasicException { - return (UomInfo) new PreparedSentence(s, - "SELECT " + - "id, name " + - "FROM uom " + - "WHERE id = ?" - , SerializerWriteString.INSTANCE, UomInfo.getSerializerRead()).find(id); - } - - public final TableDefinition getTableUom() { - return new TableDefinition(s, - "uom", - new String[]{"id", "name"}, - new String[]{"id", - AppLocal.getIntString("Label.Name")}, - new Datas[]{ - Datas.STRING, Datas.STRING}, - new Formats[]{ - Formats.STRING, Formats.STRING}, - new int[]{0} - ); - } - - public final SentenceList getUomList() { - return new StaticSentence(s, "SELECT ID, NAME FROM uom ORDER BY NAME", null, UomInfo.getSerializerRead()); - } - -/* public final SentenceList getVoucherList() { - return new StaticSentence(s, - "SELECT " + - "vouchers.ID,vouchers.VOUCHER_NUMBER,vouchers.CUSTOMER, " + - "customers.NAME,AMOUNT, STATUS " + - "FROM vouchers " + - "JOIN customers ON customers.id = vouchers.CUSTOMER " + - "WHERE STATUS='A' " + - "ORDER BY vouchers.VOUCHER_NUMBER ASC" - , null, VoucherInfo.getSerializerRead()); - } -*/ - - public final SentenceList getVoucherList() { - return new StaticSentence(s, - "SELECT " + - "vouchers.ID,vouchers.VOUCHER_NUMBER,vouchers.CUSTOMER, " + - "vouchers.AMOUNT, vouchers.STATUS " + - "FROM vouchers " + - "WHERE STATUS='A' " + - "ORDER BY vouchers.VOUCHER_NUMBER ASC" - , null, VoucherInfo.getSerializerRead()); - } - - public final SentenceExec getVoucherNonActive() { - return new PreparedSentence(s, - "UPDATE vouchers SET STATUS = 'D' " + - "WHERE VOUCHER_NUMBER = ?" - , SerializerWriteString.INSTANCE); - } - public final SentenceExec setVoucherPending() { - return new PreparedSentence(s, - "UPDATE vouchers SET STATUS = 'P' " + - "WHERE VOUCHER_NUMBER = ?" - , SerializerWriteString.INSTANCE); - } - - public final SentenceExec resetPickupId() { - - return new PreparedSentence(s, - "UPDATE pickup_number SET ID=1 " - , SerializerWriteString.INSTANCE); - - } - - /** - * - * @param id - * @return - * @throws BasicException - */ - public SupplierInfoExt loadSupplierExt(String id) throws BasicException { - return (SupplierInfoExt) new PreparedSentence(s - , "SELECT " - + "ID, " - + "SEARCHKEY, " - + "TAXID, " - + "NAME, " - + "MAXDEBT, " - + "ADDRESS, " - + "ADDRESS2, " - + "POSTAL, " - + "CITY, " - + "REGION, " - + "COUNTRY, " - + "FIRSTNAME, " - + "LASTNAME, " - + "EMAIL, " - + "PHONE, " - + "PHONE2, " - + "FAX, " - + "NOTES, " - + "VISIBLE, " - + "CURDATE, " - + "CURDEBT, " - + "VATID " - + "FROM suppliers WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new SupplierExtRead()).find(id); - } - - /** - * - */ - protected static class SupplierExtRead implements SerializerRead { - - /** - * - * @param dr - * @return - * @throws BasicException - */ - @Override - public Object readValues(DataRead dr) throws BasicException { - SupplierInfoExt s = new SupplierInfoExt(dr.getString(1)); - s.setSearchkey(dr.getString(2)); - s.setTaxid(dr.getString(3)); - s.setName(dr.getString(4)); - s.setMaxdebt(dr.getDouble(5)); - s.setAddress(dr.getString(6)); - s.setAddress2(dr.getString(7)); - s.setPostal(dr.getString(8)); - s.setCity(dr.getString(9)); - s.setRegion(dr.getString(10)); - s.setCountry(dr.getString(11)); - s.setFirstname(dr.getString(12)); - s.setLastname(dr.getString(13)); - s.setEmail(dr.getString(14)); - s.setPhone(dr.getString(15)); - s.setPhone2(dr.getString(16)); - s.setFax(dr.getString(17)); - s.setNotes(dr.getString(18)); - s.setVisible(dr.getBoolean(19)); - s.setCurdate(dr.getTimestamp(20)); - s.setCurdebt(dr.getDouble(21)); - s.setSupplierVATID(dr.getString(22)); - - return s; - } - } - - /** - * - * @return - */ - - public final SentenceExec getCustomerInsert() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - Object[] values = (Object[]) params; - int i = new PreparedSentence(s - , "INSERT INTO customers (" - + "ID, " - + "SEARCHKEY, " - + "TAXID, " - + "NAME, " - + "TAXCATEGORY, " - + "CARD, " - + "MAXDEBT, " - + "ADDRESS, " - + "ADDRESS2, " - + "POSTAL, " - + "CITY, " - + "REGION, " - + "COUNTRY, " - + "FIRSTNAME, " - + "LASTNAME, " - + "EMAIL, " - + "PHONE, " - + "PHONE2, " - + "FAX, " - + "NOTES, " - + "VISIBLE, " - + "CURDATE, " - + "CURDEBT, " - + "IMAGE, " - + "ISVIP, " - + "DISCOUNT, " - + "MEMODATE ) " - + "VALUES (" - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?, ?, ?, ?, " - + "?, ?, ?)" - , new SerializerWriteBasicExt(customersRow.getDatas(), - new int[]{0, - 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, - 25, 26})) - - .exec(params); - return i; - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getCustomerUpdate() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - Object[] values = (Object[]) params; - int i = new PreparedSentence(s - , "UPDATE customers SET " - + "ID = ?, " - + "SEARCHKEY = ?, " - + "TAXID = ?, " - + "NAME = ?, " - + "TAXCATEGORY = ?, " - + "CARD = ?, " - + "MAXDEBT = ?, " - + "ADDRESS = ?, " - + "ADDRESS2 = ?, " - + "POSTAL = ?, " - + "CITY = ?, " - + "REGION = ?, " - + "COUNTRY = ?, " - + "FIRSTNAME = ?, " - + "LASTNAME = ?, " - + "EMAIL = ?, " - + "PHONE = ?, " - + "PHONE2 = ?, " - + "FAX = ?, " - + "NOTES = ?," - + "VISIBLE = ?, " - + "CURDATE = ?, " - + "CURDEBT = ?, " - + "IMAGE = ?, " - + "ISVIP = ?, " - + "DISCOUNT = ?, " - + "MEMODATE = ? " - + "WHERE ID = ?" - , new SerializerWriteBasicExt(customersRow.getDatas(), - new int[]{0, - 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, - 26, 0})) - .exec(params); - -/* - * Use this block workflow as template to pump LOYALTY, MEMBERSHIP & etc - * updates to internal or external DB table - if (i > 0) { - if (((Boolean)values[n0])) { - if (new PreparedSentence(s - , "UPDATE tablename SET FIELD = ? WHERE CUSTOMER = ?" - , new SerializerWriteBasicExt(customersRow.getDatas() - , new int[] {n1, 0})).exec(params) == 0) { - new PreparedSentence(s - , "INSERT INTO other_tablename (CUSTOMER, FIELD) VALUES (?, ?)" - , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0, n1})).exec(params); - } - } else { - new PreparedSentence(s - , "DELETE FROM FIELD WHERE CUSTOMER = ?" - , new SerializerWriteBasicExt(customersRow.getDatas(), new int[] {0})).exec(params); - } - } -*/ - return i; - } - }; - } - - /** - * - * @return - */ - public final SentenceExec getCustomerDelete() { - return new SentenceExecTransaction(s) { - @Override - public int execInTransaction(Object params) throws BasicException { - return new PreparedSentence(s - , "DELETE FROM customers WHERE ID = ?" - , new SerializerWriteBasicExt(customersRow.getDatas(), - new int[] {0} - )).exec(params); - } - }; - } - - -} \ No newline at end of file +} diff --git a/src/main/java/com/unicenta/pos/sales/DataLogicReceipts.java b/src/main/java/com/unicenta/pos/sales/DataLogicReceipts.java index 1028db0..a80be0e 100644 --- a/src/main/java/com/unicenta/pos/sales/DataLogicReceipts.java +++ b/src/main/java/com/unicenta/pos/sales/DataLogicReceipts.java @@ -37,348 +37,330 @@ import java.util.List; * @author adrianromero */ public class DataLogicReceipts extends BeanFactoryDataSingle { - - private Session s; - - /** Creates a new instance of DataLogicReceipts */ - public DataLogicReceipts() { - } - - /** - * - * @param s - */ - @Override - public void init(Session s){ - this.s = s; - } - - /** - * - * @param Id - * @return - * @throws BasicException - */ - public final TicketInfo getSharedTicket(String Id) throws BasicException { - - if (Id == null) { - return null; - } else { - Object[]record = (Object[]) new StaticSentence(s - , "SELECT CONTENT, LOCKED FROM sharedtickets WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadBasic(new Datas[] { - Datas.SERIALIZABLE})).find(Id); - return record == null ? null : (TicketInfo) record[0]; - } - } - - /** - * - * @param pickupId - * @return - * @throws BasicException - */ - public final TicketInfo getSharedTicketPickupId(String pickupId) throws BasicException { - - if (pickupId == null) { - return null; - } else { - Object[]record = (Object[]) new StaticSentence(s - , "SELECT CONTENT, LOCKED FROM sharedtickets WHERE PICKUPID = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadBasic(new Datas[] { - Datas.SERIALIZABLE})).find(pickupId); - return record == null ? null : (TicketInfo) record[0]; - } - } - /** - * JG Dec 14 Administrator and Manager Roles always have access to ALL SHAREDtickets - * @return - * @throws BasicException - */ - public final List getSharedTicketList() throws BasicException { - - return (List) new StaticSentence(s -// , "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED FROM sharedtickets ORDER BY ID" - , "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED " - + "FROM sharedtickets ORDER BY PICKUPID" - , null - , new SerializerReadClass(SharedTicketInfo.class)).list(); - } - - /** - * Return only current APPUSER SHAREDtickets - * @param appuser - * @return - * @throws BasicException - */ - public final List getUserSharedTicketList(String appuser) throws BasicException { - String sql = "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED " - + "FROM sharedtickets " - + "WHERE APPUSER =\""+ appuser +"\" ORDER BY PICKUPID"; - - return (List) new StaticSentence(s - , sql - , null - , new SerializerReadClass(SharedTicketInfo.class)).list(); - } - - /** - * For Standard View - * @param id - * @param ticket - * @param pickupid - * @throws BasicException - */ - public final void insertSharedTicket(final String id, final TicketInfo ticket, int pickupid) throws BasicException { - - Object[] values = new Object[] { - id, - ticket.getName(), - ticket, - ticket.getUser().getId(), - pickupid + private Session s; - }; - Datas[] datas; - datas = new Datas[] { - Datas.STRING, - Datas.STRING, - Datas.SERIALIZABLE, - Datas.STRING, - Datas.INT + /** Creates a new instance of DataLogicReceipts */ + public DataLogicReceipts() { + } - }; - new PreparedSentence(s - , "INSERT INTO sharedtickets (" - + "ID, " - + "NAME, " - + "CONTENT, " - + "APPUSER, " - + "PICKUPID) " - + "VALUES (?, ?, ?, ?, ?)" - , new SerializerWriteBasicExt(datas, new int[] {0, 1, 2, 3, 4})).exec(values); - } - - /** - * - * @param id - * @param ticket - * @param pickupid - * @throws BasicException - */ - public final void updateSharedTicket(final String id, final TicketInfo ticket, int pickupid) throws BasicException { - - Object[] values = new Object[] { - id, - ticket.getName(), - ticket, - ticket.getUser().getId(), - pickupid - }; - Datas[] datas = new Datas[] { - Datas.STRING, - Datas.STRING, - Datas.SERIALIZABLE, - Datas.STRING, - Datas.INT - }; - new PreparedSentence(s - , "UPDATE sharedtickets SET " - + "NAME = ?, " - + "CONTENT = ?, " - + "APPUSER = ?, " - + "PICKUPID = ? " - + "WHERE ID = ?" - , new SerializerWriteBasicExt(datas, - new int[] { - 1, 2, 3, 4, 0})).exec(values); - } + /** + * + * @param s + */ + @Override + public void init(Session s) { + this.s = s; + } - /** - * - * @param id - * @param ticket - * @param pickupid - * @throws BasicException - */ - public final void updateRSharedTicket( - final String id, - final TicketInfo ticket, - int pickupid) throws BasicException { - - Object[] values = new Object[] { - id, - ticket.getName(), - ticket, - pickupid - }; - Datas[] datas = new Datas[] { - Datas.STRING, - Datas.STRING, - Datas.SERIALIZABLE, - Datas.INT - }; - new PreparedSentence(s - , "UPDATE sharedtickets SET " - + "NAME = ?, " - + "CONTENT = ?, " - + "PICKUPID = ? " - + "WHERE ID = ?" - , new SerializerWriteBasicExt(datas, new int[] {1, 2, 3, 0})).exec(values); + /** + * + * @param Id + * @return + * @throws BasicException + */ + public final TicketInfo getSharedTicket(String Id) throws BasicException { + + if (Id == null) { + return null; + } else { + Object[] record = (Object[]) new StaticSentence(s, "SELECT CONTENT, LOCKED FROM sharedtickets WHERE ID = ?", + SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { + Datas.SERIALIZABLE })) + .find(Id); + return record == null ? null : (TicketInfo) record[0]; } - - /** - * In place for multi-purposing like containing data from elsewhere and/or - * using Place and User for Notifications - * @param id - * @param locked - * @throws BasicException - */ - public final void lockSharedTicket(final String id, final String locked) throws BasicException { - - Object[] values = new Object[] { - id, - locked - }; - Datas[] datas = new Datas[] { - Datas.STRING, + } + + /** + * + * @param pickupId + * @return + * @throws BasicException + */ + public final TicketInfo getSharedTicketPickupId(String pickupId) throws BasicException { + + if (pickupId == null) { + return null; + } else { + Object[] record = (Object[]) new StaticSentence(s, "SELECT CONTENT, LOCKED FROM sharedtickets WHERE PICKUPID = ?", + SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { + Datas.SERIALIZABLE })) + .find(pickupId); + return record == null ? null : (TicketInfo) record[0]; + } + } + + /** + * JG Dec 14 Administrator and Manager Roles always have access to ALL + * SHAREDtickets + * + * @return + * @throws BasicException + */ + public final List getSharedTicketList() throws BasicException { + + return (List) new StaticSentence(s + // , "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED FROM sharedtickets + // ORDER BY ID" + , "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED " + + "FROM sharedtickets ORDER BY PICKUPID", + null, new SerializerReadClass(SharedTicketInfo.class)).list(); + } + + /** + * Return only current APPUSER SHAREDtickets + * + * @param appuser + * @return + * @throws BasicException + */ + public final List getUserSharedTicketList(String appuser) throws BasicException { + String sql = "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED " + + "FROM sharedtickets " + + "WHERE APPUSER =\"" + appuser + "\" ORDER BY PICKUPID"; + + return (List) new StaticSentence(s, sql, null, new SerializerReadClass(SharedTicketInfo.class)) + .list(); + } + + /** + * For Standard View + * + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void insertSharedTicket(final String id, final TicketInfo ticket, int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + ticket.getUserInfo().getId(), + pickupid + + }; + Datas[] datas; + datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.STRING, + Datas.INT + + }; + new PreparedSentence(s, "INSERT INTO sharedtickets (" + + "ID, " + + "NAME, " + + "CONTENT, " + + "APPUSER, " + + "PICKUPID) " + + "VALUES (?, ?, ?, ?, ?)", new SerializerWriteBasicExt(datas, new int[] { 0, 1, 2, 3, 4 })).exec(values); + } + + /** + * + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void updateSharedTicket(final String id, final TicketInfo ticket, int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + ticket.getUserInfo().getId(), + pickupid + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.STRING, + Datas.INT + }; + new PreparedSentence(s, "UPDATE sharedtickets SET " + + "NAME = ?, " + + "CONTENT = ?, " + + "APPUSER = ?, " + + "PICKUPID = ? " + + "WHERE ID = ?", + new SerializerWriteBasicExt(datas, + new int[] { + 1, 2, 3, 4, 0 })) + .exec(values); + } + + /** + * + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void updateRSharedTicket( + final String id, + final TicketInfo ticket, + int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + pickupid + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.INT + }; + new PreparedSentence(s, "UPDATE sharedtickets SET " + + "NAME = ?, " + + "CONTENT = ?, " + + "PICKUPID = ? " + + "WHERE ID = ?", new SerializerWriteBasicExt(datas, new int[] { 1, 2, 3, 0 })).exec(values); + } + + /** + * In place for multi-purposing like containing data from elsewhere and/or + * using Place and User for Notifications + * + * @param id + * @param locked + * @throws BasicException + */ + public final void lockSharedTicket(final String id, final String locked) throws BasicException { + + Object[] values = new Object[] { + id, + locked + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING + }; + new PreparedSentence(s, "UPDATE sharedtickets SET " + + "LOCKED = ? " + + "WHERE ID = ?", new SerializerWriteBasicExt(datas, new int[] { 1, 0 })).exec(values); + } + + /** + * In place for multi-purposing like flushing locks from elsewhere and/or + * using Place and User for Notifications + * + * @param id + * @param unlocked + * @throws BasicException + */ + public final void unlockSharedTicket(final String id, final String unlocked) throws BasicException { + + Object[] values = new Object[] { + id, + unlocked + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING + }; + new PreparedSentence(s, "UPDATE sharedtickets SET " + + "LOCKED = ? " + + "WHERE ID = ?", new SerializerWriteBasicExt(datas, new int[] { 1, 0 })).exec(values); + } + + /** + * For Restaurant View + * + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void insertRSharedTicket( + final String id, + final TicketInfo ticket, + int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + ticket.getUserInfo(), + ticket.getPickupId(), + ticket.getHost() + }; + Datas[] datas; + datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.STRING, + Datas.INT + + }; + new PreparedSentence(s, "INSERT INTO sharedtickets (" + + "ID, " + + "NAME, " + + "CONTENT, " + + "APPUSER, " + + "PICKUPID) " + + "VALUES (?, ?, ?, ?, ?)", new SerializerWriteBasicExt(datas, new int[] { 0, 1, 2, 3, 4 })).exec(values); + } + + /** + * + * @param id + * @throws BasicException + */ + public final void deleteSharedTicket(final String id) throws BasicException { + + new StaticSentence(s, "DELETE FROM sharedtickets WHERE ID = ?", SerializerWriteString.INSTANCE).exec(id); + } + + /** + * + * @param Id + * @return + * @throws BasicException + */ + public final Integer getPickupId(String Id) throws BasicException { + + if (Id == null) { + return null; + } else { + Object[] record = (Object[]) new StaticSentence(s, "SELECT PICKUPID FROM sharedtickets WHERE ID = ?", + SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { Datas.INT })).find(Id); + return record == null ? 0 : (Integer) record[0]; + } + } + + public final String getUserId(final String id) throws BasicException { + Object[] userID = (Object[]) new StaticSentence(s, "SELECT APPUSER FROM sharedtickets WHERE ID = ?", + SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { Datas.STRING })).find(id); + if (userID == null) { + return null; + } else { + return (String) userID[0]; + } + } + + public final String getLockState(final String id, String lockState) throws BasicException { + Object[] state = (Object[]) new StaticSentence(s, "SELECT LOCKED FROM sharedtickets WHERE ID = ?", + SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { Datas.STRING - }; - new PreparedSentence(s - , "UPDATE sharedtickets SET " - + "LOCKED = ? " - + "WHERE ID = ?" - , new SerializerWriteBasicExt(datas, new int[] {1, 0})).exec(values); - } + })).find(id); + return (String) state[0]; + } - /** - * In place for multi-purposing like flushing locks from elsewhere and/or - * using Place and User for Notifications - * @param id - * @param unlocked - * @throws BasicException - */ - public final void unlockSharedTicket(final String id, final String unlocked) throws BasicException { - - Object[] values = new Object[] { - id, - unlocked - }; - Datas[] datas = new Datas[] { - Datas.STRING, + public final String getServer(final String id, String user) throws BasicException { + Object[] server = (Object[]) new StaticSentence(s, "SELECT appuser FROM sharedtickets WHERE ID = ?", + SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { Datas.STRING - }; - new PreparedSentence(s - , "UPDATE sharedtickets SET " - + "LOCKED = ? " - + "WHERE ID = ?" - , new SerializerWriteBasicExt(datas, new int[] {1, 0})).exec(values); - } - - /** - * For Restaurant View - * @param id - * @param ticket - * @param pickupid - * @throws BasicException - */ - public final void insertRSharedTicket( - final String id, - final TicketInfo ticket, - int pickupid) throws BasicException { - - Object[] values = new Object[] { - id, - ticket.getName(), - ticket, - ticket.getUser(), - ticket.getPickupId(), - ticket.getHost() - }; - Datas[] datas; - datas = new Datas[] { - Datas.STRING, - Datas.STRING, - Datas.SERIALIZABLE, - Datas.STRING, - Datas.INT - - }; - new PreparedSentence(s - , "INSERT INTO sharedtickets (" - + "ID, " - + "NAME, " - + "CONTENT, " - + "APPUSER, " - + "PICKUPID) " - + "VALUES (?, ?, ?, ?, ?)" - , new SerializerWriteBasicExt(datas, new int[] {0, 1, 2, 3, 4})).exec(values); - } - - /** - * - * @param id - * @throws BasicException - */ - public final void deleteSharedTicket(final String id) throws BasicException { - - new StaticSentence(s - , "DELETE FROM sharedtickets WHERE ID = ?" - , SerializerWriteString.INSTANCE).exec(id); - } - - /** - * - * @param Id - * @return - * @throws BasicException - */ - public final Integer getPickupId(String Id) throws BasicException { - - if (Id == null) { - return null; - } else { - Object[]record = (Object[]) new StaticSentence(s - , "SELECT PICKUPID FROM sharedtickets WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadBasic(new Datas[] {Datas.INT})).find(Id); - return record == null ? 0 : (Integer)record[0]; - } - } - - - public final String getUserId(final String id) throws BasicException { - Object[] userID = (Object []) new StaticSentence(s - , "SELECT APPUSER FROM sharedtickets WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadBasic(new Datas[] {Datas.STRING})).find(id); - if( userID == null ) { - return null; - } else { - return (String) userID[0]; - } - } - - public final String getLockState(final String id, String lockState) throws BasicException { - Object[] state = (Object[]) new StaticSentence(s - , "SELECT LOCKED FROM sharedtickets WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadBasic(new Datas[] { - Datas.STRING - })).find(id); - return (String) state[0]; - } - - public final String getServer(final String id, String user) throws BasicException { - Object[] server = (Object[]) new StaticSentence(s - , "SELECT appuser FROM sharedtickets WHERE ID = ?" - , SerializerWriteString.INSTANCE - , new SerializerReadBasic(new Datas[] { - Datas.STRING - })).find(id); - return (String) server[0]; - } + })).find(id); + return (String) server[0]; + } } diff --git a/src/main/java/com/unicenta/pos/sales/JPanelTicket.java b/src/main/java/com/unicenta/pos/sales/JPanelTicket.java index b55afd1..1afb4bc 100644 --- a/src/main/java/com/unicenta/pos/sales/JPanelTicket.java +++ b/src/main/java/com/unicenta/pos/sales/JPanelTicket.java @@ -74,7 +74,6 @@ import java.util.*; import static java.awt.Window.getWindows; - /** * @author JG uniCenta */ @@ -155,7 +154,6 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac private Integer oCount = 0; private Boolean pinOK; - /** * Creates new form JTicketView */ @@ -182,8 +180,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac dlCustomers = (DataLogicCustomers) m_App.getBean("com.unicenta.pos.customers.DataLogicCustomers"); dlReceipts = (DataLogicReceipts) app.getBean("com.unicenta.pos.sales.DataLogicReceipts"); - - /* uniCenta Feb 2018 + /* + * uniCenta Feb 2018 * Changed for 4.3 * Set up main toolbar area with two rows to add cater for additional scripts * else over-crowding and some dynamic buttons off screen/not visible @@ -191,16 +189,17 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac * Resources>Menu.Root */ -// Set Configuration>General>Tickets toolbar simple : standard : restaurant option + // Set Configuration>General>Tickets toolbar simple : standard : restaurant + // option m_ticketsbag = getJTicketsBag(); m_jPanelBag.add(m_ticketsbag.getBagComponent(), BorderLayout.LINE_START); add(m_ticketsbag.getNullComponent(), "null"); -// Script event buttons + // Script event buttons m_jbtnconfig = new JPanelButtons("Ticket.Buttons", this); m_jButtonsExt.add(m_jbtnconfig); -// Configuration>Peripheral options + // Configuration>Peripheral options if (!m_App.getDeviceScale().existsScale()) { m_jbtnScale.setVisible(false); } @@ -327,7 +326,6 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } - } @Override @@ -386,9 +384,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (currentTicket != null) { try { dlReceipts.updateSharedTicket(currentTicket, m_oTicket, m_oTicket.getPickupId()); -// } catch (BasicException e) { -// new MessageInf(e).show(this); -// } + // } catch (BasicException e) { + // new MessageInf(e).show(this); + // } } catch (BasicException ex) { log.error(ex.getMessage()); } @@ -512,22 +510,22 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_oTicketExt = oTicketExt; if (m_oTicket != null) { - m_oTicket.setUser(m_App.getAppUserView().getUser().getUserInfo()); + m_oTicket.setUserInfo(m_App.getAppUserView().getUser().getUserInfo()); m_oTicket.setActiveCash(m_App.getActiveCashIndex()); m_oTicket.setDate(new Date()); if ("restaurant".equals(m_App.getProperties().getProperty("machine.ticketsbag")) - && !oTicket.getOldTicket()) { + && !oTicket.getOldTicket()) { if (restDB.getCustomerNameInTable(oTicketExt.toString()) == null) { if (m_oTicket.getCustomer() != null) { restDB.setCustomerNameInTable(m_oTicket.getCustomer().toString(), - oTicketExt.toString()); + oTicketExt.toString()); } } if (restDB.getWaiterNameInTable(oTicketExt.toString()) == null - || "".equals(restDB.getWaiterNameInTable(oTicketExt.toString()))) { + || "".equals(restDB.getWaiterNameInTable(oTicketExt.toString()))) { restDB.setWaiterNameInTable(m_App.getAppUserView().getUser().getName(), - oTicketExt.toString()); + oTicketExt.toString()); } restDB.setTicketIdInTable(m_oTicket.getId(), oTicketExt.toString()); @@ -537,14 +535,14 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } if ((m_oTicket != null) && (((Boolean.parseBoolean(m_App.getProperties() - .getProperty("table.showwaiterdetails"))) - || (Boolean.valueOf(m_App.getProperties().getProperty( + .getProperty("table.showwaiterdetails"))) + || (Boolean.valueOf(m_App.getProperties().getProperty( "table.showcustomerdetails")))))) { } if ((m_oTicket != null) && (((Boolean.valueOf(m_App.getProperties() - .getProperty("table.showcustomerdetails"))) || - (Boolean.parseBoolean(m_App.getProperties().getProperty("table.showwaiterdetails")))))) { + .getProperty("table.showcustomerdetails"))) || + (Boolean.parseBoolean(m_App.getProperties().getProperty("table.showwaiterdetails")))))) { if (restDB.getTableMovedFlag(m_oTicket.getId())) { restDB.moveCustomer(oTicketExt.toString(), m_oTicket.getId()); } @@ -600,7 +598,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_oTicket.getLines().forEach((line) -> { line.setTaxInfo(taxeslogic.getTaxInfo(line - .getProductTaxCategoryID(), m_oTicket.getCustomer())); + .getProductTaxCategoryID(), m_oTicket.getCustomer())); }); m_jTicketId.setText(m_oTicket.getName(m_oTicketExt)); @@ -609,7 +607,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac for (int i = 0; i < m_oTicket.getLinesCount(); i++) { m_ticketlines.addTicketLine(m_oTicket.getLine(i)); } -// set line here? + // set line here? countArticles(); printPartialTotals(); @@ -632,13 +630,13 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } private void countArticles() { - oCount = count; // existing line before change - count = (int) m_oTicket.getArticlesCount(); //existing line after change + oCount = count; // existing line before change + count = (int) m_oTicket.getArticlesCount(); // existing line after change if (m_oTicket != null) { for (int i = 0; i < m_oTicket.getLinesCount(); i++) { if (m_App.getAppUserView().getUser().hasPermission("sales.Total") - && m_oTicket.getArticlesCount() > 1) { + && m_oTicket.getArticlesCount() > 1) { btnSplit.setEnabled(true); } else { btnSplit.setEnabled(false); @@ -660,7 +658,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (iValue == null ? secret == null : iValue.equals(secret)) { pinOK = true; JOptionPane.showMessageDialog(this, "Units changed from " - + count + " to " + oCount); + + count + " to " + oCount); return pinOK; } else { @@ -689,13 +687,13 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac private void paintTicketLine(int index, TicketLineInfo oLine) { if (executeEventAndRefresh("ticket.setline", - new ScriptArg("index", index), new ScriptArg("line", oLine)) == null) { + new ScriptArg("index", index), new ScriptArg("line", oLine)) == null) { m_oTicket.setLine(index, oLine); m_ticketlines.setTicketLine(index, oLine); m_ticketlines.setSelectedIndex(index); - oCount = count; // pass line old multiplier value + oCount = count; // pass line old multiplier value countArticles(); visorTicketLine(oLine); @@ -708,7 +706,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac private void addTicketLine(ProductInfoExt oProduct, double dMul, double dPrice) { -// if (oProduct.isVprice() || oProduct.getID().equals("xxx999_999xxx_x9x9x9")){ + // if (oProduct.isVprice() || oProduct.getID().equals("xxx999_999xxx_x9x9x9")){ if (oProduct.isVprice()) { TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); @@ -717,13 +715,13 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } addTicketLine(new TicketLineInfo(oProduct, dMul, dPrice, tax, - (java.util.Properties) (oProduct.getProperties().clone()))); + (java.util.Properties) (oProduct.getProperties().clone()))); } else if (oProduct.getID().equals("xxx998_998xxx_x8x8x8")) { if (m_App.getProperties().getProperty("till.SCOnOff").equals("true")) { TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), - m_oTicket.getCustomer()); + m_oTicket.getCustomer()); String SCRate = (m_App.getProperties().getProperty("till.SCRate")); double scharge; @@ -731,22 +729,22 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac scharge = m_oTicket.getTotal() * (scharge / 100); addTicketLine(new TicketLineInfo(oProduct, 1, scharge, tax, - (java.util.Properties) (oProduct.getProperties().clone()))); + (java.util.Properties) (oProduct.getProperties().clone()))); } else { JOptionPane.showMessageDialog(this, "Service Charge Not Enabled"); } } else { -// get the line product tax + // get the line product tax TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); addTicketLine(new TicketLineInfo(oProduct, dMul, dPrice, tax, - (java.util.Properties) (oProduct.getProperties().clone()))); + (java.util.Properties) (oProduct.getProperties().clone()))); -// if (oProduct.getID().equals("xxx999_999xxx_x9x9x9")){ -// m_jEditLine.doClick(); -// } + // if (oProduct.getID().equals("xxx999_999xxx_x9x9x9")){ + // m_jEditLine.doClick(); + // } refreshTicket(); } @@ -799,7 +797,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } catch (BasicException ex) { MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, - AppLocal.getIntString("message.cannotfindattributes"), ex); + AppLocal.getIntString("message.cannotfindattributes"), ex); msg.show(this); } } @@ -816,12 +814,10 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac private void removeTicketLine(int i) { -// if (m_App.getProperties().getProperty("override.check").equals("true")) { + // if (m_App.getProperties().getProperty("override.check").equals("true")) { if (!m_oTicket.getLine(i).getUpdated()) { - JOptionPane.showMessageDialog(this - , AppLocal.getIntString("message.deletelinesent") - , AppLocal.getIntString("label.deleteline") - , JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(this, AppLocal.getIntString("message.deletelinesent"), + AppLocal.getIntString("label.deleteline"), JOptionPane.WARNING_MESSAGE); } else { if (executeEventAndRefresh("ticket.removeline", new ScriptArg("index", i)) == null) { String ticketID = Integer.toString(m_oTicket.getTicketId()); @@ -829,14 +825,13 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac ticketID = "Void"; } dlSystem.execLineRemoved( - new Object[]{ - m_App.getAppUserView().getUser().getName(), - ticketID, - m_oTicket.getLine(i).getProductID(), - m_oTicket.getLine(i).getProductName(), - m_oTicket.getLine(i).getMultiply() - } - ); + new Object[] { + m_App.getAppUserView().getUser().getName(), + ticketID, + m_oTicket.getLine(i).getProductID(), + m_oTicket.getLine(i).getProductName(), + m_oTicket.getLine(i).getMultiply() + }); if (m_oTicket.getLine(i).isProductCom()) { m_oTicket.removeLine(i); @@ -846,8 +841,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (m_App.getAppUserView().getUser().hasPermission("sales.DeleteLines")) { int input = JOptionPane.showConfirmDialog(this, - AppLocal.getIntString("message.deletelineyes") - , AppLocal.getIntString("label.deleteline"), JOptionPane.YES_NO_OPTION); + AppLocal.getIntString("message.deletelineyes"), AppLocal.getIntString("label.deleteline"), + JOptionPane.YES_NO_OPTION); if (input == 0) { m_oTicket.removeLine(i); @@ -855,8 +850,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else { JOptionPane.showMessageDialog(this, - AppLocal.getIntString("message.deletelineno") - , AppLocal.getIntString("label.deleteline"), JOptionPane.WARNING_MESSAGE); + AppLocal.getIntString("message.deletelineno"), AppLocal.getIntString("label.deleteline"), + JOptionPane.WARNING_MESSAGE); } } else { m_oTicket.removeLine(i); @@ -878,18 +873,18 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac executeEventAndRefresh("ticket.change"); } } -// } + // } } private ProductInfoExt getInputProduct() { ProductInfoExt oProduct = new ProductInfoExt(); -// Always add Default Prod ID + Add Name to Misc. if empty + // Always add Default Prod ID + Add Name to Misc. if empty oProduct.setID("xxx999_999xxx_x9x9x9"); oProduct.setReference("xxx999"); oProduct.setCode("xxx999"); oProduct.setName("***"); oProduct.setTaxCategoryID(((TaxCategoryInfo) taxcategoriesmodel - .getSelectedItem()).getID()); + .getSelectedItem()).getID()); oProduct.setPriceSell(includeTaxes(oProduct.getTaxCategoryID(), getInputValue())); return oProduct; @@ -911,7 +906,6 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac return dValue / (1.0 + dTaxRate); } - private double getInputValue() { try { return Double.parseDouble(m_jPrice.getText()); @@ -947,8 +941,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (oProduct == null) { Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(null, - sCode + " - " + AppLocal.getIntString("message.noproduct"), - "Check", JOptionPane.WARNING_MESSAGE); + sCode + " - " + AppLocal.getIntString("message.noproduct"), + "Check", JOptionPane.WARNING_MESSAGE); stateToZero(); } else { incProduct(oProduct); @@ -966,7 +960,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (oProduct == null) { Toolkit.getDefaultToolkit().beep(); new MessageInf(MessageInf.SGN_WARNING, AppLocal - .getIntString("message.noproduct")).show(this); + .getIntString("message.noproduct")).show(this); stateToZero(); } else { if (m_jaddtax.isSelected()) { @@ -993,7 +987,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } catch (ScaleException e) { Toolkit.getDefaultToolkit().beep(); new MessageInf(MessageInf.SGN_WARNING, AppLocal - .getIntString("message.noweight"), e).show(this); + .getIntString("message.noweight"), e).show(this); stateToZero(); } } else { @@ -1002,7 +996,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } else { Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(null, - AppLocal.getIntString("message.novprice")); + AppLocal.getIntString("message.novprice")); } } } @@ -1040,17 +1034,17 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (m_sBarcode.length() > 0) { String sCode = m_sBarcode.toString(); - String sCodetype = "EAN"; // Declare EAN. It's default + String sCodetype = "EAN"; // Declare EAN. It's default if ("true".equals(m_App.getProperties() - .getProperty("machine.barcodetype"))) { + .getProperty("machine.barcodetype"))) { sCodetype = "UPC"; } else { - sCodetype = "EAN"; // Ensure not null + sCodetype = "EAN"; // Ensure not null } if (sCode.startsWith("C") - || sCode.startsWith("c")) { + || sCode.startsWith("c")) { try { String card = sCode; CustomerInfoExt newcustomer = dlSales.findCustomerExt(card); @@ -1058,7 +1052,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (newcustomer == null) { Toolkit.getDefaultToolkit().beep(); new MessageInf(MessageInf.SGN_WARNING, AppLocal - .getIntString("message.nocustomer")).show(this); + .getIntString("message.nocustomer")).show(this); } else { m_oTicket.setCustomer(newcustomer); m_jTicketId.setText(m_oTicket.getName(m_oTicketExt)); @@ -1066,202 +1060,190 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } catch (BasicException e) { Toolkit.getDefaultToolkit().beep(); new MessageInf(MessageInf.SGN_WARNING, AppLocal - .getIntString("message.nocustomer"), e).show(this); + .getIntString("message.nocustomer"), e).show(this); } stateToZero(); } else if (sCode.startsWith(";")) { stateToZero(); - // START OF BARCODE PARSING - /* This block is deliberately verbose and is base for future scanner handling - * Some scanners inject a CR+LF... some don't... - * stateTransition() must allow for this as these add characters to .length() - * First 3 digits are GS1 CountryCode OR Retailer internal use + /* + * This block is deliberately verbose and is base for future scanner handling + * Some scanners inject a CR+LF... some don't... + * stateTransition() must allow for this as these add characters to .length() + * First 3 digits are GS1 CountryCode OR Retailer internal use * - * Prefix ManCodeProdCode CheckCode - * PPP MMMMMCCCCC K - * 012 3456789012 K - * Barcode CCCCC must be unique - * Notes: - * ManufacturerCode and ProductCode must be exactly 10 digits - * If code begins with 0 then is actually a UPC-A with prepended 0 + * Prefix ManCodeProdCode CheckCode + * PPP MMMMMCCCCC K + * 012 3456789012 K + * Barcode CCCCC must be unique + * Notes: + * ManufacturerCode and ProductCode must be exactly 10 digits + * If code begins with 0 then is actually a UPC-A with prepended 0 * - * uniCenta oPOS Retailer instore uses these RULES - * Prefixes 020 to 029 are set aside for Retailer internal use - * This means that CCCC becomes price/weight values - * Prefixes 978 and 979 are set aside for ISBN - Future use + * uniCenta oPOS Retailer instore uses these RULES + * Prefixes 020 to 029 are set aside for Retailer internal use + * This means that CCCC becomes price/weight values + * Prefixes 978 and 979 are set aside for ISBN - Future use * - * Prefix ManCode ProdCode CheckCode - * PPP MMMMM CCCCC K Format - * 012 34567 89012 K Human + * Prefix ManCode ProdCode CheckCode + * PPP MMMMM CCCCC K Format + * 012 34567 89012 K Human * */ } else if ("EAN".equals(sCodetype) - && ((sCode.startsWith("2")) || (sCode.startsWith("02"))) // check code prefix - && ((sCode.length() == 13) || (sCode.length() == 12))) { // check code length variances + && ((sCode.startsWith("2")) || (sCode.startsWith("02"))) // check code prefix + && ((sCode.length() == 13) || (sCode.length() == 12))) { // check code length variances try { - ProductInfoExt oProduct // get product(s) with PMMMMM - = dlSales.getProductInfoByShortCode(sCode); + ProductInfoExt oProduct // get product(s) with PMMMMM + = dlSales.getProductInfoByShortCode(sCode); - if (oProduct == null) { // nothing returned so display message to user + if (oProduct == null) { // nothing returned so display message to user Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(null, - sCode + " - " - + AppLocal.getIntString("message.noproduct"), - "Check", JOptionPane.WARNING_MESSAGE); - stateToZero(); // clear the user input + sCode + " - " + + AppLocal.getIntString("message.noproduct"), + "Check", JOptionPane.WARNING_MESSAGE); + stateToZero(); // clear the user input - } else if ("EAN-13".equals(oProduct.getCodetype())) { // have a valid barcode - oProduct.setProperty("product.barcode", sCode); // set the screen's barcode from input - double dPriceSell = oProduct.getPriceSell(); // default price for product - double weight = 0; // used if barcode includes weight of product - double dUnits = 0; // used for pro-rata unit - String sVariableTypePrefix = sCode.substring(0, 2); // get first two PPP digits - String sVariableNum; // CCCCC variable value of barcode + } else if ("EAN-13".equals(oProduct.getCodetype())) { // have a valid barcode + oProduct.setProperty("product.barcode", sCode); // set the screen's barcode from input + double dPriceSell = oProduct.getPriceSell(); // default price for product + double weight = 0; // used if barcode includes weight of product + double dUnits = 0; // used for pro-rata unit + String sVariableTypePrefix = sCode.substring(0, 2); // get first two PPP digits + String sVariableNum; // CCCCC variable value of barcode - if (sCode.length() == 13) { // full barcode from scanner - sVariableNum = sCode.substring(8, 12); // get the 5 CCCCC digits - } else { // barcode can be any length - sVariableNum = sCode.substring(7, 11); // get the 5 CCCCC digits - } // scanner has dropped 1st digit so shift get to left + if (sCode.length() == 13) { // full barcode from scanner + sVariableNum = sCode.substring(8, 12); // get the 5 CCCCC digits + } else { // barcode can be any length + sVariableNum = sCode.substring(7, 11); // get the 5 CCCCC digits + } // scanner has dropped 1st digit so shift get to left -// PRICE - SET value decimals - switch (sVariableTypePrefix) { // Use CCCCC value of 01049 as example - case "02": // first 2 PPP digits determine decimal position - dUnits = (Double.parseDouble(sVariableNum) // position decimal in CCC.CC - / 100) / oProduct.getPriceSell(); // 2 decimal = 010.49 + // PRICE - SET value decimals + switch (sVariableTypePrefix) { // Use CCCCC value of 01049 as example + case "02": // first 2 PPP digits determine decimal position + dUnits = (Double.parseDouble(sVariableNum) // position decimal in CCC.CC + / 100) / oProduct.getPriceSell(); // 2 decimal = 010.49 break; case "20": - dUnits = (Double.parseDouble(sVariableNum) // position decimal in CCC.CC - / 100) / oProduct.getPriceSell(); // 2 decimal = 010.49 + dUnits = (Double.parseDouble(sVariableNum) // position decimal in CCC.CC + / 100) / oProduct.getPriceSell(); // 2 decimal = 010.49 break; case "21": - dUnits = (Double.parseDouble(sVariableNum) // position decimal in CC.CCC - / 10) / oProduct.getPriceSell(); // 2 decimal = 0104.9 + dUnits = (Double.parseDouble(sVariableNum) // position decimal in CC.CCC + / 10) / oProduct.getPriceSell(); // 2 decimal = 0104.9 break; case "22": - dUnits = Double.parseDouble(sVariableNum) // position decimal in CCCC.C - / oProduct.getPriceSell(); // Price = 01049. + dUnits = Double.parseDouble(sVariableNum) // position decimal in CCCC.C + / oProduct.getPriceSell(); // Price = 01049. break; -// WEIGHT - SET value decimals - case "23": // Use CCCCC 01049kg as example + // WEIGHT - SET value decimals + case "23": // Use CCCCC 01049kg as example weight = Double.parseDouble(sVariableNum) - / 1000; // Weight = 01.049 - dUnits = weight; // set Units for price calculation + / 1000; // Weight = 01.049 + dUnits = weight; // set Units for price calculation break; case "24": weight = Double.parseDouble(sVariableNum) - / 100; // Weight = 010.49 - dUnits = weight; // set Units for price calculation + / 100; // Weight = 010.49 + dUnits = weight; // set Units for price calculation break; case "25": weight = Double.parseDouble(sVariableNum) - / 10; // Weight = 0104.9 - dUnits = weight; // set Units for price calculation + / 10; // Weight = 0104.9 + dUnits = weight; // set Units for price calculation break; default: break; } - TaxInfo tax = taxeslogic // get the TaxRate for the product - .getTaxInfo(oProduct.getTaxCategoryID() - , m_oTicket.getCustomer()); // calculate if ticket has a Customer + TaxInfo tax = taxeslogic // get the TaxRate for the product + .getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); // calculate if ticket has a + // Customer switch (sVariableTypePrefix) { -// PRICE - Assign var's - case "02": // now we need to calculate some values + // PRICE - Assign var's + case "02": // now we need to calculate some values dPriceSell = oProduct.getPriceSellTax(tax) - / (1.0 + tax.getRate()); // selling price with tax + / (1.0 + tax.getRate()); // selling price with tax dUnits = (Double.parseDouble(sVariableNum) - / 100) / oProduct.getPriceSellTax(tax); // Units as proportion of selling price - oProduct.setProperty("product.price" - , Double.toString(oProduct.getPriceSell())); // push to screen + / 100) / oProduct.getPriceSellTax(tax); // Units as proportion of selling price + oProduct.setProperty("product.price", Double.toString(oProduct.getPriceSell())); // push to screen break; - case "20": // as above + case "20": // as above dPriceSell = oProduct.getPriceSellTax(tax) - / (1.0 + tax.getRate()); + / (1.0 + tax.getRate()); dUnits = (Double.parseDouble(sVariableNum) - / 100) / oProduct.getPriceSellTax(tax); - oProduct.setProperty("product.price" - , Double.toString(oProduct.getPriceSellTax(tax))); + / 100) / oProduct.getPriceSellTax(tax); + oProduct.setProperty("product.price", Double.toString(oProduct.getPriceSellTax(tax))); break; case "21": dPriceSell = oProduct.getPriceSellTax(tax) - / (1.0 + tax.getRate()); + / (1.0 + tax.getRate()); dUnits = (Double.parseDouble(sVariableNum) - / 10) / oProduct.getPriceSellTax(tax); - oProduct.setProperty("product.price" - , Double.toString(oProduct.getPriceSell())); + / 10) / oProduct.getPriceSellTax(tax); + oProduct.setProperty("product.price", Double.toString(oProduct.getPriceSell())); break; case "22": dPriceSell = oProduct.getPriceSellTax(tax) - / (1.0 + tax.getRate()); + / (1.0 + tax.getRate()); dUnits = (Double.parseDouble(sVariableNum) - / 1) / oProduct.getPriceSellTax(tax); - oProduct.setProperty("product.price" - , Double.toString(oProduct.getPriceSell())); + / 1) / oProduct.getPriceSellTax(tax); + oProduct.setProperty("product.price", Double.toString(oProduct.getPriceSell())); break; -// WEIGHT - Assign variable to Unit + // WEIGHT - Assign variable to Unit case "23": weight = Double.parseDouble(sVariableNum) - / 1000; // 3 decimals = 01.049 kg - dUnits = weight; // which represents 1gramme Units - oProduct.setProperty("product.weight" - , Double.toString(weight)); - oProduct.setProperty("product.price" - , Double.toString(dPriceSell)); + / 1000; // 3 decimals = 01.049 kg + dUnits = weight; // which represents 1gramme Units + oProduct.setProperty("product.weight", Double.toString(weight)); + oProduct.setProperty("product.price", Double.toString(dPriceSell)); break; case "24": weight = Double.parseDouble(sVariableNum) - / 100; // 2 decimals = 010.49 kg - dUnits = weight; // which represents 10gramme Units - oProduct.setProperty("product.weight" - , Double.toString(weight)); - oProduct.setProperty("product.price" - , Double.toString(dPriceSell)); + / 100; // 2 decimals = 010.49 kg + dUnits = weight; // which represents 10gramme Units + oProduct.setProperty("product.weight", Double.toString(weight)); + oProduct.setProperty("product.price", Double.toString(dPriceSell)); break; case "25": weight = Double.parseDouble(sVariableNum) - / 10; // 1 decimal = 0104.9 kg - dUnits = weight; // which represents 100gramme Units - oProduct.setProperty("product.weight" - , Double.toString(weight)); - oProduct.setProperty("product.price" - , Double.toString(dPriceSell)); + / 10; // 1 decimal = 0104.9 kg + dUnits = weight; // which represents 100gramme Units + oProduct.setProperty("product.weight", Double.toString(weight)); + oProduct.setProperty("product.price", Double.toString(dPriceSell)); break; -/* - * Some countries use different barcode prefix 26-29 or 250 etc. - * Use this section to add more case statements but these are not mandatory - * If you have your own internal or other barcode schema then... - * Example: - case "28": - { - // price has tax. Remove it from sPriceSell - TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); - dPriceSell /= (1.0 + tax.getRate()); - oProduct.setProperty("product.price", Double.toString(dPriceSell)); - weight = -1.0; - break; -*/ + /* + * Some countries use different barcode prefix 26-29 or 250 etc. + * Use this section to add more case statements but these are not mandatory + * If you have your own internal or other barcode schema then... + * Example: + * case "28": + * { + * // price has tax. Remove it from sPriceSell + * TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), + * m_oTicket.getCustomer()); + * dPriceSell /= (1.0 + tax.getRate()); + * oProduct.setProperty("product.price", Double.toString(dPriceSell)); + * weight = -1.0; + * break; + */ default: break; } if (m_jaddtax.isSelected()) { - addTicketLine(oProduct - , dUnits //weight - , dPriceSell = oProduct.getPriceSellTax(tax)); + addTicketLine(oProduct, dUnits // weight + , dPriceSell = oProduct.getPriceSellTax(tax)); } else { - addTicketLine(oProduct - , dUnits - , dPriceSell); + addTicketLine(oProduct, dUnits, dPriceSell); } } } catch (BasicException eData) { @@ -1269,80 +1251,75 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac new MessageInf(eData).show(this); } -// UPC-A -/* Note: if begins 02 then its a standard -// UPC-A max value limitation is 4 digit price -// UPC-A Extended uses State digit to give 5 digit price -// uniCenta oPOS does not support UPC-A Extended at this time -// Identifier Prod State Cost CheckCode -// I PPPPP S CCCC K -// 1 23456 7 8901 2 - - * 0 = Standard UPC number (must have a zero to do zero-suppressed numbers) - * 1 = Reserved - * 2 = Random-weight items (fruits, vegetables, meats, etc.) - * 3 = Pharmaceuticals - * 4 = In-store marketing for retailers (Other stores will not understand) - * 5 = Coupons - * 6 = Standard UPC number - * 7 = Standard UPC number - * 8 = Reserved - * 9 = Reserved -*/ + // UPC-A + /* + * Note: if begins 02 then its a standard + * // UPC-A max value limitation is 4 digit price + * // UPC-A Extended uses State digit to give 5 digit price + * // uniCenta oPOS does not support UPC-A Extended at this time + * // Identifier Prod State Cost CheckCode + * // I PPPPP S CCCC K + * // 1 23456 7 8901 2 + * + * 0 = Standard UPC number (must have a zero to do zero-suppressed numbers) + * 1 = Reserved + * 2 = Random-weight items (fruits, vegetables, meats, etc.) + * 3 = Pharmaceuticals + * 4 = In-store marketing for retailers (Other stores will not understand) + * 5 = Coupons + * 6 = Standard UPC number + * 7 = Standard UPC number + * 8 = Reserved + * 9 = Reserved + */ } else if ("UPC".equals(sCodetype) - && (sCode.startsWith("2")) - && (sCode.length() == 12)) { + && (sCode.startsWith("2")) + && (sCode.length() == 12)) { try { - ProductInfoExt oProduct - = dlSales.getProductInfoByUShortCode(sCode); // Return only UPC product + ProductInfoExt oProduct = dlSales.getProductInfoByUShortCode(sCode); // Return only UPC product if (oProduct == null) { Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(null, - sCode + " - " - + AppLocal.getIntString("message.noproduct"), - "Check", JOptionPane.WARNING_MESSAGE); + sCode + " - " + + AppLocal.getIntString("message.noproduct"), + "Check", JOptionPane.WARNING_MESSAGE); stateToZero(); } else if ("Upc-A".equals(oProduct.getCodetype())) { oProduct.setProperty("product.barcode", sCode); - double dPriceSell = oProduct.getPriceSell(); // default price for product - double weight = 0; // used if barcode includes weight of product - double dUnits = 0; // used for pro-rata unit - String sVariableNum = sCode.substring(7, 11); // grab the value from the code only using 4 digit price + double dPriceSell = oProduct.getPriceSell(); // default price for product + double weight = 0; // used if barcode includes weight of product + double dUnits = 0; // used for pro-rata unit + String sVariableNum = sCode.substring(7, 11); // grab the value from the code only using 4 digit price - TaxInfo tax = taxeslogic // get the TaxRate for the product - .getTaxInfo(oProduct.getTaxCategoryID() - , m_oTicket.getCustomer()); + TaxInfo tax = taxeslogic // get the TaxRate for the product + .getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); - if (oProduct.getPriceSell() != 0.0) { // we have a weight barcode - weight = Double.parseDouble(sVariableNum) / 100; // 2 decimals (e.g. 10.49 kg) - dUnits = weight; // Units is now transformed to weight + if (oProduct.getPriceSell() != 0.0) { // we have a weight barcode + weight = Double.parseDouble(sVariableNum) / 100; // 2 decimals (e.g. 10.49 kg) + dUnits = weight; // Units is now transformed to weight - oProduct.setProperty("product.weight" // catch-all for weight - , Double.toString(weight)); - oProduct.setProperty("product.price" // get the prod sellprice - , Double.toString(oProduct.getPriceSell())); - dPriceSell = oProduct.getPriceSellTax(tax); // calculate the tax on sellprice - dUnits = (Double.parseDouble(sVariableNum) // calculate Units in sellprice with Tax - / 100) - / oProduct.getPriceSellTax(tax); + oProduct.setProperty("product.weight" // catch-all for weight + , Double.toString(weight)); + oProduct.setProperty("product.price" // get the prod sellprice + , Double.toString(oProduct.getPriceSell())); + dPriceSell = oProduct.getPriceSellTax(tax); // calculate the tax on sellprice + dUnits = (Double.parseDouble(sVariableNum) // calculate Units in sellprice with Tax + / 100) + / oProduct.getPriceSellTax(tax); - } else { // no sellprice so we have a price barcode - dPriceSell = (Double.parseDouble(sVariableNum) // calculate Units in sellprice with Tax - / 100); - dUnits = 1; // no sellprice to calculate so must be 1 Unit + } else { // no sellprice so we have a price barcode + dPriceSell = (Double.parseDouble(sVariableNum) // calculate Units in sellprice with Tax + / 100); + dUnits = 1; // no sellprice to calculate so must be 1 Unit } if (m_jaddtax.isSelected()) { - addTicketLine(oProduct - , dUnits - , dPriceSell); + addTicketLine(oProduct, dUnits, dPriceSell); } else { - addTicketLine(oProduct - , dUnits - , dPriceSell / (1.0 + tax.getRate())); + addTicketLine(oProduct, dUnits, dPriceSell / (1.0 + tax.getRate())); } } } catch (BasicException eData) { @@ -1351,9 +1328,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else { - incProductByCode(sCode); // returned is standard so go get it + incProductByCode(sCode); // returned is standard so go get it } -// END OF BARCODE + // END OF BARCODE } else { Toolkit.getDefaultToolkit().beep(); @@ -1370,9 +1347,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_jPrice.setText(Character.toString('0')); } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' - || cTrans == '4' || cTrans == '5' || cTrans == '6' - || cTrans == '7' || cTrans == '8' || cTrans == '9') - && (m_iNumberStatus == NUMBER_INPUTZERO)) { + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_INPUTZERO)) { if (!priceWith00) { m_jPrice.setText(m_jPrice.getText() + cTrans); @@ -1384,10 +1361,10 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_iNumberStatusInput = NUMBERVALID; } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' - || cTrans == '3' || cTrans == '4' || cTrans == '5' - || cTrans == '6' || cTrans == '7' || cTrans == '8' - || cTrans == '9') - && (m_iNumberStatus == NUMBER_INPUTINT)) { + || cTrans == '3' || cTrans == '4' || cTrans == '5' + || cTrans == '6' || cTrans == '7' || cTrans == '8' + || cTrans == '9') + && (m_iNumberStatus == NUMBER_INPUTINT)) { if (!priceWith00) { m_jPrice.setText(m_jPrice.getText() + cTrans); @@ -1395,21 +1372,20 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_jPrice.setText(setTempjPrice(m_jPrice.getText() + cTrans)); } - } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_INPUTZERO && !priceWith00) { + && m_iNumberStatus == NUMBER_INPUTZERO && !priceWith00) { m_jPrice.setText("0."); m_iNumberStatus = NUMBER_INPUTZERODEC; } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_INPUTZERO) { + && m_iNumberStatus == NUMBER_INPUTZERO) { m_jPrice.setText(""); m_iNumberStatus = NUMBER_INPUTZERO; } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_INPUTINT && !priceWith00) { + && m_iNumberStatus == NUMBER_INPUTINT && !priceWith00) { m_jPrice.setText(m_jPrice.getText() + "."); m_iNumberStatus = NUMBER_INPUTDEC; } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_INPUTINT) { + && m_iNumberStatus == NUMBER_INPUTINT) { if (!priceWith00) { m_jPrice.setText(m_jPrice.getText() + "00"); @@ -1420,7 +1396,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_iNumberStatus = NUMBER_INPUTINT; } else if ((cTrans == '0') - && (m_iNumberStatus == NUMBER_INPUTZERODEC + && (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) { if (!priceWith00) { @@ -1430,9 +1406,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' - || cTrans == '4' || cTrans == '5' || cTrans == '6' - || cTrans == '7' || cTrans == '8' || cTrans == '9') - && (m_iNumberStatus == NUMBER_INPUTZERODEC + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) { m_jPrice.setText(m_jPrice.getText() + cTrans); @@ -1440,71 +1416,71 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_iNumberStatusInput = NUMBERVALID; } else if (cTrans == '*' - && (m_iNumberStatus == NUMBER_INPUTINT + && (m_iNumberStatus == NUMBER_INPUTINT || m_iNumberStatus == NUMBER_INPUTDEC)) { m_jPor.setText("x"); m_iNumberStatus = NUMBER_PORZERO; } else if (cTrans == '*' - && (m_iNumberStatus == NUMBER_INPUTZERO + && (m_iNumberStatus == NUMBER_INPUTZERO || m_iNumberStatus == NUMBER_INPUTZERODEC)) { m_jPrice.setText("0"); m_jPor.setText("x"); m_iNumberStatus = NUMBER_PORZERO; } else if ((cTrans == '0') - && (m_iNumberStatus == NUMBER_PORZERO)) { + && (m_iNumberStatus == NUMBER_PORZERO)) { m_jPor.setText("x0"); } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' - || cTrans == '4' || cTrans == '5' || cTrans == '6' - || cTrans == '7' || cTrans == '8' || cTrans == '9') - && (m_iNumberStatus == NUMBER_PORZERO)) { + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_PORZERO)) { m_jPor.setText("x" + Character.toString(cTrans)); m_iNumberStatus = NUMBER_PORINT; m_iNumberStatusPor = NUMBERVALID; } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' - || cTrans == '3' || cTrans == '4' || cTrans == '5' - || cTrans == '6' || cTrans == '7' || cTrans == '8' - || cTrans == '9') && (m_iNumberStatus == NUMBER_PORINT)) { + || cTrans == '3' || cTrans == '4' || cTrans == '5' + || cTrans == '6' || cTrans == '7' || cTrans == '8' + || cTrans == '9') && (m_iNumberStatus == NUMBER_PORINT)) { m_jPor.setText(m_jPor.getText() + cTrans); } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_PORZERO && !priceWith00) { + && m_iNumberStatus == NUMBER_PORZERO && !priceWith00) { m_jPor.setText("x0."); m_iNumberStatus = NUMBER_PORZERODEC; } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_PORZERO) { + && m_iNumberStatus == NUMBER_PORZERO) { m_jPor.setText("x"); m_iNumberStatus = NUMBERVALID; } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_PORINT && !priceWith00) { + && m_iNumberStatus == NUMBER_PORINT && !priceWith00) { m_jPor.setText(m_jPor.getText() + "."); m_iNumberStatus = NUMBER_PORDEC; } else if (cTrans == '.' - && m_iNumberStatus == NUMBER_PORINT) { + && m_iNumberStatus == NUMBER_PORINT) { m_jPor.setText(m_jPor.getText() + "00"); m_iNumberStatus = NUMBERVALID; } else if ((cTrans == '0') - && (m_iNumberStatus == NUMBER_PORZERODEC + && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) { m_jPor.setText(m_jPor.getText() + cTrans); } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' - || cTrans == '4' || cTrans == '5' || cTrans == '6' - || cTrans == '7' || cTrans == '8' || cTrans == '9') - && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) { + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) { m_jPor.setText(m_jPor.getText() + cTrans); m_iNumberStatus = NUMBER_PORDEC; m_iNumberStatusPor = NUMBERVALID; } else if (cTrans == '\u00a7' - && m_iNumberStatusInput == NUMBERVALID - && m_iNumberStatusPor == NUMBERZERO) { + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERZERO) { if (m_App.getDeviceScale().existsScale() - && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { try { Double value = m_App.getDeviceScale().readWeight(); if (value != null) { @@ -1521,8 +1497,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac Toolkit.getDefaultToolkit().beep(); } } else if (cTrans == '\u00a7' - && m_iNumberStatusInput == NUMBERZERO - && m_iNumberStatusPor == NUMBERZERO) { + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERZERO) { int i = m_ticketlines.getSelectedIndex(); if (i < 0) { @@ -1547,18 +1523,18 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else if (cTrans == '+' - && m_iNumberStatusInput == NUMBERZERO - && m_iNumberStatusPor == NUMBERZERO) { + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERZERO) { int i = m_ticketlines.getSelectedIndex(); if (i < 0) { Toolkit.getDefaultToolkit().beep(); } else { TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i)); - //If it's a refund + button means one unit less + // If it's a refund + button means one unit less if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count - 1; //increment existing line + oCount = count - 1; // increment existing line pinOK = false; changeCount(pinOK); newline.setMultiply(newline.getMultiply() - 1.0); @@ -1571,7 +1547,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count + 1; //increment existing line + oCount = count + 1; // increment existing line pinOK = false; if (changeCount(pinOK)) { newline.setMultiply(newline.getMultiply() + 1.0); @@ -1586,9 +1562,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } } else if (cTrans == '-' - && m_iNumberStatusInput == NUMBERZERO - && m_iNumberStatusPor == NUMBERZERO - && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERZERO + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { int i = m_ticketlines.getSelectedIndex(); if (i < 0) { @@ -1598,7 +1574,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count - 1; //increment existing line + oCount = count - 1; // increment existing line pinOK = false; changeCount(pinOK); newline.setMultiply(newline.getMultiply() - 1.0); @@ -1617,7 +1593,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count - 1; //increment existing line + oCount = count - 1; // increment existing line pinOK = false; if (changeCount(pinOK)) { newline.setMultiply(newline.getMultiply() - 1.0); @@ -1639,8 +1615,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else if (cTrans == '+' - && m_iNumberStatusInput == NUMBERZERO - && m_iNumberStatusPor == NUMBERVALID) { + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERVALID) { int i = m_ticketlines.getSelectedIndex(); if (i < 0) { @@ -1651,7 +1627,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count - 1; //increment existing line + oCount = count - 1; // increment existing line pinOK = false; changeCount(pinOK); newline.setMultiply(-dPor); @@ -1666,7 +1642,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count + 1; //increment existing line + oCount = count + 1; // increment existing line pinOK = false; if (changeCount(pinOK)) { newline.setMultiply(dPor); @@ -1683,9 +1659,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } } else if (cTrans == '-' - && m_iNumberStatusInput == NUMBERZERO - && m_iNumberStatusPor == NUMBERVALID - && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERVALID + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { int i = m_ticketlines.getSelectedIndex(); if (i < 0) { @@ -1696,7 +1672,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count - 1; //increment existing line + oCount = count - 1; // increment existing line pinOK = false; changeCount(pinOK); newline.setMultiply(-dPor); @@ -1711,7 +1687,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } else { if (m_App.getProperties().getProperty("override.check").equals("true")) { - oCount = count - 1; //increment existing line + oCount = count - 1; // increment existing line pinOK = false; if (changeCount(pinOK)) { newline.setMultiply(dPor); @@ -1728,32 +1704,32 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } } else if (cTrans == '+' - && m_iNumberStatusInput == NUMBERVALID - && m_iNumberStatusPor == NUMBERZERO - && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERZERO + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { ProductInfoExt product = getInputProduct(); addTicketLine(product, 1.0, product.getPriceSell()); m_jEditLine.doClick(); } else if (cTrans == '-' - && m_iNumberStatusInput == NUMBERVALID - && m_iNumberStatusPor == NUMBERZERO - && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERZERO + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { ProductInfoExt product = getInputProduct(); addTicketLine(product, 1.0, -product.getPriceSell()); m_jEditLine.doClick(); } else if (cTrans == '+' - && m_iNumberStatusInput == NUMBERVALID - && m_iNumberStatusPor == NUMBERVALID - && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERVALID + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { ProductInfoExt product = getInputProduct(); addTicketLine(product, getPorValue(), product.getPriceSell()); } else if (cTrans == '-' - && m_iNumberStatusInput == NUMBERVALID - && m_iNumberStatusPor == NUMBERVALID - && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERVALID + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { ProductInfoExt product = getInputProduct(); addTicketLine(product, getPorValue(), -product.getPriceSell()); @@ -1765,8 +1741,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (autoLogoff != null) { if (autoLogoff.equals("true")) { if ("restaurant".equals( - m_App.getProperties().getProperty("machine.ticketsbag")) - && ("true".equals(m_App.getProperties().getProperty("till.autoLogoffrestaurant")))) { + m_App.getProperties().getProperty("machine.ticketsbag")) + && ("true".equals(m_App.getProperties().getProperty("till.autoLogoffrestaurant")))) { deactivate(); setActiveTicket(null, null); } else { @@ -1785,9 +1761,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } - private Window getActiveWindow() { - for (Window window: getWindows()) { + for (Window window : getWindows()) { if (window instanceof JRootFrame) { return window; } @@ -1824,8 +1799,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac log.debug("Show Payment Dialog"); JPaymentSelect paymentdialog = ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL - ? paymentdialogreceipt - : paymentdialogrefund; + ? paymentdialogreceipt + : paymentdialogrefund; paymentdialog.setPrintSelected("true".equals(m_jbtnconfig.getProperty("printselected", "true"))); paymentdialog.setTransactionID(ticket.getTransactionID()); @@ -1834,7 +1809,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac ticket.setPayments(paymentdialog.getSelectedPayments()); - ticket.setUser(m_App.getAppUserView().getUser().getUserInfo()); + ticket.setUserInfo(m_App.getAppUserView().getUser().getUserInfo()); ticket.setActiveCash(m_App.getActiveCashIndex()); ticket.setDate(new Date()); @@ -1849,31 +1824,37 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_config.setLastTicket(lastTicketNumber, lastTicketType); } catch (BasicException eData) { - MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), + eData); msg.show(this); } catch (IOException ex) { log.error(ex.getMessage()); } - if (m_config.getProperty("till.digital-receipt") != null && m_config.getProperty("till.digital-receipt").equals("true")){ + if (m_config.getProperty("till.digital-receipt") != null + && m_config.getProperty("till.digital-receipt").equals("true")) { log.debug("Send digital receipt"); String xml = dlSystem.getResourceAsXML("Printer.Ticket"); new Application().sendReceipt(ticket, xml, getActiveWindow()); } + // this is where we trigger the efr integration + // + // executeEvent(ticket, ticketext, "ticket.close", - new ScriptArg("print", paymentdialog.isPrintSelected())); + new ScriptArg("print", paymentdialog.isPrintSelected())); printTicket(paymentdialog.isPrintSelected() || warrantyPrint - ? "Printer.Ticket" - : "Printer.Ticket2", ticket, ticketext); + ? "Printer.Ticket" + : "Printer.Ticket2", ticket, ticketext); Notify(AppLocal.getIntString("notify.printing")); resultok = true; if ("restaurant".equals(m_App.getProperties() - .getProperty("machine.ticketsbag")) && !ticket.getOldTicket()) { - /* Deliberately Explicit to allow for reassignments - future + .getProperty("machine.ticketsbag")) && !ticket.getOldTicket()) { + /* + * Deliberately Explicit to allow for reassignments - future * even though we could do a single SQL statment sweep for reset */ restDB.clearCustomerNameInTable(ticketext.toString()); @@ -1885,7 +1866,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } catch (TaxesException e) { MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, - AppLocal.getIntString("message.cannotcalculatetaxes")); + AppLocal.getIntString("message.cannotcalculatetaxes")); msg.show(this); resultok = false; } @@ -1932,7 +1913,6 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac return (tmpPickupId); } - private void printTicket(String sresourcename, TicketInfo ticket, Object ticketext) { String sresource = dlSystem.getResourceAsXML(sresourcename); @@ -1974,14 +1954,14 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } public void printTicket(String resource) { -// this method is intended to be called only from JPanelButtons. + // this method is intended to be called only from JPanelButtons. if (resource == null) { MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute")); msg.show(this); } else { -// JG 5 Jul 17 calculate taxes disabled as causing incorrect tax recalc -// taxeslogic.calculateTaxes(m_oTicket); + // JG 5 Jul 17 calculate taxes disabled as causing incorrect tax recalc + // taxeslogic.calculateTaxes(m_oTicket); printTicket(resource, m_oTicket, m_oTicketExt); } @@ -2032,7 +2012,6 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } - Map reportparams = new HashMap(); try { @@ -2045,7 +2024,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac reportfields.put("TICKET", ticket); reportfields.put("PLACE", ticketext); - JasperPrint jp = JasperFillManager.fillReport(jr, reportparams, new JRMapArrayDataSource(new Object[]{reportfields})); + JasperPrint jp = JasperFillManager.fillReport(jr, reportparams, + new JRMapArrayDataSource(new Object[] { reportfields })); PrintService service = ReportUtils.getPrintService(m_App.getProperties().getProperty("machine.printername")); @@ -2124,7 +2104,6 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } - private Object executeEvent(TicketInfo ticket, Object ticketext, String eventkey, ScriptArg... args) { String resource = m_jbtnconfig.getEvent(eventkey); @@ -2194,7 +2173,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac private String setTempjPrice(String jPrice) { jPrice = jPrice.replace(".", ""); -// remove all leading zeros from the string + // remove all leading zeros from the string long tempL = Long.parseLong(jPrice); jPrice = Long.toString(tempL); @@ -2260,15 +2239,14 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } content = "" + - "" + AppLocal.getIntString("label.vip") + " : " + "" + vip + "
" + - "" + AppLocal.getIntString("label.discount") + " : " + "" + discount + "
"; - + "" + AppLocal.getIntString("label.vip") + " : " + "" + vip + "
" + + "" + AppLocal.getIntString("label.discount") + " : " + "" + discount + "
"; JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, - content, - "Info", - JOptionPane.WARNING_MESSAGE); + content, + "Info", + JOptionPane.WARNING_MESSAGE); } } @@ -2367,14 +2345,14 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } - /** * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ - // //GEN-BEGIN:initComponents + // //GEN-BEGIN:initComponents private void initComponents() { m_jPanContainer = new javax.swing.JPanel(); @@ -2401,7 +2379,8 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac jCheckStock = new javax.swing.JButton(); m_jPanelCentral = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); - filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767)); + filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), + new java.awt.Dimension(5, 32767)); m_jTicketId = new javax.swing.JLabel(); m_jPanTotals = new javax.swing.JPanel(); m_jLblTotalEuros3 = new javax.swing.JLabel(); @@ -2543,29 +2522,35 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac javax.swing.GroupLayout m_jButtonsLayout = new javax.swing.GroupLayout(m_jButtons); m_jButtons.setLayout(m_jButtonsLayout); m_jButtonsLayout.setHorizontalGroup( - m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(m_jButtonsLayout.createSequentialGroup() - .addContainerGap() - .addComponent(jBtnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(btnSplit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(j_btnRemotePrt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(btnReprint1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); + m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(m_jButtonsLayout.createSequentialGroup() + .addContainerGap() + .addComponent(jBtnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnSplit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(j_btnRemotePrt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnReprint1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); m_jButtonsLayout.setVerticalGroup( - m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(m_jButtonsLayout.createSequentialGroup() - .addGap(5, 5, 5) - .addGroup(m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(j_btnRemotePrt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(btnSplit, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(btnReprint1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jBtnCustomer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); + m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(m_jButtonsLayout.createSequentialGroup() + .addGap(5, 5, 5) + .addGroup(m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(j_btnRemotePrt, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnSplit, javax.swing.GroupLayout.Alignment.TRAILING, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnReprint1, javax.swing.GroupLayout.Alignment.TRAILING, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jBtnCustomer, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); m_jPanelBag.add(m_jButtons); @@ -2808,7 +2793,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac m_jPrice.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N m_jPrice.setForeground(new java.awt.Color(76, 197, 237)); m_jPrice.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); - m_jPrice.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(76, 197, 237)), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jPrice.setBorder(javax.swing.BorderFactory.createCompoundBorder( + javax.swing.BorderFactory.createLineBorder(new java.awt.Color(76, 197, 237)), + javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); m_jPrice.setOpaque(true); m_jPrice.setPreferredSize(new java.awt.Dimension(100, 25)); m_jPrice.setRequestFocusEnabled(false); @@ -2854,40 +2841,50 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); jPanel9.setLayout(jPanel9Layout); jPanel9Layout.setHorizontalGroup( - jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel9Layout.createSequentialGroup() + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jPor) + .addComponent(m_jKeyFactory, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel9Layout.createSequentialGroup() - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(m_jPor) - .addComponent(m_jKeyFactory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel9Layout.createSequentialGroup() - .addComponent(m_jaddtax, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(7, 7, 7) - .addComponent(m_jTax, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) - .addGroup(jPanel9Layout.createSequentialGroup() - .addComponent(m_jPrice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(5, 5, 5))) - .addComponent(m_jEnter, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); + .addComponent(m_jaddtax, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(7, 7, 7) + .addComponent(m_jTax, javax.swing.GroupLayout.PREFERRED_SIZE, 128, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) + .addGroup(jPanel9Layout.createSequentialGroup() + .addComponent(m_jPrice, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(5, 5, 5))) + .addComponent(m_jEnter, javax.swing.GroupLayout.PREFERRED_SIZE, 71, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap())); jPanel9Layout.setVerticalGroup( - jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel9Layout.createSequentialGroup() - .addComponent(m_jEnter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(jPanel9Layout.createSequentialGroup() - .addComponent(m_jPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(m_jTax, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(m_jaddtax, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup() - .addComponent(m_jPor) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(m_jKeyFactory, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)) - ); + jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel9Layout.createSequentialGroup() + .addComponent(m_jEnter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel9Layout.createSequentialGroup() + .addComponent(m_jPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 44, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jTax, javax.swing.GroupLayout.Alignment.TRAILING, + javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jaddtax, javax.swing.GroupLayout.Alignment.TRAILING, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup() + .addComponent(m_jPor) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jKeyFactory, javax.swing.GroupLayout.PREFERRED_SIZE, 1, + javax.swing.GroupLayout.PREFERRED_SIZE))); m_jPanEntries.add(jPanel9); @@ -2906,15 +2903,15 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac add(m_jPanContainer, "ticket"); }// //GEN-END:initComponents - private void m_jbtnScaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnScaleActionPerformed + private void m_jbtnScaleActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jbtnScaleActionPerformed stateTransition('\u00a7'); - }//GEN-LAST:event_m_jbtnScaleActionPerformed + }// GEN-LAST:event_m_jbtnScaleActionPerformed - private void m_jEditLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEditLineActionPerformed + private void m_jEditLineActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jEditLineActionPerformed - count = (int) m_oTicket.getArticlesCount(); // get existing line value + count = (int) m_oTicket.getArticlesCount(); // get existing line value int i = m_ticketlines.getSelectedIndex(); @@ -2932,32 +2929,32 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } - }//GEN-LAST:event_m_jEditLineActionPerformed + }// GEN-LAST:event_m_jEditLineActionPerformed - private void m_jEnterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnterActionPerformed + private void m_jEnterActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jEnterActionPerformed stateTransition('\n'); - }//GEN-LAST:event_m_jEnterActionPerformed + }// GEN-LAST:event_m_jEnterActionPerformed - private void m_jNumberKeysKeyPerformed(com.unicenta.beans.JNumberEvent evt) {//GEN-FIRST:event_m_jNumberKeysKeyPerformed + private void m_jNumberKeysKeyPerformed(com.unicenta.beans.JNumberEvent evt) {// GEN-FIRST:event_m_jNumberKeysKeyPerformed stateTransition(evt.getKey()); j_btnRemotePrt.setEnabled(true); j_btnRemotePrt.revalidate(); - }//GEN-LAST:event_m_jNumberKeysKeyPerformed + }// GEN-LAST:event_m_jNumberKeysKeyPerformed - private void m_jKeyFactoryKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_m_jKeyFactoryKeyTyped + private void m_jKeyFactoryKeyTyped(java.awt.event.KeyEvent evt) {// GEN-FIRST:event_m_jKeyFactoryKeyTyped m_jKeyFactory.setText(null); stateTransition(evt.getKeyChar()); - }//GEN-LAST:event_m_jKeyFactoryKeyTyped + }// GEN-LAST:event_m_jKeyFactoryKeyTyped - private void m_jDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jDeleteActionPerformed + private void m_jDeleteActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jDeleteActionPerformed int i = m_ticketlines.getSelectedIndex(); if (m_App.getProperties().getProperty("override.check").equals("true")) { pinOK = false; @@ -2977,18 +2974,18 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac jCheckStock.setText(""); } } - }//GEN-LAST:event_m_jDeleteActionPerformed + }// GEN-LAST:event_m_jDeleteActionPerformed - private void m_jListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jListActionPerformed + private void m_jListActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jListActionPerformed ProductInfoExt prod = JProductFinder.showMessage(JPanelTicket.this, dlSales); if (prod != null) { buttonTransition(prod); } - }//GEN-LAST:event_m_jListActionPerformed + }// GEN-LAST:event_m_jListActionPerformed - private void jEditAttributesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEditAttributesActionPerformed + private void jEditAttributesActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jEditAttributesActionPerformed if (listener != null) { listener.stop(); } @@ -3008,19 +3005,19 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } catch (BasicException ex) { JOptionPane.showMessageDialog(this, - AppLocal.getIntString("message.cannotfindattributes"), - AppLocal.getIntString("message.title"), - JOptionPane.INFORMATION_MESSAGE); + AppLocal.getIntString("message.cannotfindattributes"), + AppLocal.getIntString("message.title"), + JOptionPane.INFORMATION_MESSAGE); } } if (listener != null) { listener.restart(); } - }//GEN-LAST:event_jEditAttributesActionPerformed + }// GEN-LAST:event_jEditAttributesActionPerformed - private void jbtnMooringActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnMooringActionPerformed -// Display vessel selection box on screen if reply is good add to the ticket + private void jbtnMooringActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jbtnMooringActionPerformed + // Display vessel selection box on screen if reply is good add to the ticket if (listener != null) { listener.stop(); } @@ -3048,9 +3045,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } } refreshTicket(); - }//GEN-LAST:event_jbtnMooringActionPerformed + }// GEN-LAST:event_jbtnMooringActionPerformed - private void j_btnRemotePrtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j_btnRemotePrtActionPerformed + private void j_btnRemotePrtActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_j_btnRemotePrtActionPerformed String rScript = (dlSystem.getResourceAsText("script.SendOrder")); @@ -3071,20 +3068,20 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac remoteOrderDisplay(); - }//GEN-LAST:event_j_btnRemotePrtActionPerformed + }// GEN-LAST:event_j_btnRemotePrtActionPerformed - private void btnReprint1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReprint1ActionPerformed + private void btnReprint1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnReprint1ActionPerformed if (m_config.getProperty("lastticket.number") != null) { try { TicketInfo ticket = dlSales.loadTicket( - Integer.parseInt((m_config.getProperty("lastticket.type"))), - Integer.parseInt((m_config.getProperty("lastticket.number")))); + Integer.parseInt((m_config.getProperty("lastticket.type"))), + Integer.parseInt((m_config.getProperty("lastticket.number")))); if (ticket == null) { JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, - AppLocal.getIntString("message.notexiststicket"), - AppLocal.getIntString("message.notexiststickettitle"), - JOptionPane.WARNING_MESSAGE); + AppLocal.getIntString("message.notexiststicket"), + AppLocal.getIntString("message.notexiststickettitle"), + JOptionPane.WARNING_MESSAGE); } else { m_ticket = ticket; m_ticketCopy = null; @@ -3101,28 +3098,28 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac msg.show(this); } } - }//GEN-LAST:event_btnReprint1ActionPerformed + }// GEN-LAST:event_btnReprint1ActionPerformed - private void btnSplitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSplitActionPerformed + private void btnSplitActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnSplitActionPerformed if (m_oTicket.getLinesCount() > 0) { ReceiptSplit splitdialog = ReceiptSplit.getDialog(this, - dlSystem.getResourceAsXML("Ticket.Line"), dlSales, dlCustomers, taxeslogic); + dlSystem.getResourceAsXML("Ticket.Line"), dlSales, dlCustomers, taxeslogic); TicketInfo ticket1 = m_oTicket.copyTicket(); TicketInfo ticket2 = new TicketInfo(); ticket2.setCustomer(m_oTicket.getCustomer()); if (splitdialog.showDialog(ticket1, ticket2, m_oTicketExt)) { - if (closeTicket(ticket2, m_oTicketExt)) { // already checked that number of lines > 0 + if (closeTicket(ticket2, m_oTicketExt)) { // already checked that number of lines > 0 setActiveTicket(ticket1, m_oTicketExt);// set result ticket } } } - }//GEN-LAST:event_btnSplitActionPerformed + }// GEN-LAST:event_btnSplitActionPerformed - private void jCheckStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckStockActionPerformed + private void jCheckStockActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jCheckStockActionPerformed if (listener != null) { listener.stop(); @@ -3153,9 +3150,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac content = AppLocal.getIntString("message.location.current"); JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, - content, - "Info", - JOptionPane.INFORMATION_MESSAGE); + content, + "Info", + JOptionPane.INFORMATION_MESSAGE); } else { double dUnits = checkProduct.getUnits(); int iUnits; @@ -3175,9 +3172,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (listener != null) { listener.restart(); } - }//GEN-LAST:event_jCheckStockActionPerformed + }// GEN-LAST:event_jCheckStockActionPerformed - private void jCheckStockMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCheckStockMouseClicked + private void jCheckStockMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_jCheckStockMouseClicked if (evt.getClickCount() == 2) { if (listener != null) { listener.stop(); @@ -3204,9 +3201,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac content = AppLocal.getIntString("message.location.current"); JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, - content, - "Info", - JOptionPane.INFORMATION_MESSAGE); + content, + "Info", + JOptionPane.INFORMATION_MESSAGE); } else { if (checkProduct.getMinimum() != null) { pMin = checkProduct.getMinimum(); @@ -3230,20 +3227,20 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } content = "" + - "" + AppLocal.getIntString("label.currentstock") + - " : " + "" + checkProduct.getUnits() + "
" + - "" + AppLocal.getIntString("label.maximum") + - " : " + "" + pMax + "
" + - "" + AppLocal.getIntString("label.minimum") + - " : " + "" + pMin + "
" + - "" + AppLocal.getIntString("label.proddate") + - " : " + "" + pMemoDate + "
"; + "" + AppLocal.getIntString("label.currentstock") + + " : " + "" + checkProduct.getUnits() + "
" + + "" + AppLocal.getIntString("label.maximum") + + " : " + "" + pMax + "
" + + "" + AppLocal.getIntString("label.minimum") + + " : " + "" + pMin + "
" + + "" + AppLocal.getIntString("label.proddate") + + " : " + "" + pMemoDate + "
"; JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, - content, - "Info", - JOptionPane.INFORMATION_MESSAGE); + content, + "Info", + JOptionPane.INFORMATION_MESSAGE); } } catch (BasicException ex) { log.error(ex.getMessage()); @@ -3254,13 +3251,13 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac listener.restart(); } } - }//GEN-LAST:event_jCheckStockMouseClicked + }// GEN-LAST:event_jCheckStockMouseClicked - private void m_jaddtaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jaddtaxActionPerformed + private void m_jaddtaxActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jaddtaxActionPerformed m_jKeyFactory.requestFocus(); - }//GEN-LAST:event_m_jaddtaxActionPerformed + }// GEN-LAST:event_m_jaddtaxActionPerformed - private void jTBtnShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTBtnShowActionPerformed + private void jTBtnShowActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jTBtnShowActionPerformed if (jTBtnShow.isSelected()) { m_jPanelScripts.setVisible(true); m_jButtonsExt.setVisible(true); @@ -3270,26 +3267,26 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } refreshTicket(); m_jKeyFactory.requestFocus(); - }//GEN-LAST:event_jTBtnShowActionPerformed + }// GEN-LAST:event_jTBtnShowActionPerformed - private void jBtnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnCustomerActionPerformed + private void jBtnCustomerActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jBtnCustomerActionPerformed if (listener != null) { listener.stop(); } Object[] options = { - AppLocal.getIntString("label.create"), - AppLocal.getIntString("label.find"), - AppLocal.getIntString("label.cancel") + AppLocal.getIntString("label.create"), + AppLocal.getIntString("label.find"), + AppLocal.getIntString("label.cancel") }; int n = JOptionPane.showOptionDialog(null, - AppLocal.getIntString("message.customeradd"), - AppLocal.getIntString("label.customer"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - options, - options[2]); + AppLocal.getIntString("message.customeradd"), + AppLocal.getIntString("label.customer"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + options, + options[2]); if (n == 0) { JDialogNewCustomer dialog = JDialogNewCustomer.getDialog(this, m_App); @@ -3298,8 +3295,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac CustomerInfoExt m_customerInfo = dialog.getSelectedCustomer(); if (dialog.getSelectedCustomer() != null) { try { - m_oTicket.setCustomer(dlSales.loadCustomerExt - (dialog.getSelectedCustomer().getId())); + m_oTicket.setCustomer(dlSales.loadCustomerExt(dialog.getSelectedCustomer().getId())); } catch (BasicException ex) { log.error(ex.getMessage()); } @@ -3317,11 +3313,10 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (finder.getSelectedCustomer() != null) { try { - m_oTicket.setCustomer(dlSales.loadCustomerExt - (finder.getSelectedCustomer().getId())); + m_oTicket.setCustomer(dlSales.loadCustomerExt(finder.getSelectedCustomer().getId())); if ("restaurant".equals(m_App.getProperties().getProperty("machine.ticketsbag"))) { - restDB.setCustomerNameInTableByTicketId(dlSales.loadCustomerExt - (finder.getSelectedCustomer().getId()).toString(), m_oTicket.getId()); + restDB.setCustomerNameInTableByTicketId( + dlSales.loadCustomerExt(finder.getSelectedCustomer().getId()).toString(), m_oTicket.getId()); } checkCustomer(); @@ -3330,7 +3325,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } catch (BasicException e) { MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, - AppLocal.getIntString("message.cannotfindcustomer"), e); + AppLocal.getIntString("message.cannotfindcustomer"), e); msg.show(this); } } else { @@ -3341,9 +3336,9 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } else { if (JOptionPane.showConfirmDialog(this, - AppLocal.getIntString("message.customerchange"), - AppLocal.getIntString("title.editor"), - JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + AppLocal.getIntString("message.customerchange"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { finder.setAppView(m_App); finder.search(m_oTicket.getCustomer()); @@ -3352,11 +3347,10 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac if (finder.getSelectedCustomer() != null) { try { - m_oTicket.setCustomer(dlSales.loadCustomerExt - (finder.getSelectedCustomer().getId())); + m_oTicket.setCustomer(dlSales.loadCustomerExt(finder.getSelectedCustomer().getId())); if ("restaurant".equals(m_App.getProperties().getProperty("machine.ticketsbag"))) { - restDB.setCustomerNameInTableByTicketId(dlSales.loadCustomerExt - (finder.getSelectedCustomer().getId()).toString(), m_oTicket.getId()); + restDB.setCustomerNameInTableByTicketId( + dlSales.loadCustomerExt(finder.getSelectedCustomer().getId()).toString(), m_oTicket.getId()); } checkCustomer(); @@ -3365,7 +3359,7 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac } catch (BasicException e) { MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, - AppLocal.getIntString("message.cannotfindcustomer"), e); + AppLocal.getIntString("message.cannotfindcustomer"), e); msg.show(this); } } else { @@ -3378,11 +3372,11 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac refreshTicket(); - }//GEN-LAST:event_jBtnCustomerActionPerformed + }// GEN-LAST:event_jBtnCustomerActionPerformed - private void m_jPanContainerFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_m_jPanContainerFocusLost + private void m_jPanContainerFocusLost(java.awt.event.FocusEvent evt) {// GEN-FIRST:event_m_jPanContainerFocusLost jPanContainerFocusLost(evt); - }//GEN-LAST:event_m_jPanContainerFocusLost + }// GEN-LAST:event_m_jPanContainerFocusLost // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnReprint1; @@ -3432,10 +3426,11 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac private javax.swing.JButton m_jbtnScale; // End of variables declaration//GEN-END:variables -/* Remote Orders Display - We only know about uniCenta oPOS orders and won't try and handle any - that are injected from an external source -*/ + /* + * Remote Orders Display + * We only know about uniCenta oPOS orders and won't try and handle any + * that are injected from an external source + */ public void remoteOrderDisplay() { remoteOrderDisplay(remoteOrderId(), 1, true); @@ -3485,37 +3480,31 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac try { if (primary) { if ((m_oTicket.getLine(i).getProperty("display") == null) - || ("".equals(m_oTicket.getLine(i).getProperty("display")))) { + || ("".equals(m_oTicket.getLine(i).getProperty("display")))) { display = 1; } else { display = Integer.parseInt(m_oTicket.getLine(i).getProperty("display")); } } - dlSystem.addOrder(getPickupString(m_oTicket) - , (int) m_oTicket.getLine(i).getMultiply() - , m_oTicket.getLine(i).getProductName() - , m_oTicket.getLine(i).getProductAttSetInstDesc() - , m_oTicket.getLine(i).getProperty("notes") - , id - , null - , display - , null - , null); + dlSystem.addOrder(getPickupString(m_oTicket), (int) m_oTicket.getLine(i).getMultiply(), + m_oTicket.getLine(i).getProductName(), m_oTicket.getLine(i).getProductAttSetInstDesc(), + m_oTicket.getLine(i).getProperty("notes"), id, null, display, null, null); -/* this block for future - right now we're deleting all ticketlines - and resending for consistency with actual ticketlines - dlSystem.updateOrder(getPickupString(m_oTicket) - , (int) m_oTicket.getLine(i).getMultiply() - , m_oTicket.getLine(i).getProductName() - , m_oTicket.getLine(i).getProductAttSetInstDesc() - , m_oTicket.getLine(i).getProperty("notes") - , id - , null - , display - , null - , null); -*/ + /* + * this block for future - right now we're deleting all ticketlines + * and resending for consistency with actual ticketlines + * dlSystem.updateOrder(getPickupString(m_oTicket) + * , (int) m_oTicket.getLine(i).getMultiply() + * , m_oTicket.getLine(i).getProductName() + * , m_oTicket.getLine(i).getProductAttSetInstDesc() + * , m_oTicket.getLine(i).getProperty("notes") + * , id + * , null + * , display + * , null + * , null); + */ } catch (BasicException ex) { log.error(ex.getMessage()); diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.java b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.java index 67d3a66..9bdb8ab 100644 --- a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.java +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.java @@ -53,1033 +53,1027 @@ import java.util.Set; @Slf4j public class JTicketsBagRestaurantMap extends JTicketsBag { - private static class ServerCurrent { + private static class ServerCurrent { - public ServerCurrent() { - } + public ServerCurrent() { + } + } + + private java.util.List m_aplaces; + private java.util.List m_afloors; + + private JTicketsBagRestaurant m_restaurantmap; + + private final JTicketsBagRestaurantRes m_jreservations; + private Place m_PlaceCurrent; + private ServerCurrent m_ServerCurrent; + private Place m_PlaceClipboard; + private CustomerInfo customer; + + private DataLogicReceipts dlReceipts = null; + private DataLogicSales dlSales = null; + private DataLogicSystem dlSystem = null; + private final RestaurantDBUtils restDB; + private static final Icon ICO_OCU_SM = new ImageIcon( + Place.class.getResource("/com/unicenta/images/edit_group_sm.png")); + private static final Icon ICO_WAITER = new NullIcon(1, 1); + private static final Icon ICO_FRE = new NullIcon(22, 22); + private String waiterDetails; + private String customerDetails; + private String tableName; + private Boolean transBtns; + private Boolean actionEnabled = true; + private int newX; + private int newY; + private AppView m_app; + private Boolean showLayout = false; + + /** + * Creates new form JTicketsBagRestaurant + * + * @param app + * @param panelticket + */ + + public JTicketsBagRestaurantMap(AppView app, TicketsEditor panelticket) { + + super(app, panelticket); + + restDB = new RestaurantDBUtils(app); + transBtns = AppConfig.getInstance().getBoolean("table.transbtn"); + + dlReceipts = (DataLogicReceipts) app.getBean("com.unicenta.pos.sales.DataLogicReceipts"); + dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + + m_restaurantmap = new JTicketsBagRestaurant(app, this); + m_PlaceCurrent = null; + m_PlaceClipboard = null; + customer = null; + + try { + SentenceList sent = new StaticSentence( + app.getSession(), + "SELECT ID, NAME, IMAGE FROM floors ORDER BY NAME", + null, + new SerializerReadClass(Floor.class)); + m_afloors = sent.list(); + + } catch (BasicException eD) { + m_afloors = new ArrayList<>(); + } + try { + SentenceList sent = new StaticSentence( + app.getSession(), + "SELECT ID, NAME, SEATS, X, Y, FLOOR, CUSTOMER, WAITER, " + + "TICKETID, TABLEMOVED, WIDTH, HEIGHT, GUESTS, OCCUPIED " + + "FROM places " + + "ORDER BY FLOOR ", + null, + new SerializerReadClass(Place.class)); + m_aplaces = sent.list(); + } catch (BasicException eD) { + m_aplaces = new ArrayList<>(); } - private java.util.List m_aplaces; - private java.util.List m_afloors; - - private JTicketsBagRestaurant m_restaurantmap; - - private final JTicketsBagRestaurantRes m_jreservations; - private Place m_PlaceCurrent; - private ServerCurrent m_ServerCurrent; - private Place m_PlaceClipboard; - private CustomerInfo customer; + initComponents(); - private DataLogicReceipts dlReceipts = null; - private DataLogicSales dlSales = null; - private DataLogicSystem dlSystem = null; - private final RestaurantDBUtils restDB; - private static final Icon ICO_OCU_SM = new ImageIcon(Place.class.getResource("/com/unicenta/images/edit_group_sm.png")); - private static final Icon ICO_WAITER = new NullIcon(1, 1); - private static final Icon ICO_FRE = new NullIcon(22, 22); - private String waiterDetails; - private String customerDetails; - private String tableName; - private Boolean transBtns; - private Boolean actionEnabled = true; - private int newX; - private int newY; - private AppView m_app; - private Boolean showLayout = false; - - - /** Creates new form JTicketsBagRestaurant - * @param app - * @param panelticket */ + m_jbtnSave.setVisible(false); - public JTicketsBagRestaurantMap(AppView app, TicketsEditor panelticket) { - - super(app, panelticket); - - restDB = new RestaurantDBUtils(app); - transBtns = AppConfig.getInstance().getBoolean("table.transbtn"); - - dlReceipts = (DataLogicReceipts) app.getBean("com.unicenta.pos.sales.DataLogicReceipts"); - dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); - dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); - - m_restaurantmap = new JTicketsBagRestaurant(app, this); - m_PlaceCurrent = null; - m_PlaceClipboard = null; - customer = null; - - try { - SentenceList sent = new StaticSentence( - app.getSession(), - "SELECT ID, NAME, IMAGE FROM floors ORDER BY NAME", - null, - new SerializerReadClass(Floor.class)); - m_afloors = sent.list(); - - } catch (BasicException eD) { - m_afloors = new ArrayList<>(); - } - try { - SentenceList sent = new StaticSentence( - app.getSession(), - "SELECT ID, NAME, SEATS, X, Y, FLOOR, CUSTOMER, WAITER, " - + "TICKETID, TABLEMOVED, WIDTH, HEIGHT, GUESTS, OCCUPIED " - + "FROM places " - + "ORDER BY FLOOR ", - null, - new SerializerReadClass(Place.class)); - m_aplaces = sent.list(); - } catch (BasicException eD) { - m_aplaces = new ArrayList<>(); - } - - initComponents(); - - m_jbtnSave.setVisible(false); - - if (m_afloors.size() > 1) { - JTabbedPane jTabFloors = new JTabbedPane(); - jTabFloors.applyComponentOrientation(getComponentOrientation()); - jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5))); - jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); - jTabFloors.setFocusable(false); - jTabFloors.setRequestFocusEnabled(false); - m_jPanelMap.add(jTabFloors, BorderLayout.CENTER); - - m_afloors.stream().map((f) -> { - f.getContainer().applyComponentOrientation(getComponentOrientation()); - return f; - }).forEach((f) -> { - JScrollPane jScrCont = new JScrollPane(); - jScrCont.applyComponentOrientation(getComponentOrientation()); - JPanel jPanCont = new JPanel(); - jPanCont.applyComponentOrientation(getComponentOrientation()); - - jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont); - jScrCont.setViewportView(jPanCont); - jPanCont.add(f.getContainer()); - }); - } else if (m_afloors.size() == 1) { - Floor f = m_afloors.get(0); - f.getContainer().applyComponentOrientation(getComponentOrientation()); - - JPanel jPlaces = new JPanel(); - jPlaces.applyComponentOrientation(getComponentOrientation()); - jPlaces.setLayout(new BorderLayout()); - jPlaces.setBorder(new javax.swing.border.CompoundBorder( - new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)), - new javax.swing.border.TitledBorder(f.getName()))); - - JScrollPane jScrCont = new JScrollPane(); - jScrCont.applyComponentOrientation(getComponentOrientation()); - JPanel jPanCont = new JPanel(); - jPanCont.applyComponentOrientation(getComponentOrientation()); - - m_jPanelMap.add(jPlaces, BorderLayout.CENTER); - jPlaces.add(jScrCont, BorderLayout.CENTER); - jScrCont.setViewportView(jPanCont); - jPanCont.add(f.getContainer()); - } - - Floor currfloor = null; - - for (Place pl : m_aplaces) { - int iFloor = 0; - - if (currfloor == null || !currfloor.getID().equals(pl.getFloor())) { - do { - currfloor = m_afloors.get(iFloor++); - } while (!currfloor.getID().equals(pl.getFloor())); - } + if (m_afloors.size() > 1) { + JTabbedPane jTabFloors = new JTabbedPane(); + jTabFloors.applyComponentOrientation(getComponentOrientation()); + jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5))); + jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); + jTabFloors.setFocusable(false); + jTabFloors.setRequestFocusEnabled(false); + m_jPanelMap.add(jTabFloors, BorderLayout.CENTER); - currfloor.getContainer().add(pl.getButton()); - pl.setButtonBounds(); + m_afloors.stream().map((f) -> { + f.getContainer().applyComponentOrientation(getComponentOrientation()); + return f; + }).forEach((f) -> { + JScrollPane jScrCont = new JScrollPane(); + jScrCont.applyComponentOrientation(getComponentOrientation()); + JPanel jPanCont = new JPanel(); + jPanCont.applyComponentOrientation(getComponentOrientation()); - if (transBtns) { - pl.getButton().setOpaque(false); - pl.getButton().setContentAreaFilled(false); - pl.getButton().setBorderPainted(false); - } - - pl.getButton().addMouseMotionListener(new MouseAdapter() { - @Override - public void mouseDragged(MouseEvent E) { - if (!actionEnabled) { - if (pl.getDiffX() == 0) { - pl.setDiffX(pl.getButton().getX() - pl.getX()); - pl.setDiffY(pl.getButton().getY() - pl.getY()); - } - newX = E.getX() + pl.getButton().getX(); - newY = E.getY() + pl.getButton().getY(); - pl.getButton().setBounds(newX + pl.getDiffX(), newY + pl.getDiffY(), - pl.getButton().getWidth(), pl.getButton().getHeight()); - pl.setX(newX); - pl.setY(newY); - } - } - } - ); + jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont); + jScrCont.setViewportView(jPanCont); + jPanCont.add(f.getContainer()); + }); + } else if (m_afloors.size() == 1) { + Floor f = m_afloors.get(0); + f.getContainer().applyComponentOrientation(getComponentOrientation()); - pl.getButton().addActionListener(new MyActionListener(pl)); - } - - m_jreservations = new JTicketsBagRestaurantRes(app, this); - add(m_jreservations, "res"); + JPanel jPlaces = new JPanel(); + jPlaces.applyComponentOrientation(getComponentOrientation()); + jPlaces.setLayout(new BorderLayout()); + jPlaces.setBorder(new javax.swing.border.CompoundBorder( + new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)), + new javax.swing.border.TitledBorder(f.getName()))); - showLayout = m_App.getAppUserView().getUser().hasPermission("sales.Layout"); - if (showLayout) { - m_jbtnLayout.setVisible(true); - m_jbtnSave.setVisible(false); - } else { - m_jbtnLayout.setVisible(false); - m_jbtnSave.setVisible(false); - } - - if (m_App.getProperties().getProperty("till.autoRefreshTableMap").equals("true")) { - webLblautoRefresh.setText(java.util.ResourceBundle.getBundle("pos_messages") - .getString("label.autoRefreshTableMapTimerON")); - - Timer autoRefreshTimer = new Timer(Integer.parseInt(m_App.getProperties() - .getProperty("till.autoRefreshTimer"))*1000, new tableMapRefresh()); - - autoRefreshTimer.start(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - autoRefreshTimer.stop(); - } - } else { - webLblautoRefresh.setText(java.util.ResourceBundle.getBundle("pos_messages") - .getString("label.autoRefreshTableMapTimerOFF")); - } + JScrollPane jScrCont = new JScrollPane(); + jScrCont.applyComponentOrientation(getComponentOrientation()); + JPanel jPanCont = new JPanel(); + jPanCont.applyComponentOrientation(getComponentOrientation()); -} + m_jPanelMap.add(jPlaces, BorderLayout.CENTER); + jPlaces.add(jScrCont, BorderLayout.CENTER); + jScrCont.setViewportView(jPanCont); + jPanCont.add(f.getContainer()); + } - class tableMapRefresh implements ActionListener { - + Floor currfloor = null; + + for (Place pl : m_aplaces) { + int iFloor = 0; + + if (currfloor == null || !currfloor.getID().equals(pl.getFloor())) { + do { + currfloor = m_afloors.get(iFloor++); + } while (!currfloor.getID().equals(pl.getFloor())); + } + + currfloor.getContainer().add(pl.getButton()); + pl.setButtonBounds(); + + if (transBtns) { + pl.getButton().setOpaque(false); + pl.getButton().setContentAreaFilled(false); + pl.getButton().setBorderPainted(false); + } + + pl.getButton().addMouseMotionListener(new MouseAdapter() { @Override - public void actionPerformed(ActionEvent e) { - loadTickets(); - printState(); + public void mouseDragged(MouseEvent E) { + if (!actionEnabled) { + if (pl.getDiffX() == 0) { + pl.setDiffX(pl.getButton().getX() - pl.getX()); + pl.setDiffY(pl.getButton().getY() - pl.getY()); + } + newX = E.getX() + pl.getButton().getX(); + newY = E.getY() + pl.getButton().getY(); + pl.getButton().setBounds(newX + pl.getDiffX(), newY + pl.getDiffY(), + pl.getButton().getWidth(), pl.getButton().getHeight()); + pl.setX(newX); + pl.setY(newY); + } } - } - - /** - * - */ - @Override - public void activate() { + }); - showLayout = m_App.getAppUserView().getUser().hasPermission("sales.Layout"); - if (showLayout) { - m_jbtnLayout.setVisible(true); - m_jbtnSave.setVisible(false); - } else { - m_jbtnLayout.setVisible(false); - m_jbtnSave.setVisible(false); - } - - m_PlaceClipboard = null; - customer = null; - loadTickets(); - printState(); - - m_panelticket.setActiveTicket(null, null); - m_restaurantmap.activate(); - - showView("map"); + pl.getButton().addActionListener(new MyActionListener(pl)); } - - /** - * - * @return - */ + + m_jreservations = new JTicketsBagRestaurantRes(app, this); + add(m_jreservations, "res"); + + showLayout = m_App.getAppUserView().getUser().hasPermission("sales.Layout"); + if (showLayout) { + m_jbtnLayout.setVisible(true); + m_jbtnSave.setVisible(false); + } else { + m_jbtnLayout.setVisible(false); + m_jbtnSave.setVisible(false); + } + + if (m_App.getProperties().getProperty("till.autoRefreshTableMap").equals("true")) { + webLblautoRefresh.setText(java.util.ResourceBundle.getBundle("pos_messages") + .getString("label.autoRefreshTableMapTimerON")); + + Timer autoRefreshTimer = new Timer(Integer.parseInt(m_App.getProperties() + .getProperty("till.autoRefreshTimer")) * 1000, new tableMapRefresh()); + + autoRefreshTimer.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + autoRefreshTimer.stop(); + } + } else { + webLblautoRefresh.setText(java.util.ResourceBundle.getBundle("pos_messages") + .getString("label.autoRefreshTableMapTimerOFF")); + } + + } + + class tableMapRefresh implements ActionListener { + @Override - public boolean deactivate() { - - if (viewTables()) { + public void actionPerformed(ActionEvent e) { + loadTickets(); + printState(); + } + } + + /** + * + */ + @Override + public void activate() { + + showLayout = m_App.getAppUserView().getUser().hasPermission("sales.Layout"); + if (showLayout) { + m_jbtnLayout.setVisible(true); + m_jbtnSave.setVisible(false); + } else { + m_jbtnLayout.setVisible(false); + m_jbtnSave.setVisible(false); + } + + m_PlaceClipboard = null; + customer = null; + loadTickets(); + printState(); + + m_panelticket.setActiveTicket(null, null); + m_restaurantmap.activate(); + + showView("map"); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + if (viewTables()) { + m_PlaceClipboard = null; + customer = null; + + if (m_PlaceCurrent != null) { + + try { + dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), + m_panelticket.getActiveTicket(), + m_panelticket.getActiveTicket().getPickupId()); + dlReceipts.unlockSharedTicket(m_PlaceCurrent.getId(), null); + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_PlaceCurrent = null; + + } + printState(); + m_panelticket.setActiveTicket(null, null); + + return true; + } else { + return false; + } + } + + /** + * + * @return + */ + @Override + protected JComponent getBagComponent() { + return m_restaurantmap; + } + + /** + * + * @return + */ + @Override + protected JComponent getNullComponent() { + return this; + } + + /** + * + * @return + */ + public TicketInfo getActiveTicket() { + return m_panelticket.getActiveTicket(); + } + + /** + * + */ + public void moveTicket() { + if (m_PlaceCurrent != null) { + try { + dlReceipts.updateRSharedTicket(m_PlaceCurrent.getId(), + m_panelticket.getActiveTicket(), m_panelticket.getActiveTicket().getPickupId()); + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_PlaceClipboard = m_PlaceCurrent; // put FROM table to TO table + + customer = null; + // m_PlaceCurrent = null; // Hang on we'll clear later after we're done + } + + printState(); + m_panelticket.setActiveTicket(null, null); + } + + /** + * + * @param c + * @return + */ + public boolean viewTables(CustomerInfo c) { + if (m_jreservations.deactivate()) { + showView("map"); + m_PlaceClipboard = null; + customer = c; + printState(); + return true; + } else { + return false; + } + } + + /** + * + * @return + */ + public boolean viewTables() { + return viewTables(null); + } + + /** + * + */ + public void newTicket() { + + if (m_PlaceCurrent != null) { + + try { + String m_lockState = null; + m_lockState = dlReceipts.getLockState(m_PlaceCurrent.getId(), m_lockState); + dlReceipts.getSharedTicket(m_PlaceCurrent.getId()); + + if ("override".equals(m_lockState) + || "locked".equals(m_lockState)) { + dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), + m_panelticket.getActiveTicket(), + m_panelticket.getActiveTicket().getPickupId()); + dlReceipts.unlockSharedTicket(m_PlaceCurrent.getId(), null); + m_PlaceCurrent = null; + + } else { + JOptionPane.showMessageDialog(null, AppLocal.getIntString("message.sharedticketlockoverriden"), + AppLocal.getIntString("title.editor"), JOptionPane.INFORMATION_MESSAGE); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + printState(); + m_panelticket.setActiveTicket(null, null); + } + + /** + * + * @return + */ + public String getTable() { + String id = null; + if (m_PlaceCurrent != null) { + id = m_PlaceCurrent.getId(); + } + return (id); + } + + /** + * + * @return + */ + public String getTableName() { + String stableName = null; + if (m_PlaceCurrent != null) { + stableName = m_PlaceCurrent.getName(); + } + return (stableName); + } + + /** + * + */ + @Override + public void deleteTicket() { + + if (m_PlaceCurrent != null) { + String id = m_PlaceCurrent.getId(); + try { + dlReceipts.deleteSharedTicket(id); + dlSystem.execTicketRemoved( + new Object[] { + m_App.getAppUserView().getUser().getName(), + "Void", + "Ticket Deleted", + 0.0 + }); + + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_PlaceCurrent.setPeople(false); + m_PlaceCurrent = null; + } + + printState(); + m_panelticket.setActiveTicket(null, null); + } + + /** + * + */ + public void changeServer() { + + if (m_ServerCurrent != null) { + } + } + + /** + * + */ + public void loadTickets() { + + Set atickets = new HashSet<>(); + + try { + java.util.List l = dlReceipts.getSharedTicketList(); + l.stream().forEach((ticket) -> { + atickets.add(ticket.getId()); + }); + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_aplaces.stream().forEach((table) -> { + table.setPeople(atickets.contains(table.getId())); + }); + } + + /* + * Populate the floor plans and tables + */ + private void printState() { + String sDB; + sDB = m_App.getProperties().getProperty("db.engine"); + + if (m_PlaceClipboard == null) { + if (customer == null) { + m_jText.setText(null); + + m_aplaces.stream() + .map((place) -> { + place.getButton().setEnabled(true); + Integer guests = restDB.getGuestsInTable(place.getId()); + place.setGuests(guests); + Date occupied = restDB.getOccupied(place.getId()); + place.setOccupied(occupied); + return place; + }) + + .map((place) -> { + if (m_App.getProperties().getProperty("table.tablecolour") == null) { + tableName = "" + + place.getName() + ""; + } else { + if (place.getOccupied() != null) { + Date date = new java.util.Date(); + Timestamp t1 = new Timestamp(date.getTime()); + Timestamp t2 = new Timestamp(place.getOccupied().getTime()); + + long milliseconds = t1.getTime() - t2.getTime(); + int seconds = (int) milliseconds / 1000; + int hours = seconds / 3600; + int minutes = (seconds % 3600) / 60; + + Integer count = restDB.getGuestsInTable(place.getId()); + + tableName = "" + + place.getName() + " / " + place.getSeats() + "
" + // + AppLocal.getIntString("button.guest") + place.getGuests() + "
" + + AppLocal.getIntString("button.guest") + count + "
" + + AppLocal.getIntString("button.occupied") + + hours + "h" + ":" + minutes + "m" + + "
" + + "
"; + } else { + tableName = "" + + place.getName() + " / " + place.getSeats() + "
" + + "
"; + } + } + return place; + }) + + .map((place) -> { + if (Boolean.parseBoolean(m_App.getProperties().getProperty("table.showwaiterdetails"))) { + if (m_App.getProperties().getProperty("table.waitercolour") == null) { + waiterDetails = (restDB.getWaiterNameInTable(place.getName()) == null) ? "" + : "" + + restDB.getWaiterNameInTableById(place.getId()) + "
"; + } else { + waiterDetails = (restDB.getWaiterNameInTable(place.getName()) == null) ? "" + : "" + + restDB.getWaiterNameInTableById(place.getId()) + "
"; + } + place.getButton().setIcon(ICO_OCU_SM); + } else { + waiterDetails = ""; + } + return place; + }) + + .map((place) -> { + if (Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showcustomerdetails"))) { + place.getButton().setIcon((Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showwaiterdetails")) + && (restDB.getCustomerNameInTable(place.getName()) != null)) + ? ICO_WAITER + : ICO_OCU_SM); + if (m_App.getProperties().getProperty("table.customercolour") == null) { + customerDetails = (restDB.getCustomerNameInTable(place.getName()) == null) ? "" + : "" + + restDB.getCustomerNameInTableById(place.getId()) + "
"; + } else { + customerDetails = (restDB.getCustomerNameInTable(place.getName()) == null) ? "" + : "" + + restDB.getCustomerNameInTableById(place.getId()) + "
"; + } + } else { + customerDetails = ""; + } + return place; + }) + + .map((place) -> { + if ((Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showwaiterdetails"))) + || (Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showcustomerdetails")))) { + place.getButton().setText("
" + + customerDetails + waiterDetails + tableName + ""); + } else { + if (m_App.getProperties().getProperty("table.tablecolour") == null) { + tableName = "" + + place.getName() + ""; + } else { + tableName = "" + + place.getName() + ""; + } + place.getButton().setText("
" + tableName + ""); + } + return place; + }) + + .filter((place) -> (!place.hasPeople())) + + .forEach((place) -> { + place.getButton().setIcon(ICO_FRE); + }); + + m_jbtnReservations.setEnabled(true); + // places here + + } else { + m_jText.setText(AppLocal.getIntString("label.restaurantcustomer", new Object[] { + customer.getName() + })); + + m_aplaces.stream() + .forEach((place) -> { + place.getButton().setEnabled(!place.hasPeople()); + }); + m_jbtnReservations.setEnabled(false); + } + } else { + m_jText.setText(AppLocal.getIntString("label.restaurantmove", new Object[] { + m_PlaceClipboard.getName() + })); + + m_aplaces.stream() + .forEach((place) -> { + Integer guests = restDB.getGuestsInTable(place.getId()); + place.setGuests(guests); + Date occupied = restDB.getOccupied(place.getId()); + place.setOccupied(occupied); + place.getButton().setEnabled(true); + }); + + m_jbtnReservations.setEnabled(false); + } + } + + private TicketInfo getTicketInfo(Place place) { + + try { + return dlReceipts.getSharedTicket(place.getId()); + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + return null; + } + } + + private void setActivePlace(Place place, TicketInfo ticket) { + m_PlaceCurrent = place; + m_panelticket.setActiveTicket(ticket, m_PlaceCurrent.getName()); + m_restaurantmap.updateGuestCount(); + + try { + dlReceipts.lockSharedTicket(m_PlaceCurrent.getId(), "locked"); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + private void showView(String view) { + CardLayout cl = (CardLayout) (getLayout()); + cl.show(this, view); + } + + private class MyActionListener implements ActionListener { + + private final Place m_place; + + public MyActionListener(Place place) { + m_place = place; + } + + @Override + public void actionPerformed(ActionEvent evt) { + m_App.getAppUserView().getUser(); + + if (!actionEnabled) { + m_place.setDiffX(0); + } else { + if (m_PlaceClipboard == null) { + TicketInfo ticket = getTicketInfo(m_place); + if (ticket == null) { // It's an empty table + ticket = new TicketInfo(); + ticket.setUserInfo(m_App.getAppUserView().getUser().getUserInfo()); + try { + dlReceipts.insertSharedTicket(m_place.getId(), ticket, ticket.getPickupId()); + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + } + m_place.setPeople(true); + m_place.setGuests(restDB.updateGuestsInTable(m_place.getId())); + setActivePlace(m_place, ticket); + } else { // Table not empty + String m_lockState = null; + try { + m_lockState = dlReceipts.getLockState(m_place.getId(), m_lockState); // check lockstate + + if ("locked".equals(m_lockState)) { // It's locked + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.sharedticketlock")); + + if (m_App.getAppUserView().getUser().hasPermission("sales.Override")) { // Override it + int res = JOptionPane.showConfirmDialog(null, + AppLocal.getIntString("message.sharedticketlockoverride"), AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + m_place.setPeople(true); + m_PlaceClipboard = null; + setActivePlace(m_place, ticket); + dlReceipts.lockSharedTicket(m_PlaceCurrent.getId(), "locked"); + } + } + } else { // It's not locked + String m_user = m_App.getAppUserView().getUser().getId(); + String ticketuser = dlReceipts.getServer(m_place.getId(), m_user); + + if (m_App.getAppUserView().getUser().hasPermission("sales.Override") // Check User permission + || m_user.equals(ticketuser)) { + m_place.setPeople(true); + + m_PlaceClipboard = null; + m_lockState = "locked"; + setActivePlace(m_place, ticket); + } else { + JOptionPane.showMessageDialog(null, AppLocal.getIntString("message.sharedticket"), + AppLocal.getIntString("title.editor"), JOptionPane.OK_OPTION); + } + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + // printState(); // show table map. Why here? + } + } + // This block handles Merge + // at this stage m_PlaceClipboard is FROM table + // at this point m_place is TO table + + if (m_PlaceClipboard != null) { // Anything in the Clipboard? + TicketInfo ticketclip = getTicketInfo(m_PlaceClipboard); // add ticket object from clipboard + + if (ticketclip != null) { + + if (m_PlaceClipboard == m_place) { // check if FROM same as TO + Place placeclip = m_PlaceClipboard; + m_PlaceClipboard = null; + customer = null; + printState(); + setActivePlace(placeclip, ticketclip); + } + + if (m_place.hasPeople()) { // check if TO table already occupied + TicketInfo ticket = getTicketInfo(m_place); // add TO ticket object + + if (ticket != null) { // It does, so... + + if (JOptionPane.showConfirmDialog(JTicketsBagRestaurantMap.this, + AppLocal.getIntString("message.mergetablequestion"), + AppLocal.getIntString("message.mergetable"), + JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + try { + m_PlaceClipboard.setPeople(false); + + if (ticket.getCustomer() == null) { + ticket.setCustomer(ticketclip.getCustomer()); + } + ticketclip.getLines().stream().forEach((line) -> { + ticket.addLine(line); + }); + dlReceipts.updateRSharedTicket(m_place.getId(), + ticket, ticket.getPickupId()); + dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId()); + m_place.setGuests(m_PlaceClipboard.getGuests()); // Add Guests from Clipboard + + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + } + m_PlaceClipboard = null; + customer = null; + + restDB.clearCustomerNameInTable(restDB.getTableDetails(ticketclip.getId())); + restDB.clearWaiterNameInTable(restDB.getTableDetails(ticketclip.getId())); + restDB.clearTableMovedFlag(restDB.getTableDetails(ticketclip.getId())); + restDB.clearTicketIdInTable(restDB.getTableDetails(ticketclip.getId())); + restDB.clearOccupiedTable(restDB.getTableDetails(ticketclip.getId())); + + printState(); + setActivePlace(m_place, ticket); + } else { + Place placeclip = m_PlaceClipboard; // don't want to merge so clear clipboard + m_PlaceClipboard = null; + customer = null; + printState(); + setActivePlace(placeclip, ticketclip); + } + } else { + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.tableempty")) + .show(JTicketsBagRestaurantMap.this); + m_place.setPeople(false); + } + } else { // The TO table is empty + TicketInfo ticket = getTicketInfo(m_place); // fill ticket object with TO table + + if (ticket == null) { + try { + dlReceipts.insertRSharedTicket(m_place.getId(), ticketclip, ticketclip.getPickupId()); + m_place.setPeople(true); + m_place.setGuests(m_PlaceClipboard.getGuests()); // Add Guests from Clipboard + dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId()); + m_PlaceClipboard.setPeople(false); + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + } + printState(); + setActivePlace(m_place, ticketclip); + m_PlaceClipboard = null; + customer = null; + } else { + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.tablefull")) + .show(JTicketsBagRestaurantMap.this); + m_PlaceClipboard.setPeople(true); + printState(); + } + } + } else { // table empty! Do we need it here? + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.tableempty")).show(JTicketsBagRestaurantMap.this); + m_PlaceClipboard.setPeople(false); m_PlaceClipboard = null; customer = null; - - if (m_PlaceCurrent != null) { - - try { - dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), - m_panelticket.getActiveTicket(), - m_panelticket.getActiveTicket().getPickupId()); - dlReceipts.unlockSharedTicket(m_PlaceCurrent.getId(),null); - } catch (BasicException e) { - new MessageInf(e).show(this); - } - - m_PlaceCurrent = null; - - } - printState(); - m_panelticket.setActiveTicket(null, null); - - return true; - } else { - return false; - } - } - - /** - * - * @return - */ - @Override - protected JComponent getBagComponent() { - return m_restaurantmap; - } - - /** - * - * @return - */ - @Override - protected JComponent getNullComponent() { - return this; - } - - /** - * - * @return - */ - public TicketInfo getActiveTicket() { - return m_panelticket.getActiveTicket(); - } - - /** - * - */ - public void moveTicket() { - if (m_PlaceCurrent != null) { - try { - dlReceipts.updateRSharedTicket(m_PlaceCurrent.getId(), - m_panelticket.getActiveTicket(),m_panelticket.getActiveTicket().getPickupId()); - } catch (BasicException e) { - new MessageInf(e).show(this); - } - - m_PlaceClipboard = m_PlaceCurrent; // put FROM table to TO table - - customer = null; -// m_PlaceCurrent = null; // Hang on we'll clear later after we're done - } - - printState(); - m_panelticket.setActiveTicket(null, null); - } - - /** - * - * @param c - * @return - */ - public boolean viewTables(CustomerInfo c) { - if (m_jreservations.deactivate()) { - showView("map"); - m_PlaceClipboard = null; - customer = c; printState(); - return true; - } else { - return false; - } + } + } // end of Merge + } // end of !actionEnabled + } // end of actionPerformed + } // end of Action Listener + + /** + * + * @param btnText + */ + public void setButtonTextBags(String btnText) { + m_PlaceClipboard.setButtonText(btnText); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + m_jPanelMap = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jbtnReservations = new javax.swing.JButton(); + m_jbtnRefresh = new javax.swing.JButton(); + m_jbtnLayout = new javax.swing.JButton(); + m_jbtnSave = new javax.swing.JButton(); + m_jText = new javax.swing.JLabel(); + webLblautoRefresh = new com.alee.laf.label.WebLabel(); + + setLayout(new java.awt.CardLayout()); + + m_jPanelMap.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jPanelMap.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + + m_jbtnReservations.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnReservations.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + m_jbtnReservations.setText(AppLocal.getIntString("button.reservations")); // NOI18N + m_jbtnReservations.setToolTipText("Open Reservations screen"); + m_jbtnReservations.setFocusPainted(false); + m_jbtnReservations.setFocusable(false); + m_jbtnReservations.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnReservations.setMaximumSize(new java.awt.Dimension(133, 40)); + m_jbtnReservations.setMinimumSize(new java.awt.Dimension(133, 40)); + m_jbtnReservations.setPreferredSize(new java.awt.Dimension(133, 45)); + m_jbtnReservations.setRequestFocusEnabled(false); + m_jbtnReservations.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnReservationsActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnReservations); + + m_jbtnRefresh.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + m_jbtnRefresh.setText(AppLocal.getIntString("button.reloadticket")); // NOI18N + m_jbtnRefresh.setToolTipText("Reload table information"); + m_jbtnRefresh.setFocusPainted(false); + m_jbtnRefresh.setFocusable(false); + m_jbtnRefresh.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnRefresh.setMaximumSize(new java.awt.Dimension(100, 40)); + m_jbtnRefresh.setMinimumSize(new java.awt.Dimension(100, 40)); + m_jbtnRefresh.setPreferredSize(new java.awt.Dimension(100, 45)); + m_jbtnRefresh.setRequestFocusEnabled(false); + m_jbtnRefresh.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnRefreshActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnRefresh); + + m_jbtnLayout.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnLayout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/movetable.png"))); // NOI18N + m_jbtnLayout.setText(AppLocal.getIntString("button.layout")); // NOI18N + m_jbtnLayout.setToolTipText(""); + m_jbtnLayout.setFocusPainted(false); + m_jbtnLayout.setFocusable(false); + m_jbtnLayout.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnLayout.setMaximumSize(new java.awt.Dimension(100, 40)); + m_jbtnLayout.setMinimumSize(new java.awt.Dimension(100, 40)); + m_jbtnLayout.setPreferredSize(new java.awt.Dimension(100, 45)); + m_jbtnLayout.setRequestFocusEnabled(false); + m_jbtnLayout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnLayoutActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnLayout); + + m_jbtnSave.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + m_jbtnSave.setText(AppLocal.getIntString("button.save")); // NOI18N + m_jbtnSave.setToolTipText(""); + m_jbtnSave.setFocusPainted(false); + m_jbtnSave.setFocusable(false); + m_jbtnSave.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnSave.setMaximumSize(new java.awt.Dimension(100, 40)); + m_jbtnSave.setMinimumSize(new java.awt.Dimension(100, 40)); + m_jbtnSave.setPreferredSize(new java.awt.Dimension(100, 45)); + m_jbtnSave.setRequestFocusEnabled(false); + m_jbtnSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnSaveActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnSave); + + m_jText.setBackground(new java.awt.Color(255, 255, 255)); + m_jText.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jText.setForeground(new java.awt.Color(0, 153, 255)); + m_jText.setOpaque(true); + jPanel2.add(m_jText); + + jPanel1.add(jPanel2, java.awt.BorderLayout.LINE_START); + + webLblautoRefresh.setBackground(new java.awt.Color(255, 51, 51)); + webLblautoRefresh.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + webLblautoRefresh.setText(bundle.getString("label.autoRefreshTableMapTimerON")); // NOI18N + webLblautoRefresh.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.add(webLblautoRefresh, java.awt.BorderLayout.CENTER); + + m_jPanelMap.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(m_jPanelMap, "map"); + }// //GEN-END:initComponents + + private void m_jbtnRefreshActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jbtnRefreshActionPerformed + + loadTickets(); + printState(); + }// GEN-LAST:event_m_jbtnRefreshActionPerformed + + private void m_jbtnReservationsActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jbtnReservationsActionPerformed + showView("res"); + m_jreservations.activate(); + }// GEN-LAST:event_m_jbtnReservationsActionPerformed + + private void m_jbtnLayoutActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jbtnLayoutActionPerformed + if (java.util.ResourceBundle.getBundle("pos_messages") + .getString("button.layout").equals(m_jbtnLayout.getText())) { + actionEnabled = false; + m_jbtnSave.setVisible(true); + m_jbtnLayout.setText(java.util.ResourceBundle + .getBundle("pos_messages").getString("button.disablelayout")); + + m_aplaces.stream().filter((pl) -> (transBtns)).map((pl) -> { + pl.getButton().setOpaque(true); + return pl; + }).map((pl) -> { + pl.getButton().setContentAreaFilled(true); + return pl; + }).forEachOrdered((pl) -> { + pl.getButton().setBorderPainted(true); + }); + } else { + actionEnabled = true; + m_jbtnSave.setVisible(false); + m_jbtnLayout.setText(java.util.ResourceBundle + .getBundle("pos_messages").getString("button.layout")); + + m_aplaces.stream().filter((pl) -> (transBtns)).map((pl) -> { + pl.getButton().setOpaque(false); + return pl; + }).map((pl) -> { + pl.getButton().setContentAreaFilled(false); + return pl; + }).forEachOrdered((pl) -> { + pl.getButton().setBorderPainted(false); + }); } - - /** - * - * @return - */ - public boolean viewTables() { - return viewTables(null); - } - - /** - * - */ - public void newTicket() { + }// GEN-LAST:event_m_jbtnLayoutActionPerformed - if (m_PlaceCurrent != null) { + private void m_jbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_m_jbtnSaveActionPerformed + m_aplaces.forEach((pl) -> { + try { + dlSystem.updatePlaces(pl.getX(), pl.getY(), pl.getId()); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + }); + }// GEN-LAST:event_m_jbtnSaveActionPerformed - try { - String m_lockState = null; - m_lockState = dlReceipts.getLockState(m_PlaceCurrent.getId(), m_lockState); - dlReceipts.getSharedTicket(m_PlaceCurrent.getId()); + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel m_jPanelMap; + private javax.swing.JLabel m_jText; + private javax.swing.JButton m_jbtnLayout; + private javax.swing.JButton m_jbtnRefresh; + private javax.swing.JButton m_jbtnReservations; + private javax.swing.JButton m_jbtnSave; + private com.alee.laf.label.WebLabel webLblautoRefresh; + // End of variables declaration//GEN-END:variables - if ("override".equals(m_lockState) - || "locked".equals(m_lockState)) { - dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), - m_panelticket.getActiveTicket(), - m_panelticket.getActiveTicket().getPickupId()); - dlReceipts.unlockSharedTicket(m_PlaceCurrent.getId(), null); - m_PlaceCurrent = null; - - } else { - JOptionPane.showMessageDialog(null - , AppLocal.getIntString("message.sharedticketlockoverriden") - , AppLocal.getIntString("title.editor") - , JOptionPane.INFORMATION_MESSAGE); - } - } catch (BasicException ex) { - log.error(ex.getMessage()); - } - } - - printState(); - m_panelticket.setActiveTicket(null, null); - } - - /** - * - * @return - */ - public String getTable() { - String id = null; - if (m_PlaceCurrent != null) { - id = m_PlaceCurrent.getId(); - } - return(id); - } - - /** - * - * @return - */ - public String getTableName() { - String stableName = null; - if (m_PlaceCurrent != null) { - stableName = m_PlaceCurrent.getName(); - } - return(stableName); - } - - /** - * - */ - @Override - public void deleteTicket() { - - if (m_PlaceCurrent != null) { - String id = m_PlaceCurrent.getId(); - try { - dlReceipts.deleteSharedTicket(id); - dlSystem.execTicketRemoved( - new Object[] { - m_App.getAppUserView().getUser().getName(), - "Void", - "Ticket Deleted", - 0.0 - }); - - } catch (BasicException e) { - new MessageInf(e).show(this); - } - - m_PlaceCurrent.setPeople(false); - m_PlaceCurrent = null; - } - - printState(); - m_panelticket.setActiveTicket(null, null); - } - - /** - * - */ - public void changeServer() { - - if (m_ServerCurrent != null) { - } - } - - /** - * - */ - public void loadTickets() { - - Set atickets = new HashSet<>(); - - try { - java.util.List l = dlReceipts.getSharedTicketList(); - l.stream().forEach((ticket) -> { - atickets.add(ticket.getId()); - }); - } catch (BasicException e) { - new MessageInf(e).show(this); - } - - m_aplaces.stream().forEach((table) -> { - table.setPeople(atickets.contains(table.getId())); - }); - } - -/* - * Populate the floor plans and tables -*/ - private void printState() { - String sDB; - sDB = m_App.getProperties().getProperty("db.engine"); - - if (m_PlaceClipboard == null) { - if (customer == null) { - m_jText.setText(null); - - m_aplaces.stream() - .map((place) -> { - place.getButton().setEnabled(true); - Integer guests = restDB.getGuestsInTable(place.getId()); - place.setGuests(guests); - Date occupied = restDB.getOccupied(place.getId()); - place.setOccupied(occupied); - return place; - }) - - .map((place) -> { - if (m_App.getProperties().getProperty("table.tablecolour")== null){ - tableName="" - + place.getName()+""; - }else{ - if (place.getOccupied() != null) { - Date date = new java.util.Date(); - Timestamp t1 = new Timestamp(date.getTime()); - Timestamp t2 = new Timestamp(place.getOccupied().getTime()); - - long milliseconds = t1.getTime() - t2.getTime(); - int seconds = (int) milliseconds / 1000; - int hours = seconds / 3600; - int minutes = (seconds % 3600) / 60; - -Integer count = restDB.getGuestsInTable(place.getId()); - - tableName="" - + place.getName() + " / " + place.getSeats() + "
" -// + AppLocal.getIntString("button.guest") + place.getGuests() + "
" - + AppLocal.getIntString("button.guest") + count + "
" - + AppLocal.getIntString("button.occupied") - + hours + "h" + ":" + minutes + "m" - + "
" - + "
"; - } else { - tableName="" - + place.getName() + " / " + place.getSeats() + "
" - + "
"; - } - } - return place; - }) - - .map((place) -> { - if (Boolean.parseBoolean(m_App.getProperties().getProperty("table.showwaiterdetails"))){ - if (m_App.getProperties().getProperty("table.waitercolour")== null){ - waiterDetails = (restDB.getWaiterNameInTable(place.getName()) ==null)? "" - :"" - + restDB.getWaiterNameInTableById(place.getId())+"
"; - }else{ - waiterDetails = (restDB.getWaiterNameInTable(place.getName()) ==null)? "" - :"" - + restDB.getWaiterNameInTableById(place.getId())+"
"; - } - place.getButton().setIcon(ICO_OCU_SM); - } else { - waiterDetails = ""; - } - return place; - }) - - .map((place) -> { - if (Boolean.parseBoolean( - m_App.getProperties().getProperty("table.showcustomerdetails"))){ - place.getButton().setIcon((Boolean.parseBoolean( - m_App.getProperties().getProperty("table.showwaiterdetails")) - && (restDB.getCustomerNameInTable(place.getName()) !=null)) - ? ICO_WAITER:ICO_OCU_SM); - if (m_App.getProperties().getProperty("table.customercolour")== null){ - customerDetails = (restDB.getCustomerNameInTable(place.getName()) ==null)? "" - :"" - + restDB.getCustomerNameInTableById(place.getId())+"
"; - }else{ - customerDetails = (restDB.getCustomerNameInTable(place.getName()) ==null)? "" - :"" - + restDB.getCustomerNameInTableById(place.getId())+"
"; - } - } else { - customerDetails = ""; - } - return place; - }) - - .map((place) -> { - if ((Boolean.parseBoolean( - m_App.getProperties().getProperty("table.showwaiterdetails"))) - || (Boolean.parseBoolean( - m_App.getProperties().getProperty("table.showcustomerdetails")))) { - place.getButton().setText("
" - + customerDetails + waiterDetails +tableName+"" ); - }else{ - if (m_App.getProperties().getProperty("table.tablecolour")== null){ - tableName="" - + place.getName()+""; - }else{ - tableName="" - + place.getName()+""; - } - place.getButton().setText("
"+tableName+""); - } - return place; - }) - - .filter((place) -> (!place.hasPeople())) - - .forEach((place) -> { - place.getButton().setIcon(ICO_FRE); - }); - - m_jbtnReservations.setEnabled(true); -// places here - - } else { - m_jText.setText(AppLocal.getIntString("label.restaurantcustomer" - , new Object[] { - customer.getName() - } - ) - ); - - m_aplaces.stream() - .forEach((place) -> { - place.getButton().setEnabled(!place.hasPeople()); - }); - m_jbtnReservations.setEnabled(false); - } - } else { - m_jText.setText(AppLocal.getIntString("label.restaurantmove" - , new Object[] { - m_PlaceClipboard.getName() - } - )); - - m_aplaces.stream() - .forEach((place) -> { - Integer guests = restDB.getGuestsInTable(place.getId()); - place.setGuests(guests); - Date occupied = restDB.getOccupied(place.getId()); - place.setOccupied(occupied); - place.getButton().setEnabled(true); - }); - - m_jbtnReservations.setEnabled(false); - } - } - - private TicketInfo getTicketInfo(Place place) { - - try { - return dlReceipts.getSharedTicket(place.getId()); - } catch (BasicException e) { - new MessageInf(e).show(JTicketsBagRestaurantMap.this); - return null; - } - } - - private void setActivePlace(Place place, TicketInfo ticket) { - m_PlaceCurrent = place; - m_panelticket.setActiveTicket(ticket, m_PlaceCurrent.getName()); - m_restaurantmap.updateGuestCount(); - - try { - dlReceipts.lockSharedTicket(m_PlaceCurrent.getId(),"locked"); - } catch (BasicException ex) { - log.error(ex.getMessage()); - } - } - - private void showView(String view) { - CardLayout cl = (CardLayout)(getLayout()); - cl.show(this, view); - } - - private class MyActionListener implements ActionListener { - - private final Place m_place; - public MyActionListener(Place place) { - m_place = place; - } - @Override - public void actionPerformed(ActionEvent evt) { - m_App.getAppUserView().getUser(); - - if (!actionEnabled) { - m_place.setDiffX(0); - } else { - if (m_PlaceClipboard == null) { - TicketInfo ticket = getTicketInfo(m_place); - if (ticket == null) { // It's an empty table - ticket = new TicketInfo(); - ticket.setUser(m_App.getAppUserView().getUser().getUserInfo()); - try { - dlReceipts.insertSharedTicket(m_place.getId(), ticket, ticket.getPickupId()); - } catch (BasicException e) { - new MessageInf(e).show(JTicketsBagRestaurantMap.this); - } - m_place.setPeople(true); - m_place.setGuests(restDB.updateGuestsInTable(m_place.getId())); - setActivePlace(m_place, ticket); - } else { // Table not empty - String m_lockState = null; - try { - m_lockState = dlReceipts.getLockState(m_place.getId(), m_lockState); //check lockstate - - if ("locked".equals(m_lockState)) { // It's locked - JOptionPane.showMessageDialog(null, - AppLocal.getIntString("message.sharedticketlock")); - - if (m_App.getAppUserView().getUser().hasPermission("sales.Override")) { // Override it - int res = JOptionPane.showConfirmDialog(null - , AppLocal.getIntString("message.sharedticketlockoverride") - , AppLocal.getIntString("title.editor") - , JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); - - if (res == JOptionPane.YES_OPTION) { - m_place.setPeople(true); - m_PlaceClipboard = null; - setActivePlace(m_place, ticket); - dlReceipts.lockSharedTicket(m_PlaceCurrent.getId(),"locked"); - } - } - } else { // It's not locked - String m_user = m_App.getAppUserView().getUser().getId(); - String ticketuser = dlReceipts.getServer(m_place.getId(),m_user); - - if (m_App.getAppUserView().getUser().hasPermission("sales.Override") //Check User permission - || m_user.equals(ticketuser)) { - m_place.setPeople(true); - - m_PlaceClipboard = null; - m_lockState = "locked"; - setActivePlace(m_place, ticket); - } else { - JOptionPane.showMessageDialog(null - , AppLocal.getIntString("message.sharedticket") - , AppLocal.getIntString("title.editor") - , JOptionPane.OK_OPTION); - } - } - } catch (BasicException ex) { - log.error(ex.getMessage()); - } -// printState(); // show table map. Why here? - } - } -// This block handles Merge -// at this stage m_PlaceClipboard is FROM table -// at this point m_place is TO table - - if (m_PlaceClipboard != null) { // Anything in the Clipboard? - TicketInfo ticketclip = getTicketInfo(m_PlaceClipboard); // add ticket object from clipboard - - if (ticketclip != null) { - - if (m_PlaceClipboard == m_place) { // check if FROM same as TO - Place placeclip = m_PlaceClipboard; - m_PlaceClipboard = null; - customer = null; - printState(); - setActivePlace(placeclip, ticketclip); - } - - if (m_place.hasPeople()) { // check if TO table already occupied - TicketInfo ticket = getTicketInfo(m_place); // add TO ticket object - - if (ticket != null) { // It does, so... - - if (JOptionPane.showConfirmDialog(JTicketsBagRestaurantMap.this, - AppLocal.getIntString("message.mergetablequestion"), - AppLocal.getIntString("message.mergetable"), - JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { - try { - m_PlaceClipboard.setPeople(false); - - if (ticket.getCustomer() == null) { - ticket.setCustomer(ticketclip.getCustomer()); - } - ticketclip.getLines().stream().forEach((line) -> { - ticket.addLine(line); - }); - dlReceipts.updateRSharedTicket(m_place.getId(), - ticket, ticket.getPickupId()); - dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId()); - m_place.setGuests(m_PlaceClipboard.getGuests()); // Add Guests from Clipboard - - } catch (BasicException e) { - new MessageInf(e).show(JTicketsBagRestaurantMap.this); - } - m_PlaceClipboard = null; - customer = null; - - restDB.clearCustomerNameInTable(restDB.getTableDetails(ticketclip.getId())); - restDB.clearWaiterNameInTable(restDB.getTableDetails(ticketclip.getId())); - restDB.clearTableMovedFlag(restDB.getTableDetails(ticketclip.getId())); - restDB.clearTicketIdInTable(restDB.getTableDetails(ticketclip.getId())); - restDB.clearOccupiedTable(restDB.getTableDetails(ticketclip.getId())); - - printState(); - setActivePlace(m_place, ticket); - } else { - Place placeclip = m_PlaceClipboard; // don't want to merge so clear clipboard - m_PlaceClipboard = null; - customer = null; - printState(); - setActivePlace(placeclip, ticketclip); - } - } else { - new MessageInf(MessageInf.SGN_WARNING, - AppLocal.getIntString("message.tableempty")) - .show(JTicketsBagRestaurantMap.this); - m_place.setPeople(false); - } - } else { // The TO table is empty - TicketInfo ticket = getTicketInfo(m_place); // fill ticket object with TO table - - if (ticket == null) { - try { - dlReceipts.insertRSharedTicket(m_place.getId(), ticketclip, ticketclip.getPickupId()); - m_place.setPeople(true); - m_place.setGuests(m_PlaceClipboard.getGuests()); // Add Guests from Clipboard - dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId()); - m_PlaceClipboard.setPeople(false); - } catch (BasicException e) { - new MessageInf(e).show(JTicketsBagRestaurantMap.this); - } - printState(); - setActivePlace(m_place, ticketclip); - m_PlaceClipboard = null; - customer = null; - } else { - new MessageInf(MessageInf.SGN_WARNING, - AppLocal.getIntString("message.tablefull")) - .show(JTicketsBagRestaurantMap.this); - m_PlaceClipboard.setPeople(true); - printState(); - } - } - } else { // table empty! Do we need it here? - new MessageInf(MessageInf.SGN_WARNING, - AppLocal.getIntString("message.tableempty")).show(JTicketsBagRestaurantMap.this); - m_PlaceClipboard.setPeople(false); - m_PlaceClipboard = null; - customer = null; - printState(); - } - } // end of Merge - } // end of !actionEnabled - } // end of actionPerformed - } // end of Action Listener - - /** - * - * @param btnText - */ - public void setButtonTextBags(String btnText){ - m_PlaceClipboard.setButtonText(btnText); - } - - - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { - - m_jPanelMap = new javax.swing.JPanel(); - jPanel1 = new javax.swing.JPanel(); - jPanel2 = new javax.swing.JPanel(); - m_jbtnReservations = new javax.swing.JButton(); - m_jbtnRefresh = new javax.swing.JButton(); - m_jbtnLayout = new javax.swing.JButton(); - m_jbtnSave = new javax.swing.JButton(); - m_jText = new javax.swing.JLabel(); - webLblautoRefresh = new com.alee.laf.label.WebLabel(); - - setLayout(new java.awt.CardLayout()); - - m_jPanelMap.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - m_jPanelMap.setLayout(new java.awt.BorderLayout()); - - jPanel1.setLayout(new java.awt.BorderLayout()); - - jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); - - m_jbtnReservations.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - m_jbtnReservations.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N - m_jbtnReservations.setText(AppLocal.getIntString("button.reservations")); // NOI18N - m_jbtnReservations.setToolTipText("Open Reservations screen"); - m_jbtnReservations.setFocusPainted(false); - m_jbtnReservations.setFocusable(false); - m_jbtnReservations.setMargin(new java.awt.Insets(8, 14, 8, 14)); - m_jbtnReservations.setMaximumSize(new java.awt.Dimension(133, 40)); - m_jbtnReservations.setMinimumSize(new java.awt.Dimension(133, 40)); - m_jbtnReservations.setPreferredSize(new java.awt.Dimension(133, 45)); - m_jbtnReservations.setRequestFocusEnabled(false); - m_jbtnReservations.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - m_jbtnReservationsActionPerformed(evt); - } - }); - jPanel2.add(m_jbtnReservations); - - m_jbtnRefresh.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - m_jbtnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N - m_jbtnRefresh.setText(AppLocal.getIntString("button.reloadticket")); // NOI18N - m_jbtnRefresh.setToolTipText("Reload table information"); - m_jbtnRefresh.setFocusPainted(false); - m_jbtnRefresh.setFocusable(false); - m_jbtnRefresh.setMargin(new java.awt.Insets(8, 14, 8, 14)); - m_jbtnRefresh.setMaximumSize(new java.awt.Dimension(100, 40)); - m_jbtnRefresh.setMinimumSize(new java.awt.Dimension(100, 40)); - m_jbtnRefresh.setPreferredSize(new java.awt.Dimension(100, 45)); - m_jbtnRefresh.setRequestFocusEnabled(false); - m_jbtnRefresh.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - m_jbtnRefreshActionPerformed(evt); - } - }); - jPanel2.add(m_jbtnRefresh); - - m_jbtnLayout.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - m_jbtnLayout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/movetable.png"))); // NOI18N - m_jbtnLayout.setText(AppLocal.getIntString("button.layout")); // NOI18N - m_jbtnLayout.setToolTipText(""); - m_jbtnLayout.setFocusPainted(false); - m_jbtnLayout.setFocusable(false); - m_jbtnLayout.setMargin(new java.awt.Insets(8, 14, 8, 14)); - m_jbtnLayout.setMaximumSize(new java.awt.Dimension(100, 40)); - m_jbtnLayout.setMinimumSize(new java.awt.Dimension(100, 40)); - m_jbtnLayout.setPreferredSize(new java.awt.Dimension(100, 45)); - m_jbtnLayout.setRequestFocusEnabled(false); - m_jbtnLayout.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - m_jbtnLayoutActionPerformed(evt); - } - }); - jPanel2.add(m_jbtnLayout); - - m_jbtnSave.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - m_jbtnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N - m_jbtnSave.setText(AppLocal.getIntString("button.save")); // NOI18N - m_jbtnSave.setToolTipText(""); - m_jbtnSave.setFocusPainted(false); - m_jbtnSave.setFocusable(false); - m_jbtnSave.setMargin(new java.awt.Insets(8, 14, 8, 14)); - m_jbtnSave.setMaximumSize(new java.awt.Dimension(100, 40)); - m_jbtnSave.setMinimumSize(new java.awt.Dimension(100, 40)); - m_jbtnSave.setPreferredSize(new java.awt.Dimension(100, 45)); - m_jbtnSave.setRequestFocusEnabled(false); - m_jbtnSave.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - m_jbtnSaveActionPerformed(evt); - } - }); - jPanel2.add(m_jbtnSave); - - m_jText.setBackground(new java.awt.Color(255, 255, 255)); - m_jText.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - m_jText.setForeground(new java.awt.Color(0, 153, 255)); - m_jText.setOpaque(true); - jPanel2.add(m_jText); - - jPanel1.add(jPanel2, java.awt.BorderLayout.LINE_START); - - webLblautoRefresh.setBackground(new java.awt.Color(255, 51, 51)); - webLblautoRefresh.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N - webLblautoRefresh.setText(bundle.getString("label.autoRefreshTableMapTimerON")); // NOI18N - webLblautoRefresh.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N - jPanel1.add(webLblautoRefresh, java.awt.BorderLayout.CENTER); - - m_jPanelMap.add(jPanel1, java.awt.BorderLayout.NORTH); - - add(m_jPanelMap, "map"); - }// //GEN-END:initComponents - - private void m_jbtnRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnRefreshActionPerformed - - loadTickets(); - printState(); - }//GEN-LAST:event_m_jbtnRefreshActionPerformed - - private void m_jbtnReservationsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnReservationsActionPerformed - showView("res"); - m_jreservations.activate(); - }//GEN-LAST:event_m_jbtnReservationsActionPerformed - - private void m_jbtnLayoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnLayoutActionPerformed - if (java.util.ResourceBundle.getBundle("pos_messages") - .getString("button.layout").equals(m_jbtnLayout.getText())) { - actionEnabled = false; - m_jbtnSave.setVisible(true); - m_jbtnLayout.setText(java.util.ResourceBundle - .getBundle("pos_messages").getString("button.disablelayout")); - - m_aplaces.stream().filter((pl) -> (transBtns)).map((pl) -> { - pl.getButton().setOpaque(true); - return pl; - }).map((pl) -> { - pl.getButton().setContentAreaFilled(true); - return pl; - }).forEachOrdered((pl) -> { - pl.getButton().setBorderPainted(true); - }); - } else { - actionEnabled = true; - m_jbtnSave.setVisible(false); - m_jbtnLayout.setText(java.util.ResourceBundle - .getBundle("pos_messages").getString("button.layout")); - - m_aplaces.stream().filter((pl) -> (transBtns)).map((pl) -> { - pl.getButton().setOpaque(false); - return pl; - }).map((pl) -> { - pl.getButton().setContentAreaFilled(false); - return pl; - }).forEachOrdered((pl) -> { - pl.getButton().setBorderPainted(false); - }); - } - }//GEN-LAST:event_m_jbtnLayoutActionPerformed - - private void m_jbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnSaveActionPerformed - m_aplaces.forEach((pl) -> { - try { - dlSystem.updatePlaces(pl.getX(), pl.getY(), pl.getId()); - } catch (BasicException ex) { - log.error(ex.getMessage()); - } - }); - }//GEN-LAST:event_m_jbtnSaveActionPerformed - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JPanel m_jPanelMap; - private javax.swing.JLabel m_jText; - private javax.swing.JButton m_jbtnLayout; - private javax.swing.JButton m_jbtnRefresh; - private javax.swing.JButton m_jbtnReservations; - private javax.swing.JButton m_jbtnSave; - private com.alee.laf.label.WebLabel webLblautoRefresh; - // End of variables declaration//GEN-END:variables - } diff --git a/src/main/java/com/unicenta/pos/ticket/TicketLineInfo.java b/src/main/java/com/unicenta/pos/ticket/TicketLineInfo.java index 674ab9f..399aef0 100644 --- a/src/main/java/com/unicenta/pos/ticket/TicketLineInfo.java +++ b/src/main/java/com/unicenta/pos/ticket/TicketLineInfo.java @@ -37,455 +37,509 @@ import java.util.Properties; */ public class TicketLineInfo implements SerializableWrite, SerializableRead, Serializable { - private static final long serialVersionUID = 6608012948284450199L; - private String m_sTicket; - private int m_iLine; - private double multiply; + private static final long serialVersionUID = 6608012948284450199L; + private String m_sTicket; + private int m_iLine; + private double multiply; - @Override - public String toString() { - return new Gson().toJson(this); + @Override + public String toString() { + return new Gson().toJson(this); + } + + private double price; + private TaxInfo tax; + private Properties attributes; + private String productid; + private String attsetinstid; + private Boolean updated = false; + + private double newprice = 0.0; + + /** + * Creates new TicketLineInfo + * + * @param productid + * @param dMultiply + * @param dPrice + * @param tax + * @param props + */ + public TicketLineInfo(String productid, double dMultiply, double dPrice, TaxInfo tax, Properties props) { + init(productid, null, dMultiply, dPrice, tax, props); + } + + /** + * + * @param productid + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo(String productid, double dMultiply, double dPrice, TaxInfo tax) { + init(productid, null, dMultiply, dPrice, tax, new Properties()); + } + + /** + * Example: Call from script.TotalDiscount event + * + * @param productid + * @param productname + * @param producttaxcategory + * @param productprinter + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo(String productid, String productname, String producttaxcategory, String productprinter, + double dMultiply, double dPrice, TaxInfo tax) { + Properties props = new Properties(); + props.setProperty("product.name", productname); + props.setProperty("product.taxcategoryid", producttaxcategory); + props.setProperty("product.printer", productprinter); // added to props as may introduce printer redirect + + init(productid, null, dMultiply, dPrice, tax, props); + } + + /** + * Example: Call from script.LineDiscount event + * + * @param productname + * @param producttaxcategory + * @param productprinter //added to props as may introduce printer redirect + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo(String productname, String producttaxcategory, String productprinter, double dMultiply, + double dPrice, TaxInfo tax) { + + Properties props = new Properties(); + props.setProperty("product.name", productname); + props.setProperty("product.taxcategoryid", producttaxcategory); + props.setProperty("product.printer", productprinter); + + init(null, null, dMultiply, dPrice, tax, props); + } + + /** + * + */ + public TicketLineInfo() { + init(null, null, 0.0, 0.0, null, new Properties()); + } + + /** + * + * @param product + * @param dMultiply + * @param dPrice + * @param tax + * @param attributes + */ + public TicketLineInfo(ProductInfoExt product, double dMultiply, double dPrice, TaxInfo tax, Properties attributes) { + + String pid; + + if (product == null) { + pid = null; + tax = null; + } else { + pid = product.getID(); + attributes.setProperty("product.name", product.getName()); + attributes.setProperty("product.reference", product.getReference()); + attributes.setProperty("product.code", product.getCode()); + + if (product.getMemoDate() == null) { + attributes.setProperty("product.memodate", "1900-01-01 00:00:01"); + } else { + attributes.setProperty("product.memodate", product.getMemoDate()); + } + + attributes.setProperty("product.com", product.isCom() ? "true" : "false"); + attributes.setProperty("product.constant", product.isConstant() ? "true" : "false"); + + if (product.getPrinter() != null) { + attributes.setProperty("product.printer", product.getPrinter()); + } else { + attributes.setProperty("product.printer", "1"); + } + + attributes.setProperty("product.service", product.isService() ? "true" : "false"); + attributes.setProperty("product.vprice", product.isVprice() ? "true" : "false"); + attributes.setProperty("product.verpatrib", product.isVerpatrib() ? "true" : "false"); + + if (product.getTextTip() != null) { + attributes.setProperty("product.texttip", product.getTextTip()); + } + + attributes.setProperty("product.warranty", product.getWarranty() ? "true" : "false"); + + if (product.getAttributeSetID() != null) { + attributes.setProperty("product.attsetid", product.getAttributeSetID()); + } + + attributes.setProperty("product.taxcategoryid", product.getTaxCategoryID()); + + if (product.getCategoryID() != null) { + attributes.setProperty("product.categoryid", product.getCategoryID()); + } + + if ("true".equals(attributes.getProperty("ticket.updated"))) { + attributes.setProperty("ticket.updated", "false"); + } else { + attributes.setProperty("ticket.updated", "true"); + } } - private double price; - private TaxInfo tax; - private Properties attributes; - private String productid; - private String attsetinstid; - private Boolean updated = false; - - private double newprice = 0.0; - - /** Creates new TicketLineInfo - * @param productid - * @param dMultiply - * @param dPrice - * @param tax - * @param props */ - public TicketLineInfo(String productid, double dMultiply, double dPrice, TaxInfo tax, Properties props) { - init(productid, null, dMultiply, dPrice, tax, props); - } + init(pid, null, dMultiply, dPrice, tax, attributes); + } - /** - * - * @param productid - * @param dMultiply - * @param dPrice - * @param tax - */ - public TicketLineInfo(String productid, double dMultiply, double dPrice, TaxInfo tax) { - init(productid, null, dMultiply, dPrice, tax, new Properties()); - } + /** + * + * @param oProduct + * @param dPrice + * @param tax + * @param attributes + */ + public TicketLineInfo(ProductInfoExt oProduct, double dPrice, TaxInfo tax, Properties attributes) { + this(oProduct, 1.0, dPrice, tax, attributes); + } - /** - * Example: Call from script.TotalDiscount event - * @param productid - * @param productname - * @param producttaxcategory - * @param productprinter - * @param dMultiply - * @param dPrice - * @param tax - */ - public TicketLineInfo(String productid, String productname, String producttaxcategory, String productprinter, double dMultiply, double dPrice, TaxInfo tax) { - Properties props = new Properties(); - props.setProperty("product.name", productname); - props.setProperty("product.taxcategoryid", producttaxcategory); - props.setProperty("product.printer", productprinter); //added to props as may introduce printer redirect - - init(productid, null, dMultiply, dPrice, tax, props); - } + /** + * + * @param line + */ + public TicketLineInfo(TicketLineInfo line) { + init(line.productid, line.attsetinstid, line.multiply, line.price, + line.tax, (Properties) line.attributes.clone()); + } - /** - * Example: Call from script.LineDiscount event - * @param productname - * @param producttaxcategory - * @param productprinter //added to props as may introduce printer redirect - * @param dMultiply - * @param dPrice - * @param tax - */ - public TicketLineInfo(String productname, String producttaxcategory, String productprinter, double dMultiply, double dPrice, TaxInfo tax) { + private void init(String productid, String attsetinstid, double dMultiply, double dPrice, TaxInfo tax, + Properties attributes) { - Properties props = new Properties(); - props.setProperty("product.name", productname); - props.setProperty("product.taxcategoryid", producttaxcategory); - props.setProperty("product.printer", productprinter); - - init(null, null, dMultiply, dPrice, tax, props); - } + this.productid = productid; + this.attsetinstid = attsetinstid; + multiply = dMultiply; + price = dPrice; + this.tax = tax; + this.attributes = attributes; - /** - * - */ - public TicketLineInfo() { - init(null, null, 0.0, 0.0, null, new Properties()); - } + m_sTicket = null; + m_iLine = -1; + } - /** - * - * @param product - * @param dMultiply - * @param dPrice - * @param tax - * @param attributes - */ - public TicketLineInfo(ProductInfoExt product, double dMultiply, double dPrice, TaxInfo tax, Properties attributes) { + void setTicket(String ticket, int line) { + m_sTicket = ticket; + m_iLine = line; + } - String pid; + /** + * + * @param dp + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp) throws BasicException { + dp.setString(1, m_sTicket); + dp.setInt(2, m_iLine); + dp.setString(3, productid); + dp.setString(4, attsetinstid); + dp.setDouble(5, multiply); + dp.setDouble(6, price); + dp.setString(7, tax.getId()); - if (product == null) { - pid = null; - tax = null; - } else { - pid = product.getID(); - attributes.setProperty("product.name", product.getName()); - attributes.setProperty("product.reference", product.getReference()); - attributes.setProperty("product.code", product.getCode()); + try { + ByteArrayOutputStream o = new ByteArrayOutputStream(); + attributes.storeToXML(o, AppLocal.APP_NAME, "UTF-8"); + dp.setBytes(8, o.toByteArray()); + } catch (IOException e) { + dp.setBytes(8, null); + } + } - if (product.getMemoDate() == null) { - attributes.setProperty("product.memodate", "1900-01-01 00:00:01"); - } else { - attributes.setProperty("product.memodate", product.getMemoDate()); - } - - attributes.setProperty("product.com", product.isCom() ? "true" : "false"); - attributes.setProperty("product.constant", product.isConstant() ? "true" : "false"); + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sTicket = dr.getString(1); + m_iLine = dr.getInt(2); + productid = dr.getString(3); + attsetinstid = dr.getString(4); + multiply = dr.getDouble(5); + price = dr.getDouble(6); + tax = new TaxInfo( + dr.getString(7), + dr.getString(8), + dr.getString(9), + dr.getString(10), + dr.getString(11), + dr.getDouble(12), + dr.getBoolean(13), + dr.getInt(14)); + attributes = new Properties(); - if (product.getPrinter() != null) { - attributes.setProperty("product.printer", product.getPrinter()); - } else { - attributes.setProperty("product.printer", "1"); - } - - attributes.setProperty("product.service", product.isService() ? "true" : "false"); - attributes.setProperty("product.vprice", product.isVprice() ? "true" : "false"); - attributes.setProperty("product.verpatrib", product.isVerpatrib() ? "true" : "false"); + try { + byte[] img = dr.getBytes(15); + if (img != null) { + attributes.loadFromXML(new ByteArrayInputStream(img)); + } + } catch (IOException e) { + } + } - if (product.getTextTip() != null) { - attributes.setProperty("product.texttip", product.getTextTip()); - } - - attributes.setProperty("product.warranty", product.getWarranty()? "true" : "false"); - - if (product.getAttributeSetID() != null) { - attributes.setProperty("product.attsetid", product.getAttributeSetID()); - } - - attributes.setProperty("product.taxcategoryid", product.getTaxCategoryID()); - - if (product.getCategoryID() != null) { - attributes.setProperty("product.categoryid", product.getCategoryID()); - } + /** + * + * @return + */ + public TicketLineInfo copyTicketLine() { + TicketLineInfo l = new TicketLineInfo(); + l.productid = productid; + l.attsetinstid = attsetinstid; + l.multiply = multiply; + l.price = price; + l.tax = tax; + l.attributes = (Properties) attributes.clone(); - if ("true".equals(attributes.getProperty("ticket.updated"))) { - attributes.setProperty("ticket.updated", "false"); - } else { - attributes.setProperty("ticket.updated", "true"); - } - } + return l; + } - init(pid, null, dMultiply, dPrice, tax, attributes); - } + /** + * + * @return + */ + public int getTicketLine() { + return m_iLine; + } - /** - * - * @param oProduct - * @param dPrice - * @param tax - * @param attributes - */ - public TicketLineInfo(ProductInfoExt oProduct, double dPrice, TaxInfo tax, Properties attributes) { - this(oProduct, 1.0, dPrice, tax, attributes); - } + // These are the Lookups + public String getProductID() { + return productid; + } - /** - * - * @param line - */ - public TicketLineInfo(TicketLineInfo line) { - init(line.productid, line.attsetinstid, line.multiply, line.price, - line.tax, (Properties) line.attributes.clone()); - } + public String getProductCategoryID() { + return (attributes.getProperty("product.categoryid")); + } - private void init(String productid, String attsetinstid, double dMultiply, double dPrice, TaxInfo tax, Properties attributes) { + public String getProductAttSetId() { + return attributes.getProperty("product.attsetid"); + } - this.productid = productid; - this.attsetinstid = attsetinstid; - multiply = dMultiply; - price = dPrice; - this.tax = tax; - this.attributes = attributes; - - m_sTicket = null; - m_iLine = -1; - } + public String getProductAttSetInstId() { + return attsetinstid; + } - void setTicket(String ticket, int line) { - m_sTicket = ticket; - m_iLine = line; - } + public String getProductAttSetInstDesc() { + return attributes.getProperty("product.attsetdesc", ""); + } - /** - * - * @param dp - * @throws BasicException - */ - @Override - public void writeValues(DataWrite dp) throws BasicException { - dp.setString(1, m_sTicket); - dp.setInt(2, m_iLine); - dp.setString(3, productid); - dp.setString(4, attsetinstid); - dp.setDouble(5, multiply); - dp.setDouble(6, price); - dp.setString(7, tax.getId()); + public String getProductTaxCategoryID() { + return (attributes.getProperty("product.taxcategoryid")); + } - try { - ByteArrayOutputStream o = new ByteArrayOutputStream(); - attributes.storeToXML(o, AppLocal.APP_NAME, "UTF-8"); - dp.setBytes(8, o.toByteArray()); - } catch (IOException e) { - dp.setBytes(8, null); - } - } + public String getTicketUpdated() { + return (attributes.getProperty("ticket.updated")); + } - /** - * - * @param dr - * @throws BasicException - */ - @Override - public void readValues(DataRead dr) throws BasicException { - m_sTicket = dr.getString(1); - m_iLine = dr.getInt(2); - productid = dr.getString(3); - attsetinstid = dr.getString(4); - multiply = dr.getDouble(5); - price = dr.getDouble(6); - tax = new TaxInfo( - dr.getString(7), - dr.getString(8), - dr.getString(9), - dr.getString(10), - dr.getString(11), - dr.getDouble(12), - dr.getBoolean(13), - dr.getInt(14)); - attributes = new Properties(); + public TaxInfo getTaxInfo() { + return tax; + } - try { - byte[] img = dr.getBytes(15); - if (img != null) { - attributes.loadFromXML(new ByteArrayInputStream(img)); - } - } catch (IOException e) { - } - } + public void setTaxInfo(TaxInfo oTaxInfo) { + tax = oTaxInfo; + } - /** - * - * @return - */ - public TicketLineInfo copyTicketLine() { - TicketLineInfo l = new TicketLineInfo(); - l.productid = productid; - l.attsetinstid = attsetinstid; - l.multiply = multiply; - l.price = price; - l.tax = tax; - l.attributes = (Properties) attributes.clone(); + // These appear on Printed TicketLine + public String getProductName() { + return attributes.getProperty("product.name"); + } - return l; - } + public String getProductMemoDate() { + return attributes.getProperty("product.memodate"); + } - /** - * - * @return - */ - public int getTicketLine() { - return m_iLine; - } -// These are the Lookups - public String getProductID() { - return productid; - } - public String getProductCategoryID() { - return (attributes.getProperty("product.categoryid")); - } - public String getProductAttSetId() { - return attributes.getProperty("product.attsetid"); - } - public String getProductAttSetInstId() { - return attsetinstid; - } - public String getProductAttSetInstDesc() { - return attributes.getProperty("product.attsetdesc", ""); - } - public String getProductTaxCategoryID() { - return (attributes.getProperty("product.taxcategoryid")); - } - public String getTicketUpdated() { - return (attributes.getProperty("ticket.updated")); - } - public TaxInfo getTaxInfo() { - return tax; - } - public void setTaxInfo(TaxInfo oTaxInfo) { - tax = oTaxInfo; - } - -// These appear on Printed TicketLine - public String getProductName() { - return attributes.getProperty("product.name"); - } - public String getProductMemoDate() { - return attributes.getProperty("product.memodate"); - } - public double getPrice() { - return price; - } - public double getMultiply() { - return multiply; - } - public double getTaxRate() { - return tax == null ? 0.0 : tax.getRate(); - } - public double getNewPrice() { - newprice = price * (1.0 + getTaxRate()); - return price; - } - public String getProductPrinter() { - return attributes.getProperty("product.printer"); - } + public double getPrice() { + return price; + } -// These are the Summaries - public double getPriceTax() { - return price * (1.0 + getTaxRate()); - } + public double getMultiply() { + return multiply; + } - public Properties getProperties() { - return attributes; - } - public String getProperty(String key) { - return attributes.getProperty(key); - } - public String getProperty(String key, String defaultvalue) { - return attributes.getProperty(key, defaultvalue); - } + public double getTaxRate() { + return tax == null ? 0.0 : tax.getRate(); + } -// These are Ticket Totals - public double getTax() { - return price * multiply * getTaxRate(); - } - public double getValue() { - return price * multiply * (1.0 + getTaxRate()); - } - public double getSubValue() { - return price * multiply; - } + public double getNewPrice() { + newprice = price * (1.0 + getTaxRate()); + return price; + } -// SETTERS - public void setPrice(double dValue) { - price = dValue; + public String getProductPrinter() { + return attributes.getProperty("product.printer"); + } + + // These are the Summaries + public double getPriceTax() { + return price * (1.0 + getTaxRate()); + } + + public Properties getProperties() { + return attributes; + } + + public String getProperty(String key) { + return attributes.getProperty(key); + } + + public String getProperty(String key, String defaultvalue) { + return attributes.getProperty(key, defaultvalue); + } + + // These are Ticket Totals + public double getTax() { + return price * multiply * getTaxRate(); + } + + public double getValue() { + return price * multiply * (1.0 + getTaxRate()); + } + + public double getSubValue() { + return price * multiply; + } + + // SETTERS + public void setPrice(double dValue) { + price = dValue; + } + + public void setPriceTax(double dValue) { + price = dValue / (1.0 + getTaxRate()); + } + + public void setMultiply(double dValue) { + multiply = dValue; + } + + public void setProperty(String key, String value) { + attributes.setProperty(key, value); + } + + public void setProductTaxCategoryID(String taxID) { + attributes.setProperty("product.taxcategoryid", taxID); + } + + public void setProductAttSetInstId(String value) { + attsetinstid = value; + } + + public void setProductAttSetInstDesc(String value) { + if (value == null) { + attributes.remove(value); + } else { + attributes.setProperty("product.attsetdesc", value); } - public void setPriceTax(double dValue) { - price = dValue / (1.0 + getTaxRate()); + } + + public void setTicketUpdated(String key, String value) { + attributes.setProperty("ticket.updated", value); + } + + public void setProductPrinter(String value) { + if (value == null) { + attributes.remove(value); + } else { + attributes.setProperty("product.printer", value); } - public void setMultiply(double dValue) { - multiply = dValue; - } - public void setProperty(String key, String value) { - attributes.setProperty(key, value); - } - public void setProductTaxCategoryID(String taxID){ - attributes.setProperty("product.taxcategoryid",taxID); - } - public void setProductAttSetInstId(String value) { - attsetinstid = value; - } - public void setProductAttSetInstDesc(String value) { - if (value == null) { - attributes.remove(value); - } else { - attributes.setProperty("product.attsetdesc", value); - } - } - public void setTicketUpdated(String key, String value){ - attributes.setProperty("ticket.updated",value); - } - public void setProductPrinter(String value) { - if (value == null) { - attributes.remove(value); - } else { - attributes.setProperty("product.printer", value); - } - } - - /** - * - * @return - */ - // Print to actual ${ticketline - public String printReference() { - return StringUtils.encodeXML(attributes.getProperty("product.reference")); - } - public String printCode() { - return StringUtils.encodeXML(attributes.getProperty("product.code")); - } - public String printName() { - return StringUtils.encodeXML(attributes.getProperty("product.name")); - } - public String printProductMemoDate() { - return StringUtils.encodeXML(attributes.getProperty("product.memodate")); - } - public String printPrice() { - return Formats.CURRENCY.formatValue(getPrice()); - } - public String printPriceTax() { - return Formats.CURRENCY.formatValue(getPriceTax()); - } - public String printMultiply() { - return Formats.DOUBLE.formatValue(multiply); - } - public String printValue() { - return Formats.CURRENCY.formatValue(getValue()); - } - public String printTaxRate() { - return Formats.PERCENT.formatValue(getTaxRate()); - } - public String printSubValue() { - return Formats.CURRENCY.formatValue(getSubValue()); - } - public String printTax() { - return Formats.CURRENCY.formatValue(getTax()); - } - public String printTextTip() { - return attributes.getProperty("product.texttip"); - } - public String printPrinter() { - return StringUtils.encodeXML(attributes.getProperty("product.printer")); - } - public boolean isProductCom() { - return "true".equals(attributes.getProperty("product.com")); - } - public boolean isProductService() { - return "true".equals(attributes.getProperty("product.service")); - } - public boolean isProductVprice() { - return "true".equals(attributes.getProperty("product.vprice")); - } - public boolean isProductVerpatrib() { - return "true".equals(attributes.getProperty("product.verpatrib")); - } - public boolean isProductWarranty() { - return "true".equals(attributes.getProperty("product.warranty")); - } - public boolean getUpdated() { - return "true".equals(attributes.getProperty("ticket.updated")); - } - public void setUpdated(Boolean value) { - updated = value; - } - -} \ No newline at end of file + } + + /** + * + * @return + */ + // Print to actual ${ticketline + public String printReference() { + return StringUtils.encodeXML(attributes.getProperty("product.reference")); + } + + public String printCode() { + return StringUtils.encodeXML(attributes.getProperty("product.code")); + } + + public String printName() { + return StringUtils.encodeXML(attributes.getProperty("product.name")); + } + + public String printProductMemoDate() { + return StringUtils.encodeXML(attributes.getProperty("product.memodate")); + } + + public String printPrice() { + return Formats.CURRENCY.formatValue(getPrice()); + } + + public String printPriceTax() { + return Formats.CURRENCY.formatValue(getPriceTax()); + } + + public String printMultiply() { + return Formats.DOUBLE.formatValue(multiply); + } + + public String printValue() { + return Formats.CURRENCY.formatValue(getValue()); + } + + public String printTaxRate() { + return Formats.PERCENT.formatValue(getTaxRate()); + } + + public String printSubValue() { + return Formats.CURRENCY.formatValue(getSubValue()); + } + + public String printTax() { + return Formats.CURRENCY.formatValue(getTax()); + } + + public String printTextTip() { + return attributes.getProperty("product.texttip"); + } + + public String printPrinter() { + return StringUtils.encodeXML(attributes.getProperty("product.printer")); + } + + public boolean isProductCom() { + return "true".equals(attributes.getProperty("product.com")); + } + + public boolean isProductService() { + return "true".equals(attributes.getProperty("product.service")); + } + + public boolean isProductVprice() { + return "true".equals(attributes.getProperty("product.vprice")); + } + + public boolean isProductVerpatrib() { + return "true".equals(attributes.getProperty("product.verpatrib")); + } + + public boolean isProductWarranty() { + return "true".equals(attributes.getProperty("product.warranty")); + } + + public boolean getUpdated() { + return "true".equals(attributes.getProperty("ticket.updated")); + } + + public void setUpdated(Boolean value) { + updated = value; + } + +} diff --git a/test.jpg b/test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..13f36189b1fbf3bbbd3237672d6022e81934a1e4 GIT binary patch literal 12606 zcmch7cUV*R+xJ0Ga7JWk1&N9>q>38{=D2ZG2xDnU`v zDk6164JOJE6*VFiga{!F5g{ZYkc5nr=l-5x$9uic)8G62@!AV}wdBe<-*JEL&$vw= zOf^{lMe`TV$1J*Gm<9ZUnZ(!}%%(>V>mJ>0tgWqk_O$8M$G&f$-o5*LGr*2!KV&f7 zWyoM>=bljsJiCV|s$w+F;MI=av@3v2L~&mbMnA0*nst+1-NrgLVC}=w@lvy@$0;&tARZ z1NZu4-7G9EyIEOw?`~xUpN@gwV^+4^2MilGtB2k4AnW1V?Z@vsdC|socFt3W6(x!h z6E^JF-?NwFz(L;(9_i-p;W=vJq{%*0rcRqPciw!z1q&CgT=o5G|203X-MDG;FST3MrYS#*nlA4^-S?!(6Q7%*$Ob)T|JBO=SlFNIs>J$OTEO91+G04S(Rp0j+v|Vzlg%}R*0B=^1ur|- zQ@Ugh8D%_Q{(@)1xVujZq6Ql4UZ~S)=^oi!6IM6Ogo)HKbma*X)~ILfW$e8qAQa4F z0{H)V)j5jH#12|#lRA~URO zwqZpXIVy7Jn)mlY-RfFM#{)0g8Y;HxBSv{j_wCf@`MI{I)3#j_Y|{oP7e8C?s!h7w zH0}N!^^tE3^6}ok<)z-wYni&rYKKKlIjfGX4HPO;Bt)L42^-3+GNzKgu&VQ|ChP}Q zjIoM1jqT~~pgP3MGK4EWB{8yY1jeL2>nqsA|CSZ@sn?Wc3+wkixn;tn?84F03!)jx zm%mhsDt%Yt7e38XuU;bl;lqw={bO4!pBjTLfA`3yD|v=7EbU^sP-<_&PPn&{uT7W> zp?V!b-0T#Pt-_Z{R=vt%;mSr6<|}6FgsE~_li`}>2ajyrgdK@D zVZHZ|m$~`~I3+@_CwYe2B<%w@LgAN%CX7dPYD}0=*i5|fuzU+A_m2mhL5`;zOxTvU z)^F|oMJBB4fRn7W;##_4bThqIWcD%>md5@0URx;aQq^Tv+9VUUOA&L;^7G%WU8e~n z!&LBHqPQ3f7QF21YJ%ITNbg0r7kEY%=W}g4LfsdZ#fmmsCpQ$T*RaAqFHidRVA?|8 z^9)DB3S~+H>Dn}HY1U2SrDw$SS4UcIUzOeF_xs+$d2i%IxJUtY-nIrmIDhx~`guo5 zW{P*^#UX9tS+lIW z3G3vGR3?n!un+ElA0f?P3#DG>GbttSkTCr%o8S07en7ZA3M?{lrru;Kt)(5p3d86gk{lM>U;J?H_}JDBfu!P5 zo1pIK;0~i*KxwX@!mV#WZQr8GZ?{ybE5gTziFd4K48xAk?q^;8co#gaM$(Tng}d;5 z7AcYjPwqU)KBsOyJGNmV+;WlcN-!t|+v-&&C z**YxXL%6-g^GJ8nR-z3S)3x*P`ks2x9pWb3nfX=ZolkoGBNI02t@aA471**HKTlhF z2W=U54Acs2+0m#?Bia_$myw4Ryyc3<{Detp*YSb{K2bZ2*I8jriD}=wa@UMF?nlm8 zGuS;(@=at?t?yu7!4M~zsm(8%sS0JnsxKDkW#3so(j2PI9+kt;0ga#3-^4iIC~niv#FuDEpW2r z;V0VJJ;%5IV8ZMLj#{65Zof&P0Sik6q8PYU#p>(au%?sDKJ_j=ofF?Gn1&H7#hcZ* zB9VB`)^L9^Vg4oz59J%T6l;8Tle;XqmqG{!->Ele-Qdi6pvU9V(UGhbRK0{F=`ND@ zf-^Z<9t1VVlQtUr;GHA4o3LliNhK4RiD|B7L*K;?6&o}1N@2kPvX$ZQN7Kii__~za zCM<5GLPf^O4Hq5&fc_gJ@?_d56E=rNE(|1;k3=PtgywC#pS)e26u+|-5Up33xaZ1z zi?K$9>q!%KyqsRgwlV-ZEmdU3O*CQJEMbH?gf*?sc+RQuWNvmxK$5#SE1ceY_v7jL z=NZWg{c2c7;*YA_;vq-%5ffhFk?9wW6@Byf?5^EA<g5ut?s$Sz7P9(o@Plk>9B*#St?f0}qR&Ndk&iAt}f0h6^1N7=w0XTbP9@^$N z^!PlC-a8g59Ezm0>u1=6caoy)WhIjy`@v-z`d%>fV@#T^ zuOu{OgP^L^At_;&_5K6O5}3}>wjFBq~`f;t)dT+Cxu zSaXn#vGP=-=Ad_PdFgpkS8q+%W*0`s8sZIAp@2)E6dbxT=y{12s7Y;m(k4WL0FkB{|AFq1xMo zrN`%qO_;9H(FoP`WXqrj%rI_M2K+XjfqqNmiD|mVF|U>I%gm_{h*)7&#C}LGQE9(bcuM)#9v;`&DT5?xi_`d-Z9wKaBVqLl`%<)2LDXx@}JMR zY^e;({oGI?n0zdDLB-jIDnG14v}E?2A4kz{aoj_Y^#L zSR^a9ds9aAEx7GOHRS>{V6wKjabN1yhVQUN80SpZIXJ0vFDF6PCDA zKSw`DX2RN<>p#vDZjm#{_s=G8xz?0e*S>^}9v94@|Lj9YPs`;GNrb0;lO!KB5YHX? zkRA5RvL3{-TstL=bnMV18a(0sMfja{QSf@I)*RjoS0Z<+OFQulN|M{6Yo|Fyib>qe zW4+i_=!{HQ`25a#mX~ogFxlq7Se|k*YG#MqF9iI6ni(|LnA6bA4)puJ4>U6u8aZR; zH-Du-?q&+)pv`7d6zGvE3sIm9)~U%rfws+Pwj}M?N8$PrdH%+WCTsw+Q`hz{_(*1o zW^$|EuuIdl_Mfp4(=q;vat}?I6OjkCVH2k@4Cl5v86_3M_ptbR(7GG+snEKoefCJF zo%IDi);oo??Jd_XGGWl-g?CL@5!cYZPWXjn3wfDsxA3`ThRwAzTxju?ODM+C@Sz0? zXyZ6z9p*QbH(DlJ&jnZ`3abSag{M$0mE}%eC_^0H#~4=nRNWM4ZFn!&-orJ0p)QDO zcu0})u3i$q6_cYImOy-F*i&d{&y+JtLlEBG8*WhYQc2#=HTqppLOr!nqcB!G-wq67(S#=&gT&1JGs#Q;J@w`EuG*}BI$edZo19WoErw_#u;s-$+_2^ozil5oqAhR-SDYmBSR0iAg+!Z`v9WSDUIhg> zna8T~1BG}aZ%_Lt9-^wi@s26?fM{zmVKP{-2`etY(7>)>HyB?RdlXzhe&A~KYItGx zQ+U?)8yv>FFb2g`KePa=Kj((${y3}VOvB^H*DO!K=8E%$iV~sXvih8 zZv3rD-5NC3Si7G&!l$oHwic0`d{H~yLA#Q|#h)IjZsC>31Ph&v(&w7&p}^8Oh<0eI zy%blu#*3F&odkR)<4Ejt#M3qh#m{%%S31KhTN?m{qxh5q929P!VKln#g7@lH|DczM z3AxakX1Yk{*)OyB`m>&;TwHtRg7h_g^}AgcwzQC*-~-g^y%^~9H+c}@3+u^yUmP0A z$Koewb+59HB zWa5(PpjvCR2QG_^TQU0`g%iOv!3Z8AH%x$oj$^IW&Tv_{eHu9=fJgmNJ#tVz)e|6 z&gACmeGE}>E&n3vI-pd+47f&o38%~exYR<{7vY;=?7#62?!s|D6}XnUYh%FW04*ul zeEdan_UT&FMNBp@KJ8!H#D*|BUwsHGM}it1&7?{3(Wi zH4<3HiAaQk(N9Vkj#?xp(BV*eBSO5H(iEVq zGuw@xy9~}|*aJ43Ux=|#O_7d1g>ulqck#Qvc7zEVBVe8uZWf-?sBdNrxEg)@Y?GhC zO`^CJ>kWpG@uHDilS=E{-Nva(l^I0Bdsn8OR{h>lwCF8dnSBiBvZ3$qrY6Cg^NUk9 zt7IRqF#Fi}4w&iyyJW*Oe9Jx}LFEffFF4W-c4&RB+$*-2@NNzJVgAVPb`6>EZm$Pt z1=W=4&~#Fh?sBFhJq5zA@_FW=ZbAAQKUct9WG{ss&Wuc|SqkT70`< zf$IrckB7!C*Ma)|7VWGalJTQ~v3Uf&Ox{MkTi{DKgx|%bz+RD@PULw0j+@mq%MH}@ zr^Tv|V?a&Q&+7YapXm%{mljzxu%QZFU5k2bsNUiDbFgUUzKd=9abZ1wM|J*fsu6I$ zvUUf65A7-9)uQG%h`4X(oRRV6of{im8jr&J{`GFGhHppRdpn*lTU#fi+q#QCt!V+? zh(KkZjqy3?)0kEd%iBowxDe@D#Iz0V`bpWz+sWULsh$hvF3fvT@rB-Tg7HdvK}-Nt zKl|<)QGMqQ_zmWc0E0=-?^cmR|zXG7F$UL-zW_5gC zGN>?jvcRPEQoQJs=xM+ zqD|hsUEY7fAj_}(&0sekoRRviR~-9tLrWoQ++n1P~$+9??K#KoD9yaZg^q?@~x~Qv9R@ z2K^7aM2u*==Xtz(c5iOAeVEe+<;j^Y+#0TSfl%sgMyiEuIpZ~%O-9|9cW{M32#!?| z?Sn=CED~?_Wd|rzpci$poiq`G`0_Ql{yovxdgADriGQ92{oGF{0#CairciOfd#OQoMwo@~OHy`4Cxy!H7f zQ9SS?W4}8}W!FV_api@0r>UhIK9JKEp z5EyB!k7B-DSt_}*T}LV3&nm+#@B!gsNyh6rp8OCb#`aIOKrjhVANNRdfa9mA0}V)l zH@K#h5lGoS7Ehq6_N*olb^jh$!3)2gKvt0@B+tm!NmAwdUA23C4?s&f4zI%6h~CAp z506rFJGiRX_f6Oh@TRM|FOkV`CIh+>Dup|0qW3Ib%W|Ze8v43V7zSd#F}c0Yp=Fwo`Y!?Mg(l1*D4rRXcKV`%CuJYaovNfS1ozhoz$vPF6Bvx@*0|rd-9l!3 zhBS<4_LO3~Sj!vLx8cb9RY4yc(KZM5v1YIg?@=ZXatt5nXS72YF{Tij&ph9;Llq0^ zmsux(gdE@vo+;`V^*(yx9pVNY^k0NmUB_cKWtmc`05rK!)yN94&1{zE?T^=N>Sx`& zF8&YKWPngc(>`LUI?R@d@FDLx-2T{UdyHS8&VhfrMheOOgMnHacLFy80y=8!VOeR} z-WewBDegpFxVR+4NMv~(mVmS(ok>aS&6h9hJbY>*2^@T6D4D>x!3zT((Y5}1Qa%dZY^onB}hs@BGr$Ag| z04}qU>T!1rbE&vyg6!k9%tJlw^rujdb3v!3Tv-tPEE$QuV8vZB0#x6ss(b7FdRZn_ zV^io?usw11%V&1~`onpu^NNce$TIa{sa&o(`1=kM}R_00yY! z0Y{a0#TNv`7h!nC$=JwpBS_kG+AkBAP%6UA?jYW&UZ>VVyfcZU5fFplo zkDH7)?DD4#HuY2Mjnn<<0EugeezEyfp)EGp1$~OiBxf{K2*V{Edw^t=Uyar+v#8-( z8Q^KNK#jM<6}d!2L8dlMV!S@E@mMaHj7)3smFPoYrJ; z^b89SS3)BM||065;-85@Xrvm8hL{G3nda_EkGtuZ7L z0*PZn=@2+6fgZl4a}8{EJ9hRD!B8bwScWt2vN3Pch` z2G$2il2sKhwL`~PI!N;%yk#84|xR)U+CcL zcawQzYo!lZ2I5bP)i>aF%|7n%#2K67P!0(d6jt0y6E=Zow8Uk=Oqz-J#IK!ji+Jlj zEYlHttSL8)gnIy-4kVczBw4D6y6AlKMaNM#K#tKEj^fI>09+|XsD^Uf$H?w1{4vtK zCMBV(4QA&{lp{b%5~Ujf=|g$Oz*Guf@4{<70;TE-&PSzB1v%s?G9iHW&ju3$nC#GP zxUv#!Ho(@PH4l_Ht{E**$J?ck7(cGz@ErYbO!p4JPb;Bx zJyCFkjAyqeb%G+f%2gL51+k2(nrL6$(k!qrkEmp-;lOW0dN^NqtTPU>dcn{wJ^@^D z`)%pTFD&=XbOuv>wB2$gy$IUKyHK(u1_x8<@yc-Vrj5n@t+BKvdjK@5ke!-;%$>^d zC?5wreq`e;@a-Qt2`;{)iZnBgcle(~BdLS|&N=v8J(4ds;{b{J+y{b}*ZHA28;gf- z*FRypQ!#g<2X?9J=N2BI4XBaWHrr9L=aD9L=PBc_oBq7!AN-TFVsfCjVWdWaaxgm$ z0XbL_PL(1@LPW3{W?CCovHEdXCTu3u!+my076$lXvCtT^01o;C6#}L`J ztPC&fGj)Ycz2(zeIPwEeaSd0A3@Fwjoy4$5uHUoFIvX|$BGb9v09zKj>#^#ovAPVzM*r_ZNb{cOdbQ-`+2jD6A!5yA63--?^O)ga&Sq-8iGtJsH08 ztp$XWLvsBx%ov`-jYt_&Y+rRRF>O#c2)w-r%DIE6xV9hE50P*pROQXPA*&jDFjltk zAXy(LjUhFYE-Ds3Glw{{6`4RbA;Woxm!R^vd@9BWC-`+N zS`^ddC|Ria$@&g3VXq+ey5Jn3o?nvv!pW=8G>@8o=fD)=W|{3h5xg-~qp^i!p2hHQ z%?4qR{9^laUHGm4;AOYbDMEPuS(ZW%gb?E2HVzd-jQWm)tmKu~e4a74 zgfS{IY0ZJ!et=>}nlw=nVw4sms)23mg{X!Est8f}T3P~CMllTeeF+;n>e+mHt8{3; zZr;6H_nfZ>m8TqN#yLvP14kY!X1U>=jg*|13n@82Zl)9Y&oLyjQIYcl$v(<*3Kqhd zk5+;C4L0g9`a=krlwU+9>}Wh#J{27h6;@|RMaSQ6mGnmzW)J!O;v5JqH{>X7hANgJ zOU9D&7|o5j7w2nZ{*G$QamE(Zm_OpY^9!>EE5&|yYq7)bxg3*+y zTcDjmP$k8Hb{+*UY7Xa@qw#<_h{eU!3Q@YE619}C-z_xgZ-%xlkjVS_J^l|O>GEqK z(MU<&WK#13^V;>`rX|BwKyDgV(?k0BF*x#onWN~s3qqNMjK$^Ux@^^X6)2Z=!bb2I z>dFnR>6XtVifo3nkq?Ydo1(4EF9wH_v-nPIm897RQUYEe3S+t?=Pk; zm|YuzN3L2pp^993OoJ%VMTI__5PB~iI{oI6}1%0fbxUBjVSb459!Q< zvGo>DfZE(hN1CnJJYt4CKy3sXtPnsG03rb~?-PhDrw2mMk;FYpO6WM|PUTpUYrzOe zku6HSf8&}o5Mo)&eL8<4>oXT|Ip$>p15%T?bg|llR|!ea;H5u}6v=z1F-wnr4P1@W z^U~}~Vff}SM2}gVWLbPlcgFRiSN+?Uo;@{tER4mCV8Iw3XSE^| zoQDW?C{qJdaiL<(3ZNxB+R}_u(`mp-{;xA{xt4Wo!)aLr32dP~ZQ5JlO;iMD=1l_V zl>;k60b{?7+JtTESznH4eNIExVN^T3v&_Yl%Rc9*h53}fOmVf-z)ztJ?4@Yp4;k3i zoA_hEz~1fb0S5NWn%H~IIyacl0=C1MMKM2+ReH_~{?@b1)(?B9bcaMBS^-x#3>hZo zn+t{sU-lcCnQDM+;UTac7$&KkBtuAmGL&ACE0>{c`6r}LDWN7Po*2AM;ce7!|q$SjH3GBAiLT9^4^JDTfI1Eo zKN`3^@1grC>uw-+yVCWqD2UNj5!^RsAu>|o%VBhkuty9g<}~H@|7MT#A%$C8 zXAXxIyqg^V+Q&E<9dot$4G+wM@UKD4uP_>D_WC=hAubpkLPK2F;9!Fm) zr$c#TQbMu}d?7TGw>%FS+?GJ0ll*yF_ouir_+K2)uI(s)W5O~Ifhi$IrbGs5pOP=q z4HUM81N%O{%=(o}Pk3kqIY3YEO88M^2QEC)kF3`kbvyYz5G6x^NV^K}0EbUpWH1mC zNr$k}p2$0ehRtSc$fX|%_gsjiSIE|S+8GaVZtWHlcSl& zd_v)>5h}r&3uS1em5*qM(axh7?cem$e8>!879pCLrtE7sS1XggcKOQ?(FaIl{}>|L zPe^ybm;BXY)WRM9a}BF3o`CO0%_{zNk^$Dqod=JBX~k$_lmxt6$Oa&1gGsnaG&K0d zazim2n()vhxmWVhoZ2qA?PoXvG^VEfjv5gKNZkbK0E`Ryxpn~aw@)#wrFRY#)`G>E zEzw1SoJsRXy$pNub(9ER*3*QITucoN{s7196rmG+B#H#BLY)KKgnf|#B~rs*F2cs$ z!I0YR1~i-k5x_1sa=Id5F!eNyY+jfCl1J=VP*2pohfZ(91SbG)8VbTAq#W5e{90!^(+tr`agQiX2Fe-@B;-*j dE(4ST6dyxG&Z;5*ZP9AKd>;1y^M^21{1>0N7Ks1= literal 0 HcmV?d00001