public String[] checkAndProcessReturn(int receiptid, int qtyReturned, String upc) throws Exception {
		int retid = 0;
	    String amount=null;
		
		try {
			PreparedStatement ps = con.prepareStatement(
					"SELECT purchase_date, card_no, item_price, quantity " +
					"FROM Purchase P, PurchaseItem PI, Item I " +
					"WHERE P.receiptid = PI.receiptid AND I.upc = PI.upc " +
					"AND PI.upc=? AND P.receiptid=?");
			
			ps.setString(1, upc);
			ps.setInt(2, receiptid);
			
			ResultSet rs = ps.executeQuery();
			
			if (!rs.next()) {
				throw new ReturnException("ERROR: No such purchase exists.");
				
			} else {				
				// get data
				float price = rs.getFloat("item_price");
				int qty = rs.getInt("quantity");					
				String cardno = rs.getString("card_no");
				java.sql.Date purchaseDate = rs.getDate("purchase_date");
				
				// make sure not returning more than was bought
				if (qtyReturned > qty) {
					throw new ReturnException("Returning more items than purchased.");
				}
	
				// get the current date from the database
				java.sql.Date returnDate = getCurrentDate();			
				
				// check if return is within valid date range
				if (isValidReturn(purchaseDate, returnDate)) {		
					// insert into tables and update stock
					retid = processReturn(receiptid, returnDate, upc, qtyReturned);	
					is.UpdateItem(upc, qtyReturned);
					amount=printReturn(price, cardno, qty, qtyReturned);	
					
				} else {
					throw new ReturnException("Return is invalid. Over 15 days have passed.");
				}
			}		
		} catch (SQLException e) {
			e.printStackTrace();
			throw new ReturnException("Could not process return.");
		}
		return new String[]{Integer.toString(retid),amount};	
	}