You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2024/02/22 11:48:58 UTC

(ofbiz-framework) 02/04: Fixed: Tax calculation not considering productStoreGroup (OFBIZ-12686)

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

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

commit c419a774cb9504452ca6fd2f4efcd4d79b53d45c
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Sat Aug 27 10:13:23 2022 +0200

    Fixed: Tax calculation not considering productStoreGroup (OFBIZ-12686)
    
    By default OOTB there is no primaryStoreGroupId. So a test fails because of that.
    This checks that it's present before searching for it.
    
    I did not check it's related but maybe a look at how it's handled in
    PriceServices::calculateProductPrice might help to possibly enhance.
---
 .../ofbiz/accounting/tax/TaxAuthorityServices.java | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

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 cbc12da540..0704c2e07b 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
@@ -659,13 +659,22 @@ public class TaxAuthorityServices {
      */
     private static GenericValue getProductPrice(Delegator delegator, GenericValue product, GenericValue productStore, String taxAuthGeoId,
             String taxAuthPartyId) throws GenericEntityException {
-        return EntityQuery.use(delegator).from("ProductPrice")
-                .where("productId", product.get("productId"),
-                        "taxAuthPartyId", taxAuthPartyId,
-                        "taxAuthGeoId", taxAuthGeoId,
-                        "productPricePurposeId", "PURCHASE",
-                        "productStoreId", productStore.get("primaryStoreGroupId"))
-                .orderBy("-fromDate").filterByDate().queryFirst();
+        if (UtilValidate.isNotEmpty(productStore.getString("primaryStoreGroupId"))) {
+            return EntityQuery.use(delegator).from("ProductPrice")
+                    .where("productId", product.get("productId"),
+                            "taxAuthPartyId", taxAuthPartyId,
+                            "taxAuthGeoId", taxAuthGeoId,
+                            "productPricePurposeId", "PURCHASE",
+                            "productStoreId", productStore.get("primaryStoreGroupId"))
+                    .orderBy("-fromDate").filterByDate().queryFirst();
+        } else {
+            return EntityQuery.use(delegator).from("ProductPrice")
+                    .where("productId", product.get("productId"),
+                            "taxAuthPartyId", taxAuthPartyId,
+                            "taxAuthGeoId", taxAuthGeoId,
+                            "productPricePurposeId", "PURCHASE")
+                            .orderBy("-fromDate").filterByDate().queryFirst();
+        }
     }
 
     /**