Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to apply rules #10

Open
janoschbatschi opened this issue Nov 18, 2020 · 2 comments
Open

Not possible to apply rules #10

janoschbatschi opened this issue Nov 18, 2020 · 2 comments

Comments

@janoschbatschi
Copy link

janoschbatschi commented Nov 18, 2020

Whenever a rule is applied, an error is thrown:
KCO error: BAD_VALUE: Bad value: order_tax_amount (must be greater than or equal to 0)

Independent of if the rule is applied to subtotal or to each product.

This seems to be due to the cart_total being smaller than the cart_taxFreeTotal which leads to a negative value for order_tax_amount which is not allowed near

'order_tax_amount' => (int) round(

and in the other classes where order_tax_amount is manipulated.

Example: 
	Zwischensumme		 	€ 27,00	 
 	davon Umsatzsteuer	13%	€ 3,11	 
 	Versand (Pauschalversand)	€ 10,00	 
 	Gutschein			€ -20,00	 
 	Bestellsumme		 	€ 17,00	

CartTotal: 17€ 
CartTaxFreeTotal: 37€ (27€+10€)
@janoschbatschi
Copy link
Author

janoschbatschi commented Nov 21, 2020

Obviously, the CartTaxFreeTotal is calculated wrong. If I use the standard Isotope checkout everything works correctly. Using KlarnaCheckout it throws the bad_value error. It seems to be depending on the shipping (taxes or not) and depending on the rules (whole cart or individual items). Once the order_tax_amount is correct but than the order_amount throws the bad value error.

For me following workaround seems to work (KlarnaCheckout.php):
'order_tax_amount' => (int) round(($this->cart->getSubTotal() - $this->cart->getTaxFreeSubTotal()) / $this->cart->getSubTotal() * ($this->cart->getTotal()-$this->cart->getShippingMethod()->price) * 100, 0),

OrderLine.php -> addTotalDiscountAmountForItem()
$this->total_discount_amount += ($surcharge->total_price * (-1));
instead of
$this->total_discount_amount += ($surcharge->getAmountForCollectionItem($this->item) * (-1));

@janoschbatschi
Copy link
Author

janoschbatschi commented Nov 28, 2020

The issue seems to be due to the standard tax (13%) being included in the product. For foreign customers, a different tax is added (e.g. 20%). Klarna complains because the total amount correctly has the 20% tax calculated and the product itself still has 13%. E.g. the formula Klarna checks (https://developers.klarna.com/documentation/klarna-payments/in-depth-knowledge/tax-handling/) is not correct anymore.

Another problem occurs if in the Isotope config the "Preisanzeige" is changed from "Brutto" to "Festgelegt". Then the calculation is also wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant