Improved: Replace deprecated BigDecimal.ROUND_HALF by  RoundingMode.HALF (OFBIZ-13103)

Address this deprecation

int java.math.BigDecimal.ROUND_HALF_UP
Deprecated. Use RoundingMode.HALF_UP instead.

Rounding mode to round towards "nearest neighbor" unless both neighbors are
equidistant, in which case round up. Behaves as for ROUND_UP if the discarded
fraction is ≥ 0.5; otherwise, behaves as for ROUND_DOWN. Note that this is the
rounding mode that most of us were taught in grade school.
diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/admin/AcctgAdminServices.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/admin/AcctgAdminServices.groovy
index 1a4dda7..46a6c9e 100644
--- a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/admin/AcctgAdminServices.groovy
+++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/admin/AcctgAdminServices.groovy
@@ -19,10 +19,12 @@
 package org.apache.ofbiz.accounting.admin
 
 import java.sql.Timestamp
+import java.math.RoundingMode
+
 import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.base.util.UtilProperties
-import org.apache.ofbiz.entity.condition.EntityConditionBuilder
 import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.condition.EntityConditionBuilder
 import org.apache.ofbiz.entity.util.EntityUtil
 import org.apache.ofbiz.service.ModelService
 
@@ -156,7 +158,7 @@
 
     BigDecimal conversionRate
     int decimalScale = 2
