gurkcity / ps_legalcompliance

This module helps merchants in getting compliant with applicable e-commerce law.
Academic Free License v3.0
5 stars 4 forks source link

Option to calculate shipping taxes based on tax rates in cart totally crashes invoices #7

Open rdggithub opened 8 months ago

rdggithub commented 8 months ago

When activating this option (Prestashop 8.1.3) it totally crashes invoice generation (for paypal, bank transfer...)

For invoices with only 19% taxed items the error is: [ErrorException Code 0]: Warning: Trying to access array offset on value of type float

For invoices with mixed taxed items (7%,19%) the error (debug mode) says; Cannot use a scalar value as an array (classes/tools.php line 4033)

In addition, when I disable this option it has the following effect:

Invoices with 19% taxed items are ok.

Invoices having mixed taxes in basket (7%, 19%) are stating tax free shipping instead of using the default setting (19%).

Looks like we have to disable the module because the tax free shipping for mixed items is plain wrong.

criwe commented 8 months ago

Hi! Same here... when activating "Proportionate tax for shipping and wrapping" creating of invoices is not possible anymore.

When having debug mode on: Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: No route found for "GET /sell/orders/377/invoice": Method Not Allowed (Allow: POST)

When disabling the function, the invoice show wrong information (there must be tax):

Zwischenablage01

Without that setting you can´t have the shop legal when having different tax rates :-(

If any more informations are needed, just drop me a line!

Thanks Christoph

Dierk65 commented 6 months ago

Hello everyone,

My English isn't the best and I'm not a trained programmer either. But I took a closer look at the files in question. I found out that the error can probably be found in the file “classes/tax/AverageTaxOfProductsTaxCalculator.php” on line 93. The "id_tax" listed there seems pointless and wrong to me. The whole “if ($price_after_tax) {” query doesn’t seem coherent to me. The value "$price_after_tax" is otherwise not defined anywhere in any shop file. Only and exclusively in this function and in this file... If I now hide the entire "if" request from lines 86 - 95,

if ($price_after_tax) {
            $actual_tax = array_sum($amounts);

            Tools::spreadAmount(
                $price_after_tax - $price_before_tax - $actual_tax,
                $round_precision,
                $amounts,
                'id_tax'
            );
}

even if "Proportionate tax for shipping and wrapping" is activated, I no longer see an error and the taxes are calculated correctly on the invoice - even with a mixed taxation of e.g. 7 % and 19%.

Can someone check this and see if I'm correct? Please respond here too...

Dierk