update code to add payment
This commit is contained in:
		
							parent
							
								
									f602027e88
								
							
						
					
					
						commit
						b21f48c4ff
					
				
					 2 changed files with 39 additions and 18 deletions
				
			
		|  | @ -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") | ||||
| 	// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||||
| 	 | ||||
| 	private void initComponents() { | ||||
| 		java.awt.GridBagConstraints gridBagConstraints; | ||||
| 
 | ||||
|  | @ -241,7 +237,6 @@ 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() { | ||||
|  | @ -249,6 +244,8 @@ public class OnTransact extends javax.swing.JFrame { | |||
| 				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(); | ||||
| 	}// </editor-fold> | ||||
| 
 | ||||
|  | @ -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();		 | ||||
| 		}; | ||||
| 	}; | ||||
| 	 | ||||
| 	 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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. | ||||
| 		*/ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue