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 2022/08/26 17:34:09 UTC
[ofbiz-framework] branch release22.01 updated: 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 release22.01
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release22.01 by this push:
new 0871208ddd Fixed: Tax calculation not considering productStoreGroup (OFBIZ-12686)
0871208ddd is described below
commit 0871208ddd5a0e6d04b5eb1f43d2b47e8929c6d8
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Fri Aug 26 19:28:21 2022 +0200
Fixed: Tax calculation not considering productStoreGroup (OFBIZ-12686)
For one product I have different prices according to the product store:
B2C store: taxinPrice = Y
B2B store: taxinPrice = N
The tax calc service takes the most current price and ignores the product store.
Therefore it may happen that SALES_TAX is calculated instead of VAT_TAX.
Thanks: Ingo Wolfmayr for the initial patch
---
.../ofbiz/accounting/tax/TaxAuthorityServices.java | 40 +++++++++++++---------
1 file changed, 24 insertions(+), 16 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 7691d60109..daafda3ceb 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
@@ -483,21 +483,11 @@ public class TaxAuthorityServices {
if (product != null && taxAuthPartyId != null && taxAuthGeoId != null) {
// find a ProductPrice for the productId and taxAuth* values, and see if it has
// a priceWithTax value
- productPrice = EntityQuery.use(delegator).from("ProductPrice")
- .where("productId", product.get("productId"),
- "taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId,
- "productPricePurposeId", "PURCHASE")
- .orderBy("-fromDate").filterByDate().queryFirst();
-
+ productPrice = getProductPrice(delegator, product, productStore, taxAuthGeoId, taxAuthPartyId);
if (productPrice == null) {
- GenericValue virtualProduct = ProductWorker.getParentProduct(product.getString("productId"),
- delegator);
+ GenericValue virtualProduct = ProductWorker.getParentProduct(product.getString("productId"), delegator);
if (virtualProduct != null) {
- productPrice = EntityQuery.use(delegator).from("ProductPrice")
- .where("productId", virtualProduct.get("productId"),
- "taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId,
- "productPricePurposeId", "PURCHASE")
- .orderBy("-fromDate").filterByDate().queryFirst();
+ productPrice = getProductPrice(delegator, virtualProduct, productStore, taxAuthGeoId, taxAuthPartyId);
}
}
}
@@ -656,11 +646,29 @@ public class TaxAuthorityServices {
}
/**
- * Private helper method which determines, based on the state of the product,
- * how the ProdCondition should be set for the main condition.
* @param delegator
* @param product
- * which may be null
+ * @param productStore
+ * @param taxAuthGeoId
+ * @param taxAuthPartyId
+ * @return productPrice
+ * @throws GenericEntityException
+ */
+ 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();
+ }
+
+ /**
+ * Private helper method which determines, based on the state of the product, how the ProdCondition should be set for the main condition.
+ * @param delegator
+ * @param product which may be null
* @return non-null Condition
* @throws GenericEntityException
*/