# MwSt Berechnung in Plug-In korrigieren

**URL:** <https://forum.shopware.com/t/mwst-berechnung-in-plug-in-korrigieren/70363>\
**Category:** Programmierung\
**Created:** [21. Oktober 2020 um 16:37 UTC](https://forum.shopware.com/t/mwst-berechnung-in-plug-in-korrigieren/70363 "2020-10-21T16:37:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaverikMS2001](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@MaverikMS2001](https://forum.shopware.com/u/MaverikMS2001)\
**Post date:** [21. Oktober 2020 um 16:37 UTC](https://forum.shopware.com/t/mwst-berechnung-in-plug-in-korrigieren/70363/1 "2020-10-21T16:37:09Z")

</div>

Hallo zusammen,

ich bin etwas eingerostet was die programmierung betrifft und mein Entwickler ist im Urlaub. Ich habe aber trotzdem versucht das problem zu lösen, stecke aber gerade etwas fest.  
Ich habe ein Plug-In was es ermöglicht ein Artikel nach Fläche berechnen zu lassen. Leider wurde vergessen die verschiedenen Kundengruppen zu berücksichtigen. Somit passiert folgendes. Wenn man sich in einer Kundengruppe befindet in der der Shop Nettopreise anzeigt, wird die Mwst dummerweise nochmal im Warenkorb abgezogen. Ist man normaler EK ist alles fein.

Schaut man sich dann als Händler das Produkt im S\_order\_Basket an so sieht man das beide preise price und netprice gleich sind.

Also auf die Suche im Plug-In und siehe da:

$calculatorArray = $this-\>getBasketItemAreaCalculator($id);

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($calculatorArray) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Preis-Brutto  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $totalPrice = $calculatorArray[‚totalprice‘];

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $taxRate = Shopware()-\>Modules()-\>Articles()-\>getTaxRateByConditions($return[„taxID“]);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $netTotalPrice = $totalPrice / (100.0 + $taxRate) \* 100.0;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $return[‚price‘] = $netTotalPrice;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //alle Basket-Daten ermitteln  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //$basketData = Shopware()-\>Modules()-\>Basket()-\>sGetBasketData();  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $return;

&nbsp; &nbsp; &nbsp; &nbsp; } catch (\Exception $e) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Shopware()-\>PluginLogger()-\>error($e-\>getMessage());  
&nbsp; &nbsp; &nbsp; &nbsp; }

Alles klar. Hier stellt sich schon diue Frage welchen Preis das ganze zurück gibt. Von  
der Logik her würde ich sagen das er price als nettopreis zurück gibt. Allerdings  
ist der preis von SArticle\_price ja immer netto. Also macht das eigentlich keinen Sinn oder?

Da der Fehler schon auftritt wenn man das ganze in den Warenkorb legt habe ich mir nochmal&nbsp;  
sBasket.php angeschaut. Denn in der products.tpl und auch in der cart\_footer.tpl wird ja je  
nach Kundengruppe der Preis Brutto oder Netto ausgegeben.

Meine Idee war diese Abfrage in das Plug-In zu übernehmen. Hier bin ich dann über  
folgende stelle gestolpert:&nbsp;public function sGetBasketData()

&nbsp;if (!empty($result[‚content‘])) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach ($result[‚content‘] as $key =\> $value) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!empty($value[‚amountWithTax‘])) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t = round((float) str\_replace(’,’, ‚.‘, $value[‚amountWithTax‘]), 2);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t = str\_replace(’,’, ‚.‘, $value[‚price‘]);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t = (float) round($t \* $value[‚quantity‘], 2);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!$this-\>sSYSTEM-\>sUSERGROUPDATA[‚tax‘] && $this-\>sSYSTEM-\>sUSERGROUPDATA[‚id‘]) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $p = (float) $this-\>moduleManager-\>Articles()-\>sRound(  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-\>moduleManager-\>Articles()-\>sRound(round($value[‚netprice‘], 2) \* $value[‚quantity‘])  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $p = (float) $this-\>moduleManager-\>Articles()-\>sRound(  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-\>moduleManager-\>Articles()-\>sRound($value[‚netprice‘] \* $value[‚quantity‘])  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $calcDifference = $this-\>moduleManager-\>Articles()-\>sFormatPrice($t - $p);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result[‚content‘][$key][‚tax‘] = $calcDifference;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; }

In der Usergroup steht ja tax=1 für brutto und 0 für netto. Allerdings versteh ich ich hier nicht  
wie er das ermittelt. Er fragt nach meinem Verständnis nur ab ob amountWithTax leer ist.

Als ich dann in die Templates geschaut habe, das die unterschiedlichen Werte als:&nbsp;  
$sAmountWithTax und $sAmount ausgegeben werden war ich TILT. 🙂

Kann mir hier jemand vielleicht sagen wie ich das am besten anstelle und wo ich  
die Variablen her bekomme das ich die Abfrage ins Plug-In bekomme? Vielleicht ist  
mein Ansatz aber auch komplett falsch, da ich nicht so tief in der Produktkallkulation  
von Shopware drin bin. Mein Part sind eher Themes 🙂

Ich bedanke mich schonmal bei allen für die Hilfe.
