Account created on 17 February 2018, almost 7 years ago
#

Recent comments

🇩🇪Germany Greenhorn

Due to some reason, The error, I am getting the same error with 5.4.0

yes me too.

patch #26 works for me thanks @rakesh.gectcr

🇩🇪Germany Greenhorn

@idimopoulos, thanks for the patch.

Your patch has successfully solved the issue I was facing, as detailed in this issue: https://www.drupal.org/project/commerce/issues/3184028#comment-15495720 💬 VAT Rounding Error Closed: duplicate

I greatly appreciate your work on this.

I only made one adjustment to the following query:
from

+    if ($adjustments) {
+      foreach ($adjustments as $adjustment) {
+        if (!empty($adjustment['total']) && $adjustment['total'] instanceof Price) {
+          $total = $total->add($adjustment['total']);
+        }
+      }
+    }

to:

+    if ($adjustments) {
+      foreach ($adjustments as $adjustment) {
+        if (!empty($adjustment['total']) && $adjustment['total'] instanceof Price && (isset($adjustment['included']) && !$adjustment['included'])) {
+          $total = $total->add($adjustment['total']);
+        }
+      }
+    }

I made this change because in the order admin view, the total price was being increased by the amounts that were already included in the price, such as taxes in my case. This adjustment ensures that included items, like taxes, are not added again to the total price.

I'll keep an eye on this and will report back if any issues arise that I haven't noticed yet.

Thanks again for your contribution!

🇩🇪Germany Greenhorn

Hello,
I would like to address this problem here again, even though it was a long time ago.
First of all, I would like to thank you, the developers, because anyone can complain but it is always difficult to provide constructive solutions. I would like to help find solutions, but I don't know where to start right now.

Nevertheless the problem still exists. If there is already a patch that I haven't considered, please let me know.

We created a shop with Drupal commerce 8.x-2.38.
The prices in the shop have all been set to include tax.
Now we have the problem that when ordering several products, the tax is not calculated correctly.
We have noticed that the tax is calculated per order item and then added up.
This is not a problem for smaller orders but for multiple items the tax becomes inaccurate.

Here is a simple example with a tax of 7%:
One item costs €4.20 including 7% tax
So the calculation of the tax is:
(4.20 / 107) * 7 = 0.2747... rounded = 0.27, is ok

but for 5 items with the price of 4.20 including tax of 7%
the correct calculation would be:
5 x 4.20 = 21.00
Tax:
(21.00 / 107) *7 = 1.3738... rounded = 1.37 is ok

Since you calculate the tax per order item and then add it up, you get the following tax:
(4.20 / 107) * 7 = 0.2747... rounded = 0.27

0.27 x 5 = 1.35 and that is not correct in a tax country like Germany ;)

Is it possible to create a new property that contains the following per order:
Total tax per tax rate (7%, 19%, .... depending on the settings) only based on the order items and depending on whether tax is included or not.
These values should also be saved in the order as total tax, if that is possible.

Thank you very much and we look forward to a constructive exchange

🇩🇪Germany Greenhorn

Can confirm that this patch is needed to fix a bug in combination with Drupal Commerce. I could not delete order items from order because of this error:

InvalidArgumentException: Field 0 is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (Zeile 587 in /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

Patch #9 was really helpful and issue was resolved. thank you @dhirendra.mishra!

🇩🇪Germany Greenhorn

It works now. We think that having the SDC module now included in Core from Drupal 10.1, you have to follow another process.

we did following steps to make it work:

at first we have disabled following modules:
- sdc:^2.0@alpha
- sdc_examples
- cl_server:^2.0@beta

after that you also can remove entirely following module:
- sdc:^2.0@alpha

Then enable the Core SDC module and cl_server:^2.0@beta,

Now setting up the Storybook works well following these instructions:
https://git.drupalcode.org/project/cl_server/-/blob/2.x/docs/storybook.md

Please note that from Storybook 7 onwards in the ".storybook/main.js"
select only one format. This is also well described in the sdc_examples module in the Readme.md

stories : [
     "../web/themes/**/*.stories.@(json|yml)"
   ],

use

stories : [
     "../web/themes/**/*.stories.yml"
    ],

Many thanks to the developers!

Production build 0.71.5 2024