This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 3160cc3a55 Fixed: Tax calculation not considering productStoreGroup
(OFBIZ-12686)
3160cc3a55 is described below
commit 3160cc3a55f8a6ca7ceb2f55f3bc80cf3c768bcb
Author: Jacques Le Roux <[email protected]>
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
*/