-    int roundingMode = BigDecimal.ROUND_HALF_UP
+    int roundingMode = RoundingMode.ROUND_HALF_UP
     if (rates) {
         conversionFactor = EntityUtil.getFirst(rates).getBigDecimal('conversionFactor')
         BigDecimal originalValue = BigDecimal.ONE
diff --git a/applications/party/src/main/groovy/org/apache/ofbiz/party/party/PartyFinancialHistory.groovy b/applications/party/src/main/groovy/org/apache/ofbiz/party/party/PartyFinancialHistory.groovy
index aaca58f..88b30fb 100644
--- a/applications/party/src/main/groovy/org/apache/ofbiz/party/party/PartyFinancialHistory.groovy
+++ b/applications/party/src/main/groovy/org/apache/ofbiz/party/party/PartyFinancialHistory.groovy
@@ -18,6 +18,8 @@
 */
 package org.apache.ofbiz.party.party
 
+import java.math.RoundingMode
+
 import org.apache.ofbiz.accounting.invoice.InvoiceWorker
 import org.apache.ofbiz.accounting.payment.PaymentWorker
 import org.apache.ofbiz.entity.condition.EntityCondition
@@ -61,12 +63,12 @@
     Boolean isSalesInvoice = EntityTypeUtil.hasParentType(delegator, 'InvoiceType', 'invoiceTypeId', (String) invoice.getString('invoiceTypeId'),
             'parentTypeId', 'SALES_INVOICE')
     if (isPurchaseInvoice) {
-        totalInvPuApplied += InvoiceWorker.getInvoiceApplied(invoice, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
-        totalInvPuNotApplied += InvoiceWorker.getInvoiceNotApplied(invoice, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
+        totalInvPuApplied += InvoiceWorker.getInvoiceApplied(invoice, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
+        totalInvPuNotApplied += InvoiceWorker.getInvoiceNotApplied(invoice, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
     }
     else if (isSalesInvoice) {
-        totalInvSaApplied += InvoiceWorker.getInvoiceApplied(invoice, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
-        totalInvSaNotApplied += InvoiceWorker.getInvoiceNotApplied(invoice, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
+        totalInvSaApplied += InvoiceWorker.getInvoiceApplied(invoice, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
+        totalInvSaNotApplied += InvoiceWorker.getInvoiceNotApplied(invoice, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
     }
     else {
         logError('InvoiceType: ' + invoice.invoiceTypeId + ' without a valid parentTypeId: ' + invoice.parentTypeId
@@ -101,12 +103,12 @@
 while (payIterator.next()) {
     payment = payIterator.next()
     if (payment.parentTypeId == 'DISBURSEMENT' || payment.parentTypeId == 'TAX_PAYMENT') {
-        totalPayOutApplied += PaymentWorker.getPaymentApplied(payment, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
-        totalPayOutNotApplied += PaymentWorker.getPaymentNotApplied(payment, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
+        totalPayOutApplied += PaymentWorker.getPaymentApplied(payment, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
+        totalPayOutNotApplied += PaymentWorker.getPaymentNotApplied(payment, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
     }
     else if (payment.parentTypeId == 'RECEIPT') {
-        totalPayInApplied += PaymentWorker.getPaymentApplied(payment, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
-        totalPayInNotApplied += PaymentWorker.getPaymentNotApplied(payment, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
+        totalPayInApplied += PaymentWorker.getPaymentApplied(payment, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
+        totalPayInNotApplied += PaymentWorker.getPaymentNotApplied(payment, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
     }
     else {
         logError('PaymentTypeId: ' + payment.paymentTypeId + ' without a valid parentTypeId: ' + payment.parentTypeId
diff --git a/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedInvoicesForParty.groovy b/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedInvoicesForParty.groovy
index 61ab4c8..d802a46 100644
--- a/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedInvoicesForParty.groovy
+++ b/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedInvoicesForParty.groovy
@@ -18,6 +18,8 @@
 */
 package org.apache.ofbiz.party.party
 
+import java.math.RoundingMode
+
 import org.apache.ofbiz.accounting.invoice.InvoiceWorker
 import org.apache.ofbiz.entity.condition.EntityCondition
 import org.apache.ofbiz.entity.condition.EntityOperator
@@ -48,7 +50,7 @@
 invoiceList = []
 while (invIterator.next()) {
     invoice = invIterator.next()
-    unAppliedAmount = InvoiceWorker.getInvoiceNotApplied(invoice, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
+    unAppliedAmount = InvoiceWorker.getInvoiceNotApplied(invoice, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
     if (unAppliedAmount.signum() == 1) {
         if (actualCurrency == true) {
             invoiceCurrencyUomId = invoice.currencyUomId
@@ -59,7 +61,7 @@
                          invoiceDate: invoice.invoiceDate,
                          unAppliedAmount: unAppliedAmount,
                          invoiceCurrencyUomId: invoiceCurrencyUomId,
-                         amount: InvoiceWorker.getInvoiceTotal(invoice, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP),
+                         amount: InvoiceWorker.getInvoiceTotal(invoice, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP),
                          invoiceTypeId: invoice.invoiceTypeId,
                          invoiceParentTypeId: invoice.parentTypeId])
     }
diff --git a/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedPaymentsForParty.groovy b/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedPaymentsForParty.groovy
index 1860746..d105889 100644
--- a/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedPaymentsForParty.groovy
+++ b/applications/party/src/main/groovy/org/apache/ofbiz/party/party/UnAppliedPaymentsForParty.groovy
@@ -18,6 +18,8 @@
 */
 package org.apache.ofbiz.party.party
 
+import java.math.RoundingMode
+
 import org.apache.ofbiz.accounting.payment.PaymentWorker
 import org.apache.ofbiz.entity.util.EntityFindOptions
 import org.apache.ofbiz.entity.condition.EntityCondition
@@ -50,7 +52,7 @@
 
 while (payIterator.next()) {
     payment = payIterator.next()
-    unAppliedAmount = PaymentWorker.getPaymentNotApplied(payment, actualCurrency).setScale(2, BigDecimal.ROUND_HALF_UP)
+    unAppliedAmount = PaymentWorker.getPaymentNotApplied(payment, actualCurrency).setScale(2, RoundingMode.ROUND_HALF_UP)
     if (unAppliedAmount.signum() == 1) {
         if (actualCurrency == true && payment.actualCurrencyAmount && payment.actualCurrencyUomId) {
             amount = payment.actualCurrencyAmount
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/catalog/product/BestProducts.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/catalog/product/BestProducts.groovy
index eb9ba80..1ec7153 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/catalog/product/BestProducts.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/catalog/product/BestProducts.groovy
@@ -18,6 +18,8 @@
 */
 package org.apache.ofbiz.product.catalog.product
 
+import java.math.RoundingMode
+
 import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.entity.condition.EntityCondition
 import org.apache.ofbiz.entity.condition.EntityOperator
@@ -92,7 +94,7 @@
     }
     if (!orderItemDetail.isEmpty()) {
         if (orderItemDetail.amount) {
-            orderItemDetail.amount = orderItemDetail.amount.setScale(2, BigDecimal.ROUND_HALF_UP)
+            orderItemDetail.amount = orderItemDetail.amount.setScale(2, RoundingMode.ROUND_HALF_UP)
         }
         topSellingProducts.add(orderItemDetail)
         bestSellingProducts.remove(orderItemDetail)
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
index 0eac51b..048c1c4 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
@@ -217,7 +217,7 @@
      * Method to get BigDecimal rounding mode from a property
      * @param   file     - Name of the property file
      * @param   property - Name of the config property from ARITH_PROP_FILE (e.g., "invoice.rounding")
-     * @return  int - Rounding mode to pass to BigDecimal's methods. Defaults to BigDecimal.ROUND_HALF_UP
+     * @return  int - Rounding mode to pass to BigDecimal's methods. Defaults to RoundingMode.ROUND_HALF_UP
      * @deprecated Use {@link #getRoundingMode(String, String)} instead
      */
     @Deprecated
@@ -228,7 +228,7 @@
     /**
      * Method to get BigDecimal rounding mode from a property. Use the default ARITH_PROP_FILE properties file
      * @param   property - Name of the config property from ARITH_PROP_FILE (e.g., "invoice.rounding")
-     * @return  int - Rounding mode to pass to BigDecimal's methods. Defaults to BigDecimal.ROUND_HALF_UP
+     * @return  int - Rounding mode to pass to BigDecimal's methods. Defaults to RoundingMode.ROUND_HALF_UP
      * @deprecated Use {@link #getRoundingMode(String)} instead
      */
     @Deprecated