updated GUI-based transaction payment handling
This commit is contained in:
		
							parent
							
								
									3f63c102a9
								
							
						
					
					
						commit
						a2d30d0586
					
				
					 2 changed files with 112 additions and 84 deletions
				
			
		|  | @ -39,26 +39,6 @@ | |||
| 
 | ||||
|       <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> | ||||
|       <SubComponents> | ||||
|         <Component class="javax.swing.JComboBox" name="jComboBox_Payment"> | ||||
|           <Properties> | ||||
|             <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> | ||||
|               <StringArray count="4"> | ||||
|                 <StringItem index="0" value="Item 1"/> | ||||
|                 <StringItem index="1" value="Item 2"/> | ||||
|                 <StringItem index="2" value="Item 3"/> | ||||
|                 <StringItem index="3" value="Item 4"/> | ||||
|               </StringArray> | ||||
|             </Property> | ||||
|           </Properties> | ||||
|           <AuxValues> | ||||
|             <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> | ||||
|           </AuxValues> | ||||
|           <Constraints> | ||||
|             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> | ||||
|               <BorderConstraints direction="East"/> | ||||
|             </Constraint> | ||||
|           </Constraints> | ||||
|         </Component> | ||||
|         <Component class="javax.swing.JLabel" name="jLabel_Status"> | ||||
|           <Properties> | ||||
|             <Property name="horizontalAlignment" type="int" value="0"/> | ||||
|  | @ -86,6 +66,16 @@ | |||
|             </Constraint> | ||||
|           </Constraints> | ||||
|         </Component> | ||||
|         <Component class="javax.swing.JButton" name="jButton_Action_Pay"> | ||||
|           <Properties> | ||||
|             <Property name="text" type="java.lang.String" value="Payment"/> | ||||
|           </Properties> | ||||
|           <Constraints> | ||||
|             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> | ||||
|               <BorderConstraints direction="After"/> | ||||
|             </Constraint> | ||||
|           </Constraints> | ||||
|         </Component> | ||||
|       </SubComponents> | ||||
|     </Container> | ||||
|     <Container class="javax.swing.JPanel" name="jPanel_Main"> | ||||
|  |  | |||
|  | @ -6,7 +6,6 @@ package tech.iBeans.POSware.Lite; | |||
| import java.util.*; | ||||
| import javax.swing.*; | ||||
| import javax.swing.event.*; | ||||
| import tech.iBeans.POSware.Lite.transaction; | ||||
| import tech.iBeans.POSware.Lite.transact; | ||||
| import tech.iBeans.POSware.Lite.WindowManagement; | ||||
| import tech.iBeans.POSware.Lite.receipt; | ||||
|  | @ -36,9 +35,9 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         java.awt.GridBagConstraints gridBagConstraints; | ||||
| 
 | ||||
|         jPanel_statusinfo = new javax.swing.JPanel(); | ||||
|         jComboBox_Payment = new javax.swing.JComboBox<>(); | ||||
|         jLabel_Status = new javax.swing.JLabel(); | ||||
|         jToggleButton_Discard = new javax.swing.JToggleButton(); | ||||
|         jButton_Action_Pay = new javax.swing.JButton(); | ||||
|         jPanel_Main = new javax.swing.JPanel(); | ||||
|         jPanel_Items = new javax.swing.JPanel(); | ||||
|         jScrollPane1 = new javax.swing.JScrollPane(); | ||||
|  | @ -82,9 +81,6 @@ public class OnTransact extends javax.swing.JFrame { | |||
| 
 | ||||
|         jPanel_statusinfo.setLayout(new java.awt.BorderLayout()); | ||||
| 
 | ||||
|         jComboBox_Payment.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); | ||||
|         jPanel_statusinfo.add(jComboBox_Payment, java.awt.BorderLayout.EAST); | ||||
| 
 | ||||
