Fixed: Tax calculation not considering productStoreGroup
For Purchase Orders we need to check for the productstore.
Thanks: Ingo
@@ -656,6 +656,7 @@ public class TaxAuthorityServices {
*/
private static GenericValue getProductPrice(Delegator delegator, GenericValue product, GenericValue productStore, String taxAuthGeoId,
String taxAuthPartyId) throws GenericEntityException {
+ if (productStore != null && UtilValidate.isNotEmpty(productStore.getString("primaryStoreGroupId"))) {
return EntityQuery.use(delegator).from("ProductPrice")
.where("productId", product.get("productId"),
"taxAuthPartyId", taxAuthPartyId,
@@ -663,6 +664,15 @@ public class TaxAuthorityServices {
"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();
+ }
}
/**
