# Gutschrift erstellen

**URL:** <https://forum.shopware.com/t/gutschrift-erstellen/7304>\
**Category:** Shopware 3.5\
**Tags:** administration\
**Created:** [5. Juni 2012 um 13:46 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304 "2012-06-05T13:46:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Headake](https://avatars.discourse-cdn.com/v4/letter/h/c6cbf5/32.png) [@Headake](https://forum.shopware.com/u/Headake)\
**Post date:** [5. Juni 2012 um 13:46 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304/1 "2012-06-05T13:46:05Z")

</div>

Hallo, wer kann helfen? Ich müsste dringend wissen, wie ich im Shopware Backend korrekt eine Gutschrift erstelle, so dass buchhalterisch alles seine Richtigkeit hat. Vielen Dank vorab für jede Hilfe! 🙂

---

<div class="post-metadata">

**Author:** ![artep](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@artep](https://forum.shopware.com/u/artep)\
**Post date:** [5. Juni 2012 um 17:29 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304/2 "2012-06-05T17:29:37Z")

</div>

Da gehst Du auf die Bestellung auf Positionen und änderst dort die Stückzahl auf 0 die nicht zur Gutschrift gehören und speicherst ab. Evtl. noch die Versandkosten löschen in den Stammdaten wenn diese nicht zum Gutschriftumfang gehören. Dann auf Belege, dort auf Gutschrift umstellen und Beleg generieren. Anschließend Stückzahl wieder in die Normale bringen! Ist leider mit Aufwand verbunden. Wünsche mir da auch eine Vereinfachung! Genauso ist es mit Nach/bzw. Teillieferungen!

---

<div class="post-metadata">

**Author:** ![jipo](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jipo](https://forum.shopware.com/u/jipo)\
**Post date:** [5. Juni 2012 um 19:09 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304/3 "2012-06-05T19:09:51Z")

</div>

Hi, das ist aber nicht gerade die komfortable Version. Wir haben das anders gelöst und zwar: alle Artikel die in der Gutschrift sein sollen - werden unter Bestellung - Positionen auf STORNIERT gesetzt und dann haben wir den Code um eine paar Zeilen angepasst. Wir haben in der Datei /engine/shopware/models/Order.php echt nur wenige Zeilen geändert u.a. auch das wir bei einer Gutschrift die Versandkosten nicht mit gutschreiben 😉 Anbei der Code der gesamten Datei: bitte nach “JIPO” suchen - dort sind die Änderungen kommentiert. Bei Fragen einfach melden. Ach so unsere Shopware Version ist 3.5.3 [quote]\<?php /\*\*

- Shopware order model

- @link [http://www.shopware.de](http://www.shopware.de)

- @package Models

- @subpackage Order

- @copyright © Shopware AG 2002-2010

- @version Shopware 3.5.0  
_/  
class Shopware\_Models\_Order extends Enlight\_Class implements Enlight\_Hook  
{  
/_\*

Farbe: gelb";s:6:“status”;s:1:“0”;s:7:“shipped”;s:1:“0”;s:12:“shippedgroup”;s:1:“0”;s:11:“releasedate”;s:10:“0000-00-00”;s:5:“modus”;s:1:“0”;s:10:“esdarticle”;s:1:“0”;s:5:“taxID”;s:1:“1”;s:6:“config”;s:0:"";s:8:“od\_attr1”;s:0:"";s:8:“od\_attr2”;s:0:"";s:8:“od\_attr3”;s:0:"";s:8:“od\_attr4”;s:0:"";s:8:“od\_attr5”;s:0:"";s:8:“od\_attr6”;s:0:"";s:5:“attr1”;s:0:"";s:5:“attr2”;s:0:"";s:5:“attr3”;s:0:"";s:5:“attr4”;s:0:"";s:5:“attr5”;s:0:"";s:5:“attr6”;s:0:"";s:5:“attr7”;s:0:"";s:5:“attr8”;s:0:"";s:5:“attr9”;s:0:"";s:6:“attr10”;s:0:"";s:6:“attr11”;s:0:"";s:6:“attr12”;s:0:"";s:6:“attr13”;s:0:"";s:6:“attr14”;s:0:"";s:6:“attr15”;s:0:"";s:6:“attr16”;s:0:"";s:6:“attr17”;s:10:“0000-00-00”;s:6:“attr18”;s:0:"";s:6:“attr19”;s:0:"";s:6:“attr20”;s:0:"";s:4:“meta”;b:0;s:3:“tax”;s:2:“19”;s:5:“netto”;d:84.025210084033602697672904469072818756103515625;s:12:“amount\_netto”;d:84.025210084033602697672904469072818756103515625;s:6:“amount”;d:99.9899999999999948840923025272786617279052734375;}i:1;a:47:{s:2:“id”;s:2:“39”;s:7:“orderID”;s:2:“13”;s:11:“ordernumber”;s:5:“10080”;s:9:“articleID”;s:1:“0”;s:18:“articleordernumber”;s:11:“sw-discount”;s:5:“price”;d:-2.100000000000000088817841970012523233890533447265625;s:8:“quantity”;s:1:“1”;s:4:“name”;s:21:"- 2 % Warenkorbrabatt";s:6:“status”;s:1:“0”;s:7:“shipped”;s:1:“0”;s:12:“shippedgroup”;s:1:“0”;s:11:“releasedate”;s:10:“0000-00-00”;s:5:“modus”;s:1:“3”;s:10:“esdarticle”;s:1:“0”;s:5:“taxID”;s:1:“0”;s:6:“config”;s:0:"";s:8:“od\_attr1”;s:0:"";s:8:“od\_attr2”;s:0:"";s:8:“od\_attr3”;s:0:"";s:8:“od\_attr4”;s:0:"";s:8:“od\_attr5”;s:0:"";s:8:“od\_attr6”;s:0:"";s:5:“attr1”;N;s:5:“attr2”;N;s:5:“attr3”;N;s:5:“attr4”;N;s:5:“attr5”;N;s:5:“attr6”;N;s:5:“attr7”;N;s:5:“attr8”;N;s:5:“attr9”;N;s:6:“attr10”;N;s:6:“attr11”;N;s:6:“attr12”;N;s:6:“attr13”;N;s:6:“attr14”;N;s:6:“attr15”;N;s:6:“attr16”;N;s:6:“attr17”;N;s:6:“attr18”;N;s:6:“attr19”;N;s:6:“attr20”;N;s:4:“meta”;b:0;s:3:“tax”;s:2:“19”;s:5:“netto”;d:-1.76470588235294112422479884116910398006439208984375;s:12:“amount\_netto”;d:-1.76470588235294112422479884116910398006439208984375;s:6:“amount”;d:-2.100000000000000088817841970012523233890533447265625;}i:2;a:47:{s:2:“id”;s:2:“38”;s:7:“orderID”;s:2:“13”;s:11:“ordernumber”;s:5:“10080”;s:9:“articleID”;s:1:“0”;s:18:“articleordernumber”;s:12:“sw-surcharge”;s:5:“price”;d:5;s:8:“quantity”;s:1:“1”;s:4:“name”;s:20:“Mindermengenzuschlag”;s:6:“status”;s:1:“0”;s:7:“shipped”;s:1:“0”;s:12:“shippedgroup”;s:1:“0”;s:11:“releasedate”;s:10:“0000-00-00”;s:5:“modus”;s:1:“4”;s:10:“esdarticle”;s:1:“0”;s:5:“taxID”;s:1:“0”;s:6:“config”;s:0:"";s:8:“od\_attr1”;s:0:"";s:8:“od\_attr2”;s:0:"";s:8:“od\_attr3”;s:0:"";s:8:“od\_attr4”;s:0:"";s:8:“od\_attr5”;s:0:"";s:8:“od\_attr6”;s:0:"";s:5:“attr1”;N;s:5:“attr2”;N;s:5:“attr3”;N;s:5:“attr4”;N;s:5:“attr5”;N;s:5:“attr6”;N;s:5:“attr7”;N;s:5:“attr8”;N;s:5:“attr9”;N;s:6:“attr10”;N;s:6:“attr11”;N;s:6:“attr12”;N;s:6:“attr13”;N;s:6:“attr14”;N;s:6:“attr15”;N;s:6:“attr16”;N;s:6:“attr17”;N;s:6:“attr18”;N;s:6:“attr19”;N;s:6:“attr20”;N;s:4:“meta”;b:0;s:3:“tax”;s:2:“19”;s:5:“netto”;d:4.20168067226890773468994666473008692264556884765625;s:12:“amount\_netto”;d:4.20168067226890773468994666473008692264556884765625;s:6:“amount”;i:5;}i:3;a:9:{s:8:“quantity”;i:1;s:5:“netto”;d:14.28571428571428469922466319985687732696533203125;s:3:“tax”;s:2:“19”;s:5:“price”;s:2:“17”;s:6:“amount”;s:2:“17”;s:5:“modus”;i:1;s:12:“amount\_netto”;d:14.28571428571428469922466319985687732696533203125;s:18:“articleordernumber”;s:0:"";s:4:“name”;s:13:“Versandkosten”;}}";s:7:"\_userID";s:1:“5”;s:5:"\_user";s:586:“O:11:“ArrayObject”:19:{s:2:“[id";s:1:“5”;s:8:“password”;s:32:“a15370144783d9da799fcfacb99a881d”;s:5:“email”;s:14:"sk@shopware.de](mailto:id%22;s:1:%225%22;s:8:%22password%22;s:32:%22a15370144783d9da799fcfacb99a881d%22;s:5:%22email%22;s:14:%22sk@shopware.de)”;s:6:“active”;s:1:“1”;s:11:“accountmode”;s:1:“0”;s:15:“confirmationkey”;s:0:”";s:9:“paymentID”;s:1:“5”;s:10:“firstlogin”;s:10:“2010-09-27”;s:9:“lastlogin”;s:19:“2010-09-27 18:01:47”;s:9:“sessionID”;s:26:“10pfde4j8usf5u5i9sr647aoi6”;s:10:“newsletter”;s:1:“0”;s:10:“validation”;s:0:"";s:9:“affiliate”;s:1:“0”;s:13:“customergroup”;s:2:“EK”;s:13:“paymentpreset”;s:1:“0”;s:8:“language”;s:2:“de”;s:9:“subshopID”;s:1:“1”;s:7:“referer”;s:0:"";s:12:“pricegroupID”;N;}";s:8:"\_billing";s:966:“O:11:“ArrayObject”:24:{s:2:“id”;s:2:“13”;s:6:“userID”;s:1:“5”;s:7:“orderID”;s:2:“13”;s:7:“company”;s:0:”";s:10:“department”;s:0:"";s:10:“salutation”;s:2:“mr”;s:14:“customernumber”;s:5:“20033”;s:9:“firstname”;s:9:“Sebastian”;s:8:“lastname”;s:7:“Klöpper”;s:6:“street”;s:11:“Hauptstraße”;s:12:“streetnumber”;s:2:“36”;s:7:“zipcode”;s:5:“48624”;s:4:“city”;s:11:“Schöppingen”;s:5:“phone”;s:12:“02555-997500”;s:3:“fax”;s:0:"";s:9:“countryID”;s:1:“2”;s:5:“ustid”;s:0:"";s:5:“text1”;s:0:"";s:5:“text2”;s:0:"";s:5:“text3”;s:0:"";s:5:“text4”;s:0:"";s:5:“text5”;s:0:"";s:5:“text6”;s:0:"";s:7:“country”;O:11:“ArrayObject”:13:{s:2:“id”;s:1:“2”;s:11:“countryname”;s:11:“Deutschland”;s:10:“countryiso”;s:2:“DE”;s:11:“countryarea”;s:11:“deutschland”;s:9:“countryen”;s:7:“GERMANY”;s:8:“position”;s:1:“1”;s:6:“notice”;s:0:"";s:12:“shippingfree”;s:1:“0”;s:7:“taxfree”;s:1:“0”;s:13:“taxfree\_ustid”;s:1:“0”;s:21:“taxfree\_ustid\_checked”;s:1:“0”;s:6:“active”;s:1:“1”;s:4:“iso3”;s:3:“DEU”;}}";s:9:"\_shipping";s:864:“O:11:“ArrayObject”:20:{s:2:“id”;s:2:“13”;s:6:“userID”;s:1:“5”;s:7:“orderID”;s:2:“13”;s:7:“company”;s:0:”";s:10:“department”;s:0:"";s:10:“salutation”;s:2:“mr”;s:9:“firstname”;s:9:“Sebastian”;s:8:“lastname”;s:7:“Klöpper”;s:6:“street”;s:11:“Hauptstraße”;s:12:“streetnumber”;s:2:“36”;s:7:“zipcode”;s:5:“48624”;s:4:“city”;s:11:“Schöppingen”;s:9:“countryID”;s:1:“2”;s:5:“text1”;s:0:"";s:5:“text2”;s:0:"";s:5:“text3”;s:0:"";s:5:“text4”;s:0:"";s:5:“text5”;s:0:"";s:5:“text6”;s:0:"";s:7:“country”;O:11:“ArrayObject”:13:{s:2:“id”;s:1:“2”;s:11:“countryname”;s:11:“Deutschland”;s:10:“countryiso”;s:2:“DE”;s:11:“countryarea”;s:11:“deutschland”;s:9:“countryen”;s:7:“GERMANY”;s:8:“position”;s:1:“1”;s:6:“notice”;s:0:"";s:12:“shippingfree”;s:1:“0”;s:7:“taxfree”;s:1:“0”;s:13:“taxfree\_ustid”;s:1:“0”;s:21:“taxfree\_ustid\_checked”;s:1:“0”;s:6:“active”;s:1:“1”;s:4:“iso3”;s:3:“DEU”;}}";s:8:"\_payment";s:563:“O:11:“ArrayObject”:16:{s:2:“id”;s:1:“5”;s:4:“name”;s:10:“prepayment”;s:11:“description”;s:8:“Vorkasse”;s:8:“template”;s:14:“prepayment.tpl”;s:5:“class”;s:14:“prepayment.php”;s:5:“table”;s:0:”";s:4:“hide”;s:1:“0”;s:21:“additionaldescription”;s:107:“Sie zahlen einfach vorab und erhalten die Ware bequem und günstig bei Zahlungseingang nach Hause geliefert.”;s:13:“debit\_percent”;s:1:“0”;s:9:“surcharge”;s:1:“0”;s:15:“surchargestring”;s:0:"";s:8:“position”;s:1:“1”;s:6:“active”;s:1:“1”;s:9:“esdactive”;s:1:“0”;s:11:“embediframe”;s:0:"";s:12:“hideprospect”;s:1:“0”;}";s:9:"\_dispatch";s:83:“O:11:“ArrayObject”:2:{s:4:“name”;s:15:“Express Versand”;s:11:“description”;s:0:”";}";s:4:"\_net";b:0;s:11:"\_summaryNet";b:0;s:12:"\_amountNetto";d:100.74789915966385933643323369324207305908203125;s:7:"\_amount";d:119.8900000000000005684341886080801486968994140625;s:4:"\_tax";a:1:{i:19;d:19.14210084033613412657359731383621692657470703125;}s:9:"\_currency";s:115:“O:11:“ArrayObject”:4:{s:8:“currency”;s:3:“EUR”;s:4:“name”;s:4:“Euro”;s:6:“factor”;s:1:“1”;s:4:“char”;s:6:“€”;}”;s:14:"\_shippingCosts";s:2:“17”;s:24:"\_shippingCostsAsPosition";b:1;s:9:"\_discount";d:-2.100000000000000088817841970012523233890533447265625;}’;

```
		if (floatval(phpversion()) >= 5.3){ $test = $php53; }else { $test = $php52; } $test = unserialize($test); foreach ($test as $key =\> $v){ if (preg\_match("/\{/",$v)){ $this-\>$key = unserialize($v); }else { $this-\>$key = $v; } } return; } $this-\>\_id = $id; $this-\>\_typ = $typ; /\*\*\* JIPO \*\*\*/ $this-\>\_summaryNet = isset($config["summaryNet"]) ? $config["summaryNet"] : false; $this-\>\_shippingCostsAsPosition = isset($config["shippingCostsAsPosition"]) ? $config["shippingCostsAsPosition"] : false; $this-\>getOrder(); $this-\>getPositions(); $this-\>getUser(); $this-\>getBilling(); $this-\>getShipping(); $this-\>getDispatch(); $this-\>getPayment(); $this-\>processPositions(); $this-\>processOrder(); /\*$array = $this-\>\_\_toArray(); $array["\_order"] = serialize(new ArrayObject($array["\_order"])); $array["\_positions"] =serialize(new ArrayObject($array["\_positions"])); $array["\_user"] = serialize(new ArrayObject($array["\_user"])); $array["\_billing"] = serialize(new ArrayObject($array["\_billing"])); $array["\_shipping"] = serialize(new ArrayObject($array["\_shipping"])); $array["\_payment"] = serialize(new ArrayObject($array["\_payment"])); $array["\_dispatch"] = serialize(new ArrayObject($array["\_dispatch"])); $array["\_currency"] = serialize(new ArrayObject($array["\_currency"])); die(serialize($array)); print\_r($array);exit;\*/ } public function getOrder(){ $this-\>\_order = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT s\_order.\*,s\_core\_currencies.factor,s\_core\_currencies.id AS currencyID,s\_core\_currencies.templatechar,s\_core\_currencies.name AS currencyName FROM s\_order LEFT JOIN s\_core\_currencies ON s\_core\_currencies.currency = s\_order.currency WHERE s\_order.id = ? ",array($this-\>\_id)), ArrayObject::ARRAY\_AS\_PROPS); if (empty($this-\>\_order["id"])){ throw new Enlight\_Exception ("Order with id $id not found!"); } $this-\>\_userID = $this-\>\_order["userID"]; if (!empty($this-\>\_order["net"]))$this-\>\_net = true; else $this-\>\_net = false; $this-\>\_currency = new ArrayObject(array("currency"=\>$this-\>\_order["currency"],"name"=\>$this-\>\_order["currencyName"],"factor"=\>$this-\>\_order["factor"],"char"=\>$this-\>\_order["templatechar"]), ArrayObject::ARRAY\_AS\_PROPS); } public function \_\_toArray(){ $array = get\_object\_vars($this); $array["\_order"] = $array["\_order"]-\>getArrayCopy(); $array["\_positions"] = $array["\_positions"]-\>getArrayCopy(); $array["\_user"] = $array["\_user"]-\>getArrayCopy(); $array["\_billing"] = $array["\_billing"]-\>getArrayCopy(); $array["\_shipping"] = $array["\_shipping"]-\>getArrayCopy(); $array["\_payment"] = $array["\_payment"]-\>getArrayCopy(); $array["\_dispatch"] = $array["\_dispatch"]-\>getArrayCopy(); $array["\_currency"] = $array["\_currency"]-\>getArrayCopy(); //$array["\_order"] = current($array["\_order"]); return $array; } public function processOrder(){ $sql = " SELECT `value` as tax FROM s\_core\_config WHERE name='sTAXSHIPPING' AND ROUND(?\*100/(100+`value`),2)=? UNION SELECT tax FROM `s_core_tax` WHERE ROUND(?\*100/(100+tax),2)=? "; $taxShipping = Shopware()-\>Db()-\>fetchOne($sql,array( $this-\>\_order["invoice\_shipping"], $this-\>\_order["invoice\_shipping\_net"], $this-\>\_order["invoice\_shipping"], $this-\>\_order["invoice\_shipping\_net"] )); if ($this-\>\_typ != 2){ // JIPO: Keine Versandkosten auf der Gutschrift if ($this-\>\_order["taxfree"]){ $this-\>\_amountNetto = $this-\>\_amountNetto + $this-\>\_order["invoice\_shipping"]; }else { $this-\>\_amountNetto = $this-\>\_amountNetto + ($this-\>\_order["invoice\_shipping"]/(100+$taxShipping)\*100); if(!empty($taxShipping)) { $this-\>\_tax[$taxShipping] += ($this-\>\_order["invoice\_shipping"]/(100+$taxShipping))\*$taxShipping; } } $this-\>\_amount = $this-\>\_amount + $this-\>\_order["invoice\_shipping"]; $this-\>\_shippingCosts = $this-\>\_order["invoice\_shipping"]; } if ($this-\>\_shippingCostsAsPosition == true && $this-\>\_typ != 2){ // JIPO: Keine Versandkosten auf der Gutschrift $shipping = array(); $shipping['quantity'] = 1; if ($this-\>\_order["taxfree"]){ $shipping['netto'] = $this-\>\_shippingCosts; $shipping['tax'] = 0; }else { $shipping['netto'] = $this-\>\_shippingCosts/(100+$taxShipping)\*100; $shipping['tax'] = $taxShipping; } $shipping['price'] = $this-\>\_shippingCosts; $shipping['amount'] = $shipping['price']; $shipping["modus"] = 1; $shipping['amount\_netto'] = $shipping['netto']; $shipping['articleordernumber'] = ""; $shipping['name'] = "Versandkosten"; $this-\>positions[] = $shipping; } } public function getPositions(){ if ($this-\>\_typ == 2) { // JIPO: Gutschrift nur Storno-Positionen $this-\>\_positions = new ArrayObject(Shopware()-\>Db()-\>fetchAll(" SELECT od.\*, at.attr1, at.attr2, at.attr3, at.attr4, at.attr5, at.attr6, at.attr7, at.attr8, at.attr9, at.attr10, at.attr11, at.attr12, at.attr13, at.attr14, at.attr15, at.attr16, at.attr17, at.attr18, at.attr19, at.attr20 FROM s\_order\_details od LEFT JOIN s\_articles\_groups\_value g ON g.ordernumber=od.articleordernumber AND g.articleID=od.articleID AND od.modus=0 LEFT JOIN s\_articles\_details d ON (g.articleID=d.articleID OR d.ordernumber=od.articleordernumber) AND d.articleID=od.articleID AND od.modus=0 LEFT JOIN s\_articles\_attributes at ON at.articledetailsID=d.id WHERE od.orderID=? AND od.status = 2 ORDER BY od.modus ASC ",array($this-\>\_id)), ArrayObject::ARRAY\_AS\_PROPS); } elseif ($this-\>\_typ == 3) { // JIPO: Stornorechnung mit allen Positionen $this-\>\_positions = new ArrayObject(Shopware()-\>Db()-\>fetchAll(" SELECT od.\*, at.attr1, at.attr2, at.attr3, at.attr4, at.attr5, at.attr6, at.attr7, at.attr8, at.attr9, at.attr10, at.attr11, at.attr12, at.attr13, at.attr14, at.attr15, at.attr16, at.attr17, at.attr18, at.attr19, at.attr20 FROM s\_order\_details od LEFT JOIN s\_articles\_groups\_value g ON g.ordernumber=od.articleordernumber AND g.articleID=od.articleID AND od.modus=0 LEFT JOIN s\_articles\_details d ON (g.articleID=d.articleID OR d.ordernumber=od.articleordernumber) AND d.articleID=od.articleID AND od.modus=0 LEFT JOIN s\_articles\_attributes at ON at.articledetailsID=d.id WHERE od.orderID=? ORDER BY od.modus ASC ",array($this-\>\_id)), ArrayObject::ARRAY\_AS\_PROPS); } else { // JIPO: Rechnung und Lieferschein mit Position ungleich Storno $this-\>\_positions = new ArrayObject(Shopware()-\>Db()-\>fetchAll(" SELECT od.\*, at.attr1, at.attr2, at.attr3, at.attr4, at.attr5, at.attr6, at.attr7, at.attr8, at.attr9, at.attr10, at.attr11, at.attr12, at.attr13, at.attr14, at.attr15, at.attr16, at.attr17, at.attr18, at.attr19, at.attr20 FROM s\_order\_details od LEFT JOIN s\_articles\_groups\_value g ON g.ordernumber=od.articleordernumber AND g.articleID=od.articleID AND od.modus=0 LEFT JOIN s\_articles\_details d ON (g.articleID=d.articleID OR d.ordernumber=od.articleordernumber) AND d.articleID=od.articleID AND od.modus=0 LEFT JOIN s\_articles\_attributes at ON at.articledetailsID=d.id WHERE od.orderID=? AND od.status != 2 ORDER BY od.modus ASC ",array($this-\>\_id)), ArrayObject::ARRAY\_AS\_PROPS); } foreach ($this-\>\_positions as &$position){ $position["meta"] = Shopware()-\>Modules()-\>Articles()-\>sGetPromotionById('fix',0,$position["articleordernumber"]); } } public function processPositions(){ foreach ($this-\>\_positions as &$position){ $position["name"] = str\_replace(array(""),array("€"),$position["name"]); if (empty($position["quantity"])) continue; /\* modus 0 = default article modus 1 = premium articles modus 2 = voucher modus 3 = customergroup discount modus 4 = payment surcharge / discount modus 10 = bundle discount \*/ if ($position["modus"]==0 || $position["modus"]==4 || $position["modus"]==10) { /\* Read tax for each order position \*/ if($position["modus"]==4) { // Discounts get tax from configuration $position["tax"] = Shopware()-\>Config()-\>sDISCOUNTTAX; } elseif(empty($position["taxID"])) { // Articles get tax per item configuration $position["tax"] = Shopware()-\>Db()-\>fetchOne("SELECT s\_core\_tax.tax AS tax FROM s\_core\_tax, s\_articles WHERE s\_articles.id=? AND s\_core\_tax.id=s\_articles.taxID",array($position["articleID"])); } else { // Bundles tax $position["tax"] = Shopware()-\>Db()-\>fetchOne("SELECT tax FROM s\_core\_tax WHERE s\_core\_tax.id=?",array($position["taxID"])); } if ($this-\>\_net == true){ $position["netto"] = round($position["price"],2); $position["price"] = round($position["price"],2)\*(1+$position["tax"]/100); }else { $position["netto"] = $position["price"] / (100 + $position["tax"]) \* 100; } } elseif ($position["modus"]==2||$position["modus"]==3) { $position["tax"] = Shopware()-\>Config()-\>sVOUCHERTAX; if($this-\>\_net == true) { $position["netto"] = $position["price"]; $position["price"] = $position["price"]\*(1+$position["tax"]/100); } else { $position["netto"] = $position["price"]/(100+$position["tax"])\*100; } } elseif ($position["modus"]==1) { $position["tax"] = 0; $position["netto"] = 0; } $position["amount\_netto"] = $position["netto"] \* $position["quantity"]; $position["amount"] = $position["price"] \* $position["quantity"]; $this-\>\_amountNetto += $position["amount\_netto"]; $this-\>\_amount += $position["amount"]; if($this-\>\_net == true) { $position["price"] = $position["price"]; $position["netto"] = $position["netto"]; } else { $position["netto"] = $position["netto"]; $position["price"] = $position["price"]; $position["price"] = round($position["price"],2); } if(!empty($position["tax"])){ $this-\>\_tax[$position["tax"]] += ($position["amount"] / ($position["tax"]+100) \*$position["tax"]); } if ($position["amount"] \<= 0) $this-\>\_discount += $position["amount"]; $position["price"] = $position["price"]; } } public function getUser(){ $this-\>\_user = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT \* FROM s\_user WHERE id = ? ",array($this-\>\_userID)), ArrayObject::ARRAY\_AS\_PROPS); } public function getBilling(){ $this-\>\_billing = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT sob.\*,sub.ustid,sub.customernumber FROM s\_order\_billingaddress AS sob LEFT JOIN s\_user\_billingaddress AS sub ON sub.userID = ? WHERE sob.userID = ? AND sob.orderID = ? ",array($this-\>\_userID,$this-\>\_userID,$this-\>\_id)), ArrayObject::ARRAY\_AS\_PROPS); $this-\>\_billing["country"] = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT \* FROM s\_core\_countries WHERE id=? ",array($this-\>\_billing["countryID"])), ArrayObject::ARRAY\_AS\_PROPS); } public function getShipping(){ $this-\>\_shipping = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT \* FROM s\_order\_shippingaddress WHERE userID = ? AND orderID = ? ",array($this-\>\_userID,$this-\>\_id)), ArrayObject::ARRAY\_AS\_PROPS); if (!$this-\>\_shipping){ $this-\>\_shipping = clone $this-\>\_billing; }else { if (empty($this-\>\_shipping["countryID"])){ $this-\>\_shipping["countryID"] = $this-\>\_billing["countryID"]; } $this-\>\_shipping["country"] = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT \* FROM s\_core\_countries WHERE id=? ",array($this-\>\_shipping["countryID"])), ArrayObject::ARRAY\_AS\_PROPS); } } public function getDispatch(){ if (!empty(Shopware()-\>Config()-\>sPREMIUMSHIPPIUNG)) { $dispatch\_table = 's\_premium\_dispatch'; } else { $dispatch\_table = 's\_shippingcosts\_dispatch'; } $this-\>\_dispatch = Shopware()-\>Db()-\>fetchRow(" SELECT name, description FROM $dispatch\_table WHERE id = ? ",array($this-\>\_order["dispatchID"])); if(empty($this-\>\_dispatch)) { $this-\>\_dispatch = array(); } $this-\>\_dispatch = new ArrayObject($this-\>\_dispatch, ArrayObject::ARRAY\_AS\_PROPS); } public function getPayment(){ $this-\>\_payment = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT \* FROM s\_core\_paymentmeans WHERE id=? ",array($this-\>\_order["paymentID"])), ArrayObject::ARRAY\_AS\_PROPS); if (!empty($this-\>\_payment["table"])){ $this-\>\_payment["data"] = new ArrayObject(Shopware()-\>Db()-\>fetchRow(" SELECT \* FROM ".$this-\>\_payment["table"]." WHERE userID=?",$this-\>\_userID), ArrayObject::ARRAY\_AS\_PROPS); } } public function \_\_get($var\_name) { $var\_name = "\_".$var\_name; if (property\_exists($this,$var\_name)){ return $this-\>$var\_name; }else { throw new Enlight\_Exception("Property $var\_name does not exists"); } } } ?\>[/quote]
```

---

<div class="post-metadata">

**Author:** ![sfquadrat](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sfquadrat](https://forum.shopware.com/u/sfquadrat)\
**Post date:** [17. August 2013 um 12:06 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304/4 "2013-08-17T12:06:37Z")

</div>

Hallo, dieser Workaround scheint sich als praktikabel anzuhören. Gibt es auch solch eine Anpassung für die SW-Version 4.1.2? Da die Order.php sich stark von der alten (SW 3.5.8) unterscheidet!

---

<div class="post-metadata">

**Author:** ![florian.nagel](https://avatars.discourse-cdn.com/v4/letter/f/919ad9/32.png) [@florian.nagel](https://forum.shopware.com/u/florian.nagel)\
**Post date:** [30. August 2013 um 08:40 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304/5 "2013-08-30T08:40:00Z")

</div>

[quote=„sfquadrat“]Gibt es auch solch eine Anpassung für die SW-Version 4.1.2?[/quote] Würde mich auch stark interessieren, bzw. wie geht ihr mit Gutschriften in 4.x um?

---

<div class="post-metadata">

**Author:** ![Number7](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@Number7](https://forum.shopware.com/u/Number7)\
**Post date:** [20. Januar 2015 um 10:27 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304/6 "2015-01-20T10:27:15Z")

</div>

Na, da wiederhole ich doch einfach nochmal die Frage im frischen Jahr 2015: Gibt es auch solch eine Anpassung für die SW-Version 4.1.2?

---

<div class="post-metadata">

**Author:** ![Julia1978](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@Julia1978](https://forum.shopware.com/u/Julia1978)\
**Post date:** [3. Mai 2015 um 23:29 UTC](https://forum.shopware.com/t/gutschrift-erstellen/7304/7 "2015-05-03T23:29:13Z")

</div>

Ich schiebe hier auch nochmals. Teilgutschriften sind wirklich sehr wichtig.
