attempt fixing the decimal places

This commit is contained in:
buzz-lightsnack-2007 2024-02-28 00:57:50 +08:00
parent b21f48c4ff
commit 1d8a2816ae

View file

@ -33,6 +33,8 @@ public class transact {
}
}
*/
private final static DecimalFormat FORMAT_DECIMAL = new DecimalFormat("#.00");
public static void init() {
@ -120,7 +122,6 @@ public class transact {
if (item_details != null) {
if (item_details.get("Price") != null) {
// Set up the decimal format.
DecimalFormat FORMAT_DECIMAL = new DecimalFormat("#.00");
item_pricing.put("unit", Float.valueOf(FORMAT_DECIMAL.format(Float.valueOf(item_details.get("Price").toString()))));
item_pricing.put("subtotal", Float.valueOf(FORMAT_DECIMAL.format(Float.parseFloat(item_details.get("Price").toString()) * QUANTITY)));
@ -251,7 +252,7 @@ public class transact {
public static void pay() {
/* Initialize the payment process of the transaction. */
payment.init();
payment.init(Float.valueOf(FORMAT_DECIMAL.format(Float.valueOf(price.get("total").toString()))));
};
public static void finalise() {