|         jLabel_Status.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); | ||||
|         jLabel_Status.setText("Store"); | ||||
|         jPanel_statusinfo.add(jLabel_Status, java.awt.BorderLayout.CENTER); | ||||
|  | @ -98,6 +94,9 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         jPanel_statusinfo.add(jToggleButton_Discard, java.awt.BorderLayout.LINE_START); | ||||
|         jToggleButton_Discard.setVisible(interface_adjust_clear()); | ||||
| 
 | ||||
|         jButton_Action_Pay.setText("Payment"); | ||||
|         jPanel_statusinfo.add(jButton_Action_Pay, java.awt.BorderLayout.LINE_END); | ||||
| 
 | ||||
|         getContentPane().add(jPanel_statusinfo, java.awt.BorderLayout.PAGE_END); | ||||
| 
 | ||||
|         jPanel_Main.setLayout(new java.awt.BorderLayout()); | ||||
|  | @ -107,7 +106,7 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         jTextArea1.setColumns(20); | ||||
|         jTextArea1.setLineWrap(true); | ||||
|         jTextArea1.setRows(5); | ||||
|         jTextArea1.setEnabled(false); | ||||
|         jTextArea1.setEditable(false); | ||||
|         jScrollPane1.setViewportView(jTextArea1); | ||||
| 
 | ||||
|         jPanel_Items.add(jScrollPane1, java.awt.BorderLayout.CENTER); | ||||
|  | @ -278,6 +277,7 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         jPanel_ItemDetails.add(jTextField_ItemDetails_SKU, gridBagConstraints); | ||||
| 
 | ||||
