diff --git a/src/main/java/tech/iBeans/POSware/Lite/OnTransact.java b/src/main/java/tech/iBeans/POSware/Lite/OnTransact.java index fae9b0b..00f0e7b 100644 --- a/src/main/java/tech/iBeans/POSware/Lite/OnTransact.java +++ b/src/main/java/tech/iBeans/POSware/Lite/OnTransact.java @@ -6,9 +6,11 @@ package tech.iBeans.POSware.Lite; import java.util.*; import javax.swing.*; import javax.swing.event.*; +import java.awt.event.*; import tech.iBeans.POSware.Lite.transact; import tech.iBeans.POSware.Lite.WindowManagement; import tech.iBeans.POSware.Lite.receipt; +import tech.iBeans.POSware.Lite.OnPayment; /** * @@ -24,13 +26,7 @@ public class OnTransact extends javax.swing.JFrame { initComponents(); } - /** - * 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. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents + private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; @@ -241,14 +237,15 @@ public class OnTransact extends javax.swing.JFrame { gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; - jPanel_Inventory.add(jPanel_Inventory_Actions, gridBagConstraints); - + jList1_Inventory.setModel(refresh_inventory_list()); jList1_Inventory.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jList1_InventoryValueChanged(evt); } }); + + jPanel_Inventory.add(jPanel_Inventory_Actions, gridBagConstraints); jScrollPane_Inventory.setViewportView(jList1_Inventory); gridBagConstraints = new java.awt.GridBagConstraints(); @@ -318,6 +315,9 @@ public class OnTransact extends javax.swing.JFrame { getContentPane().add(jPanel_Main, java.awt.BorderLayout.CENTER); + // Add action listeners. + jButton_Action_Pay.addActionListener(select_payment); + pack(); }// @@ -598,7 +598,13 @@ public class OnTransact extends javax.swing.JFrame { return(state); }; - + // Action events. + ActionListener select_payment = new ActionListener() { + public void actionPerformed(ActionEvent e) { + transact.pay(); + OnPayment.display(); + }; + }; diff --git a/src/main/java/tech/iBeans/POSware/Lite/payment.java b/src/main/java/tech/iBeans/POSware/Lite/payment.java index 0ff7490..2dfab23 100644 --- a/src/main/java/tech/iBeans/POSware/Lite/payment.java +++ b/src/main/java/tech/iBeans/POSware/Lite/payment.java @@ -1,5 +1,7 @@ package tech.iBeans.POSware.Lite; +import tech.iBeans.POSware.Lite.receipt.*; + // Import module import java.util.*; import java.math.*; @@ -8,26 +10,28 @@ public class payment{ public static Float total = null; public static Float change = null; public static Float in = null; + public static boolean OK = false; + public static Boolean state = null; - public static void init() { + public static void init(float TOTAL) { /* Set up the payment. */ change = (float) 0; in = (float) 0; + total = TOTAL; }; - public static Float calculate() { + public static boolean calculate() { /* Calculate the change. * - * Returns: (float) the calculated change + * Returns: (float) the transaction state */ - - if (total > in) {return (null);}; // Do not calculate a smaller change. - change = in - total; - return(change); + OK = (total <= in); + if (OK) {change = in - total;}; // Do not calculate a smaller change. + return(OK); }; - public static Float calculate(float TOTAL, float IN) { + public static boolean calculate(float TOTAL, float IN) { /* Calculate the change from a provided total and input. * * Returns: (float) the calculated change @@ -39,6 +43,17 @@ public class payment{ return(calculate()); }; + public static boolean calculate(float IN) { + /* Calculate the change from a provided input. + * + * Returns: (float) the calculated change + */ + + in = IN; + + return(calculate()); + }; + public static void log() { /* Log the payment. */