add payment recording
This commit is contained in:
parent
8f0193f55f
commit
49e089f0e5
1 changed files with 51 additions and 24 deletions
|
@ -85,33 +85,33 @@ public class receipt {
|
|||
/* Generate the headers.
|
||||
*/
|
||||
|
||||
Dictionary <String, String> content_headers_raw = data_test.read_properties();
|
||||
Enumeration<String> content_headers_raw_headers = content_headers_raw.keys();
|
||||
String content_headers = "";
|
||||
Dictionary <String, String> content_headers_raw = data_test.read_properties();
|
||||
Enumeration<String> content_headers_raw_headers = content_headers_raw.keys();
|
||||
String content_headers = "";
|
||||
|
||||
if (content_headers_raw.get("Full Name") != null) {
|
||||
content_headers = content_headers_raw.get("Full Name");
|
||||
} else if (content_headers_raw.get("Name") != null) {
|
||||
content_headers = content_headers_raw.get("Name");
|
||||
};
|
||||
if (content_headers_raw.get("Full Name") != null) {
|
||||
content_headers = content_headers_raw.get("Full Name").toUpperCase();
|
||||
} else if (content_headers_raw.get("Name") != null) {
|
||||
content_headers = content_headers_raw.get("Name").toUpperCase();
|
||||
};
|
||||
|
||||
while (content_headers_raw_headers.hasMoreElements()) {
|
||||
String content_headers_header = content_headers_raw_headers.nextElement();
|
||||
if (content_headers_raw.get(content_headers_header) != null) {
|
||||
if (!content_headers_header.contains("Name")) {
|
||||
content_headers = content_headers.concat("\n");
|
||||
content_headers = content_headers.concat(content_headers_header.concat(": "));
|
||||
content_headers = content_headers.concat(content_headers_raw.get(content_headers_header));
|
||||
};
|
||||
};
|
||||
};
|
||||
while (content_headers_raw_headers.hasMoreElements()) {
|
||||
String content_headers_header = content_headers_raw_headers.nextElement();
|
||||
if (content_headers_raw.get(content_headers_header) != null) {
|
||||
if (!content_headers_header.contains("Name")) {
|
||||
content_headers = content_headers.concat("\n");
|
||||
content_headers = content_headers.concat(content_headers_header.concat(": "));
|
||||
content_headers = content_headers.concat(content_headers_raw.get(content_headers_header));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
data.put("headers", content_headers);
|
||||
data.put("headers", content_headers);
|
||||
refresh();
|
||||
|
||||
return(content_headers);
|
||||
};
|
||||
return(content_headers);
|
||||
};
|
||||
|
||||
public static String action(String NAME, int QUANTITY, double PRICE, double TOTAL) {
|
||||
/* Add an item to the cart.
|
||||
|
@ -127,15 +127,42 @@ public class receipt {
|
|||
data.put("cart", "Quantity\tItem\n\tPrice\tTotal");
|
||||
};
|
||||
|
||||
data.put("cart", data.get("cart").toString().concat("\n"));
|
||||
data.put("cart", data.get("cart").toString().concat("\n"));
|
||||
String item_current = String.join("\t", String.valueOf(QUANTITY), NAME, "\n", String.valueOf(PRICE), String.valueOf(TOTAL));
|
||||
data.put("cart", data.get("cart").toString().concat(item_current));
|
||||
|
||||
// Refresh.
|
||||
// Refresh.
|
||||
refresh();
|
||||
|
||||
// Return the updated receipt section preview.
|
||||
// Return the updated receipt section preview.
|
||||
return(data.get("cart").toString());
|
||||
};
|
||||
|
||||
public static String payment(Dictionary<String, Float> details) {
|
||||
/* Add the payment data.
|
||||
*
|
||||
* Parameters:
|
||||
* (Dict) details: the payment details, including total, subtotal, and change
|
||||
*
|
||||
* Returns: (String) the portion of the receipt
|
||||
*/
|
||||
|
||||
// re-initialize the payment details
|
||||
data.put("payment", "");
|
||||
|
||||
// Check for the details
|
||||
Enumeration<String> details_contents = details.keys();
|
||||
|
||||
while (details_contents.hasMoreElements()) {
|
||||
String details_content = details_contents.nextElement();
|
||||
|
||||
data.put("payment", data.get("payment").concat("\n"));
|
||||
data.put("payment", data.get("payment").concat(String.join(": ", (details_content.contains("total")) ? details_content.toUpperCase() : details_content.substring(0, 1).toUpperCase() + details_content.substring(1), String.valueOf(details.get(details_content)))));
|
||||
};
|
||||
|
||||
refresh();
|
||||
|
||||
return(data.get("payment"));
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue