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 549910411eb68b75f8657e176102b6ef861e7448
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Mon Sep 5 12:09:38 2022 +0200

    Fixed: Tax calculation not considering productStoreGroup (OFBIZ-12686)
    
    For Purchase Orders we need to check for the productstore.
    
    Thanks: Ingo
---
 .../ofbiz/accounting/tax/TaxAuthorityServices.java | 24 +++++++++++++++-------
 1 file changed, 17 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 abc0e64a1a..cb191b5f98 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,23 @@ 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",
-                        "productStoreGroupId", 
productStore.get("primaryStoreGroupId"))
-                .orderBy("-fromDate").filterByDate().queryFirst();
+        if (productStore != null && 
UtilValidate.isNotEmpty(productStore.getString("primaryStoreGroupId"))) {
+            return EntityQuery.use(delegator).from("ProductPrice")
+                    .where("productId", product.get("productId"),
+                            "taxAuthPartyId", taxAuthPartyId,
+                            "taxAuthGeoId", taxAuthGeoId,
+                            "productPricePurposeId", "PURCHASE",
+                            "productStoreGroupId", 
productStore.get("primaryStoreGroupId"))
+                    .orderBy("-fromDate").filterByDate().queryFirst();
+        } else {
+            // Purchase order case
+            return EntityQuery.use(delegator).from("ProductPrice")
+                    .where("productId", product.get("productId"),
+                            "taxAuthPartyId", taxAuthPartyId,
+                            "taxAuthGeoId", taxAuthGeoId,
+                            "productPricePurposeId", "PURCHASE")
+                    .orderBy("-fromDate").filterByDate().queryFirst();
+        }
     }
 
     /**

Reply via email to