You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by su...@apache.org on 2020/06/13 09:31:20 UTC

[ofbiz-framework] branch trunk updated: Improved: Changed decimals, rounding, zero static variables names as per best practices in accounting component. (#202)

This is an automated email from the ASF dual-hosted git repository.

surajk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new e797845  Improved: Changed decimals, rounding, zero static variables names as per best practices in accounting component. (#202)
e797845 is described below

commit e797845dda3141206aaebe0d48c662fd4908c16c
Author: Suraj Khurana <64...@users.noreply.github.com>
AuthorDate: Sat Jun 13 15:01:11 2020 +0530

    Improved: Changed decimals, rounding, zero static variables names as per best practices in accounting component. (#202)
    
    (OFBIZ-11804)
    Also make them private data members of the class.
---
 .../accounting/agreement/AgreementServices.java    | 10 ++---
 .../ofbiz/accounting/invoice/InvoiceServices.java  | 24 ++++++------
 .../ofbiz/accounting/invoice/InvoiceWorker.java    | 32 ++++++++--------
 .../accounting/payment/PaymentGatewayServices.java | 44 +++++++++++-----------
 .../ofbiz/accounting/payment/PaymentWorker.java    | 18 ++++-----
 .../ofbiz/accounting/tax/TaxAuthorityServices.java | 31 +++++++--------
 6 files changed, 82 insertions(+), 77 deletions(-)

diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java
index 4375f30..26ca8c9 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java
@@ -46,9 +46,9 @@ public class AgreementServices {
 
     private static final String MODULE = AgreementServices.class.getName();
     // set some BigDecimal properties
-    public static final int decimals = UtilNumber.getBigDecimalScale("finaccount.decimals");
-    public static final RoundingMode rounding = UtilNumber.getRoundingMode("finaccount.rounding");
-    public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(decimals, rounding);
+    private static final int DECIMALS = UtilNumber.getBigDecimalScale("finaccount.decimals");
+    private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("finaccount.rounding");
+    private static final BigDecimal ZERO = BigDecimal.ZERO.setScale(DECIMALS, ROUNDING);
 
     /**
      * Determines commission receiving parties and amounts for the provided product, price, and quantity
@@ -124,7 +124,7 @@ public class AgreementServices {
                                 commission = commission.add(termValue);
                             } else if ("FIN_COMM_VARIABLE".equals(termTypeId)) {
                                 // if variable percentage commission, need to divide by 100, because 5% is stored as termValue of 5.0
-                                commission = commission.add(termValue.multiply(amount).divide(new BigDecimal("100"), 12, rounding));
+                                commission = commission.add(termValue.multiply(amount).divide(new BigDecimal("100"), 12, ROUNDING));
                             } else if ("FIN_COMM_MIN".equals(termTypeId)) {
                                 min = termValue;
                             } else if ("FIN_COMM_MAX".equals(termTypeId)) {
@@ -150,7 +150,7 @@ public class AgreementServices {
                     if (commission.compareTo(max) > 0)
                         commission = max;
                     commission = negative ? commission.negate() : commission;
-                    commission = commission.setScale(decimals, rounding);
+                    commission = commission.setScale(DECIMALS, ROUNDING);
 
                     Map<String, Object> partyCommissionResult = UtilMisc.toMap(
                             "partyIdFrom", agreementItem.getString("partyIdFrom"),
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
index dbeb4ea..f7eaa39 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
@@ -2712,7 +2712,7 @@ public class InvoiceServices {
                         "AccountingPaymentRecordNotFound", UtilMisc.toMap("paymentId", paymentId), locale));
                 return ServiceUtil.returnError(errorMessageList);
             }
-            paymentApplyAvailable = payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentApplied(payment)).setScale(DECIMALS,ROUNDING);
+            paymentApplyAvailable = payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentApplied(payment)).setScale(DECIMALS, ROUNDING);
 
             if ("PMNT_CANCELLED".equals(payment.getString("statusId"))) {
                 errorMessageList.add(UtilProperties.getMessage(RESOURCE,
@@ -2741,7 +2741,7 @@ public class InvoiceServices {
                         "AccountingPaymentRecordNotFound", UtilMisc.toMap("paymentId", toPaymentId), locale));
                 return ServiceUtil.returnError(errorMessageList);
             }
-            toPaymentApplyAvailable = toPayment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentApplied(toPayment)).setScale(DECIMALS,ROUNDING);
+            toPaymentApplyAvailable = toPayment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentApplied(toPayment)).setScale(DECIMALS, ROUNDING);
 
             if ("PMNT_CANCELLED".equals(toPayment.getString("statusId"))) {
                 errorMessageList.add(UtilProperties.getMessage(RESOURCE,
@@ -2867,7 +2867,7 @@ public class InvoiceServices {
                             errorMessageList.add("actual currency on payment (" + currencyUomId + ") not the same as original invoice currency (" + invoice.getString("currencyUomId") + ")");
                         }
                     }
-                    paymentApplyAvailable = payment.getBigDecimal("actualCurrencyAmount").subtract(PaymentWorker.getPaymentApplied(payment)).setScale(DECIMALS,ROUNDING);
+                    paymentApplyAvailable = payment.getBigDecimal("actualCurrencyAmount").subtract(PaymentWorker.getPaymentApplied(payment)).setScale(DECIMALS, ROUNDING);
                 }
 
                 // check if the invoice already covered by payments
@@ -2932,9 +2932,9 @@ public class InvoiceServices {
                     if (invoiceItem.get("quantity") == null) {
                         quantity = BigDecimal.ONE;
                     } else {
-                        quantity = invoiceItem.getBigDecimal("quantity").setScale(DECIMALS,ROUNDING);
+                        quantity = invoiceItem.getBigDecimal("quantity").setScale(DECIMALS, ROUNDING);
                     }
-                    invoiceItemApplyAvailable = invoiceItem.getBigDecimal("amount").multiply(quantity).setScale(DECIMALS,ROUNDING).subtract(InvoiceWorker.getInvoiceItemApplied(invoiceItem));
+                    invoiceItemApplyAvailable = invoiceItem.getBigDecimal("amount").multiply(quantity).setScale(DECIMALS, ROUNDING).subtract(InvoiceWorker.getInvoiceItemApplied(invoiceItem));
                     // check here for too much application if a new record is added
                     if (paymentApplicationId == null && amountApplied.compareTo(invoiceItemApplyAvailable) > 0) {
                         // new record
@@ -3278,10 +3278,10 @@ public class InvoiceServices {
                 }
                 BigDecimal itemQuantity = BigDecimal.ONE;
                 if (currentInvoiceItem.get("quantity") != null && currentInvoiceItem.getBigDecimal("quantity").signum() != 0) {
-                    itemQuantity = new BigDecimal(currentInvoiceItem.getString("quantity")).setScale(DECIMALS,ROUNDING);
+                    itemQuantity = new BigDecimal(currentInvoiceItem.getString("quantity")).setScale(DECIMALS, ROUNDING);
                 }
-                BigDecimal itemAmount = currentInvoiceItem.getBigDecimal("amount").setScale(DECIMALS,ROUNDING);
-                BigDecimal itemTotal = itemAmount.multiply(itemQuantity).setScale(DECIMALS,ROUNDING);
+                BigDecimal itemAmount = currentInvoiceItem.getBigDecimal("amount").setScale(DECIMALS, ROUNDING);
+                BigDecimal itemTotal = itemAmount.multiply(itemQuantity).setScale(DECIMALS, ROUNDING);
 
                 // get the application(s) already allocated to this
                 // item, if available
@@ -3299,9 +3299,9 @@ public class InvoiceServices {
                     Iterator<GenericValue> p = paymentApplications.iterator();
                     while (p.hasNext()) {
                         paymentApplication = p.next();
-                        alreadyApplied = alreadyApplied.add(paymentApplication.getBigDecimal("amountApplied").setScale(DECIMALS,ROUNDING));
+                        alreadyApplied = alreadyApplied.add(paymentApplication.getBigDecimal("amountApplied").setScale(DECIMALS, ROUNDING));
                     }
-                    tobeApplied = itemTotal.subtract(alreadyApplied).setScale(DECIMALS,ROUNDING);
+                    tobeApplied = itemTotal.subtract(alreadyApplied).setScale(DECIMALS, ROUNDING);
                 } else {
                     // no application connected yet
                     tobeApplied = itemTotal;
@@ -3431,7 +3431,7 @@ public class InvoiceServices {
             if (paymentApplication.get("paymentApplicationId") == null)    {
                 // add 2 amounts together
                 checkAppl.set("amountApplied", paymentApplication.getBigDecimal("amountApplied").
-                        add(checkAppl.getBigDecimal("amountApplied")).setScale(DECIMALS,ROUNDING));
+                        add(checkAppl.getBigDecimal("amountApplied")).setScale(DECIMALS, ROUNDING));
                 if (debug) {
                     Debug.logInfo("Update paymentApplication record: " + checkAppl.getString("paymentApplicationId") + " with appliedAmount:" + checkAppl.getBigDecimal("amountApplied"), MODULE);
                 }
@@ -3454,7 +3454,7 @@ public class InvoiceServices {
             } else    { // two existing records, an updated one added to the existing one
                 // add 2 amounts together
                 checkAppl.set("amountApplied", paymentApplication.getBigDecimal("amountApplied").
-                        add(checkAppl.getBigDecimal("amountApplied")).setScale(DECIMALS,ROUNDING));
+                        add(checkAppl.getBigDecimal("amountApplied")).setScale(DECIMALS, ROUNDING));
                 // delete paymentApplication record and update the checkAppls one.
                 if (debug) {
                     Debug.logInfo("Delete paymentApplication record: " + paymentApplication.getString("paymentApplicationId") + " with appliedAmount:" + paymentApplication.getBigDecimal("amountApplied"), MODULE);
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
index c276f61..8c78fb3 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
@@ -55,8 +55,9 @@ import org.apache.ofbiz.service.LocalDispatcher;
 public final class InvoiceWorker {
 
     private static final String MODULE = InvoiceWorker.class.getName();
-    private static final int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static final RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
+
+    private static final int DECIMALS = UtilNumber.getBigDecimalScale("invoice.decimals");
+    private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("invoice.rounding");
     private static final int taxDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
     private static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
 
@@ -114,7 +115,7 @@ public final class InvoiceWorker {
         if (amount == null) {
             amount = BigDecimal.ZERO;
         }
-        return quantity.multiply(amount).setScale(decimals, rounding);
+        return quantity.multiply(amount).setScale(DECIMALS, ROUNDING);
     }
 
     /**
@@ -223,12 +224,12 @@ public final class InvoiceWorker {
         }
         if (invoiceItems != null) {
             for (GenericValue invoiceItem : invoiceItems) {
-                invoiceTotal = invoiceTotal.add(getInvoiceItemTotal(invoiceItem)).setScale(decimals,rounding);
+                invoiceTotal = invoiceTotal.add(getInvoiceItemTotal(invoiceItem)).setScale(DECIMALS, ROUNDING);
             }
         }
-        invoiceTotal = invoiceTotal.add(invoiceTaxTotal).setScale(decimals, rounding);
+        invoiceTotal = invoiceTotal.add(invoiceTaxTotal).setScale(DECIMALS, ROUNDING);
         if (UtilValidate.isNotEmpty(invoiceTotal) && !actualCurrency) {
-            invoiceTotal = invoiceTotal.multiply(getInvoiceCurrencyConversionRate(invoice)).setScale(decimals,rounding);
+            invoiceTotal = invoiceTotal.multiply(getInvoiceCurrencyConversionRate(invoice)).setScale(DECIMALS, ROUNDING);
         }
         return invoiceTotal;
     }
@@ -499,11 +500,11 @@ public final class InvoiceWorker {
         }
         if (paymentApplications != null) {
             for (GenericValue paymentApplication : paymentApplications) {
-                invoiceApplied = invoiceApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(decimals,rounding);
+                invoiceApplied = invoiceApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(DECIMALS, ROUNDING);
             }
         }
         if (UtilValidate.isNotEmpty(invoiceApplied) && !actualCurrency) {
-            invoiceApplied = invoiceApplied.multiply(getInvoiceCurrencyConversionRate(delegator, invoiceId)).setScale(decimals,rounding);
+            invoiceApplied = invoiceApplied.multiply(getInvoiceCurrencyConversionRate(delegator, invoiceId)).setScale(DECIMALS, ROUNDING);
         }
         return invoiceApplied;
     }
@@ -569,7 +570,7 @@ public final class InvoiceWorker {
         }
         if (paymentApplications != null) {
             for (GenericValue paymentApplication : paymentApplications) {
-                invoiceItemApplied = invoiceItemApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(decimals,rounding);
+                invoiceItemApplied = invoiceItemApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(DECIMALS, ROUNDING);
             }
         }
         return invoiceItemApplied;
@@ -603,7 +604,7 @@ public final class InvoiceWorker {
                 GenericValue acctgTransEntry = (acctgTransEntries.get(0)).getRelated("AcctgTransEntry", null, null, false).get(0);
                 BigDecimal origAmount = acctgTransEntry.getBigDecimal("origAmount");
                 if (origAmount.compareTo(BigDecimal.ZERO) == 1) {
-                    conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(decimals,rounding);
+                    conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(DECIMALS, ROUNDING);
                 }
             }
             // check if a payment is applied and use the currency conversion from there
@@ -613,9 +614,10 @@ public final class InvoiceWorker {
                     GenericValue payment = paymentAppl.getRelatedOne("Payment", false);
                     if (UtilValidate.isNotEmpty(payment.getBigDecimal("actualCurrencyAmount"))) {
                         if (UtilValidate.isEmpty(conversionRate)) {
-                            conversionRate = payment.getBigDecimal("amount").divide(payment.getBigDecimal("actualCurrencyAmount"),new MathContext(100)).setScale(decimals,rounding);
+                            conversionRate = payment.getBigDecimal("amount").divide(payment.getBigDecimal("actualCurrencyAmount"),new MathContext(100)).setScale(DECIMALS, ROUNDING);
                         } else {
-                            conversionRate = conversionRate.add(payment.getBigDecimal("amount").divide(payment.getBigDecimal("actualCurrencyAmount"),new MathContext(100))).divide(new BigDecimal("2"),new MathContext(100)).setScale(decimals,rounding);
+                            conversionRate = conversionRate.add(payment.getBigDecimal("amount").divide(payment.getBigDecimal("actualCurrencyAmount"),
+                                    new MathContext(100))).divide(new BigDecimal("2"),new MathContext(100)).setScale(DECIMALS, ROUNDING);
                         }
                     }
                 }
@@ -624,7 +626,7 @@ public final class InvoiceWorker {
             if (UtilValidate.isEmpty(conversionRate)) {
                 GenericValue rate = EntityQuery.use(delegator).from("UomConversionDated").where("uomIdTo", invoice.get("currencyUomId"), "uomId", otherCurrencyUomId).filterByDate(invoice.getTimestamp("invoiceDate")).queryFirst();
                 if (rate != null) {
-                    conversionRate = BigDecimal.ONE.divide(rate.getBigDecimal("conversionFactor"), new MathContext(100)).setScale(decimals,rounding);
+                    conversionRate = BigDecimal.ONE.divide(rate.getBigDecimal("conversionFactor"), new MathContext(100)).setScale(DECIMALS, ROUNDING);
                 } else {
                     Debug.logError("Could not find conversionrate for invoice: " + invoice.getString("invoiceId"), MODULE);
                     return new BigDecimal("1");
@@ -704,7 +706,7 @@ public final class InvoiceWorker {
                                 }
                                 totalAmount = totalAmount.add(amount).setScale(taxDecimals, taxRounding);
                             }
-                            totalAmount = totalAmount.setScale(UtilNumber.getBigDecimalScale("salestax.calc.decimals"), UtilNumber.getRoundingMode("salestax.rounding"));
+                            totalAmount = totalAmount.setScale(taxDecimals, taxRounding);
                             taxByTaxAuthGeoAndPartyList.add(UtilMisc.<String, Object>toMap("taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, "totalAmount", totalAmount));
                             taxGrandTotal = taxGrandTotal.add(totalAmount);
                         }
@@ -825,6 +827,6 @@ public final class InvoiceWorker {
             amount = amount.setScale(taxDecimals, taxRounding);
             taxTotal = taxTotal.add(amount);
         }
-        return taxTotal.setScale(decimals, rounding);
+        return taxTotal.setScale(DECIMALS, ROUNDING);
     }
 }
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
index b88b7e8..71b72c6 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
@@ -76,19 +76,21 @@ import com.ibm.icu.util.Calendar;
 public class PaymentGatewayServices {
 
     private static final String MODULE = PaymentGatewayServices.class.getName();
-    public static final String AUTH_SERVICE_TYPE = "PRDS_PAY_AUTH";
+    private static final String RESOURCE = "AccountingUiLabels";
+    private static final String RES_ERROR = "AccountingErrorUiLabels";
+    private static final String RES_ORDER = "OrderUiLabels";
+
+    private static final String AUTH_SERVICE_TYPE = "PRDS_PAY_AUTH";
     private static final String REAUTH_SERVICE_TYPE = "PRDS_PAY_REAUTH";
     private static final String RELEASE_SERVICE_TYPE = "PRDS_PAY_RELEASE";
     private static final String CAPTURE_SERVICE_TYPE = "PRDS_PAY_CAPTURE";
     private static final String REFUND_SERVICE_TYPE = "PRDS_PAY_REFUND";
     private static final String CREDIT_SERVICE_TYPE = "PRDS_PAY_CREDIT";
     private static final int TX_TIME = 300;
-    public static final int decimals = UtilNumber.getBigDecimalScale("order.decimals");
-    public static final RoundingMode rounding = UtilNumber.getRoundingMode("order.rounding");
-    public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(decimals, rounding);
-    private static final String RESOURCE = "AccountingUiLabels";
-    private static final String RES_ERROR = "AccountingErrorUiLabels";
-    private static final String RES_ORDER = "OrderUiLabels";
+
+    private static final int DECIMALS = UtilNumber.getBigDecimalScale("order.decimals");
+    private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("order.rounding");
+    private static final BigDecimal ZERO = BigDecimal.ZERO.setScale(DECIMALS, ROUNDING);
 
     /**
      * Authorizes a single order preference with an option to specify an amount. The result map has the Booleans
@@ -168,7 +170,7 @@ public class PaymentGatewayServices {
         }
 
         // round this before moving on just in case a funny number made it this far
-        transAmount = transAmount.setScale(decimals, rounding);
+        transAmount = transAmount.setScale(DECIMALS, ROUNDING);
 
         // if our transaction amount exists and is zero, there's nothing to process, so return
         if ((transAmount != null) && (transAmount.compareTo(BigDecimal.ZERO) <= 0)) {
@@ -525,7 +527,7 @@ public class PaymentGatewayServices {
         }
 
         // format the decimal
-        processAmount = processAmount.setScale(decimals, rounding);
+        processAmount = processAmount.setScale(DECIMALS, ROUNDING);
 
         if (Debug.verboseOn()) {
             Debug.logVerbose("Charging amount: " + processAmount, MODULE);
@@ -1185,7 +1187,7 @@ public class PaymentGatewayServices {
         String billingAccountId = (String) context.get("billingAccountId");
         BigDecimal amountToCapture = (BigDecimal) context.get("captureAmount");
         Locale locale = (Locale) context.get("locale");
-        amountToCapture = amountToCapture.setScale(decimals, rounding);
+        amountToCapture = amountToCapture.setScale(DECIMALS, ROUNDING);
 
         // get the order header and payment preferences
         GenericValue orderHeader = null;
@@ -1220,9 +1222,9 @@ public class PaymentGatewayServices {
         // amount that we are going to capture.
         OrderReadHelper orh = new OrderReadHelper(orderHeader);
         BigDecimal orderGrandTotal = orh.getOrderGrandTotal();
-        orderGrandTotal = orderGrandTotal.setScale(decimals, rounding);
+        orderGrandTotal = orderGrandTotal.setScale(DECIMALS, ROUNDING);
         BigDecimal totalPayments = PaymentWorker.getPaymentsTotal(orh.getOrderPayments());
-        totalPayments = totalPayments.setScale(decimals, rounding);
+        totalPayments = totalPayments.setScale(DECIMALS, ROUNDING);
         BigDecimal remainingTotal = orderGrandTotal.subtract(totalPayments);
         if (Debug.infoOn()) {
             Debug.logInfo("The Remaining Total for order: " + orderId + " is: " + remainingTotal, MODULE);
@@ -1242,7 +1244,7 @@ public class PaymentGatewayServices {
                 if (authAmount == null) {
                     authAmount = ZERO;
                 }
-                authAmount = authAmount.setScale(decimals, rounding);
+                authAmount = authAmount.setScale(DECIMALS, ROUNDING);
 
                 if (authAmount.compareTo(ZERO) == 0) {
                     // nothing to capture
@@ -1285,7 +1287,7 @@ public class PaymentGatewayServices {
                             Debug.logInfo("Amount captured for order [" + orderId + "] from unapplied payments associated to billing account [" + billingAccountId + "] is: " + amountCaptured, MODULE);
                         }
 
-                        amountCaptured = amountCaptured.setScale(decimals, rounding);
+                        amountCaptured = amountCaptured.setScale(DECIMALS, ROUNDING);
 
                         if (amountCaptured.compareTo(BigDecimal.ZERO) == 0) {
                             continue;
@@ -1353,7 +1355,7 @@ public class PaymentGatewayServices {
                 if (authAmount == null) {
                     authAmount = ZERO;
                 }
-                authAmount = authAmount.setScale(decimals, rounding);
+                authAmount = authAmount.setScale(DECIMALS, ROUNDING);
 
                 if (authAmount.compareTo(ZERO) == 0) {
                     // nothing to capture
@@ -1394,7 +1396,7 @@ public class PaymentGatewayServices {
                         amountCaptured = (BigDecimal) captureResult.get("processAmount");
                     }
 
-                    amountCaptured = amountCaptured.setScale(decimals, rounding);
+                    amountCaptured = amountCaptured.setScale(DECIMALS, ROUNDING);
 
                     // decrease amount of next payment preference to capture
                     amountToCapture = amountToCapture.subtract(amountCaptured);
@@ -1530,7 +1532,7 @@ public class PaymentGatewayServices {
         String invoiceId = (String) context.get("invoiceId");
         String billingAccountId = (String) context.get("billingAccountId");
         BigDecimal captureAmount = (BigDecimal) context.get("captureAmount");
-        captureAmount = captureAmount.setScale(decimals, rounding);
+        captureAmount = captureAmount.setScale(DECIMALS, ROUNDING);
         BigDecimal capturedAmount = BigDecimal.ZERO;
 
         try {
@@ -1555,7 +1557,7 @@ public class PaymentGatewayServices {
                     // TODO: check the statusId of the payment
                     BigDecimal paymentApplicationAmount = paymentApplication.getBigDecimal("amountApplied");
                     BigDecimal amountToCapture = paymentApplicationAmount.min(captureAmount.subtract(capturedAmount));
-                    amountToCapture = amountToCapture.setScale(decimals, rounding);
+                    amountToCapture = amountToCapture.setScale(DECIMALS, ROUNDING);
                     if (amountToCapture.compareTo(paymentApplicationAmount) == 0) {
                         // apply the whole payment application to the invoice
                         paymentApplication.set("invoiceId", invoiceId);
@@ -1578,7 +1580,7 @@ public class PaymentGatewayServices {
         } catch (GenericEntityException ex) {
             return ServiceUtil.returnError(ex.getMessage());
         }
-        capturedAmount = capturedAmount.setScale(decimals, rounding);
+        capturedAmount = capturedAmount.setScale(DECIMALS, ROUNDING);
         Map<String, Object> results = ServiceUtil.returnSuccess();
         results.put("captureAmount", capturedAmount);
         return results;
@@ -2054,7 +2056,7 @@ public class PaymentGatewayServices {
         }
 
         // setup the amount big decimal
-        amount = amount.setScale(decimals, rounding);
+        amount = amount.setScale(DECIMALS, ROUNDING);
 
         result.put("orderPaymentPreference", paymentPreference);
         result.put("userLogin", userLogin);
@@ -2417,7 +2419,7 @@ public class PaymentGatewayServices {
                 // get the creditCard/address/email
                 String payToPartyId = orh.getBillToParty().getString("partyId");
 
-                BigDecimal processAmount = refundAmount.setScale(decimals, rounding);
+                BigDecimal processAmount = refundAmount.setScale(DECIMALS, ROUNDING);
                 serviceContext.put("refundAmount", processAmount);
                 serviceContext.put("userLogin", userLogin);
 
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java
index f5657ad..513fedb 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java
@@ -49,10 +49,10 @@ import org.apache.ofbiz.entity.util.EntityUtil;
 public final class PaymentWorker {
 
     private static final String MODULE = PaymentWorker.class.getName();
-    private static final int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static final RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
+    private static final int DECIMALS = UtilNumber.getBigDecimalScale("invoice.decimals");
+    private static final RoundingMode ROUNDING_MODE = UtilNumber.getRoundingMode("invoice.rounding");
 
-    private PaymentWorker() {}
+    private PaymentWorker() { }
 
     // to be able to use in minilanguage where Boolean cannot be used
     public static List<Map<String, GenericValue>> getPartyPaymentMethodValueMaps(Delegator delegator, String partyId) {
@@ -229,7 +229,7 @@ public final class PaymentWorker {
 
         BigDecimal paymentsTotal = BigDecimal.ZERO;
         for (GenericValue payment : payments) {
-            paymentsTotal = paymentsTotal.add(payment.getBigDecimal("amount")).setScale(decimals, rounding);
+            paymentsTotal = paymentsTotal.add(payment.getBigDecimal("amount")).setScale(DECIMALS, ROUNDING_MODE);
         }
         return paymentsTotal;
     }
@@ -323,7 +323,7 @@ public final class PaymentWorker {
                                amountApplied = amountApplied.multiply(payment.getBigDecimal("amount")).divide(payment.getBigDecimal("actualCurrencyAmount"),new MathContext(100));
                         }
                     }
-                    paymentApplied = paymentApplied.add(amountApplied).setScale(decimals,rounding);
+                    paymentApplied = paymentApplied.add(amountApplied).setScale(DECIMALS, ROUNDING_MODE);
                 }
             }
         } catch (GenericEntityException e) {
@@ -334,16 +334,16 @@ public final class PaymentWorker {
 
     public static BigDecimal getPaymentNotApplied(GenericValue payment) {
         if (payment != null) { 
-            return payment.getBigDecimal("amount").subtract(getPaymentApplied(payment)).setScale(decimals,rounding);
+            return payment.getBigDecimal("amount").subtract(getPaymentApplied(payment)).setScale(DECIMALS, ROUNDING_MODE);
         } 
         return BigDecimal.ZERO;
     }
 
     public static BigDecimal getPaymentNotApplied(GenericValue payment, Boolean actual) {
         if (actual.equals(Boolean.TRUE) && UtilValidate.isNotEmpty(payment.getBigDecimal("actualCurrencyAmount"))) {
-            return payment.getBigDecimal("actualCurrencyAmount").subtract(getPaymentApplied(payment, actual)).setScale(decimals,rounding);
+            return payment.getBigDecimal("actualCurrencyAmount").subtract(getPaymentApplied(payment, actual)).setScale(DECIMALS, ROUNDING_MODE);
         }
-        return payment.getBigDecimal("amount").subtract(getPaymentApplied(payment)).setScale(decimals,rounding);
+        return payment.getBigDecimal("amount").subtract(getPaymentApplied(payment)).setScale(DECIMALS, ROUNDING_MODE);
     }
 
     public static BigDecimal getPaymentNotApplied(Delegator delegator, String paymentId) {
@@ -365,6 +365,6 @@ public final class PaymentWorker {
         if (payment == null) {
             throw new IllegalArgumentException("The paymentId passed does not match an existing payment");
         }
-        return payment.getBigDecimal("amount").subtract(getPaymentApplied(delegator,paymentId, actual)).setScale(decimals,rounding);
+        return payment.getBigDecimal("amount").subtract(getPaymentApplied(delegator,paymentId, actual)).setScale(DECIMALS, ROUNDING_MODE);
     }
 }
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java
index d0ee210..f5d88ba 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java
@@ -55,14 +55,15 @@ import org.apache.ofbiz.service.ServiceUtil;
 public class TaxAuthorityServices {
 
     private static final String MODULE = TaxAuthorityServices.class.getName();
-    public static final BigDecimal ZERO_BASE = BigDecimal.ZERO;
-    public static final BigDecimal ONE_BASE = BigDecimal.ONE;
-    public static final BigDecimal PERCENT_SCALE = new BigDecimal("100.000");
-    public static final int salestaxFinalDecimals = UtilNumber.getBigDecimalScale("salestax.final.decimals");
-    public static final int salestaxCalcDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
-    public static final RoundingMode salestaxRounding = UtilNumber.getRoundingMode("salestax.rounding");
     private static final String RESOURCE = "AccountingUiLabels";
 
+    private static final BigDecimal ZERO_BASE = BigDecimal.ZERO;
+    private static final BigDecimal ONE_BASE = BigDecimal.ONE;
+    private static final BigDecimal PERCENT_SCALE = new BigDecimal("100.000");
+    private static final int TAX_FINAL_SCALE = UtilNumber.getBigDecimalScale("salestax.final.decimals");
+    private static final int TAX_SCALE = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
+    private static final RoundingMode TAX_ROUNDING = UtilNumber.getRoundingMode("salestax.rounding");
+
     public static Map<String, Object> rateProductTaxCalcForDisplay(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
         String productStoreId = (String) context.get("productStoreId");
@@ -137,10 +138,10 @@ public class TaxAuthorityServices {
                         taxPercentage = taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage"));
                         BigDecimal adjAmount = taxAdjustment.getBigDecimal("amount");
                         taxTotal = taxTotal.add(adjAmount);
-                        priceWithTax = priceWithTax.add(adjAmount.divide(quantity, salestaxCalcDecimals,
-                                salestaxRounding));
+                        priceWithTax = priceWithTax.add(adjAmount.divide(quantity, TAX_SCALE,
+                                TAX_ROUNDING));
                         Debug.logInfo("For productId [" + productId + "] added [" + adjAmount.divide(quantity,
-                                salestaxCalcDecimals, salestaxRounding) + "] of tax to price for geoId ["
+                                TAX_SCALE, TAX_ROUNDING) + "] of tax to price for geoId ["
                                 + taxAdjustment.getString("taxAuthGeoId") + "], new price is [" + priceWithTax + "]",
                                 MODULE);
                     }
@@ -153,8 +154,8 @@ public class TaxAuthorityServices {
         }
 
         // round to 2 decimal places for display/etc
-        taxTotal = taxTotal.setScale(salestaxFinalDecimals, salestaxRounding);
-        priceWithTax = priceWithTax.setScale(salestaxFinalDecimals, salestaxRounding);
+        taxTotal = taxTotal.setScale(TAX_FINAL_SCALE, TAX_ROUNDING);
+        priceWithTax = priceWithTax.setScale(TAX_FINAL_SCALE, TAX_ROUNDING);
 
         Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("taxTotal", taxTotal);
@@ -273,7 +274,7 @@ public class TaxAuthorityServices {
         for (GenericValue prod : productWeight.keySet()) {
             BigDecimal value = productWeight.get(prod);
             if (totalPrice.compareTo(BigDecimal.ZERO) > 0) {
-                BigDecimal weight = value.divide(totalPrice, 100, salestaxRounding);
+                BigDecimal weight = value.divide(totalPrice, 100, TAX_ROUNDING);
                 productWeight.put(prod, weight);
             }
         }
@@ -462,8 +463,8 @@ public class TaxAuthorityServices {
                 }
 
                 // taxRate is in percentage, so needs to be divided by 100
-                BigDecimal taxAmount = (taxable.multiply(taxRate)).divide(PERCENT_SCALE, salestaxCalcDecimals,
-                        salestaxRounding);
+                BigDecimal taxAmount = (taxable.multiply(taxRate)).divide(PERCENT_SCALE, TAX_SCALE,
+                        TAX_ROUNDING);
 
                 String taxAuthGeoId = taxAuthorityRateProduct.getString("taxAuthGeoId");
                 String taxAuthPartyId = taxAuthorityRateProduct.getString("taxAuthPartyId");
@@ -594,7 +595,7 @@ public class TaxAuthorityServices {
                     BigDecimal price = productPrice.getBigDecimal("price");
                     BigDecimal baseSubtotal = price.multiply(itemQuantity);
                     BigDecimal baseTaxAmount = (baseSubtotal.multiply(taxRate)).divide(PERCENT_SCALE,
-                            salestaxCalcDecimals, salestaxRounding);
+                            TAX_SCALE, TAX_ROUNDING);
 
                     // tax is not already in price so we want to add it in, but this is a VAT
                     // situation so adjust to make it as accurate as possible