|         jLabel_ItemDetails_UnitPrice.setText("Unit Price"); | ||||
| 		jLabel_ItemDetails_UnitPrice.setHorizontalAlignment(javax.swing.JTextField.TRAILING); | ||||
|         gridBagConstraints = new java.awt.GridBagConstraints(); | ||||
|         gridBagConstraints.gridx = 0; | ||||
|         gridBagConstraints.gridy = 1; | ||||
|  | @ -332,7 +332,7 @@ public class OnTransact extends javax.swing.JFrame { | |||
|     private void transaction_check(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_transaction_check | ||||
|         boolean CLOSING_STATE = false;  | ||||
|          | ||||
|         if (transact.items.size() <= 0) { | ||||
|         if (!transact.check()) { | ||||
|             CLOSING_STATE = true; | ||||
|         } else { | ||||
|             CLOSING_STATE = confirm_discard(); | ||||
|  | @ -347,7 +347,13 @@ public class OnTransact extends javax.swing.JFrame { | |||
|     }//GEN-LAST:event_jList1_InventoryValueChanged | ||||
| 
 | ||||
|     private void jToggleButton_DiscardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton_DiscardActionPerformed | ||||
|         init(); | ||||
|         boolean CLOSING_STATE = false;  | ||||
|          | ||||
|         if (transact.check()) { | ||||
|             CLOSING_STATE = confirm_discard(); | ||||
|         }; | ||||
| 
 | ||||
|         if (CLOSING_STATE) {init();}; | ||||
|     }//GEN-LAST:event_jToggleButton_DiscardActionPerformed | ||||
| 
 | ||||
|     /** | ||||
|  | @ -356,10 +362,10 @@ public class OnTransact extends javax.swing.JFrame { | |||
|      | ||||
|     public static void display() { | ||||
|         /* Display the transaction. */ | ||||
|          | ||||
|         java.awt.EventQueue.invokeLater(new Runnable() { | ||||
|             public void run() { | ||||
|                 new OnTransact().setVisible(true); | ||||
| 				init(); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | @ -405,18 +411,27 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         return (USER_CHOICE); | ||||
|     }; | ||||
|      | ||||
|     private boolean interface_adjust_clear() { | ||||
|     private static boolean interface_adjust_clear() { | ||||
|         /* Adjust the ability to reset.  | ||||
|          | ||||
|         Returns: (boolean) the new state of the appearance | ||||
|         */ | ||||
|          | ||||
|         boolean CLEARABLE_STATE = (transact.items.size() > 0);  | ||||
|         boolean CLEARABLE_STATE = (transact.check());  | ||||
|         jToggleButton_Discard.setVisible(CLEARABLE_STATE); | ||||
|         return (jToggleButton_Discard.isVisible()); | ||||
|     }; | ||||
| 	 | ||||
|     private AbstractListModel<String> refresh_inventory_list() { | ||||
| 	public static boolean interface_adjust_payment() { | ||||
| 		/* Adjust the ability to pay.  | ||||
| 			 | ||||
| 		Returns: (boolean) the payment status */ | ||||
| 			 | ||||
| 		jButton_Action_Pay.setEnabled(transact.check()); | ||||
| 		return(transact.check()); | ||||
| 	} | ||||
|      | ||||
|     private static AbstractListModel<String> refresh_inventory_list() { | ||||
|         /* Pull the list from inventory.  | ||||
|         */ | ||||
|          | ||||
|  | @ -429,7 +444,7 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         return(INVENTORY_LIST); | ||||
|     }; | ||||
|      | ||||
|     private void cart_calculation_refresh() { | ||||
|     private static void cart_calculation_refresh() { | ||||
|         /* Refresh the cart's details, such as the total cost. */ | ||||
|         Dictionary<String, String> prices = transact.calculate();  | ||||
|          | ||||
|  | @ -440,14 +455,25 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         jTextField_price_discounted.setText(String.valueOf(prices.get("discount"))); | ||||
|         jTextField_price_VAT_value.setText(String.valueOf(prices.get("tax"))); | ||||
|          | ||||
|         receipt_refresh(); | ||||
| 		product_information_refresh(); | ||||
| 		interface_adjust_payment(); | ||||
|         interface_adjust_clear(); | ||||
|     }; | ||||
|      | ||||
|     private boolean product_information_refresh() { | ||||
|         /* Refresh the select product information's details. */ | ||||
|     private static boolean product_information_refresh() { | ||||
|         /* Refresh the select product information's details and the corresponding button states. */ | ||||
|         Integer ITEM_SELECTED = jList1_Inventory.getSelectedIndex(); | ||||
|          | ||||
|         if (ITEM_SELECTED == null) {return false;}; | ||||
| 		// Set the initial values.  | ||||
| 		jSpinner_item_quantity.setEnabled((ITEM_SELECTED >= 0)); | ||||
| 		jButton_item_void.setEnabled((ITEM_SELECTED >= 0));  | ||||
| 		jButton_item_add.setEnabled((ITEM_SELECTED >= 0));  | ||||
| 		 | ||||
|         if (ITEM_SELECTED < 0) { | ||||
|             // Stop when there is no value selected.  | ||||
| 			return(false); | ||||
|         }; | ||||
|          | ||||
|         Dictionary<String, String> ITEM_SELECTED_DETAILS_PROCESSED = new Hashtable<>(); | ||||
|          | ||||
|  | @ -468,17 +494,23 @@ public class OnTransact extends javax.swing.JFrame { | |||
|             ITEM_SELECTED_DETAILS_PROCESSED.put("Discount",""); | ||||
|         }; | ||||
|          | ||||
| 		// Change the void state. You can't void something that doesn't already exist in the cart.  | ||||
| 		jButton_item_void.setEnabled((((transact.items).get(ITEM_SELECTED_DETAILS_PROCESSED.get("SKU"))) != null)); | ||||
| 		 | ||||
|         // Place the corresponding information.  | ||||
|         jTextField_ItemDetails_SKU.setText(ITEM_SELECTED_DETAILS_PROCESSED.get("SKU")); | ||||
|         jTextField_ItemDetails_UnitPrice.setText(ITEM_SELECTED_DETAILS_PROCESSED.get("Unit Price")); | ||||
|         jTextField_ItemDetails_Discount.setText(ITEM_SELECTED_DETAILS_PROCESSED.get("Discount")); | ||||
|          | ||||
|          | ||||
|          | ||||
|         return (true); | ||||
|     }; | ||||
|       | ||||
|     private void cart_tip_add() { | ||||
|         /* Add a tip. */ | ||||
|          | ||||
|         transact.price.put("tip", (double) jSpinner_price_tip_value.getValue()); | ||||
|         transact.price.put("tip", Float.valueOf(String.valueOf(jSpinner_price_tip_value.getValue()))); | ||||
|         transact.calculate(); | ||||
|         cart_calculation_refresh(); | ||||
|     }; | ||||
|  | @ -491,7 +523,7 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         boolean state = false;  | ||||
|          | ||||
|         int ITEM_SELECTED = jList1_Inventory.getSelectedIndex(); | ||||
|         int ITEM_SELECTED_QUANTITY = (int) jSpinner_item_quantity.getValue(); | ||||
|         int ITEM_SELECTED_QUANTITY = Integer.parseInt(String.valueOf(jSpinner_item_quantity.getValue())); | ||||
|          | ||||
|         if (ITEM_SELECTED >= 0) { | ||||
|             // Get the selected details.  | ||||
|  | @ -533,58 +565,64 @@ public class OnTransact extends javax.swing.JFrame { | |||
|         return(state); | ||||
|     }; | ||||
|      | ||||
|     private void init() { | ||||
| 	public static void reset() { | ||||
| 		/* Reset the transaction. */ | ||||
| 		Boolean DISCARD_STATE = confirm_discard(); | ||||
| 		if (DISCARD_STATE) { | ||||
| 			init(); | ||||
| 		}; | ||||
| 		 | ||||
| 	} | ||||
| 	 | ||||
|     private static void init() { | ||||
|         transact.init(); | ||||
|         refresh_inventory_list(); | ||||
|         cart_calculation_refresh(); | ||||
|             receipt.init(); | ||||
|             receipt.headers(); | ||||
|         receipt_refresh(); | ||||
|         }; | ||||
| 		product_information_refresh(); | ||||
|     }; | ||||
|      | ||||
|      | ||||
|     private void receipt_refresh() { | ||||
|     private static void receipt_refresh() { | ||||
|         jTextArea1.setText(receipt.content); | ||||
|     }; | ||||
| 	 | ||||
| 
 | ||||
|     // Variables declaration - do not modify//GEN-BEGIN:variables | ||||
|     private javax.swing.JButton jButton_item_add; | ||||
|     private javax.swing.JButton jButton_item_void; | ||||
|     private javax.swing.JComboBox<String> jComboBox_Payment; | ||||
|     private javax.swing.JLabel jLabel2_information_discount; | ||||
|     private javax.swing.JLabel jLabel_ItemDetails_Discount; | ||||
|     private javax.swing.JLabel jLabel_ItemDetails_SKU; | ||||
|     private javax.swing.JLabel jLabel_ItemDetails_UnitPrice; | ||||
|     private javax.swing.JLabel jLabel_Status; | ||||
|     private javax.swing.JLabel jLabel_price_VAT; | ||||
|     private javax.swing.JLabel jLabel_price_subtotal; | ||||
|     private javax.swing.JLabel jLabel_price_tip; | ||||
|     private javax.swing.JLabel jLabel_price_total; | ||||
|     private javax.swing.JList<String> jList1_Inventory; | ||||
|     private javax.swing.JPanel jPanel_Information; | ||||
|     private javax.swing.JPanel jPanel_Inventory; | ||||
|     private javax.swing.JPanel jPanel_Inventory_Actions; | ||||
|     private javax.swing.JPanel jPanel_ItemDetails; | ||||
|     private javax.swing.JPanel jPanel_Items; | ||||
|     private javax.swing.JPanel jPanel_Main; | ||||
|     private javax.swing.JPanel jPanel_statusinfo; | ||||
|     private javax.swing.JScrollPane jScrollPane1; | ||||
|     private javax.swing.JScrollPane jScrollPane_Inventory; | ||||
|     private javax.swing.JSpinner jSpinner_item_quantity; | ||||
|     private javax.swing.JSpinner jSpinner_price_tip_value; | ||||
|     private javax.swing.JTextArea jTextArea1; | ||||
|     private javax.swing.JTextField jTextField_ItemDetails_Discount; | ||||
|     private javax.swing.JTextField jTextField_ItemDetails_SKU; | ||||
|     private javax.swing.JTextField jTextField_ItemDetails_UnitPrice; | ||||
|     private javax.swing.JTextField jTextField_price_VAT_value; | ||||
|     private javax.swing.JTextField jTextField_price_discounted; | ||||
|     private javax.swing.JTextField jTextField_price_subtotal_value; | ||||
|     private javax.swing.JTextField jTextField_price_total_value; | ||||
|     private javax.swing.JToggleButton jToggleButton_Discard; | ||||
|     private javax.swing.JToolBar jToolBar_Information; | ||||
|     private javax.swing.JToolBar jToolBar_Inventory; | ||||
|     private static javax.swing.JButton jButton_Action_Pay; | ||||
|     private static javax.swing.JButton jButton_item_add; | ||||
|     private static javax.swing.JButton jButton_item_void; | ||||
|     private static javax.swing.JLabel jLabel2_information_discount; | ||||
|     private static javax.swing.JLabel jLabel_ItemDetails_Discount; | ||||
|     private static javax.swing.JLabel jLabel_ItemDetails_SKU; | ||||
|     private static javax.swing.JLabel jLabel_ItemDetails_UnitPrice; | ||||
|     private static javax.swing.JLabel jLabel_Status; | ||||
|     private static javax.swing.JLabel jLabel_price_VAT; | ||||
|     private static javax.swing.JLabel jLabel_price_subtotal; | ||||
|     private static javax.swing.JLabel jLabel_price_tip; | ||||
|     private static javax.swing.JLabel jLabel_price_total; | ||||
|     private static javax.swing.JList<String> jList1_Inventory; | ||||
|     private static javax.swing.JPanel jPanel_Information; | ||||
|     private static javax.swing.JPanel jPanel_Inventory; | ||||
|     private static javax.swing.JPanel jPanel_Inventory_Actions; | ||||
|     private static javax.swing.JPanel jPanel_ItemDetails; | ||||
|     private static javax.swing.JPanel jPanel_Items; | ||||
|     private static javax.swing.JPanel jPanel_Main; | ||||
|     private static javax.swing.JPanel jPanel_statusinfo; | ||||
|     private static javax.swing.JScrollPane jScrollPane1; | ||||
|     private static javax.swing.JScrollPane jScrollPane_Inventory; | ||||
|     private static javax.swing.JSpinner jSpinner_item_quantity; | ||||
|     private static javax.swing.JSpinner jSpinner_price_tip_value; | ||||
|     private static javax.swing.JTextArea jTextArea1; | ||||
|     private static javax.swing.JTextField jTextField_ItemDetails_Discount; | ||||
|     private static javax.swing.JTextField jTextField_ItemDetails_SKU; | ||||
|     private static javax.swing.JTextField jTextField_ItemDetails_UnitPrice; | ||||
|     private static javax.swing.JTextField jTextField_price_VAT_value; | ||||
|     private static javax.swing.JTextField jTextField_price_discounted; | ||||
|     private static javax.swing.JTextField jTextField_price_subtotal_value; | ||||
|     private static javax.swing.JTextField jTextField_price_total_value; | ||||
|     private static javax.swing.JToggleButton jToggleButton_Discard; | ||||
|     private static javax.swing.JToolBar jToolBar_Information; | ||||
|     private static javax.swing.JToolBar jToolBar_Inventory; | ||||
|     // End of variables declaration//GEN-END:variables | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue