Index: /controller/wpsg_OrderController.class.php
===================================================================
--- /controller/wpsg_OrderController.class.php	(revision 7242)
+++ /controller/wpsg_OrderController.class.php	(revision 7243)
@@ -1118,9 +1118,12 @@
 				
 				$oCalculation = new \wpsg\wpsg_calculation();
+				
+				$oCalculation->fromDB($_REQUEST['edit_id']);				
+				$oCalculation->setTaxMode($_REQUEST['tax_mode']);								
+				$oCalculation->toDB($_REQUEST['edit_id']);
+				
+				// Umweg ist hier notwendig, da sonst beim Ã€ndern der Besteuerung auch die Produkte neu geladen werden mÃŒssten
+				$oCalculation = new \wpsg\wpsg_calculation();
 				$oCalculation->fromDB($_REQUEST['edit_id']);
-				
-				$oCalculation->setTaxMode($_REQUEST['tax_mode']);
-				
-				$oCalculation->toDB($_REQUEST['edit_id']);
 				
 				$this->shop->view['oCalculation'] = $oCalculation;
Index: /controller/wpsg_ShopController.class.php
===================================================================
--- /controller/wpsg_ShopController.class.php	(revision 7242)
+++ /controller/wpsg_ShopController.class.php	(revision 7243)
@@ -4090,4 +4090,15 @@
 		{
 
+			if (!wpsg_isSizedInt($o_id)) {
+				
+				$o_id = $this->db->ImportQuery(WPSG_TBL_ORDER, [
+					'cdate' => 'NOW()',
+					'status' => wpsg_q(wpsg_ShopController::STATUS_UNVOLLSTAENDIG)
+				]);
+				
+				$_SESSION['wpsg']['order_id'] = $o_id;
+				
+			}
+			
 			$onr_modul = "";
 			if ($this->callMods('buildONR', array(&$k_id, &$o_id, &$onr_modul)) === false)
Index: /lib/wpsg_basket.class.php
===================================================================
--- /lib/wpsg_basket.class.php	(revision 7242)
+++ /lib/wpsg_basket.class.php	(revision 7243)
@@ -1,4 +1,4 @@
 <?php
-
+	
 	/**
 	 * Diese Klasse kapselt die Produkte
@@ -7,37 +7,37 @@
 	class wpsg_basket
 	{
-
+		
 		/** @var wpsg_db */
 		var $db;
-
+		
 		/** @var wpsg_ShopController */
 		var $shop;
-
+		
 		/** Array mit den Produkten */
 		public $arProdukte;
-
+		
 		/** Gutscheinwert */
 		public $gs_value = false;
-
+		
 		/** Gutscheinberechnungstyp */
 		public $gs_calc = false;
-
+		
 		/** Gutscheincode */
 		public $gs_code = false;
-
+		
 		/** Gutschein ID */
 		public $gs_id = false;
-
+		
 		/** True wenn aus Session geladen */
 		public $loadFromSession = false;
-
+		
 		/** Wenn der Warenkorb aus der DB kommt ist hier die BestellID drin */
 		public $o_id = false;
-
+		
 		/** EnthÃ€lt die ID der Bestellung wenn aus DB geladen */
 		public $db_id = false;
-
+		
 		public $arCheckout;
-
+		
 		/**
 		 * Konstruktor
@@ -45,15 +45,15 @@
 		public function __construct()
 		{
-
+			
 			$this->db = &$GLOBALS['wpsg_db'];
 			$this->shop = &$GLOBALS['wpsg_sc'];
-
+			
 			$this->reset();
-
+			
 		} // public function __construct()
-
+		
 		public function reset()
 		{
-
+			
 			$this->arProdukte = array();
 			$this->arCheckout = array();
@@ -64,7 +64,7 @@
 			$this->gs_code = false;
 			$this->gs_calc = false;
-
+			
 		}
-
+		
 		/**
 		 * FÃŒgt ein Produkt in die Session ein
@@ -72,106 +72,106 @@
 		public function addProduktToSession($produkt_key, $menge)
 		{
-
+			
 			if (!wpsg_isSizedArray($_SESSION['wpsg']['basket'])) $_SESSION['wpsg']['basket'] = array();
-
+			
 			$product_data = $this->shop->cache->loadProduct($this->shop->getProduktId($produkt_key));
-
+			
 			if ($product_data['basket_multiple'] == 1)
 			{
-
+				
 				// Nur einmal mit beliebiger Menge
 				// Hier nichts machen, es wird weiter unten hinzugefÃŒgt
-
+				
 			}
 			else if ($product_data['basket_multiple'] == 2)
 			{
-
+				
 				// Mehrfach mit Menge 1
 				if ($menge > 1)
 				{
-
+					
 					$bOK = true;
-
+					
 					// Hier die Funktion mehrfach aufrufen (mit Menge 1) und dann abbrechen
 					for ($i = 1; $i <= $menge; $i ++)
 					{
-
+						
 						$bOK = $bOK && $this->addProduktToSession($produkt_key, 1);
-
-					}
-
+						
+					}
+					
 					return $bOK;
-
-				}
-
+					
+				}
+				
 			}
 			else if ($product_data['basket_multiple'] == 4)
 			{
-
+				
 				// Einmal mit Menge 1
 				// Basket durchgehen und schauen ob es schon drin ist und dann abbrechen sonst mit 1 hinzufÃŒgen
 				foreach ((array)$_SESSION['wpsg']['basket'] as $p_key => $p)
 				{
-
+					
 					if ($p['id'] == $produkt_key)
 					{
-
+						
 						// Produkt ist schon drin, ich breche hier mit -1 ab, damit zum Warenkorb geleitet wird und eine Meldung wird angezeigt
 						$this->shop->addFrontendMessage(__('Das Produkt befindet sich bereits im Warenkorb, es kann nur einmal erworben werden.', 'wpsg'));
 						return -1;
-
-					}
-
-				}
-
+						
+					}
+					
+				}
+				
 				$menge = 1;
-
+				
 			}
 			else
 			{
-                
+				
 				// Nur einmal mit beliebiger Menge
 				// Basket durchgehen und schauen ob es schon drin ist und dann abbrechen sonst neu hinzufÃŒgen
 				foreach ((array)$_SESSION['wpsg']['basket'] as $p_key => $p)
 				{
-
+					
 					if ($p['id'] == $produkt_key)
 					{
-
+						
 						$bOK = $this->shop->callMods('basket_produkttosession', array($produkt_key, &$menge, &$_SESSION['wpsg']['basket'][$p_key]));
- 
+						
 						if ($bOK === false)
 						{
-						    
+							
 							return false;
-
-						}
-
+							
+						}
+						
 						$GLOBALS['wpsg_lastInsertIndex'] = $p_key;
 						
 						$_SESSION['wpsg']['basket'][$p_key]['menge'] += intval($menge);
-
+						
 						// Sollte die Menge auf 0 korrigiert werden dann Produkt entfernen
 						if ($_SESSION['wpsg']['basket'][$p_key]['menge'] <= 0)
 						{
-                            
+							
 							unset($_SESSION['wpsg']['basket'][$p_key]);
-
-						}
-                         
+							
+						}
+						
 						return true;
-
-					}
-
-				}
-
-			}
-
+						
+					}
+					
+				}
+				
+			}
+			
 			$ses_data = array();
-
+			
 			$bOK = $this->shop->callMods('basket_produkttosession', array($produkt_key, &$menge, &$ses_data));
 			
 			if ($bOK === false) return false;
-            
+			
 			// War noch nicht drin => neu hinzufÃŒgen
 			$ses_data = wpsg_array_merge($ses_data, array(
@@ -180,16 +180,16 @@
 				'referer' => ''
 			));
-
+			
 			if (isset($_REQUEST['myReferer'])) $ses_data['referer'] = $_REQUEST['myReferer'];
-
+			
 			//$_SESSION['wpsg']['basket'][] = wpsg_xss($ses_data);
 			array_push($_SESSION['wpsg']['basket'], wpsg_xss($ses_data));
 			end($_SESSION['wpsg']['basket']);
 			$GLOBALS['wpsg_lastInsertIndex'] = key($_SESSION['wpsg']['basket']);
-
+			
 			return true;
-
+			
 		} // public function addProduktToBasket($produkt_id, $menge)
-
+		
 		/**
 		 * FÃŒgt einen Gutschein zum Warenkorb hinzu
@@ -199,10 +199,10 @@
 		public function addGutscheinToSession($value, $calc, $code, $gs_id)
 		{
-
+			
 			$this->gs_value = $value;
 			$this->gs_calc = $calc;
 			$this->gs_code = $code;
 			$this->gs_id = $gs_id;
-
+			
 			$_SESSION['wpsg']['gs'] = wpsg_xss(array(
 				'value' => $this->gs_value,
@@ -211,7 +211,7 @@
 				'id' => $this->gs_id
 			));
-
+			
 		} // public function addGutscheinToSession($value, $calc, $code)
-
+		
 		/**
 		 * Entfernt ein Produkt aus dem Warenkorb
@@ -219,15 +219,15 @@
 		public function removeProduktFromSession($produkt_index)
 		{
-
+			
 			unset($_SESSION['wpsg']['basket'][$produkt_index]);
-            
-            $this->shop->callMods('basket_removeProduktFromSession', [$produkt_index]);
-            
+			
+			$this->shop->callMods('basket_removeProduktFromSession', [$produkt_index]);
+			
 			$this->shop->cache->clearShopBasketArray();
-
+			
 			return true;
-
+			
 		} // public function removeProduktFromSession($produkt_key)
-
+		
 		/**
 		 * Aktualisiert den Warenkorb in der Session
@@ -235,33 +235,33 @@
 		public function updateProduktFromSession($product_index, $produkt_menge)
 		{
-
+			
 			if (intval($produkt_menge) <= 0)
 			{
-
+				
 				$this->removeProduktFromSession($product_index);
 				return true;
-
-			}
-
-
+				
+			}
+			
+			
 			foreach ($_SESSION['wpsg']['basket'] as $k => $p)
 			{
-
+				
 				if ($k == $product_index)
 				{
-
+					
 					$this->shop->callMods('basket_updateProduktFromSession', array(&$product_index, &$produkt_menge));
 					$_SESSION['wpsg']['basket'][$k]['menge'] = intval($produkt_menge);
-
+					
 					if (!wpsg_isSizedInt($_SESSION['wpsg']['basket'][$k]['menge'])) unset($_SESSION['wpsg']['basket'][$k]);
-
-				}
-
-			}
-
+					
+				}
+				
+			}
+			
 			return true;
-
+			
 		} // public function updateProduktFromSession($produkt_key, $produkt_menge)
-
+		
 		/**
 		 * Initiiert den Warenkorb aus der Session heraus
@@ -269,27 +269,27 @@
 		public function initFromSession($rebuild = false)
 		{
-
+			
 			if (!isset($_SESSION['wpsg']['basket'])) return;
 			if ($this->loadFromSession === true && $rebuild === false) return;
-
+			
 			$this->arProdukte = array();
-
+			
 			foreach ((array)$_SESSION['wpsg']['basket'] as $produkt_key => $b)
 			{
-
+				
 				$this->arProdukte[$produkt_key] = $b;
-
-			}
-
+				
+			}
+			
 			if (isset($_SESSION['wpsg']['gs']))
 			{
-
+				
 				$this->gs_value = $_SESSION['wpsg']['gs']['value'];
 				$this->gs_calc = $_SESSION['wpsg']['gs']['calc'];
 				$this->gs_code = $_SESSION['wpsg']['gs']['code'];
 				$this->gs_id = $_SESSION['wpsg']['gs']['id'];
-
-			}
-
+				
+			}
+			
 			$this->arCheckout = wpsg_array_merge(array(
 				'firma' => '',
@@ -308,9 +308,9 @@
 				'comment' => ''
 			), wpsg_isSizedArray($_SESSION['wpsg']['checkout'])?$_SESSION['wpsg']['checkout']:array());
-
+			
 			$this->loadFromSession = true;
-
+			
 		} // public function initFromSession()
-
+		
 		/**
 		 * Gibt die ID eines Produktes in der Datenbank zurÃŒck
@@ -318,36 +318,36 @@
 		public function getProduktDBID($produkt_key)
 		{
-
+			
 			if (is_numeric($produkt_key)) return $produkt_key;
 			else if (preg_match('/pv_\d(.*)/', $produkt_key))
 			{
-
+				
 				// Varianten ProduktschlÃŒssel
 				$produkt_id = preg_replace('/(pv_)|(\|(.*))/', '', $produkt_key);
-
+				
 				return $produkt_id;
-
+				
 			}
 			else return false;
-
+			
 		}
-
-        /**
-         * Wandelt die Daten des Basket in die neue Klasse zur Berechnung
-         * @return wpsg\wpsg_calculation
-         */
+		
+		/**
+		 * Wandelt die Daten des Basket in die neue Klasse zur Berechnung
+		 * @return wpsg\wpsg_calculation
+		 */
 		public function toCalculation() {
-		    
-		    $b = new \wpsg\wpsg_calculation();
-		    
-		    foreach ($this->arProdukte as $p) {
-		        
-		        $b->addProduct($p['productkey'], $p['product_index'], $p['preis_netto'], $p['menge'], $p['op_mwst_key'], $p['order_product_id']);
-		          
-            }
-            
-            return $b;
-		    
-        }
+			
+			$b = new \wpsg\wpsg_calculation();
+			
+			foreach ($this->arProdukte as $p) {
+				
+				$b->addProduct($p['productkey'], $p['product_index'], $p['preis_netto'], $p['menge'], $p['op_mwst_key'], $p['order_product_id']);
+				
+			}
+			
+			return $b;
+			
+		}
 		
 		/**
@@ -356,5 +356,5 @@
 		public function initFromDB($o_id, $backend = false)
 		{
-
+			
 			$order = $this->db->fetchRow("
 				SELECT
@@ -365,5 +365,5 @@
 			  		`id` = '".wpsg_q($o_id)."'
 			");
-
+			
 			$kunde = $this->db->fetchRow("
 				SELECT
@@ -375,5 +375,5 @@
 					K.`id` = '".wpsg_q($order['k_id'])."'
 			");
-
+			
 			$this->arCheckout = array(
 				'firma' => $kunde['firma'],
@@ -399,19 +399,19 @@
 				'datum' => strtotime($order['cdate'])
 			);
-
+			
 			if ($this->shop->hasMod('wpsg_mod_autodebit'))
 			{
-
+				
 				$this->arCheckout['mod_autodebit_name'] = wpsg_getStr($order['mod_autodebit_name']);
-		   		$this->arCheckout['mod_autodebit_blz'] = wpsg_getStr($order['mod_autodebit_blz']);
+				$this->arCheckout['mod_autodebit_blz'] = wpsg_getStr($order['mod_autodebit_blz']);
 				$this->arCheckout['mod_autodebit_bic'] = wpsg_getStr($order['mod_autodebit_bic']);
-		   		$this->arCheckout['mod_autodebit_inhaber'] = wpsg_getStr($order['mod_autodebit_inhaber']);
-		   		$this->arCheckout['mod_autodebit_knr'] = wpsg_getStr($order['mod_autodebit_knr']);
+				$this->arCheckout['mod_autodebit_inhaber'] = wpsg_getStr($order['mod_autodebit_inhaber']);
+				$this->arCheckout['mod_autodebit_knr'] = wpsg_getStr($order['mod_autodebit_knr']);
 				$this->arCheckout['mod_autodebit_iban'] = wpsg_getStr($order['mod_autodebit_iban']);
-
-			}
-
+				
+			}
+			
 			$this->arOrder = $order;
-
+			
 			// Produkte
 			$arProdukte = $this->db->fetchAssoc("
@@ -430,19 +430,19 @@
 					OP.`o_id` = '".wpsg_q($o_id)."'
 			", "product_index");
-
+			
 			foreach ($arProdukte as $k => $v)
 			{
-
+				
 				$arProdukte[$k]['varPriceAdded'] = 1;
 				
 				if ($v['productkey'] != '') $arProdukte[$k]['id'] = $v['productkey'];
 				else if ($v['mod_vp_varkey'] != '') $arProdukte[$k]['id'] = $v['mod_vp_varkey'];
-
+				
 				// Preis ist immer in Brutto in der WPSG_TBL_ORDERPRODUCTS
 				$arProdukte[$k]['preis_netto'] = wpsg_calculatePreis($v['preis_brutto'], WPSG_NETTO, $v['mwst_value']);
-
+				
 				if ($backend)
 				{
-
+					
 					if ($this->shop->get_option('wpsg_preisangaben') == WPSG_BRUTTO)
 					{
@@ -453,9 +453,9 @@
 						$arProdukte[$k]['preis'] = $arProdukte[$k]['preis_netto'];
 					}
-
+					
 				}
 				else
 				{
-
+					
 					if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
 					{
@@ -466,22 +466,22 @@
 						$arProdukte[$k]['preis'] = $arProdukte[$k]['preis_netto'];
 					}
-
-				}
-
-			}
-
+					
+				}
+				
+			}
+			
 			// Gutschein
 			if ($order['gs_id'] > 0)
 			{
-
+				
 				$gs = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_GUTSCHEIN."` WHERE `id` = '".wpsg_q($order['gs_id'])."'");
-
+				
 				$this->gs_value = $gs['value'];
 				$this->gs_calc = $gs['calc_typ'];
 				$this->gs_code = $gs['code'];
 				$this->gs_id = $gs['id'];
-
-			}
-
+				
+			}
+			
 			// Gutschein-Wert aus der Order-Tabelle wegen Bearbeitung
 			if ($backend)
@@ -489,14 +489,14 @@
 				$val = abs($order['price_gs']);
 				$this->gs_value = $val;
-
-			}
-
+				
+			}
+			
 			$this->arProdukte = $arProdukte;
-
+			
 			$this->loadFromSession = false;
 			$this->o_id = $o_id;
-
+			
 		} // public function initFromDB($o_id)
-
+		
 		/**
 		 * LÃ¶scht die Session
@@ -504,32 +504,32 @@
 		public function clearSession($customer_id)
 		{
-
+			
 			$this->shop->callMods('clearSession');
-
+			
 			if ($this->shop->get_option('wpsg_afterorder') == '1')
 			{
-
+				
 				// LÃ¶schen
 				unset($_SESSION['wpsg']);
-
+				
 			}
 			else
 			{
-
+				
 				// In Session belassen
 				unset($_SESSION['wpsg']['basket']);
 				unset($_SESSION['wpsg']['gs']);
-
+				
 				if ($this->shop->hasMod('wpsg_mod_kundenverwaltung'))
 				{
-
+					
 					$this->shop->callMod('wpsg_mod_kundenverwaltung', 'login', array($customer_id));
-
-				}
-
-			}
-
+					
+				}
+				
+			}
+			
 		} // public function clearSession()
-
+		
 		/**
 		 * Sendet die Mails beim Kauf an Admin und Kunden
@@ -539,42 +539,42 @@
 		public function sendOrderSaveMails($order_id, $arBasket, $bCustomerMail = true, $bAdminMail = true, $bDebug = false)
 		{
-
+			
 			$oOrder = wpsg_order::getInstance($order_id);
-
+			
 			$this->shop->view['oOrder'] = $oOrder;
 			$this->shop->view['basket'] = $arBasket;
-
+			
 			$this->shop->view['o_id'] = $order_id;
 			$this->shop->view['order'] = $this->shop->cache->loadOrder($order_id);
 			$this->shop->view['customer'] = $this->shop->cache->loadKunden($this->shop->view['oOrder']->k_id);
- 
+			
 			if ($bDebug === true)
 			{
-
+				
 				$this->shop->view['basket']['checkout']['datum'] = time();
 				$this->shop->view['basket']['checkout']['onr'] = $this->shop->view['oOrder']->onr;
 				$this->shop->view['basket']['checkout']['knr'] = $this->shop->view['customer']['knr'];
 				$this->shop->view['basket']['checkout']['comment'] = $oOrder->comment;
-
-			}
-
+				
+			}
+			
 			// Adminmail
 			if ($bAdminMail === true)
 			{
-
+				
 				$arAttach = array();
 				// Anhang aufbereiten
 				$this->shop->callMod('wpsg_mod_orderupload', 'getAdminAttachment', array(&$arAttach));
-
+				
 				$mail_text = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/adminmail.phtml', false);
-
+				
 				if ($this->shop->get_option('wpsg_htmlmail') === '1') $mail_html = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/html/adminmail.phtml', false);
 				else $mail_html = false;
-
+				
 				$this->shop->sendMail($mail_text, $this->shop->get_option('wpsg_adminmail_empfaenger'), 'adminmail', $arAttach, $order_id, $oOrder->k_id, $mail_html);
-
+				
 				if ($bDebug === false)
 				{
-
+					
 					$this->db->ImportQuery(WPSG_TBL_OL, array(
 						"o_id" => wpsg_q($order_id),
@@ -583,44 +583,44 @@
 						"mailtext" => wpsg_q($mail_text)
 					));
-
-				}
-
+					
+				}
+				
 				sleep(1);
-
-			}
-
+				
+			}
+			
 			// Kundenmail
 			if ($bCustomerMail === true)
 			{
-
+				
 				$mail_text = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/kundenmail.phtml', false);
-
+				
 				if ($this->shop->get_option('wpsg_htmlmail') === '1') $mail_html = $this->shop->render(WPSG_PATH_VIEW.'/mailtemplates/html/kundenmail.phtml', false);
 				else $mail_html = false;
-
+				
 				$arAttachments = array();
-				 
+				
 				if ($this->shop->get_option('wpsg_widerrufsformular_kundenmail') === '1' && wpsg_isSizedString($this->shop->get_option('wpsg_revocationform')))
 				{
-
+					
 					$revocationFile = WPSG_PATH_UPLOADS.'wpsg_revocation/'.$this->shop->get_option('wpsg_revocationform');
-
+					
 					if (file_exists($revocationFile) && is_file($revocationFile))
 					{
-
+						
 						$arAttachments[] = $revocationFile;
-
-					}
-
-				}
-
+						
+					}
+					
+				}
+				
 				if ($bDebug === true) $empfaenger = $this->shop->get_option('wpsg_adminmail_empfaenger');
 				else $empfaenger = $this->arCheckout['email'];
-
+				
 				$this->shop->sendMail($mail_text, $empfaenger, 'kundenmail', $arAttachments, $order_id, $oOrder->k_id, $mail_html);
-
+				
 				if ($bDebug === false)
 				{
-
+					
 					$this->db->ImportQuery(WPSG_TBL_OL, array(
 						"o_id" => wpsg_q($order_id),
@@ -629,11 +629,11 @@
 						"mailtext" => wpsg_q($mail_text)
 					));
-
-				}
-
-			}
-
+					
+				}
+				
+			}
+			
 		} // public function sendOrderSaveMails($order_id)
-
+		
 		/**
 		 * Speichert die Bestellung in die Datenbank
@@ -641,9 +641,9 @@
 		 */
 		public function save($finish_order = true, $sendmail = true) {
- 
+			
 			$knr = '';
 			
 			try {
-               
+				
 				// Eintrag in Kundentabelle
 				$data = array(
@@ -653,61 +653,61 @@
 					'ustidnr' => wpsg_q(wpsg_getStr($this->arCheckout['ustidnr']))
 				);
-
+				
 				$this->shop->callMods('basket_save_kunde', array(&$data, &$this->arCheckout));
-               
+				
 				$k_id = wpsg_getStr($this->arCheckout['id']);
-
+				
 				// Sollte die ID des eingeloggten Kunden nicht mit der ID in der Bestellung passen
 				if (wpsg_isSizedInt($_SESSION['wpsg']['checkout']['id'])) {
-
+					
 					if (wpsg_isSizedInt($k_id) && $k_id != $_SESSION['wpsg']['checkout']['id']) {
-
+						
 						$k_id = $_SESSION['wpsg']['checkout']['id'];
-
-					}
-
-				}
-
+						
+					}
+					
+				}
+				
 				$data['custom'] = array();
-
+				
 				if (isset($this->arCheckout['custom']) && wpsg_isSizedArray($this->arCheckout)) $data['custom'] = $this->arCheckout['custom'];
-
+				
 				if (wpsg_isSizedInt($k_id)) {
-
+					
 					// Kunde existiert bereits, hier muss aufgepasst werden dass nur abgefragte Kundenvariablen ersetzt werden
 					$kunde_data = $this->shop->cache->loadKunden($k_id);
 					$custom_old = @unserialize($kunde_data['custom']);
-
+					
 					if (wpsg_isSizedArray($custom_old))
 					{
-
+						
 						$data['custom'] = wpsg_array_merge($custom_old, (array)$this->arCheckout['custom']);
-
-					}
-
-				}
-
+						
+					}
+					
+				}
+				
 				$data['custom'] = serialize($data['custom']);
-
+				
 				$update_customer_data = array();
-
+				
 				if ($k_id > 0) {
-
+					
 					$this->db->UpdateQuery(WPSG_TBL_KU, $data, "`id` = '".wpsg_q($k_id)."'");
 					$knr = $this->db->fetchOne("SELECT `knr` FROM `".WPSG_TBL_KU."` WHERE `id` = '".wpsg_q($k_id)."'");
- 
+					
 					$this->shop->callMods('customer_updatePwd', array(&$k_id, &$this->arCheckout['password']));
 					$this->shop->callMods('customer_updated', array(&$k_id));
-
+					
 				} else {
-
+					
 					if ($this->shop->hasMod('wpsg_mod_customergroup')) {
-
+						
 						if (wpsg_isSizedInt($this->shop->get_option('wpsg_page_mod_kundenverwaltung_group_checkout'))) $data['group_id'] = $this->shop->get_option('wpsg_page_mod_kundenverwaltung_group_checkout');
-
-					}
-
+						
+					}
+					
 					if (wpsg_isSizedString($data['email'])) {
-												
+						
 						if (!wpsg_isSizedInt($_SESSION['wpsg']['checkout']['id'])) {
 							
@@ -723,5 +723,5 @@
 						
 						$knr = $this->shop->buildKNR($k_id);
-
+						
 						$update_customer_data['knr'] = wpsg_q($knr);
 						
@@ -729,10 +729,10 @@
 					
 					$this->shop->callMods('customer_created', array(&$k_id, &$this->arCheckout['password']));
-
-				}
-				 
+					
+				}
+				
 				// Adresse speichern wenn der Kunde noch keine Adresse hat
 				$customer_data = $this->shop->cache->loadKunden($k_id, true);
-
+				
 				$adress_data = array(
 					'firma' => wpsg_q(wpsg_getStr($this->arCheckout['firma'])),
@@ -755,5 +755,5 @@
 				
 				if (!wpsg_isSizedInt($customer_data['adress_id'])) {
-
+					
 					$adress_data['cdate'] = 'NOW()';
 					
@@ -766,23 +766,23 @@
 					
 				} else {
-
+					
 					$this->db->UpdateQuery(WPSG_TBL_ADRESS, $adress_data, " `id` = '".wpsg_q($customer_data['adress_id'])."' ");
-
+					
 				}
 				
 				$re_adress_id = $customer_data['adress_id'];
-
+				
 				// Kundendaten ggf. aktualisieren
 				if (wpsg_isSizedArray($update_customer_data)) $this->db->UpdateQuery(WPSG_TBL_KU, $update_customer_data, "`id` = '".wpsg_q($k_id)."'");
-
+				
 				$arBasket['checkout']['k_id'] = $k_id;
 				$arBasket['checkout']['knr'] = $knr;
- 				
-				if (($finish_order === true) && (wpsg_getStr($this->arCheckout['diff_shippingadress']) == '1')) {	
+				
+				if (($finish_order === true) && (wpsg_getStr($this->arCheckout['diff_shippingadress']) == '1')) {
 					
 					// Gesonderte Lieferadresse speichern
-
+					
 					$adata['cdate'] = 'NOW()';
-
+					
 					$adata['title'] 	= $this->arCheckout['shipping_title'];
 					$adata['vname'] 	= $this->arCheckout['shipping_vname'];
@@ -793,7 +793,7 @@
 					$adata['firma'] 	= $this->arCheckout['shipping_firma'];
 					$adata['land'] 		= $this->arCheckout['shipping_land'];
-
+					
 					$update_data['shipping_adress_id'] = wpsg_q($this->db->ImportQuery(WPSG_TBL_ADRESS, $adata));
-
+					
 				}
 				
@@ -802,13 +802,15 @@
 				$update_data['custom_data']['basket']['oOrder'] = Array();
 				$update_data['custom_data'] = wpsg_q(serialize($update_data['custom_data']));
-
+				
 				// Neu durch calculation Klasse speichern				
 				$oCalculation = \wpsg\wpsg_calculation::getSessionCalculation();
-				$o_id = $oCalculation->toDB(@$_SESSION['wpsg']['order_id'], [], $finish_order);
-							
-				if ($o_id !== @$_SESSION['wpsg']['order_id']) {
-					
-					$update_data['onr'] = wpsg_q($this->shop->buildONR($o_id, $k_id, $knr));
-															
+				//$o_id = $oCalculation->toDB(@$_SESSION['wpsg']['order_id'], [], $finish_order);
+				
+				if ($finish_order) {
+					
+					$update_data['onr'] = wpsg_q($this->shop->buildONR(@$_SESSION['wpsg']['order_id'], $k_id, $knr));
+					
+					$o_id = $oCalculation->toDB(@$_SESSION['wpsg']['order_id'], [], $finish_order);
+					
 				}
 				
@@ -817,5 +819,5 @@
 				
 				$this->db->UpdateQuery(WPSG_TBL_ORDER, $update_data, "`id` = '".wpsg_q($o_id)."'");
-								 
+				
 				// URL Benachrichtigung beim Kauf
 				if ($finish_order === true) {
@@ -835,5 +837,5 @@
 						
 					}
-					 
+					
 					$this->shop->callMods('basket_save_done', array(&$o_id, &$k_id, &$this));
 					$this->shop->callMods('basket_save_done_array', array(&$o_id, &$k_id, &$arBasket));
@@ -844,13 +846,13 @@
 					// Wenn CrefoPay aktiv, werden die Mails spÃ€ter versendet
 					if (!$this->shop->hasMod('wpsg_mod_crefopay') && $sendmail) $this->sendOrderSaveMails($o_id, $arBasket);
-
+					
 					// Bestellung direkt auf "Zahlung akzeptiert setzen" wenn option aktiv ist
 					if ($this->shop->get_option('wpsg_emptyorder_clear') == '1' && $arBasket['sum']['preis_gesamt_brutto'] == 0)
 					{
-
+						
 						$this->shop->setOrderStatus($o_id, 100, true);
-
-					}
-
+						
+					}
+					
 					// Eintrag in die Kundentabelle
 					$kdata = array(
@@ -859,5 +861,5 @@
 					
 					$this->db->UpdateQuery(WPSG_TBL_KU, $kdata, "`id` = '".wpsg_q($k_id)."'");
-
+					
 					// Alte BestellID muss nach Abschluss entfernt werden
 					unset($_SESSION['wpsg']['order_id']);
@@ -865,32 +867,32 @@
 					unset($_SESSION['wpsg']['checkout']['paymentId']);
 					unset($_SESSION['wpsg']['checkout']['payer_id']);
-
+					
 					$this->clearSession($k_id);
-
+					
 				} else {
-
+					
 					$_SESSION['wpsg']['order_id'] = $o_id;
-
-				}
-
+					
+				}
+				
 			} catch (Exception $e) {
-
+				
 				$this->db->unlockTables();
-
+				
 				die($e->getMessage());
-
-			}
-
+				
+			}
+			
 			$this->db->unlockTables();
-
+			
 			return $o_id;
-
+			
 		} // public function save()
-
+		
 		/**
 		 * Wird als letzte ÃberprÃŒfung der Bestellung aufgerufen und leitet zu overview.phtml wenn $error true wird
 		 */
 		public function checkFinaly(&$error) { }
-
+		
 		/**
 		 * ÃberprÃŒft die Korrektheit der Kunden- und Bestelldaten
@@ -898,232 +900,232 @@
 		public function checkCheckout($state = true)
 		{
-
+			
 			$bError = false;
-
+			
 			// Darf hier nicht ÃŒberschrieben werden sonst keine Feldmarkierung fÃŒr ordercondition
 			if (!wpsg_isSizedArray($_SESSION['wpsg']['errorFields'])) $_SESSION['wpsg']['errorFields'] = array();
-
+			
 			$custom_config = $GLOBALS['wpsg_sc']->loadPflichtFeldDaten();
-
+			
 			$this->shop->callMods('checkCheckout', array(&$state, &$bError, &$this->arCheckout));
-
+			
 			if ($state == 1 || $state)
 			{
-
+				
 				// Anrede ÃŒberprÃŒfen
 				if ($custom_config['anrede'] != '2' && $custom_config['anrede'] != '1' && $this->arCheckout['title'] == '-1')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte im Feld "Anrede" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'title';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Firma
 				if ($custom_config['firma'] != '2' && $custom_config['firma'] != '1' && trim($this->arCheckout['firma']) == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte im Feld "Firma" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'firma';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Vorname
 				if ($custom_config['vname'] != '2' && $custom_config['vname'] != '1' && trim(wpsg_getStr($this->arCheckout['vname'])) == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte im Feld "Vorname" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'vname';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Name
 				if ($custom_config['name'] != '2' && $custom_config['name'] != '1' && trim(wpsg_getStr($this->arCheckout['name'])) == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte im Feld "Name" eine Angabe machen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'name';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Geburtsdatum
 				if (
-						($custom_config['geb'] != '2' && $custom_config['geb'] != '1' && !wpsg_isValidGeb($this->arCheckout['geb'])) ||
-						(wpsg_isSizedString($this->arCheckout['geb']) && !wpsg_isValidGeb($this->arCheckout['geb']))
-
-					)
-				{
-
+					($custom_config['geb'] != '2' && $custom_config['geb'] != '1' && !wpsg_isValidGeb($this->arCheckout['geb'])) ||
+					(wpsg_isSizedString($this->arCheckout['geb']) && !wpsg_isValidGeb($this->arCheckout['geb']))
+				
+				)
+				{
+					
 					$this->shop->addFrontendError(__('Bitte die Eingabe im Feld "Geburtsdatum" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'geb';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// E-Mail Adresse
 				if (
-						($custom_config['email'] != '2' && $custom_config['email'] != '1' && !wpsg_isValidEMail($this->arCheckout['email'])) ||
-						(wpsg_isSizedString($this->arCheckout['email']) && !wpsg_isValidEMail($this->arCheckout['email']))
-					)
-				{
-
+					($custom_config['email'] != '2' && $custom_config['email'] != '1' && !wpsg_isValidEMail($this->arCheckout['email'])) ||
+					(wpsg_isSizedString($this->arCheckout['email']) && !wpsg_isValidEMail($this->arCheckout['email']))
+				)
+				{
+					
 					$this->shop->addFrontendError(__('Bitte die Eingabe der E-Mail Adresse ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'email';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// E-Mail EingabeÃŒberprÃŒfung
 				if ($custom_config['emailconfirm'] == '1')
 				{
-
+					
 					$this->arCheckout['email'] = strtolower($this->arCheckout['email']);
 					$this->arCheckout['email2'] = strtolower($this->arCheckout['email2']);
-
+					
 					if ($this->arCheckout['email'] != wpsg_getStr($this->arCheckout['email2']))
 					{
-
+						
 						$this->shop->addFrontendError(__('Bitte ÃŒberprÃŒfen Sie die Eingaben in der E-Mail BestÃ€tigung!', 'wpsg'));
 						$_SESSION['wpsg']['errorFields'][] = 'email';
 						$bError = true;
-
-					}
-
-				}
-
+						
+					}
+					
+				}
+				
 				// Telefonnummer validieren
 				if ($custom_config['tel'] != '2' && $custom_config['tel'] != '1' && $this->arCheckout['tel'] == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte die Eingabe im Feld "Telefonnummer" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'tel';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// StraÃe prÃŒfen
 				if ($custom_config['strasse'] != '2' && $custom_config['strasse'] != '1' && wpsg_getStr($this->arCheckout['strasse']) == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "StraÃe" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'strasse';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Fax prÃŒfen
 				if ($custom_config['fax'] != '2' && $custom_config['fax'] != '1' && $this->arCheckout['fax'] == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "Fax" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'fax';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// PLZ ÃŒberprÃŒfen
 				if ($custom_config['plz'] != '2' && $custom_config['plz'] != '1' && wpsg_getStr($this->arCheckout['plz']) == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "PLZ" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'plz';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Ort ÃŒberprÃŒfen
 				if ($custom_config['ort'] != '2' && $custom_config['ort'] != '1' && wpsg_getStr($this->arCheckout['ort']) == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "Ort" ÃŒberprÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'ort';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Land ÃŒberprÃŒfen
 				if ($custom_config['land'] != '2' && $custom_config['land'] != '1' && $this->arCheckout['land'] <= 0)
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte ein Land auswÃ€hlen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'land';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// UStIdNr prÃŒfen
 				if ($custom_config['ustidnr'] != '2' && $custom_config['ustidnr'] != '1' && !preg_match("/^[a-zA-Z]+\d+/", $this->arCheckout['ustidnr']))
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte die Eingaben im Feld "UStIdNr." prÃŒfen!', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'ustidnr';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Benutzerdefinierte Felder prÃŒfen
 				foreach ((array)$custom_config['custom'] as $c_id => $c)
 				{
-
+					
 					// Wenn die Kundenvariable nicht im Request drin ist dann auch nichts machen
 					// Problem war der Fall, dass eine Kundenvariable nicht angezeigt wurde
 					if (!isset($this->arCheckout['custom'][$c_id])) continue;
-
+					
 					if ($c['show'] == '0')
 					{
-
+						
 						if ($c['typ'] == '2')
 						{
-
+							
 							// Checkbox
 							if ($this->arCheckout['custom'][$c_id] != '1')
 							{
-
+								
 								$this->shop->addFrontendError(wpsg_translate(__('Bitte "#1#" akzeptieren!', 'wpsg'), __($c['name'], 'wpsg')));
 								$_SESSION['wpsg']['errorFields'][] = 'custom_'.$c_id;
 								$bError = true;
-
+								
 							}
-
+							
 						}
 						else if ($c['typ'] == '1')
 						{
-
+							
 							// Auswahl
 							if ($this->arCheckout['custom'][$c_id] == '-1')
 							{
-
+								
 								$this->shop->addFrontendError(wpsg_translate(__('Bitte eine Auswahl im Feld "#1#" treffen!', 'wpsg'), __($c['name'], 'wpsg')));
 								$_SESSION['wpsg']['errorFields'][] = 'custom_'.$c_id;
 								$bError = true;
-
+								
 							}
-
+							
 						}
 						else if ($c['typ'] == '0')
 						{
-
+							
 							// Texte
 							if (trim($this->arCheckout['custom'][$c_id]) == '')
 							{
-
+								
 								$this->shop->addFrontendError(wpsg_translate(__('Bitte machen Sie in Feld "#1#" eine Angabe!', 'wpsg'), __($c['name'], 'wpsg')));
 								$_SESSION['wpsg']['errorFields'][] = 'custom_'.$c_id;
 								$bError = true;
-
+								
 							}
-
-						}
-
-					}
-
-				}
-				
-			}
-
+							
+						}
+						
+					}
+					
+				}
+				
+			}
+			
 			/**
 			 * Versand- und Zahlungsarten nur Checken wenn State=2 oder alle State=true (Alles prÃŒfen)
@@ -1133,40 +1135,40 @@
 				($this->shop->hasMod('wpsg_mod_onepagecheckout') && $state == 1 && !isset($_REQUEST['wpsg_mod_kundenverwaltung_save']) && !isset($_REQUEST['wpsg_mod_kundenverwaltung_register'])))
 			{
-
+				
 				$this->shop->checkShippingAvailable();
-
+				
 				// Versandart prÃŒfen
 				if (!isset($this->arCheckout['shipping']) || !array_key_exists($this->arCheckout['shipping'], $this->shop->arShipping) || $this->arCheckout['shipping'] == '')
 				{
-
+					
 					$this->shop->addFrontendError(__('Bitte eine gÃŒltige Versandart auswÃ€hlen.', 'wpsg'));
 					$_SESSION['wpsg']['errorFields'][] = 'shipping';
 					$bError = true;
-
-				}
-
+					
+				}
+				
 				// Zahlungsart prÃŒfen
 				if (!$this->shop->hasMod('wpsg_mod_crefopay'))
 				{
-
+					
 					if (!isset($this->arCheckout['payment']) || !array_key_exists($this->arCheckout['payment'], $this->shop->arPayment) || $this->arCheckout['payment'] == '')
 					{
-
+						
 						// Fake Zahlungsart PayPal Plus soll keinen Fehler schreiben
 						if ($this->arCheckout['payment'] != 'ppp')
 						{
-
+							
 							$this->shop->addFrontendError(__('Bitte eine gÃŒltige Zahlungsart auswÃ€hlen.', 'wpsg'));
 							$_SESSION['wpsg']['errorFields'][] = 'payment';
 							$bError = true;
-
-						}
-
-					}
-
-				}
-
-			}
-
+							
+						}
+						
+					}
+					
+				}
+				
+			}
+			
 			// prÃŒft ob tatsÃ€chlich mind. ein Produkt im Warenkorb liegt
 			if (isset($_SESSION['wpsg']['basket']) && count($_SESSION['wpsg']['basket']) < 1 && !is_numeric($state))
@@ -1176,9 +1178,9 @@
 				$bError = true;
 			}
-
+			
 			return !$bError;
-
+			
 		} // public function checkCheckout()
-
+		
 		/**
 		 * ÃberprÃŒft den Basket Array auf ein EU-Leistungsort Produkt und gibt true oder false zurÃŒck
@@ -1186,16 +1188,16 @@
 		public function hasEULeistungsortProduct(&$arBasket)
 		{
-
+			
 			foreach ($arBasket['produkte'] as $p)
 			{
-
+				
 				if (wpsg_isSizedInt($p['euleistungsortregel'])) return true;
-
-			}
-
+				
+			}
+			
 			return false;
-
+			
 		} // public function hasEULeistungsortProduct(&$arBasket)
-				
+		
 		/**
 		 * Wandelt die in der Session gespeicherten Produkte in einen aufgewerteten Array
@@ -1203,27 +1205,27 @@
 		public function toArray($backend = false, $clearVK = false)
 		{
-
+			
 			if ($this->o_id > 0 && false)
 			{
-
+				
 				$order_data = $this->shop->cache->loadOrder($this->o_id);
 				$custom_data = @unserialize($order_data['custom_data']);
-
+				
 				if (is_array($custom_data['basket']))
 				{
-
+					
 					$arBasket = $custom_data['basket'];
-
+					
 					// Ich vereinige die Checkoutdaten mit den Kundendaten aus der Datenbank
 					// Damit sind hier die aktuellen Werte aus der Datenbank enthalten
 					$arBasket['checkout'] = wpsg_array_merge($arBasket['checkout'], $this->shop->cache->loadKunden($arBasket['checkout']['k_id']));
-
+					
 					// FÃŒr das Backend eventuell Preise drehen
 					if ($backend === true)
 					{
-
+						
 						if ($this->shop->get_option('wpsg_preisangaben') == WPSG_NETTO)
 						{
-
+							
 							if (isset($arBasket['sum']['preis_payment_netto'])) $arBasket['sum']['preis_payment'] = $arBasket['sum']['preis_payment_netto'];
 							if (isset($arBasket['sum']['preis_shipping_netto'])) $arBasket['sum']['preis_shipping'] = $arBasket['sum']['preis_shipping_netto'];
@@ -1232,9 +1234,9 @@
 							if (isset($arBasket['sum']['preis_netto'])) $arBasket['sum']['preis'] = $arBasket['sum']['preis_netto'];
 							if (isset($arBasket['sum']['preis_gesamt_netto'])) $arBasket['sum']['preis_gesamt'] = $arBasket['sum']['preis_gesamt_netto'];
-
+							
 						}
 						else
 						{
-
+							
 							if (isset($arBasket['sum']['preis_payment_brutto'])) $arBasket['sum']['preis_payment'] = $arBasket['sum']['preis_payment_brutto'];
 							if (isset($arBasket['sum']['preis_shipping_brutto'])) $arBasket['sum']['preis_shipping'] = $arBasket['sum']['preis_shipping_brutto'];
@@ -1243,648 +1245,716 @@
 							if (isset($arBasket['sum']['preis_brutto'])) $arBasket['sum']['preis'] = $arBasket['sum']['preis_brutto'];
 							if (isset($arBasket['sum']['preis_gesamt_brutto'])) $arBasket['sum']['preis_gesamt'] = $arBasket['sum']['preis_gesamt_brutto'];
-
-						}
-
-					}
-
+							
+						}
+						
+					}
+					
 					$arBasket['oOrder'] = wpsg_order::getInstance($this->o_id);
-
+					
 					return $arBasket;
-
-				}
-
-			}	// if (($this->o_id > 0) && false)
-
-			$arReturn = array();
-
-			if (wpsg_isSizedInt($_SESSION['wpsg']['order_id'])) $arReturn['oOrder'] = wpsg_order::getInstance($_SESSION['wpsg']['order_id']);
-			
-			$land = $this->shop->db->fetchRow("SELECT * FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($this->arCheckout['land'])."'");
-			 
-			if ($land['mwst'] == '1' || $this->shop->get_option('wpsg_kleinunternehmer') == '1') $noMwSt = true;
-			else if ($land['mwst'] == '2' && wpsg_isSizedString($this->arCheckout['ustidnr'])) $noMwSt = true;
-			else $noMwSt = false;
-			
-			$arReturn['noMwSt'] = $noMwSt;
-			$arReturn['produkte'] = array();
-			$arReturn['mwst'] = array();
-			$arReturn['sum'] = array(
-				'preis' => 0,
-				'preis_netto' => 0,
-				'preis_brutto' => 0,
-				'preis_gesamt_brutto' => 0,
-				'preis_gesamt_netto' => 0,
-				'preis_payment' => 0,
-				'preis_shipping' => 0,
-				'preis_shipping_netto' => 0,
-				'preis_shipping_brutto' => 0,
-				'preis_rabatt' => 0
-			);
-
-			// Hier sammel ich die Produktpreise
-			$arProductPrice = array(
-				WPSG_NETTO => array(),
-				WPSG_BRUTTO => array()
-			);
-            
-			foreach ($this->arProdukte as $product_index => &$b)
-			{
-
-				$produkt_id = $this->shop->getProduktID($b['id']);
-
-				wpsg_addSet($arReturn['menge'], $b['menge']);
-
-				$country = $this->shop->getDefaultCountry();
-
-				if (is_numeric($produkt_id))
-				{
-
-					// Preis wird berechnet daher entfernen
-					unset($b['preis']);
-					unset($b['preis_netto']);
-					unset($b['preis_brutto']);
-					unset($b['mwst_key']); // Key muss auch gelÃ¶scht werden, damit die loadProduktArray den Preis korrekt ermittelt (Sonst funktioniert es beim 2. Mal nicht)
-
-					// in $b sind eventuell auch Moduldaten drin (Produktvariablen)
-					$this->shop->country = $land['id'];
-					$b = $this->shop->loadProduktArray($produkt_id, $b, true);
-					//$this->shop->country = 0;
-
-					if (wpsg_isSizedInt($b['euleistungsortregel']))
-					{
-
-						$this->shop->showEULayer = true;
-						$country = $this->shop->getFrontendCountry();
-
-					}
-					
-					if ($backend === true)
-					{
-						$country = wpsg_country::getInstance($this->arCheckout['land']);
-					}
-
-					$b['productkey'] = $b['id'];
-
-				}
-
-				$this->shop->callMods('basket_toArray', array(&$b, $backend, $noMwSt));
-				$this->checkMwSt($b['mwst_key'], $country, $arReturn);
- 
-				if ($noMwSt)
-				{
-
-					// Damit erreiche ich, dass 0% angezeigt wird, wenn keine MwSt. berechnet wird
-					$this->arProdukte[$product_index]['mwst_key'] = false;
-
-					$price_product_netto = $b['preis_netto'];
-					$price_product_brutto = $b['preis_netto'];
-
+					
+				}
+				
+			} else {
+				
+				$arReturn = array();
+				
+				if (wpsg_isSizedInt($_SESSION['wpsg']['order_id'])) $arReturn['oOrder'] = wpsg_order::getInstance($_SESSION['wpsg']['order_id']);
+				
+				$land = $this->shop->db->fetchRow("SELECT * FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($this->arCheckout['land'])."'");
+				
+				if ($land['mwst'] == '1' || $this->shop->get_option('wpsg_kleinunternehmer') == '1') $noMwSt = true;
+				else if ($land['mwst'] == '2' && wpsg_isSizedString($this->arCheckout['ustidnr'])) $noMwSt = true;
+				else $noMwSt = false;
+				
+				$arReturn['noMwSt'] = $noMwSt;
+				$arReturn['produkte'] = array();
+				$arReturn['mwst'] = array();
+				$arReturn['sum'] = array(
+					'preis' => 0,
+					'preis_netto' => 0,
+					'preis_brutto' => 0,
+					'preis_gesamt_brutto' => 0,
+					'preis_gesamt_netto' => 0,
+					'preis_payment' => 0,
+					'preis_shipping' => 0,
+					'preis_shipping_netto' => 0,
+					'preis_shipping_brutto' => 0,
+					'preis_rabatt' => 0
+				);
+				
+				// Hier sammel ich die Produktpreise
+				$arProductPrice = array(
+					WPSG_NETTO => array(),
+					WPSG_BRUTTO => array()
+				);
+				
+				foreach ($this->arProdukte as $product_index => &$b)
+				{
+					
+					$produkt_id = $this->shop->getProduktID($b['id']);
+					
+					wpsg_addSet($arReturn['menge'], $b['menge']);
+					
+					$country = $this->shop->getDefaultCountry();
+					
+					if (is_numeric($produkt_id))
+					{
+						
+						// Preis wird berechnet daher entfernen
+						unset($b['preis']);
+						unset($b['preis_netto']);
+						unset($b['preis_brutto']);
+						unset($b['mwst_key']); // Key muss auch gelÃ¶scht werden, damit die loadProduktArray den Preis korrekt ermittelt (Sonst funktioniert es beim 2. Mal nicht)
+						
+						// in $b sind eventuell auch Moduldaten drin (Produktvariablen)
+						$this->shop->country = $land['id'];
+						$b = $this->shop->loadProduktArray($produkt_id, $b, true);
+						//$this->shop->country = 0;
+						
+						if (wpsg_isSizedInt($b['euleistungsortregel']))
+						{
+							
+							$this->shop->showEULayer = true;
+							$country = $this->shop->getFrontendCountry();
+							
+						}
+						
+						if ($backend === true)
+						{
+							$country = wpsg_country::getInstance($this->arCheckout['land']);
+						}
+						
+						$b['productkey'] = $b['id'];
+						
+					}
+					
+					$this->shop->callMods('basket_toArray', array(&$b, $backend, $noMwSt));
+					$this->checkMwSt($b['mwst_key'], $country, $arReturn);
+					
+					if ($noMwSt)
+					{
+						
+						// Damit erreiche ich, dass 0% angezeigt wird, wenn keine MwSt. berechnet wird
+						$this->arProdukte[$product_index]['mwst_key'] = false;
+						
+						$price_product_netto = $b['preis_netto'];
+						$price_product_brutto = $b['preis_netto'];
+						
+					}
+					else
+					{
+						
+						$price_product_netto = $b['preis_netto'];
+						$price_product_brutto = $b['preis_brutto'];
+						
+					}
+					
+					// Hier wird entschieden ob der gerundete oder der genaue Wert zum Gesamtpreis hinzuaddiert wird
+					if ($this->shop->addRoundedValues === true)
+					{
+						
+						$b['preis_netto'] = round($price_product_netto, 2);
+						$b['preis_brutto'] = round($price_product_brutto, 2);
+						
+					}
+					else
+					{
+						
+						$b['preis_netto'] = $price_product_netto;
+						$b['preis_brutto'] = $price_product_brutto;
+						
+					}
+					
+					$price_sum_netto = $b['preis_netto'] * $b['menge'];
+					$price_sum_brutto = $b['preis_brutto'] * $b['menge'];
+					
+					if ($this->shop->getFrontendTaxView() == WPSG_NETTO) $b['preis'] = round($b['preis_netto'], 2);
+					else $b['preis'] = round($b['preis_brutto'], 2);
+					
+					$arProductPrice[WPSG_NETTO][$b['mwst_key'].'_'.$country->id][] = $price_sum_netto;
+					$arProductPrice[WPSG_BRUTTO][$b['mwst_key'].'_'.$country->id][] = $price_sum_brutto;
+					
+					$b['product_index'] = $product_index;
+					$arReturn['produkte'][$product_index] = $b;
+					
+				} // foreach Produkte
+				
+				// Die Basis der Preisberechnung, wenn Brutto, dann wird Netto berechnet
+				if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
+				{
+					
+					$base = WPSG_NETTO;
+					$calc = WPSG_BRUTTO;
+					
 				}
 				else
 				{
-
-					$price_product_netto = $b['preis_netto'];
-					$price_product_brutto = $b['preis_brutto'];
-
-				}
-
-				// Hier wird entschieden ob der gerundete oder der genaue Wert zum Gesamtpreis hinzuaddiert wird
-				if ($this->shop->addRoundedValues === true)
-				{
-
-					$b['preis_netto'] = round($price_product_netto, 2);
-					$b['preis_brutto'] = round($price_product_brutto, 2);
-
+					
+					$base = WPSG_BRUTTO;
+					$calc = WPSG_NETTO;
+					
+				}
+				
+				// Jetzt die jeweilige Steuer berechnen, damit die Anzeige stimmt
+				foreach ($arProductPrice[$base] as $tax_key_lang => $tax)
+				{
+					
+					$arTaxKey = explode('_', $tax_key_lang);
+					$country_id = $arTaxKey[1];
+					$country_id = $this->arCheckout['land'];
+					$country = wpsg_country::getInstance($country_id);
+					$tax_key = $arTaxKey[0];
+					
+					if ($noMwSt === true) $tax_value = 0; else $tax_value = $country->getTax($tax_key);
+					
+					$sum_tax_value = round(wpsg_calculateSteuer(array_sum($tax), $base, $tax_value), 2);
+					
+					wpsg_addSet($arReturn['sum']['mwst'], $sum_tax_value);
+					
+					if ($calc === WPSG_NETTO)
+					{
+						
+						$sum_netto = round(wpsg_calculatePreis(array_sum($tax), WPSG_NETTO, $tax_value), 2);
+						$sum_brutto = array_sum($tax);
+						
+					}
+					else
+					{
+						
+						$sum_netto = array_sum($tax);
+						$sum_brutto = round(wpsg_calculatePreis(array_sum($tax), WPSG_BRUTTO, $tax_value), 2);
+						
+						// Rundungsfehler abfangen
+						if (abs($price_sum_brutto - $sum_brutto) < 0.02) $sum_brutto = $price_sum_brutto;
+						
+					}
+					
+					wpsg_addSet($arReturn['sum']['preis_netto'], $sum_netto);
+					wpsg_addSet($arReturn['sum']['preis_gesamt_netto'], $sum_netto);
+					wpsg_addSet($arReturn['sum']['preis_brutto'], $sum_brutto);
+					wpsg_addSet($arReturn['sum']['preis_gesamt_brutto'], $sum_brutto);
+					
+					if (!$noMwSt)
+					{
+						/*
+						if ((isset($this->arOrder['price_frontend'])) && ($this->arOrder['price_frontend'] == WPSG_BRUTTO))
+						{
+							wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
+							wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_brutto);
+	
+						}
+						else if ((isset($this->arOrder['price_frontend'])) && ($this->arOrder['price_frontend'] == WPSG_NETTO))
+						{
+							wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
+							wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_netto);
+	
+						}
+						else */
+						{
+							wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
+							wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_brutto);
+							
+						}
+						
+					}
+					
+				}
+				
+				if ($base === WPSG_NETTO)
+				{
+					
+					wpsg_addSet($arReturn['sum']['preis'], $arReturn['sum']['preis_netto']);
+					wpsg_addSet($arReturn['sum']['preis_gesamt'], $arReturn['sum']['preis_gesamt_netto']);
+					
 				}
 				else
 				{
-
-					$b['preis_netto'] = $price_product_netto;
-					$b['preis_brutto'] = $price_product_brutto;
-
-				}
-
-				$price_sum_netto = $b['preis_netto'] * $b['menge'];
-				$price_sum_brutto = $b['preis_brutto'] * $b['menge'];
-
-				if ($this->shop->getFrontendTaxView() == WPSG_NETTO) $b['preis'] = round($b['preis_netto'], 2);
-				else $b['preis'] = round($b['preis_brutto'], 2);
-
-				$arProductPrice[WPSG_NETTO][$b['mwst_key'].'_'.$country->id][] = $price_sum_netto;
-				$arProductPrice[WPSG_BRUTTO][$b['mwst_key'].'_'.$country->id][] = $price_sum_brutto;
-
-				$b['product_index'] = $product_index;
-				$arReturn['produkte'][$product_index] = $b;
-
-			} // foreach Produkte
- 
-			// Die Basis der Preisberechnung, wenn Brutto, dann wird Netto berechnet
-			if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
-			{
-
-				$base = WPSG_NETTO;
-				$calc = WPSG_BRUTTO;
-
-			}
-			else
-			{
-
-				$base = WPSG_BRUTTO;
-				$calc = WPSG_NETTO;
-
-			}
- 
-			// Jetzt die jeweilige Steuer berechnen, damit die Anzeige stimmt
-			foreach ($arProductPrice[$base] as $tax_key_lang => $tax)
-			{
-
-				$arTaxKey = explode('_', $tax_key_lang);
-				$country_id = $arTaxKey[1];
-				$country_id = $this->arCheckout['land'];
-				$country = wpsg_country::getInstance($country_id);
-				$tax_key = $arTaxKey[0];
-
-				if ($noMwSt === true) $tax_value = 0; else $tax_value = $country->getTax($tax_key);
-
-				$sum_tax_value = round(wpsg_calculateSteuer(array_sum($tax), $base, $tax_value), 2);
-
-				wpsg_addSet($arReturn['sum']['mwst'], $sum_tax_value);
-
-				if ($calc === WPSG_NETTO)
-				{
-
-					$sum_netto = round(wpsg_calculatePreis(array_sum($tax), WPSG_NETTO, $tax_value), 2);
-					$sum_brutto = array_sum($tax);
-
+					
+					wpsg_addSet($arReturn['sum']['preis'], $arReturn['sum']['preis_brutto']);
+					wpsg_addSet($arReturn['sum']['preis_gesamt'], $arReturn['sum']['preis_gesamt_brutto']);
+					
+				}
+				
+				if ($backend)
+				{
+					$arReturn['backend'] = $backend;
+					$arReturn['price_frontend'] = $this->arOrder['price_frontend'];
+					$arReturn['order_rabatt'] = $this->arOrder['price_rabatt'];
+					$arReturn['gs_value'] = $this->arOrder['price_gs'];
+					
+				}
+				
+				// Gutschein einberechnen
+				$this->shop->callMod('wpsg_mod_gutschein', 'basket_toArray_gs', array(&$this, &$arReturn));
+				
+				// Staffelrabatt
+				$this->shop->callMod('wpsg_mod_discount', 'basket_toArray_discount', array(&$this, &$arReturn));
+				
+				// Kundendaten einfÃŒgen
+				$arReturn['checkout'] = $this->arCheckout;
+				
+				$this->shop->callMods('basket_toArray_preshippayment', array(&$this, &$arReturn));
+				
+				// Die Versandkosten fÃŒr den Warenkorb berechnen
+				// Dies darf im checkout2 nicht passieren, oder wenn der Parameter auf true
+				//			if (false && $this->o_id > 0)
+				if ($this->o_id > 0)
+				{
+					
+					$order_data = $this->shop->cache->loadOrder($this->o_id);
+					$price_shipping = $order_data['price_shipping'];
+					$price_payment = $order_data['price_payment'];
+					$arReturn['sum']['preis_payment_brutto'] = $order_data['price_payment_brutto'];
+					$arReturn['sum']['preis_payment_netto'] = $order_data['price_payment_netto'];
+					$arReturn['sum']['preis_shipping_brutto'] = $order_data['price_shipping_brutto'];
+					$arReturn['sum']['preis_shipping_netto'] = $order_data['price_shipping_netto'];
+					
+					/*
+	
+					if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
+					{
+	
+						$arReturn['sum']['preis_payment_brutto'] = $price_payment;
+						$arReturn['sum']['preis_payment_netto'] = wpsg_calculatePreis($price_payment, WPSG_NETTO, $order_data['mwst_payment']);
+	
+						$arReturn['sum']['preis_shipping_brutto'] = $price_shipping;
+						$arReturn['sum']['preis_shipping_netto'] = wpsg_calculatePreis($price_shipping, WPSG_NETTO, $order_data['mwst_shipping']);
+	
+					}
+					else
+					{
+	
+						$arReturn['sum']['preis_payment_netto'] = $price_payment;
+						$arReturn['sum']['preis_payment_brutto'] = wpsg_calculatePreis($price_payment, WPSG_BRUTTO, $order_data['mwst_payment']);
+	
+						$arReturn['sum']['preis_shipping_netto'] = $price_shipping;
+						$arReturn['sum']['preis_shipping_brutto'] = wpsg_calculatePreis($price_shipping, WPSG_BRUTTO, $order_data['mwst_shipping']);
+	
+					}
+					*/
 				}
 				else
 				{
-
-					$sum_netto = array_sum($tax);
-					$sum_brutto = round(wpsg_calculatePreis(array_sum($tax), WPSG_BRUTTO, $tax_value), 2);
-					
-					// Rundungsfehler abfangen
-					if (abs($price_sum_brutto - $sum_brutto) < 0.02) $sum_brutto = $price_sum_brutto;
-
-				}
-
-				wpsg_addSet($arReturn['sum']['preis_netto'], $sum_netto);
-				wpsg_addSet($arReturn['sum']['preis_gesamt_netto'], $sum_netto);
-				wpsg_addSet($arReturn['sum']['preis_brutto'], $sum_brutto);
-				wpsg_addSet($arReturn['sum']['preis_gesamt_brutto'], $sum_brutto);
-
-				if (!$noMwSt)
-				{
-					/*
-					if ((isset($this->arOrder['price_frontend'])) && ($this->arOrder['price_frontend'] == WPSG_BRUTTO))
-					{
-						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
-						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_brutto);
-
-					}
-					else if ((isset($this->arOrder['price_frontend'])) && ($this->arOrder['price_frontend'] == WPSG_NETTO))
-					{
-						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
-						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_netto);
-
-					}
-					else */
-					{
-						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['sum'], $sum_tax_value);
-						wpsg_addSet($arReturn['mwst'][$tax_key_lang]['base_value'], $sum_brutto);
-
-					}
-
-				}
-
-			}
-
-			if ($base === WPSG_NETTO)
-			{
-
-				wpsg_addSet($arReturn['sum']['preis'], $arReturn['sum']['preis_netto']);
-				wpsg_addSet($arReturn['sum']['preis_gesamt'], $arReturn['sum']['preis_gesamt_netto']);
-
-			}
-			else
-			{
-
-				wpsg_addSet($arReturn['sum']['preis'], $arReturn['sum']['preis_brutto']);
-				wpsg_addSet($arReturn['sum']['preis_gesamt'], $arReturn['sum']['preis_gesamt_brutto']);
-
-			}
-
-			if ($backend)
-			{
-				$arReturn['backend'] = $backend;
-				$arReturn['price_frontend'] = $this->arOrder['price_frontend'];
-				$arReturn['order_rabatt'] = $this->arOrder['price_rabatt'];
-				$arReturn['gs_value'] = $this->arOrder['price_gs'];
-
-			}
-
-			// Gutschein einberechnen
-			$this->shop->callMod('wpsg_mod_gutschein', 'basket_toArray_gs', array(&$this, &$arReturn));
-
-			// Staffelrabatt
-			$this->shop->callMod('wpsg_mod_discount', 'basket_toArray_discount', array(&$this, &$arReturn));
-
-			// Kundendaten einfÃŒgen
-			$arReturn['checkout'] = $this->arCheckout;
-
-			$this->shop->callMods('basket_toArray_preshippayment', array(&$this, &$arReturn));
-
-			// Die Versandkosten fÃŒr den Warenkorb berechnen
-			// Dies darf im checkout2 nicht passieren, oder wenn der Parameter auf true
-//			if (false && $this->o_id > 0)
-			if ($this->o_id > 0)
-			{
-
-				$order_data = $this->shop->cache->loadOrder($this->o_id);
-				$price_shipping = $order_data['price_shipping'];
-				$price_payment = $order_data['price_payment'];
-				$arReturn['sum']['preis_payment_brutto'] = $order_data['price_payment_brutto'];
-				$arReturn['sum']['preis_payment_netto'] = $order_data['price_payment_netto'];
-				$arReturn['sum']['preis_shipping_brutto'] = $order_data['price_shipping_brutto'];
-				$arReturn['sum']['preis_shipping_netto'] = $order_data['price_shipping_netto'];
- 
+					
+					// Bin mir nicht sicher warum die Versandkosten/Zahlungskosten im Checkout nicht berechnet wurde
+					// Aufgrund von PayPal (PayPal Plus) brauch ich sie aber
+					//if (!isset($_REQUEST['wpsg_checkout2']) && !$clearVK)
+					{
+						
+						if ($backend) $arReturn['backend'] = true;
+						else $arReturn['backend'] = false;
+						
+						if (!$backend)
+						{
+							
+							/*
+							 * PrÃŒfen ob die gesetzte Zahlungsart auch in den VerfÃŒgbaren ist
+							 * Ist fÃŒr die Auswahl der LÃ€nder, Zahlungsarten und Versandarten im Warenkorb nÃ¶tig geworden
+							 */
+							if (wpsg_isSizedInt($arReturn['checkout']['shipping']) && !@array_key_exists($arReturn['checkout']['shipping'], $this->shop->arShipping))
+							{
+								
+								unset($arReturn['checkout']['shipping']);
+								
+							}
+							
+							if (wpsg_isSizedInt($arReturn['checkout']['payment']) && !array_key_exists($arReturn['checkout']['payment'], $this->shop->arPayment))
+							{
+								
+								unset($arReturn['checkout']['payment']);
+								
+							}
+							
+						}
+						
+						// Versandarten kÃ¶nnen gruppiert sein, vorher trennen
+						if (wpsg_isSizedString($arReturn['checkout']['shipping']) && preg_match('/(.*)\-(.*)/', $arReturn['checkout']['shipping']))
+						{
+							
+							$arShipping = explode('-', $arReturn['checkout']['shipping']);
+							
+							// Ich simuliere hier die Berechnung in einem Extra Array, da die Funktion leider so gebaut ist
+							// Sonst ist die Grundlage fÃŒr die Berechnung nicht die Selbe
+							$arBasketPreShipping = $arReturn;
+							
+							foreach ($arShipping as $shipping)
+							{
+								
+								$basket_calc = $arBasketPreShipping;
+								
+								$this->shop->callMods('calcShipping', array(&$basket_calc, $shipping));
+								
+								wpsg_addSet($arReturn['sum']['preis_shipping'], $basket_calc['sum']['preis_shipping']);
+								wpsg_addSet($arReturn['sum']['preis_shipping_brutto'], $basket_calc['sum']['preis_shipping_brutto']);
+								wpsg_addSet($arReturn['sum']['preis_shipping_netto'], $basket_calc['sum']['preis_shipping_netto']);
+								
+								wpsg_addSet($arReturn['shipping']['mwst'], $basket_calc['shipping']['mwst']);
+								wpsg_addSet($arReturn['shipping']['preis_shipping_netto'], $basket_calc['shipping']['preis_shipping_netto']);
+								wpsg_addSet($arReturn['shipping']['preis_shipping_brutto'], $basket_calc['shipping']['preis_shipping_brutto']);
+								
+								foreach ($basket_calc['mwst'] as $tax_key => $mwst)
+								{
+									
+									$this->shop->basket->checkMwSt(substr($tax_key, 0, 1), $this->shop->getDefaultCountry(), $arReturn);
+									
+									if (!array_key_exists($tax_key, $arBasketPreShipping['mwst']))
+									{
+										
+										// Satz war vorher noch nicht drin
+										$arReturn['mwst'][$tax_key]['sum'] += $mwst['sum'];
+										$arReturn['mwst'][$tax_key]['base_value'] += $mwst['base_value'];
+										
+									}
+									else
+									{
+										
+										$arReturn['mwst'][$tax_key]['sum'] += ($mwst['sum'] - $arBasketPreShipping['mwst'][$tax_key]['sum']);
+										$arReturn['mwst'][$tax_key]['base_value'] += ($mwst['base_value'] - $arBasketPreShipping['mwst'][$tax_key]['base_value']);
+										
+									}
+									
+								}
+								
+								if (wpsg_isSizedArray($arReturn['shipping']['methods'])) $arReturn['shipping']['methods'][] = $shipping;
+								else $arReturn['shipping']['methods'] = array($shipping);
+								
+							}
+							
+							//wpsg_debug($arReturn);die();
+							
+							// In den Produktdaten sind die fÃŒr das Produkt zulÃ€ssigen Versandarten gespeichert, hier entferne ich noch die die in dieser Bestellung nicht gewÃ€hlt wurden
+							foreach ($arReturn['produkte'] as &$p)
+							{
+								
+								if (wpsg_isSizedString($p['allowedshipping']))
+								{
+									
+									$arAllowedShipping = explode(',', $p['allowedshipping']);
+									
+									foreach ($arAllowedShipping as $shipping)
+									{
+										
+										if (!in_array($shipping, $arReturn['shipping']['methods'])) unset($arReturn['shipping']['methods'][$shipping]);
+										
+									}
+									
+									$p['order_allowedshipping'] = $arAllowedShipping;
+									
+								}
+								
+							}
+							
+							// Anteilig und kein eindeutiger Satz, wenn zusammengesetzte Versandart
+							unset($arReturn['shipping']['mwst']);
+							$arReturn['shipping']['tax_rata'] = true;
+							
+						}
+						else
+						{
+							
+							$this->shop->callMods('calcShipping', array(&$arReturn, $arReturn['checkout']['shipping']));
+							
+						}
+						
+						$this->shop->callMods('calcPayment', array(&$arReturn));
+						
+					}
+					
+				}
 				/*
-
-				if ($this->shop->getFrontendTaxview() == WPSG_BRUTTO)
-				{
-
-					$arReturn['sum']['preis_payment_brutto'] = $price_payment;
-					$arReturn['sum']['preis_payment_netto'] = wpsg_calculatePreis($price_payment, WPSG_NETTO, $order_data['mwst_payment']);
-
-					$arReturn['sum']['preis_shipping_brutto'] = $price_shipping;
-					$arReturn['sum']['preis_shipping_netto'] = wpsg_calculatePreis($price_shipping, WPSG_NETTO, $order_data['mwst_shipping']);
-
-				}
-				else
-				{
-
-					$arReturn['sum']['preis_payment_netto'] = $price_payment;
-					$arReturn['sum']['preis_payment_brutto'] = wpsg_calculatePreis($price_payment, WPSG_BRUTTO, $order_data['mwst_payment']);
-
-					$arReturn['sum']['preis_shipping_netto'] = $price_shipping;
-					$arReturn['sum']['preis_shipping_brutto'] = wpsg_calculatePreis($price_shipping, WPSG_BRUTTO, $order_data['mwst_shipping']);
-
-				}
-				*/
-			}
-			else
-			{
-                 
-				// Bin mir nicht sicher warum die Versandkosten/Zahlungskosten im Checkout nicht berechnet wurde
-				// Aufgrund von PayPal (PayPal Plus) brauch ich sie aber
-				//if (!isset($_REQUEST['wpsg_checkout2']) && !$clearVK)
-				{
-
-					if ($backend) $arReturn['backend'] = true;
-					else $arReturn['backend'] = false;
-
-					if (!$backend)
-					{
-
-						/*
-						 * PrÃŒfen ob die gesetzte Zahlungsart auch in den VerfÃŒgbaren ist
-						 * Ist fÃŒr die Auswahl der LÃ€nder, Zahlungsarten und Versandarten im Warenkorb nÃ¶tig geworden
-						 */
-						if (wpsg_isSizedInt($arReturn['checkout']['shipping']) && !@array_key_exists($arReturn['checkout']['shipping'], $this->shop->arShipping))
-						{
-
-							unset($arReturn['checkout']['shipping']);
-
-						}
-
-						if (wpsg_isSizedInt($arReturn['checkout']['payment']) && !array_key_exists($arReturn['checkout']['payment'], $this->shop->arPayment))
-						{
-
-							unset($arReturn['checkout']['payment']);
-
-						}
-
-					}
-
-					// Versandarten kÃ¶nnen gruppiert sein, vorher trennen
-					if (wpsg_isSizedString($arReturn['checkout']['shipping']) && preg_match('/(.*)\-(.*)/', $arReturn['checkout']['shipping']))
-					{
-
-						$arShipping = explode('-', $arReturn['checkout']['shipping']);
-
-						// Ich simuliere hier die Berechnung in einem Extra Array, da die Funktion leider so gebaut ist
-						// Sonst ist die Grundlage fÃŒr die Berechnung nicht die Selbe
-						$arBasketPreShipping = $arReturn;
-
-						foreach ($arShipping as $shipping)
-						{
-
-							$basket_calc = $arBasketPreShipping;
-
-							$this->shop->callMods('calcShipping', array(&$basket_calc, $shipping));
-
-							wpsg_addSet($arReturn['sum']['preis_shipping'], $basket_calc['sum']['preis_shipping']);
-							wpsg_addSet($arReturn['sum']['preis_shipping_brutto'], $basket_calc['sum']['preis_shipping_brutto']);
-							wpsg_addSet($arReturn['sum']['preis_shipping_netto'], $basket_calc['sum']['preis_shipping_netto']);
-
-							wpsg_addSet($arReturn['shipping']['mwst'], $basket_calc['shipping']['mwst']);
-							wpsg_addSet($arReturn['shipping']['preis_shipping_netto'], $basket_calc['shipping']['preis_shipping_netto']);
-							wpsg_addSet($arReturn['shipping']['preis_shipping_brutto'], $basket_calc['shipping']['preis_shipping_brutto']);
-
-							foreach ($basket_calc['mwst'] as $tax_key => $mwst)
-							{
-
-								$this->shop->basket->checkMwSt(substr($tax_key, 0, 1), $this->shop->getDefaultCountry(), $arReturn);
-
-								if (!array_key_exists($tax_key, $arBasketPreShipping['mwst']))
-								{
-
-									// Satz war vorher noch nicht drin
-									$arReturn['mwst'][$tax_key]['sum'] += $mwst['sum'];
-									$arReturn['mwst'][$tax_key]['base_value'] += $mwst['base_value'];
-
-								}
-								else
-								{
-
-									$arReturn['mwst'][$tax_key]['sum'] += ($mwst['sum'] - $arBasketPreShipping['mwst'][$tax_key]['sum']);
-									$arReturn['mwst'][$tax_key]['base_value'] += ($mwst['base_value'] - $arBasketPreShipping['mwst'][$tax_key]['base_value']);
-
-								}
-
-							}
-
-							if (wpsg_isSizedArray($arReturn['shipping']['methods'])) $arReturn['shipping']['methods'][] = $shipping;
-							else $arReturn['shipping']['methods'] = array($shipping);
-
-						}
-
-						//wpsg_debug($arReturn);die();
-
-						// In den Produktdaten sind die fÃŒr das Produkt zulÃ€ssigen Versandarten gespeichert, hier entferne ich noch die die in dieser Bestellung nicht gewÃ€hlt wurden
-						foreach ($arReturn['produkte'] as &$p)
-						{
-
-							if (wpsg_isSizedString($p['allowedshipping']))
-							{
-
-								$arAllowedShipping = explode(',', $p['allowedshipping']);
-
-								foreach ($arAllowedShipping as $shipping)
-								{
-
-									if (!in_array($shipping, $arReturn['shipping']['methods'])) unset($arReturn['shipping']['methods'][$shipping]);
-
-								}
-
-								$p['order_allowedshipping'] = $arAllowedShipping;
-
-							}
-
-						}
-
-						// Anteilig und kein eindeutiger Satz, wenn zusammengesetzte Versandart
-						unset($arReturn['shipping']['mwst']);
-						$arReturn['shipping']['tax_rata'] = true;
-                       
-					}
-					else
-					{
-
-						$this->shop->callMods('calcShipping', array(&$arReturn, $arReturn['checkout']['shipping']));
-
-					}
- 
-					$this->shop->callMods('calcPayment', array(&$arReturn));
-
-				}
-
-			}
-			/*
-			// Zahlungskosten der Summe hinzurechnen
-			if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
-			if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-
-			// Versandkosten der Summe hinzurechnen
-			if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
-			if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-			*/
-			if ($backend)
-			{
-
-				// Preise so anzeigen wie im Backend eingestellt
-				$price_option = $this->shop->get_option('wpsg_preisangaben');
-				foreach ($arReturn['produkte'] as $produkt_key => &$p) {
-					//if ($arReturn['price_frontend'] == WPSG_NETTO)
-					if ($price_option == WPSG_NETTO)
-							{
-						$p['preis'] = $p['preis_netto'];
-					}
-					else
-					{
-						$p['preis'] = $p['preis_brutto'];
-					}
-				}
-
-/*
 				// Zahlungskosten der Summe hinzurechnen
 				if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
 				if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-
+	
 				// Versandkosten der Summe hinzurechnen
 				if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
 				if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-*/
-				//if ($arReturn['price_frontend'] == WPSG_NETTO)
-				if ($price_option == WPSG_NETTO)
-				{
-					$taxp = 0.0;
-					//$taxp = $this->addMwSt($arReturn, $arReturn['sum']['preis_payment_netto']);
-					//$taxs = $this->addMwSt($arReturn, $arReturn['sum']['preis_shipping_netto']);
-					//$taxp = abs($taxp);
-					//$taxs = abs($taxs);
-
-					$mb = new wpsg_mod_basic;
-					//$t = $this->shop->get_option('wpsg_mod_targo_mwst');	// 0=anteilig, sonst a,b,c,d,e
-					$pricep = $arReturn['sum']['preis_payment_brutto'];
-					$prices = $arReturn['sum']['preis_shipping_brutto'];
-					unset($arReturn['sum']['preis_payment_netto']);
-					unset($arReturn['sum']['preis_payment_brutto']);
-					unset($arReturn['sum']['preis_shipping_netto']);
-					unset($arReturn['sum']['preis_shipping_brutto']);
-
-                    $id = $arReturn['checkout']['payment'];
-					$tax_keyp = $this->shop->arPayment[$id]['mwst'];
-					$mb->setPaymentKosten($arReturn, $pricep, $tax_keyp);
-					$taxp = $arReturn['payment']['mwst'];
-
-					$id = $arReturn['checkout']['shipping'];
-					$tax_keys = $this->shop->arShipping[$id]['mwst'];
-					$mb->setShippingKosten($arReturn, 'x', $prices, $tax_keys);
-					$taxs = $arReturn['shipping']['mwst'];
-
-					if ($this->shop->addRoundedValues === true)
-					{
-
-						$arReturn['sum']['preis_payment_brutto'] = round($arReturn['sum']['preis_payment_brutto'], 2);
-						$arReturn['sum']['preis_payment_netto'] = round($arReturn['sum']['preis_payment_netto'], 2);
-						$arReturn['sum']['preis_shipping_brutto'] = round($arReturn['sum']['preis_shipping_brutto'], 2);
-						$arReturn['sum']['preis_shipping_netto'] = round($arReturn['sum']['preis_shipping_netto'], 2);
-
-					}
-					else
-					{
-
-						$arReturn['sum']['preis_payment_brutto'] = $arReturn['sum']['preis_payment_netto'] + $taxp;
-						$arReturn['sum']['preis_payment_netto'] = $arReturn['sum']['preis_payment_netto'];
-						$arReturn['sum']['preis_shipping_brutto'] = $arReturn['sum']['preis_shipping_netto'] + $taxs;
-						$arReturn['sum']['preis_shipping_netto'] = $arReturn['sum']['preis_shipping_netto'];
-
-					}
-
+				*/
+				if ($backend)
+				{
+					
+					// Preise so anzeigen wie im Backend eingestellt
+					$price_option = $this->shop->get_option('wpsg_preisangaben');
+					foreach ($arReturn['produkte'] as $produkt_key => &$p) {
+						//if ($arReturn['price_frontend'] == WPSG_NETTO)
+						if ($price_option == WPSG_NETTO)
+						{
+							$p['preis'] = $p['preis_netto'];
+						}
+						else
+						{
+							$p['preis'] = $p['preis_brutto'];
+						}
+					}
+					
+					/*
+									// Zahlungskosten der Summe hinzurechnen
+									if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
+									if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
+					
+									// Versandkosten der Summe hinzurechnen
+									if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
+									if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
+					*/
+					//if ($arReturn['price_frontend'] == WPSG_NETTO)
+					if ($price_option == WPSG_NETTO)
+					{
+						$taxp = 0.0;
+						//$taxp = $this->addMwSt($arReturn, $arReturn['sum']['preis_payment_netto']);
+						//$taxs = $this->addMwSt($arReturn, $arReturn['sum']['preis_shipping_netto']);
+						//$taxp = abs($taxp);
+						//$taxs = abs($taxs);
+						
+						$mb = new wpsg_mod_basic;
+						//$t = $this->shop->get_option('wpsg_mod_targo_mwst');	// 0=anteilig, sonst a,b,c,d,e
+						$pricep = $arReturn['sum']['preis_payment_brutto'];
+						$prices = $arReturn['sum']['preis_shipping_brutto'];
+						unset($arReturn['sum']['preis_payment_netto']);
+						unset($arReturn['sum']['preis_payment_brutto']);
+						unset($arReturn['sum']['preis_shipping_netto']);
+						unset($arReturn['sum']['preis_shipping_brutto']);
+						
+						$id = $arReturn['checkout']['payment'];
+						$tax_keyp = $this->shop->arPayment[$id]['mwst'];
+						$mb->setPaymentKosten($arReturn, $pricep, $tax_keyp);
+						$taxp = $arReturn['payment']['mwst'];
+						
+						$id = $arReturn['checkout']['shipping'];
+						$tax_keys = $this->shop->arShipping[$id]['mwst'];
+						$mb->setShippingKosten($arReturn, 'x', $prices, $tax_keys);
+						$taxs = $arReturn['shipping']['mwst'];
+						
+						if ($this->shop->addRoundedValues === true)
+						{
+							
+							$arReturn['sum']['preis_payment_brutto'] = round($arReturn['sum']['preis_payment_brutto'], 2);
+							$arReturn['sum']['preis_payment_netto'] = round($arReturn['sum']['preis_payment_netto'], 2);
+							$arReturn['sum']['preis_shipping_brutto'] = round($arReturn['sum']['preis_shipping_brutto'], 2);
+							$arReturn['sum']['preis_shipping_netto'] = round($arReturn['sum']['preis_shipping_netto'], 2);
+							
+						}
+						else
+						{
+							
+							$arReturn['sum']['preis_payment_brutto'] = $arReturn['sum']['preis_payment_netto'] + $taxp;
+							$arReturn['sum']['preis_payment_netto'] = $arReturn['sum']['preis_payment_netto'];
+							$arReturn['sum']['preis_shipping_brutto'] = $arReturn['sum']['preis_shipping_netto'] + $taxs;
+							$arReturn['sum']['preis_shipping_netto'] = $arReturn['sum']['preis_shipping_netto'];
+							
+						}
+						
+						// Zahlungskosten der Summe hinzurechnen
+						if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
+						if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
+						
+						// Versandkosten der Summe hinzurechnen
+						if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
+						if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
+						
+						foreach ($arReturn['mwst'] as $key => $value) {
+							$arReturn['sum']['preis_gesamt_netto'] += $value['sum'];
+						}
+						$arReturn['sum']['preis'] = $arReturn['sum']['preis_netto'];
+						$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_netto'];
+						$arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_netto'];
+						$arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_netto'];
+						$arReturn['sum']['preis_rabatt'] = $arReturn['sum']['preis_rabatt_netto'];
+						if (array_key_exists('gs', $arReturn['sum']))
+						{
+							$arReturn['sum']['gs'] = $arReturn['sum']['gs_netto'];
+						}
+						
+					}
+					else	// if ($price_option == WPSG_NETTO)
+					{
+						$taxp = 0;
+						$mb = new wpsg_mod_basic;
+						//$t = $this->shop->get_option('wpsg_mod_targo_mwst');	// 0=anteilig, sonst a,b,c,d,e
+						$pricep = $arReturn['sum']['preis_payment_brutto'];
+						$prices = $arReturn['sum']['preis_shipping_brutto'];
+						unset($arReturn['sum']['preis_payment_netto']);
+						unset($arReturn['sum']['preis_payment_brutto']);
+						unset($arReturn['sum']['preis_shipping_netto']);
+						unset($arReturn['sum']['preis_shipping_brutto']);
+						
+						$id = $arReturn['checkout']['payment'];
+						$tax_keyp = $this->shop->arPayment[$id]['mwst'];
+						$mb->setPaymentKosten($arReturn, $pricep, $tax_keyp);
+						$taxp = $arReturn['payment']['mwst'];
+						
+						$id = $arReturn['checkout']['shipping'];
+						$tax_keys = wpsg_getStr($this->shop->arShipping[$id]['mwst']);
+						$mb->setShippingKosten($arReturn, 'x', $prices, $tax_keys);
+						$taxs = $arReturn['shipping']['mwst'];
+						
+						//$taxp = $this->addMwSt($arReturn, $arReturn['sum']['preis_payment_brutto']);
+						//$taxs = $this->addMwSt($arReturn, $arReturn['sum']['preis_shipping_brutto']);
+						//$taxp = abs($taxp);
+						//$taxs = abs($taxs);
+						
+						if ($this->shop->addRoundedValues === true)
+						{
+							
+							$arReturn['sum']['preis_payment_brutto'] = round($arReturn['sum']['preis_payment_brutto'], 2);
+							$arReturn['sum']['preis_payment_netto'] = round($arReturn['sum']['preis_payment_brutto'] - $taxp, 2);
+							$arReturn['sum']['preis_shipping_brutto'] = round($arReturn['sum']['preis_shipping_brutto'], 2);
+							$arReturn['sum']['preis_shipping_netto'] = round($arReturn['sum']['preis_shipping_brutto'] - $taxs, 2);
+							
+						}
+						else
+						{
+							
+							$arReturn['sum']['preis_payment_brutto'] = $arReturn['sum']['preis_payment_netto'];
+							$arReturn['sum']['preis_payment_netto'] = $arReturn['sum']['preis_payment_brutto'] - $taxp;
+							$arReturn['sum']['preis_shipping_brutto'] = $arReturn['sum']['preis_shipping_brutto'];
+							$arReturn['sum']['preis_shipping_netto'] = $arReturn['sum']['preis_shipping_brutto'] - $taxs;
+							
+						}
+						
+						// Zahlungskosten der Summe hinzurechnen
+						if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
+						if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
+						
+						// Versandkosten der Summe hinzurechnen
+						if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
+						if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
+						
+						$arReturn['sum']['preis'] = $arReturn['sum']['preis_brutto'];
+						$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_brutto'];
+						$arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_brutto'];
+						$arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_brutto'];
+						$arReturn['sum']['preis_rabatt'] = wpsg_getFloat($arReturn['sum']['preis_rabatt_brutto']);
+						if (array_key_exists('gs', $arReturn['sum']))
+						{
+							$arReturn['sum']['gs'] = $arReturn['sum']['gs_brutto'];
+						}
+					}	// else if ($price_option == WPSG_NETTO)
+					
+				}
+				else 	// if ($backend)
+				{
+					
 					// Zahlungskosten der Summe hinzurechnen
 					if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
 					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-
+					
 					// Versandkosten der Summe hinzurechnen
 					if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
 					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-
-					foreach ($arReturn['mwst'] as $key => $value) {
-						$arReturn['sum']['preis_gesamt_netto'] += $value['sum'];
-					}
-					$arReturn['sum']['preis'] = $arReturn['sum']['preis_netto'];
-					$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_netto'];
-					$arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_netto'];
-					$arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_netto'];
-					$arReturn['sum']['preis_rabatt'] = $arReturn['sum']['preis_rabatt_netto'];
-					if (array_key_exists('gs', $arReturn['sum']))
-					{
-						$arReturn['sum']['gs'] = $arReturn['sum']['gs_netto'];
-					}
-
-				}
-				else	// if ($price_option == WPSG_NETTO)
-				{
-					$taxp = 0;
-					$mb = new wpsg_mod_basic;
-					//$t = $this->shop->get_option('wpsg_mod_targo_mwst');	// 0=anteilig, sonst a,b,c,d,e
-					$pricep = $arReturn['sum']['preis_payment_brutto'];
-					$prices = $arReturn['sum']['preis_shipping_brutto'];
-					unset($arReturn['sum']['preis_payment_netto']);
-					unset($arReturn['sum']['preis_payment_brutto']);
-					unset($arReturn['sum']['preis_shipping_netto']);
-					unset($arReturn['sum']['preis_shipping_brutto']);
- 
-					$id = $arReturn['checkout']['payment']; 
-					$tax_keyp = $this->shop->arPayment[$id]['mwst']; 
-					$mb->setPaymentKosten($arReturn, $pricep, $tax_keyp);
-					$taxp = $arReturn['payment']['mwst'];
-
-                    $id = $arReturn['checkout']['shipping'];
-					$tax_keys = wpsg_getStr($this->shop->arShipping[$id]['mwst']);
-					$mb->setShippingKosten($arReturn, 'x', $prices, $tax_keys);
-					$taxs = $arReturn['shipping']['mwst'];
-
-					//$taxp = $this->addMwSt($arReturn, $arReturn['sum']['preis_payment_brutto']);
-					//$taxs = $this->addMwSt($arReturn, $arReturn['sum']['preis_shipping_brutto']);
-					//$taxp = abs($taxp);
-					//$taxs = abs($taxs);
-
-					if ($this->shop->addRoundedValues === true)
-					{
-
-						$arReturn['sum']['preis_payment_brutto'] = round($arReturn['sum']['preis_payment_brutto'], 2);
-						$arReturn['sum']['preis_payment_netto'] = round($arReturn['sum']['preis_payment_brutto'] - $taxp, 2);
-						$arReturn['sum']['preis_shipping_brutto'] = round($arReturn['sum']['preis_shipping_brutto'], 2);
-						$arReturn['sum']['preis_shipping_netto'] = round($arReturn['sum']['preis_shipping_brutto'] - $taxs, 2);
-
+					
+					// Preisangaben fÃŒrs Frontend
+					if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
+					{
+						
+						if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_shipping_netto'];
+						if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_payment_netto'];
+						
+						if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_netto'];
+						if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_netto'];
+						
 					}
 					else
 					{
-
-						$arReturn['sum']['preis_payment_brutto'] = $arReturn['sum']['preis_payment_netto'];
-						$arReturn['sum']['preis_payment_netto'] = $arReturn['sum']['preis_payment_brutto'] - $taxp;
-						$arReturn['sum']['preis_shipping_brutto'] = $arReturn['sum']['preis_shipping_brutto'];
-						$arReturn['sum']['preis_shipping_netto'] = $arReturn['sum']['preis_shipping_brutto'] - $taxs;
-
-					}
-
-					// Zahlungskosten der Summe hinzurechnen
-					if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
-					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-
-					// Versandkosten der Summe hinzurechnen
-					if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
-					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-
-					$arReturn['sum']['preis'] = $arReturn['sum']['preis_brutto'];
-					$arReturn['sum']['preis_gesamt'] = $arReturn['sum']['preis_gesamt_brutto'];
-					$arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_brutto'];
-					$arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_brutto'];
-					$arReturn['sum']['preis_rabatt'] = wpsg_getFloat($arReturn['sum']['preis_rabatt_brutto']);
-					if (array_key_exists('gs', $arReturn['sum']))
-					{
-						$arReturn['sum']['gs'] = $arReturn['sum']['gs_brutto'];
-					}
-				}	// else if ($price_option == WPSG_NETTO)
-
-			}
-			else 	// if ($backend)
-			{
-
-				// Zahlungskosten der Summe hinzurechnen
-				if (isset($arReturn['sum']['preis_payment_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_payment_netto'];
-				if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_payment_brutto'];
-
-				// Versandkosten der Summe hinzurechnen
-				if (isset($arReturn['sum']['preis_shipping_netto'])) $arReturn['sum']['preis_gesamt_netto'] += $arReturn['sum']['preis_shipping_netto'];
-				if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt_brutto'] += $arReturn['sum']['preis_shipping_brutto'];
-
-				// Preisangaben fÃŒrs Frontend
-				if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
-				{
-
-					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_shipping_netto'];
-					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_payment_netto'];
-
-					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_netto'];
-					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_netto'];
-
-				}
-				else
-				{
-
-					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_shipping_brutto'];
-					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_payment_brutto'];
-
-					if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_brutto'];
-					if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_brutto'];
-
-				}
-
-			}	// else if ($backend)
-
-			// Leere MwSt. SÃ€tze entfernen
-			foreach ((array)$arReturn['mwst'] as $k => $v)
-			{
-				if ($v['sum'] <= 0) unset($arReturn['mwst'][$k]);
-			}
-
-			// Negative Bestellungen Verhindern
-			if (isset($arReturn['sum']['preis_netto']) && $arReturn['sum']['preis_netto'] < 0) $arReturn['sum']['preis_netto'] = 0;
-			if (isset($arReturn['sum']['preis_brutto']) && $arReturn['sum']['preis_brutto'] < 0) $arReturn['sum']['preis_brutto'] = 0;
-			if (isset($arReturn['sum']['preis']) && $arReturn['sum']['preis'] < 0) $arReturn['sum']['preis'] = 0;
-			if (isset($arReturn['sum']['preis_gesamt_netto']) && $arReturn['sum']['preis_gesamt_netto'] < 0) $arReturn['sum']['preis_gesamt_netto'] = 0;
-			if (isset($arReturn['sum']['preis_gesamt_brutto']) && $arReturn['sum']['preis_gesamt_brutto'] < 0) $arReturn['sum']['preis_gesamt_brutto'] = 0;
-			if (isset($arReturn['sum']['preis_gesamt']) && $arReturn['sum']['preis_gesamt'] < 0) $arReturn['sum']['preis_gesamt'] = 0;
-
-			$this->shop->callMods('basket_toArray_final', array(&$this, &$arReturn));
-
+						
+						if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_shipping_brutto'];
+						if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_gesamt'] += $arReturn['sum']['preis_payment_brutto'];
+						
+						if (isset($arReturn['sum']['preis_shipping_brutto'])) $arReturn['sum']['preis_shipping'] = $arReturn['sum']['preis_shipping_brutto'];
+						if (isset($arReturn['sum']['preis_payment_brutto'])) $arReturn['sum']['preis_payment'] = $arReturn['sum']['preis_payment_brutto'];
+						
+					}
+					
+				}	// else if ($backend)
+				
+				// Leere MwSt. SÃ€tze entfernen
+				foreach ((array)$arReturn['mwst'] as $k => $v)
+				{
+					if ($v['sum'] <= 0) unset($arReturn['mwst'][$k]);
+				}
+				
+				// Negative Bestellungen Verhindern
+				if (isset($arReturn['sum']['preis_netto']) && $arReturn['sum']['preis_netto'] < 0) $arReturn['sum']['preis_netto'] = 0;
+				if (isset($arReturn['sum']['preis_brutto']) && $arReturn['sum']['preis_brutto'] < 0) $arReturn['sum']['preis_brutto'] = 0;
+				if (isset($arReturn['sum']['preis']) && $arReturn['sum']['preis'] < 0) $arReturn['sum']['preis'] = 0;
+				if (isset($arReturn['sum']['preis_gesamt_netto']) && $arReturn['sum']['preis_gesamt_netto'] < 0) $arReturn['sum']['preis_gesamt_netto'] = 0;
+				if (isset($arReturn['sum']['preis_gesamt_brutto']) && $arReturn['sum']['preis_gesamt_brutto'] < 0) $arReturn['sum']['preis_gesamt_brutto'] = 0;
+				if (isset($arReturn['sum']['preis_gesamt']) && $arReturn['sum']['preis_gesamt'] < 0) $arReturn['sum']['preis_gesamt'] = 0;
+				
+				$this->shop->callMods('basket_toArray_final', array(&$this, &$arReturn));
+				
+			}
+			
+			$oCalculation = new \wpsg\wpsg_calculation();
+			
+			if (!$this->loadFromSession) {
+				
+				$oCalculation->fromDB($this->o_id);
+				
+			} else {
+				
+				$oCalculation->fromSession();
+				
+			}
+			
+			$arCalculation = $oCalculation->getCalculationArray();
+			
+			unset($p); // Wichtig, da oben mit der Referenzt &$p gearbeitet wurde
+			
+			foreach ($arCalculation['product'] as $product_index => $p) {
+				
+				$arReturn['produkte'][$product_index]['preis'] = (($this->shop->getFrontendTaxview() === WPSG_NETTO)?$p['netto']:$p['brutto']);
+				$arReturn['produkte'][$product_index]['preis_netto'] = $p['netto'];
+				$arReturn['produkte'][$product_index]['preis_brutto'] = $p['brutto'];
+				
+			}
+			
+			$arReturn['sum'] = [
+				'preis' => (($this->shop->getFrontendTaxview() === WPSG_NETTO)?$arCalculation['sum']['productsum_netto']:$arCalculation['sum']['productsum_brutto']),
+				'preis_netto' => $arCalculation['sum']['productsum_netto'],
+				'preis_brutto' => $arCalculation['sum']['productsum_brutto'],
+				'preis_gesamt_brutto' => $arCalculation['sum']['brutto'],
+				'preis_gesamt_netto' => $arCalculation['sum']['netto'],
+				'preis_payment' => (($this->shop->getFrontendTaxview() === WPSG_NETTO)?$arCalculation['sum']['payment_netto']:$arCalculation['sum']['payment_brutto']),
+				'preis_shipping' => (($this->shop->getFrontendTaxview() === WPSG_NETTO)?$arCalculation['sum']['shipping_netto']:$arCalculation['sum']['shipping_brutto']),
+				'preis_shipping_netto' => $arCalculation['sum']['shipping_netto'],
+				'preis_shipping_brutto' => $arCalculation['sum']['shipping_brutto'],
+				'preis_rabatt' => -1 * (($this->shop->getFrontendTaxview() === WPSG_NETTO)?$arCalculation['sum']['discount_netto']:$arCalculation['sum']['discount_brutto']),
+				'mwst' => $arCalculation['sum']['tax'],
+				'preis_gesamt' => (($this->shop->getFrontendTaxview() === WPSG_NETTO)?$arCalculation['sum']['netto']:$arCalculation['sum']['brutto']),
+				'preis_rabatt_netto' => -1 * $arCalculation['sum']['discount_netto'],
+				'preis_rabatt_brutto' => -1 * $arCalculation['sum']['discount_brutto']
+			];
+			
+			//wpsg_debug($arReturn['sum']); die(wpsg_debug($arCalculation['sum']));         
+			
+			//$arReturn['noMwSt'] = '0';
+			
+			$arReturn['mwst'] = [];
+			
+			foreach ($arCalculation['tax'] as $tax_key => $tax) {
+				
+				if (wpsg_isSizedDouble($tax['sum'])) {
+					
+					$arTaxKey = explode('_', $tax_key);
+					
+					$arReturn['mwst'][$tax_key] = [
+						'country' => $arTaxKey[1],
+						'tax_key' => $arTaxKey[0],
+						'sum' => $tax['sum'],
+						'name' => $oCalculation->getTaxLabelArray()[$tax_key],
+						'value' => $tax['tax_value'],
+						'base_value' => $tax['brutto']
+					];
+					
+				}
+				
+			}
+			
 			return $arReturn;
-
+			
 		} // public function toArray()
-
-
+		
+		
 		/**
 		 * Verteilt den Wert $value auf die MwSt SÃ€tze in $arBasket
@@ -1893,13 +1963,13 @@
 		public function addMwSt(&$arBasket, $value)
 		{
-
+			
 			if (wpsg_tf($value) <= 0) return 0;
-
+			
 			$price_option = $this->shop->get_option('wpsg_preisangaben');
-
+			
 			// Anteilig auf die SÃ€tze verteilen
 			foreach ((array)$arBasket['mwst'] as $mw_id => $mw)
 			{
-
+				
 				if ($mw['base_value'] > 0)
 				{
@@ -1907,42 +1977,42 @@
 					{
 						$proz = $mw['base_value'] / $arBasket['sum']['preis_brutto'];
-
+						
 						$arBasket['mwst'][$mw_id]['base_value'] += $proz * $value;
 						$arBasket['mwst'][$mw_id]['sum'] = wpsg_calculateSteuer($arBasket['mwst'][$mw_id]['base_value'], WPSG_BRUTTO, $mw['value']);
-
+						
 					}
 					else
 					{
 						$proz = $mw['base_value'] / $arBasket['sum']['preis_netto'];
-
+						
 						$arBasket['mwst'][$mw_id]['base_value'] -= wpsg_calculatePreis($proz * $value, WPSG_NETTO, $mw['value']);
 						//$arBasket['mwst'][$mw_id]['base_value'] += $proz * $value;
 						$arBasket['mwst'][$mw_id]['sum'] = wpsg_calculateSteuer($arBasket['mwst'][$mw_id]['base_value'], WPSG_NETTO, $mw['value']);
-
-					}
-
-				}
-
-			}
-
+						
+					}
+					
+				}
+				
+			}
+			
 			// Mehrwertsteuer Summe korrigieren
 			$sum_mwst = 0;
 			foreach ($arBasket['mwst'] as $mw_id => $mw)
 			{
-
+				
 				$sum_mwst += $arBasket['mwst'][$mw_id]['sum'];
-
-			}
-
+				
+			}
+			
 			$sub = $arBasket['sum']['mwst'];
-
+			
 			$arBasket['sum']['mwst'] = abs($sum_mwst);
-
+			
 			return $sub - $arBasket['sum']['mwst'];
-
+			
 		} // public function addMwSt(&$arBasket, $value)
-
-
-
+		
+		
+		
 		/**
 		 * Gibt die Anzahl zurÃŒck, die im Warenkorb zu einem ProduktKEY enthalten ist
@@ -1950,25 +2020,25 @@
 		public function getBasketAmount($product_key)
 		{
-
+			
 			$nAmount = 0;
-
+			
 			if (!wpsg_isSizedArray($_SESSION['wpsg']['basket'])) return 0;
-
+			
 			foreach ($_SESSION['wpsg']['basket'] as $product_index => $product_data)
 			{
-
+				
 				if ($product_data['id'] == $product_key)
 				{
-
+					
 					$nAmount += $product_data['menge'];
-
-				}
-
-			}
-
+					
+				}
+				
+			}
+			
 			return $nAmount;
-
+			
 		} // public function getBasketAmount($product_key)
-
+		
 		/**
 		 * Gibt die ProduktIDs der Produkte aus dem Warenkorb zurÃŒck
@@ -1976,19 +2046,19 @@
 		public function getProductIDs()
 		{
-
+			
 			$arReturn = array();
-
+			
 			foreach ($this->arProdukte as $p)
 			{
-
+				
 				$product_id = $this->shop->getProduktID($p['id']);
 				if (!in_array($product_id, $arReturn)) $arReturn[] = $product_id;
-
-			}
-
+				
+			}
+			
 			return $arReturn;
-
+			
 		} // public function getProductIDs()
-
+		
 		/**
 		 * Verteilt den Wert $value auf die Steuerarten in $arReturn
@@ -1996,8 +2066,8 @@
 		public function distributeMwSt($value, &$arReturn)
 		{
-
+			
 			if ($arReturn['noMwSt'] == true)
 			{
-
+				
 				$arReturn['sum']['preis_brutto'] -= $value;
 				$arReturn['sum']['preis_gesamt_brutto'] -= $value;
@@ -2006,7 +2076,7 @@
 				$arReturn['sum']['preis'] -= $value;
 				$arReturn['sum']['preis_gesamt'] -= $value;
-
-			}
-
+				
+			}
+			
 			// Da ich hier nicht weiÃ ob der Basket fÃŒrs Frontend/Backend berechnet werden soll schaue ich hier ob der NETTO oder BRUTTO Preis im Preisarray ist
 			// Die unterschiedliche Speicherung in preis is ansich quatsch ... Bei Ausgabe sollte immer Brutto / Netto entsprechend verwendet werden
@@ -2019,19 +2089,19 @@
 				$brut_nett = WPSG_BRUTTO;
 			}
-
+			
 			// Gesamt Brutto. vor der Verteilung
 			$netto_gesamt = $arReturn['sum']['preis_netto'];
-
+			
 			foreach ($arReturn['mwst'] as $k => $v)
 			{
-
+				
 				$proz = ($v['base_value'] - $v['sum']) * 100 / $netto_gesamt; // Anteil
 				$value_anteilig = $value / 100 * $proz; // Der Teil, der mit der Steuer besteuert werden soll 70% mit 19%, 30% mit 7% usw.
-
+				
 				if ($brut_nett == WPSG_BRUTTO)
 				{
-
+					
 					$mwst_anteilig = wpsg_calculateSteuer($value_anteilig, WPSG_BRUTTO, $v['value']); // Der anteilige Steuerwert
-
+					
 					$arReturn['mwst'][$k]['sum'] -= $mwst_anteilig;
 					$arReturn['sum']['mwst'] -= $mwst_anteilig;
@@ -2042,11 +2112,11 @@
 					$arReturn['sum']['preis'] -= $value_anteilig;
 					$arReturn['sum']['preis_gesamt'] -= $value_anteilig;
-
+					
 				}
 				else
 				{
-
+					
 					$mwst_anteilig = wpsg_calculateSteuer($value_anteilig, WPSG_NETTO, $v['value']); // Der anteilige Steuerwert
-
+					
 					$arReturn['mwst'][$k]['sum'] -= $mwst_anteilig;
 					$arReturn['sum']['mwst'] -= $mwst_anteilig;
@@ -2057,11 +2127,11 @@
 					$arReturn['sum']['preis'] -= $value_anteilig;
 					$arReturn['sum']['preis_gesamt'] -= $value_anteilig;
-
-				}
-
-			}
-
+					
+				}
+				
+			}
+			
 		} // public function distributeMwSt($value, &$arReturn)
-
+		
 		/**
 		 * Hilfsfunktion
@@ -2070,14 +2140,14 @@
 		public function checkMwSt($tax_key, $country, &$arReturn)
 		{
-
+			
 			if ($tax_key != null && !array_key_exists($tax_key.'_'.$country->id, (array)$arReturn['mwst']))
 			{
-
+				
 				if (is_object($country)) $tax_value = $country->getTax($tax_key);
 				else $tax_value = 0;
-
+				
 				$name = wpsg_ff($tax_value, '%');
 				if ($country->id != $this->shop->getDefaultCountry(true)) $name .= ' / '.$country->name;
-
+				
 				$arReturn['mwst'][$tax_key.'_'.$country->id] = array(
 					'country' => $country->id,
@@ -2087,9 +2157,9 @@
 					'value' => $tax_value
 				);
-
-			}
-
+				
+			}
+			
 		} // private function checkMwSt($mwst_id, $country, &$arReturn)
-
+		
 	} // class wpsg_basket
 
Index: /lib/wpsg_calculation.class.php
===================================================================
--- /lib/wpsg_calculation.class.php	(revision 7242)
+++ /lib/wpsg_calculation.class.php	(revision 7243)
@@ -54,4 +54,6 @@
         	
         	$this->tax_mode = $tax_mode;
+	
+			$this->arCalculation = null;
         	
 		}
@@ -216,7 +218,46 @@
         
         public function addProduct($set, $bruttonetto, $tax_key, $amount, $product_key, $product_index = false, $order_product_id = false, $eu = false, $ses_data = false) {
-            					
-            $tax_key = $this->normalizeTaxKey($tax_key, (($eu === true)?$this->getTargetCountryID():$this->getDefaultCountryID()));
-          
+	
+			$targetCountry = false; 
+			
+			if ($eu === true) {
+				 
+				/*
+				if ($this->getTaxMode() === self::TAXMODE_B2B && $this->arCountry[$this->getTargetCountryID()]['tax_mode'] == '2') {
+					
+					$tax_key = 'e';
+					
+				} else if ($this->arCountry[$this->getTargetCountryID()]['tax_mode'] == '1') {
+					
+					$tax_key = 'e';
+					
+				} else {
+					
+					$country_id = $this->getTargetCountryID();
+					
+					$tax_key = $this->normalizeTaxKey($tax_key, $country_id);
+					
+				}
+				*/
+				
+				if ($this->getTaxMode() === self::TAXMODE_B2C) {
+					
+					$targetCountry = true;
+					$country_id = $this->getTargetCountryID(); 					
+					
+				} else {
+					
+					$country_id = $this->getDefaultCountryID();
+										
+				}
+				
+				$tax_key = $this->normalizeTaxKey($tax_key, $country_id);
+				 
+			} else {
+				
+				$tax_key = $this->normalizeTaxKey($tax_key, $this->getDefaultCountryID());
+				
+			} 
+			
             if ($product_index === false) $product_index = $this->getMaxProductIndex();
             
@@ -242,5 +283,6 @@
 					'product_index' => $product_index,
 					'order_product_id' => $order_product_id,
-					'eu' => $eu
+					'eu' => $eu,
+					'targetCountry' => $targetCountry
 				]
 			];
@@ -249,5 +291,5 @@
 	
 			$this->arCalculationRow[] = $p;
-	
+	 
 			$this->arCalculation = null;
             
@@ -343,13 +385,13 @@
                 	$this->addTax($cr['tax_key']);
                 	$this->calculateTaxProportionally($cr['bruttonetto']);
-                	
-                	if (strpos($cr['set'], '%') !== false) {
-                		
-                		// Prozentualer Wert
+							                	
+					if (strpos($cr['set'], '%') !== false) {
+						
+						// Prozentualer Wert
 						$netto = $this->arCalculation['sum']['netto'] / 100 * wpsg_tf($cr['set']);
 						$brutto = $this->arCalculation['sum']['brutto'] / 100 * wpsg_tf($cr['set']);
 				
 					} else {
-                	
+												
 						// Netto / Brutto berechnen
 						if ($cr['bruttonetto'] === WPSG_NETTO) {
@@ -362,12 +404,29 @@
 						} else {
 							
-							$brutto = wpsg_tf($cr['set']);
+							if (wpsg_isTrue($cr['data']['targetCountry'])) {
+							
+								$tax_key_part = preg_replace('/\_(.*)/', '', $cr['tax_key']);
+								
+								$tax_default = $this->arCountry[$this->getDefaultCountryID()][$tax_key_part.'_'.$this->getDefaultCountryID()];
+								$tax_target = $this->arCountry[$this->getTargetCountryID()][$tax_key_part.'_'.$this->getTargetCountryID()];
+																
+								$brutto = wpsg_calculatePreis(
+									wpsg_calculatePreis(wpsg_tf($cr['set']), WPSG_NETTO, $tax_default),
+									WPSG_BRUTTO,
+									$tax_target
+								);
+								
+							} else {
+							
+								$brutto = wpsg_tf($cr['set']);
+								
+							}
 							
 							list($netto, $brutto) = $this->calculateTaxPart(WPSG_BRUTTO, $brutto, $cr['tax_key']);
 								
 						}
-																		
+																								
 					}
-	
+						
 					$country_id = preg_replace('/(.*)\_/', '',$cr['tax_key']);
 	
@@ -375,19 +434,22 @@
 						
 						// Land ist auf "Keine Steuer" gestellt
-						$brutto = $netto;
-						
+						$brutto = $netto; 
+					
 					} else {
 					
 						if ($this->tax_mode === self::TAXMODE_SMALLBUSINESS) {
 						
-							// Kleinunternehmer	
-							
-							$brutto = $netto;
+							// Kleinunternehmer								
+							$brutto = $netto; 
 							
 						} else if ($this->tax_mode === self::TAXMODE_B2B) {
 							
-							// Endkunde
-							if ($this->arCountry[$this->getTargetCountryID()]['tax_mode'] == '2') $brutto = $netto;
-							
+							// Firmenkunde // keine MwSt. bei USt.IdNr. = 2
+							if ($this->arCountry[$this->getTargetCountryID()]['tax_mode'] == '2') {
+								
+								$brutto = $netto;
+								
+							}
+						
 						}
 						
@@ -399,5 +461,5 @@
 					$netto *= $cr['amount'];
 					$brutto *= $cr['amount'];
-						
+						 
 					$this->arCalculation['tax'][$cr['tax_key']]['netto'] += $netto;
 					$this->arCalculation['tax'][$cr['tax_key']]['brutto'] += $brutto;
@@ -752,6 +814,6 @@
 				
 				// c_1
-				if ($product_data['euleistungsortregel'] === '1') $eu = '1';
-				$eu = '0';
+				if ($product_data['euleistungsortregel'] === '1') $eu = true;
+				$eu = false;
 							
 				$this->addProduct($product_set, $this->shop->getBackendTaxview(), $tax_key, $db_p['menge'],$db_p['productkey'], $db_p['product_index'], $db_p['id'], $eu);
@@ -850,5 +912,5 @@
 						$product_index, 
 						false, 
-						$oProduct->euleistungsortregel,
+						(($oProduct->euleistungsortregel === '1')?true:false),
 						$p
 					);
@@ -877,5 +939,20 @@
 				
 			$this->shop->callMods('calculation_fromSession',[&$this, true, true]);			
-						
+			
+			// Besteuerung
+			if ($this->shop->get_option('wpsg_kleinunternehmer') === '1') {
+				
+				$this->setTaxMode(self::TAXMODE_SMALLBUSINESS);
+				
+			} else if ($this->getTargetCountry()['tax_mode'] === '2' && wpsg_isSizedString($_SESSION['wpsg']['checkout']['ustidnr'])) {
+				
+				$this->setTaxMode(self::TAXMODE_B2B);
+				
+			} else {
+				
+				$this->setTaxMode(self::TAXMODE_B2C);
+				
+			}
+			
 		}
 		
@@ -915,6 +992,5 @@
 					$this->arCalculation['tax'][$tax_key]['part'] = 0;
 					
-				}
-				else {
+				} else {
 					
 					if ($sum <= 0) $this->arCalculation['tax'][$tax_key]['part'] = 0;
@@ -937,5 +1013,5 @@
         	if (!is_numeric($val)) $val = 0;
         	
-        	if ($tax_key == '0') {
+        	if ($tax_key == '0') { // 0, bedeutet hier anteilig
 		
 				$ret_netto = 0;
@@ -993,7 +1069,8 @@
         /**
          * Im Array sollen die Tax SchlÃŒssel immer mit Land gespeichert sein
+		 * Erzwingt auch 0% Mwst
          */
         private function normalizeTaxKey($tax_key, $country_id = false, $defaultCountryID = true) {
-
+	
             if ($tax_key == '') $tax_key = '0';
             
@@ -1077,10 +1154,11 @@
 				if ($short === true) {
 					
-					if ($tax_key !== '0') $arTaxLabel[$tax['key']] = wpsg_ff(wpsg_tf($tax_value), '%');
+					if (!in_array($tax_key, ['0', 'e'])) $arTaxLabel[$tax['key']] = wpsg_ff(wpsg_tf($tax_value), '%');
+					else if ($tax_key === 'e') $arTaxLabel[$tax_key] = '0';
 					else $arTaxLabel[$tax['key']] = 'anteilig';
 					
 				} else {
 					
-					if ($tax_key !== '0') $arTaxLabel[$tax['key']] = $arTaxGgroup[$tax_key].' ('.wpsg_ff(wpsg_tf($tax_value), '%').' / '.$kuerzel.')';
+					if (!in_array($tax_key, ['0', 'e'])) $arTaxLabel[$tax['key']] = $arTaxGgroup[$tax_key].' ('.wpsg_ff(wpsg_tf($tax_value), '%').' / '.$kuerzel.')';
 					else $arTaxLabel[$tax['key']] = $arTaxGgroup[$tax_key];
 					
@@ -1088,5 +1166,5 @@
 				
 			}
-		
+			
 			return $arTaxLabel;
 		
Index: /system/tests/wpsg_calculationTestTest.php
===================================================================
--- /system/tests/wpsg_calculationTestTest.php	(revision 7242)
+++ /system/tests/wpsg_calculationTestTest.php	(revision 7243)
@@ -158,7 +158,5 @@
 	
 		public function test6() {
-		
-			//$this->markTestSkipped(); return;
-		
+		 
 			$b = new \wpsg\wpsg_calculation();
 		
@@ -171,12 +169,41 @@
 			$b->addProduct('120', WPSG_BRUTTO, 'c', 10,'1', false, false,true);
 				
-			$ar = $b->getCalculationArray();
-		
-			$this->assertTrue($this->compareArray($ar, [
-				'sum' => [
-					'product_netto' => 1000,
-					'product_brutto' => 1200,
-					'netto' => 1200,
-					'brutto' => 1438,
+			$b->setTaxMode(\wpsg\wpsg_calculation::TAXMODE_B2C);
+			
+			$ar = $b->getCalculationArray();
+		 
+			$this->assertTrue($this->compareArray($ar, [
+				'sum' => [
+					'product_netto' => 1008.4033613445,
+					'product_brutto' => 1210.0840336134,
+					'netto' => 1208.4033613445,
+					'brutto' => 1448.0840336134,
+				]
+			]));
+		
+		}
+	
+		public function test7() {
+		 
+			$b = new \wpsg\wpsg_calculation();
+		
+			$b->addCountry(1, 0, 0, 7, 19, 0, true); // Standardland
+			$b->addCountry(2, 2, 0, 7, 20, 0, false); // Rechnungsland
+		
+			$b->addShipping('119', WPSG_BRUTTO, 'c','sss');
+			$b->addPayment('119', WPSG_BRUTTO, 'c', 'ppp');
+		
+			$b->addProduct('120', WPSG_BRUTTO, 'c', 10,'1', false, false,true);
+		
+			$b->setTaxMode(\wpsg\wpsg_calculation::TAXMODE_B2B);
+		
+			$ar = $b->getCalculationArray();
+			 
+			$this->assertTrue($this->compareArray($ar, [
+				'sum' => [
+					'product_netto' => 1008.4033613445,
+					'product_brutto' => 1008.4033613445,
+					'netto' => 1208.4033613445,
+					'brutto' => 1208.4033613445,
 				]
 			]));
Index: /views/mods/mod_rechnungen/invoice_pdf.phtml
===================================================================
--- /views/mods/mod_rechnungen/invoice_pdf.phtml	(revision 7242)
+++ /views/mods/mod_rechnungen/invoice_pdf.phtml	(revision 7243)
@@ -1,105 +1,105 @@
 <?php
-
+	
 	/**
 	 * Template fÃŒr die PDF Rechnung
 	 */
-
+	
 	require_once WPSG_PATH_LIB.'fpdf/fpdf.php';
 	require_once WPSG_PATH_LIB.'fpdf/fpdi.php';
 	require_once WPSG_PATH_LIB.'wpsg_fpdf.class.php';
-
+	
 	global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top;
-
+	
 	// Positionierung der Absenderadresszeile
 	$absender_left				= 25;
 	$absender_top				= 50;
-
+	
 	// Positionierung der Zieladress
 	$adress_left 				= 25;
 	$adress_top					= 55;
-
+	
 	// Positionierung des Rechnungskopfes
 	$rdata_left					= 25;
 	$rdata_top					= 90;
-
+	
 	// Positionierung der Produktdaten
 	$prod_left					= 25;
 	$prod_top					= 105;
-
+	
 	// Anzahl an Produkten pro Seite
 	$prod_break					= $this->get_option('wpsg_rechnungen_pdfperpage');
-
+	
 	// Damit die Steuer bei der Kleinunternehmerregelung nicht angezeigt wird leer ich den Array sicherheitshalber
 	if ($this->get_option('wpsg_kleinunternehmer') == '1')
 	{
-
+		
 		unset($this->view['basket']['mwst']);
-
-	}
-
+		
+	}
+	
 	if (!function_exists('AddRechnungPage'))
 	{
-
+		
 		function AddRechnungPage($shop, $pdf)
 		{
-
+			
 			global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top;
-
+			
 			$pdf->AddPage();
-
+			
 			if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.pdf")) {
-
+				
 				$pdf->setSourceFile($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.pdf");
 				$tplidx = $pdf->importPage(1, '/MediaBox');
 				$pdf->useTemplate($tplidx, 0, 0, 210);
-
+				
 			} else if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.jpg")) {
-			    
+				
 				$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.jpg", 0, 0, 210, 297, 'jpg');
 				
 			}
-
-
+			
+			
 			if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg"))
 			{
-
+				
 				list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg");
-
+				
 				// Umrechnung von Inch zu Pixel
 				$wPix = (25.4 * (int)$width) / 96;
 				$hPix = (25.4 * (int)$height) / 96;
-
+				
 				$leftPos = 110 - $wPix;
 				$midPos = $wPix * 2.6 - $width / 2;
 				$rightPos = 210 - $wPix;
-
+				
 				$abscissa = $rightPos;
 				$ordinate = 0;
-
+				
 				$transparency = str_replace("%", "", $shop->get_option('wpsg_rechnungen_logo_transparency'));
 				if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);
-
+				
 				$alpha = 1;
 				if(!is_null($transparency) && $transparency !== "100") $alpha = "0.$transparency";
 				if(!is_null($transparency) && $transparency === "100") $alpha = $transparency;
-
+				
 				$logo_pos = $shop->get_option('wpsg_rechnungen_logo_position');
-
+				
 				if(isset($logo_pos) && $logo_pos === "left") { $abscissa = $leftPos; $ordinate = 20; }
 				if(isset($logo_pos) && $logo_pos === "center") { $abscissa = $midPos; $ordinate = 20; }
 				if(isset($logo_pos) && $logo_pos === "right") { $abscissa = $rightPos; }
-
+				
 				$pdf->SetAlpha($alpha);
 				$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg", $abscissa, $ordinate, $wPix, $hPix);
 				$pdf->SetAlpha(1);
-
-			}
-
+				
+			}
+			
 			// Absenderadresszeile (Wird in der Konfiguration hinterlegt)
 			$pdf->SetFont('Arial', '', 6);
 			$pdf->Text($absender_left, $absender_top, $shop->replaceUniversalPlatzhalter(__($shop->get_option("wpsg_rechnungen_adresszeile"), 'wpsg'), $shop->view['data']['id']));
-
+			
 			if (wpsg_getStr($shop->view['kunde']['kuerzel']) != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
-
+			
 			// Adresse des Kunden
 			$pdf->SetFont('Arial', '', 12);
@@ -110,5 +110,5 @@
 			if ($shop->get_option("wpsg_mod_rechnungen_hideCountry") == '0')
 				$pdf->Text($adress_left, $adress_top + 20, strtoupper($shop->view['oOrder']->getInvoiceCountryName()));
-
+			
 			// Rechnungsdaten
 			$pdf->SetFont('Arial', 'B', 16);
@@ -117,65 +117,58 @@
 			$pdf->Text($rdata_left, $rdata_top + 6, $shop->view['rnr']);
 			$pdf->SetFont('Arial', '', 9);
-
+			
 			if (isset($shop->view['faelligkeitdatum']))
 			{
-
+				
 				$pdf->Text($rdata_left + 35, $rdata_top, __("FÃ€llig am", "wpsg"));
 				$pdf->Text($rdata_left + 35, $rdata_top + 6, (int)$shop->view['faelligkeitdatum']);
-
-			}
-
+				
+			}
+			
 			if (isset($shop->view['payment']))
 			{
-
+				
 				$pdf->Text($rdata_left + 58, $rdata_top, __("Zahlungsbedingungen", "wpsg"));
 				$pdf->Text($rdata_left + 58, $rdata_top + 6, $shop->view['payment']);
-
-			}
-
+				
+			}
+			
 			$pdf->Text($rdata_left + 105, $rdata_top, __("Kunden-Nr", "wpsg"));
 			$pdf->Text($rdata_left + 105, $rdata_top + 6, (($shop->view['kunde']['knr'] != '')?$shop->view['kunde']['knr']:$shop->view['kunde']['id']));
-
+			
 			$pdf->Text($rdata_left + 135, $rdata_top, __("Best. Nr.", "wpsg"));
 			$pdf->Text($rdata_left + 135, $rdata_top + 6, ((trim($shop->view['data']['onr']) != '')?$shop->view['data']['onr']:$shop->view['data']['id']));
-
+			
 			$pdf->Text($rdata_left + 155, $rdata_top, __("Datum", "wpsg"));
 			$pdf->Text($rdata_left + 155, $rdata_top + 6, $shop->view['rDatum']);
-
+			
 			if ($shop->view['oOrder']->isInnerEu())
 			{
-
-            	$pdf->SetFont('Arial', '', 9);
-                $pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg"));
-
-            } else if (!$shop->view['oOrder']->isInnerEu() && $shop->view['oOrder']->getShippingCountryID() != $shop->getDefaultCountry(true)) {
-
-			// Nicht InnerEU und Nicht Inland
-
-             	$pdf->SetFont('Arial', '', 9);
-                $pdf->Text($adress_left, $rdata_top + 11.5, __("Steuerfreie Ausfuhrlieferung.", "wpsg"));
-
-			}
-
+				
+				$pdf->SetFont('Arial', '', 9);
+				$pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg"));
+				
+			}
+			
 			// Benutzerdefinierte Felder
 			$arTexte = $shop->callMod('wpsg_mod_rechnungen', 'getRechnungstexte', array($shop->view['data']['id']));
-
+			
 			foreach ((array)$arTexte as $text)
 			{
-
+				
 				if (isset($text['aktiv']) && $text['aktiv'] == 1)
 				{
-
+					
 					$pdf->SetFont('Arial', 'B', ((intval($text['fontsize']) > 0)?intval($text['fontsize']):10));
 					$pdf->wpsg_SetTextColor($text['color']);
 					$pdf->wpsg_MultiCell($text['x'], $text['y'], 5, $text['text']);
 					$pdf->wpsg_SetTextColor("#000000");
-
-				}
-
-			}
-
-		}
-
+					
+				}
+				
+			}
+			
+		}
+		
 	}
 	
@@ -183,115 +176,115 @@
 	$pdf->SetAutoPageBreak(true, 5);
 	AddRechnungPage($this, $pdf);
-
+	
 	$summe = 0;
-
+	
 	$bKopf = false; $pnr = 1; $offset = 0; $count = 0;
 	foreach ($this->view['basket']['produkte'] as $p)
 	{
-
+		
 		if (!$bKopf)
 		{
-
+			
 			$pdf->SetFont('Arial', 'B', 9);
 			$pdf->setXY($prod_left, $prod_top);
 			$pdf->Cell(10, 8, __("Nr.", "wpsg"), 1, 0, 'C');
-
+			
 			$pdf->setXY($prod_left + 10, $prod_top);
 			$pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, "Name", 1, 0, 'L');
-
+			
 			if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
 			{
-
+				
 				$pdf->setXY($prod_left + 97, $prod_top);
 				$pdf->Cell(15, 8, __("MwSt.", "wpsg"), 1, 0, 'C');
-
-			}
-
+				
+			}
+			
 			$pdf->setXY($prod_left + 112, $prod_top);
 			$pdf->Cell(15, 8, __("Menge", "wpsg"), 1, 0, 'C');
-
+			
 			$pdf->setXY($prod_left + 127, $prod_top);
 			$pdf->Cell(25, 8, __("Einzelpreis", "wpsg"), 1, 0, 'R');
-
+			
 			$pdf->setXY($prod_left + 152, $prod_top);
 			$pdf->Cell(25, 8, __("Gesamtpreis", "wpsg"), 1, 0, 'R');
-
+			
 			$offset = 8;
 			$bKopf = true;
-
-		}
-
+			
+		}
+		
 		$pdf->SetFont('Arial', '', 9);
 		$pdf->setXY($prod_left, $prod_top + $offset);
-
+		
 		if ($this->get_option('wpsg_mod_rechnungen_anr') == '1')
 		{
-
+			
 			$pdf->Cell(10, 8,  $p['anr'], 0, 0, 'C');
-
+			
 		}
 		else
 		{
-
+			
 			$pdf->Cell(10, 8, $pnr.".", 0, 0, 'C');
-
-		}
-
+			
+		}
+		
 		/* Wenn Detailname vorhanden, wird der Detailname auf Rechnung verwendet */
 		$produkt_text = $this->getProductName($this->getProduktID($p['id']), true);
-
+		
 		/* Falls Detailname vorhanden, wird jetzt der Produktname verwendet */
 		/* $produkt_text = $this->getProductName($this->getProduktID($p['id']), false); */
-
+		
 		$produktBeschreibung = trim(strip_tags($p['beschreibung']));
-
+		
 		if ($this->isOtherLang())
 		{
-
+			
 			$trans_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($this->getProduktID($p['id']))."' AND `lang_code` = '".wpsg_q($this->getCurrentLanguageCode())."'");
-
+			
 			if (is_array($trans_db) && sizeof($trans_db) > 0)
 			{
-
+				
 				$produkt_text = $trans_db['name'];
 				$produktBeschreibung = trim(strip_tags($trans_db['beschreibung']));
-
-			}
-
-		}
-
+				
+			}
+			
+		}
+		
 		$height = 0; // HÃ¶he der Zeile fÃŒr den Rahmen
-
+		
 		$pdf->setXY($prod_left + 10, $prod_top + $offset);
-
+		
 		// Produktvariablen 
 		if ($this->hasMod('wpsg_mod_productvars') && $this->get_option("wpsg_mod_rechnungen_showpv") == "1")
 		{
-
+			
 			$arPV = $this->callMod('wpsg_mod_productvars', 'getAllProductVarValues', array($this->view['data']['id'], $p['product_index']));
-
+			
 			if (wpsg_isSizedArray($arPV))
 			{
-
+				
 				foreach ($arPV as $pv)
 				{
-
+					
 					$produkt_text .= "\r\n".$pv['name'].': '.$pv['value'];
 					$height += 5;
-
-				}
-
-			}
-
-		}
-
+					
+				}
+				
+			}
+			
+		}
+		
 		if ($this->get_option('wpsg_mod_rechnungen_anr') === '2')
 		{
-
+			
 			$anr = $this->getProductAnr($p['productkey']);
 			$produkt_text .= "\r\n".wpsg_translate(__('Artikelnummer: #1#', 'wpsg'), $anr);
-
-		}
-
+			
+		}
+		
 		$produkt_text_cell_width = 102;
 		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
@@ -299,31 +292,31 @@
 			$produkt_text_cell_width = 87;
 		}
-
+		
 		$produkt_text_width = $pdf->GetStringWidth($produkt_text);
 		//$produkt_text_cell_width = (($this->arMwSt == "-1")?87:102);
-
+		
 		$height += 5 * ceil($produkt_text_width / $produkt_text_cell_width) + 3;
-
+		
 		$height_y = $pdf->getY();
 		$height = 2 + $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $offset + 1.5, 5, $produkt_text, 0, 'L', 0, $produkt_text_cell_width);
-
+		
 		//$height += 3 + 5 + $pdf->getY() - $height_y;
 		//$pdf->Cell((($this->arMwSt == "-1")?102:87), 8, $produkt_text, 0, 0, 'L');
-
+		
 		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
 		{
-
+			
 			$pdf->setXY($prod_left + 97, $prod_top + $offset);
 			$pdf->Cell(15, 8, (($this->view['basket']['noMwSt'] == '1')?'0.00 %':wpsg_ff($p['mwst_value'], '%')), 0, 0, 'C');
-
-		}
-
+			
+		}
+		
 		$pdf->setXY($prod_left + 112, $prod_top + $offset);
 		$pdf->Cell(15, 8, $p['menge'], 0, 0, 'C');
-
+		
 		if (wpsg_ShopController::get_option('wpsg_preisangaben') == WPSG_NETTO)
 		{
 			$preis = $p['preis_netto'];
-
+			
 			//TODO
 		}
@@ -332,11 +325,11 @@
 			$preis = $p['preis_brutto'];
 		}
-
+		
 		$pdf->setXY($prod_left + 127, $prod_top + $offset);
 		$pdf->Cell(25, 8, wpsg_ff($preis, $this->get_option('wpsg_currency')), 0, 0, 'R');
-
+		
 		$pdf->setXY($prod_left + 152, $prod_top + $offset);
 		$pdf->Cell(25, 8, wpsg_ff($preis * $p['menge'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-
+		
 		/**
 		 * Produktbeschreibung anzeigen Ja/Nein
@@ -345,23 +338,23 @@
 		if ($this->get_option("wpsg_rechnungen_pbeschreibung") == "1" && trim(strip_tags($p['beschreibung'])) != '')
 		{
-
+			
 			$produktBeschreibung = nl2br($produktBeschreibung);
 			preg_match_all('/\<br \/\>/', $produktBeschreibung, $treffer);
 			$produktBeschreibung = strip_tags($produktBeschreibung);
-
+			
 			$pBeschreibungWidth = $pdf->getStringWidth($produktBeschreibung);
 			$pBeschreibungHeight = 5 * (ceil($pBeschreibungWidth / $produkt_text_cell_width) + @sizeof($treffer[0]));
-
+			
 			$pdf->SetFont('Arial', 'I', 9);
-
+			
 			$cellY = $pdf->getY();
 			$pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 1, 5, $produktBeschreibung, 0, 'L', 0, $produkt_text_cell_width);
 			$pBeschreibungHeight = $pdf->getY() - $cellY - $height + 1;
 			$pdf->SetFont('Arial', '', 9);
-
-		}
-
+			
+		}
+		
 		$height += $pBeschreibungHeight;
-
+		
 		/**
 		 * Produktattribute ?
@@ -369,16 +362,16 @@
 		if ($this->get_option('wpsg_rechnungen_produktattribute') == '1')
 		{
-
+			
 			$attributeInfo = $this->callMod('wpsg_mod_produktattribute', 'getProductAttributeByProductId', array($this->getProduktId($p['id'])));
-
+			
 			foreach ($attributeInfo as $pa)
 			{
-
+				
 				$pa_text = $pa['name'].': '.$pa['value'];
 				$height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5, 5, $pa_text, 0, 'L', 0, $produkt_text_cell_width);
-
-			}
-		}
-
+				
+			}
+		}
+		
 		/**
 		 * Variante ?
@@ -386,91 +379,91 @@
 		if (preg_match('/pv_(.*)/', $p['productkey']))
 		{
-
+			
 			$variInfo = $this->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($p['productkey']));
-
+			
 			$height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5, 5, wpsg_translate(__('Variante: #1#', 'wpsg'), $variInfo['key']), 0, 'L', 0, $produkt_text_cell_width);
-
+			
 			//$height += 5;
-
-		}
-
+			
+		}
+		
 		if ($this->hasMod('wpsg_mod_deliverynote'))
 		{
-
+			
 			$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($this->view['data']['id']));
-
+			
 			if (sizeof($arDN_order) > 1)
 			{
-
+				
 				$deliveryTimeProduct = $this->callMod('wpsg_mod_deliverynote', 'getProductDeliveryTime', array($this->view['data']['id'], $p['product_index']));
-
+				
 				if ($deliveryTimeProduct !== false)
 				{
-
+					
 					$height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5, 5, wpsg_translate(__('Lieferdatum: #1#', 'wpsg'), date('d.m.Y', $deliveryTimeProduct)), 0, 'L', 0, $produkt_text_cell_width);
-
-				}
-
-			}
-
-		}
-
+					
+				}
+				
+			}
+			
+		}
+		
 		// Jetzt die Rahmen zeichnen
 		$pdf->Rect($prod_left, $prod_top + $offset, 10, $height);
-
+		
 		$pdf->Rect($prod_left + 10, $prod_top + $offset, ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), $height);
-
+		
 		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
 		{
-
+			
 			$pdf->Rect($prod_left + 97, $prod_top + $offset, 15, $height);
-
-		}
-
+			
+		}
+		
 		$pdf->Rect($prod_left + 112, $prod_top + $offset, 15, $height);
 		$pdf->Rect($prod_left + 127, $prod_top + $offset, 25, $height);
 		$pdf->Rect($prod_left + 152, $prod_top + $offset, 25, $height);
-
+		
 		$offset += $height;
-
+		
 		$pnr ++;
 		$count ++;
-
+		
 		$summe += $p['price'] * $p['menge'];
-
+		
 		if ($pdf->getY() > 220 || ($count >= $prod_break && sizeof($this->view['basket']['produkte']) > ($pnr - 1)))
 		{
-
+			
 			AddRechnungPage($this, $pdf);
 			$bKopf = false; $offset = 0; $count = 0;
-
-		}
-
+			
+		}
+		
 	} // produkte
-
+	
 	// Gutschein
 	if ((isset($this->view['basket']['gs'])) && ($this->view['basket']['gs_value'] > 0))
 	{
-
+		
 		$pdf->SetFont('Arial', '', 9);
 		$pdf->setXY($prod_left, $prod_top + $offset);
 		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
-
+		
 		$pdf->setXY($prod_left + 10, $prod_top + $offset);
 		$pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $this->view['basket']['gs']['code']), 1, 0, 'L');
-
+		
 		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
 		{
-
+			
 			$mwst = __('anteilig', 'wpsg');
-
+			
 			$pdf->setXY($prod_left + 97, $prod_top + $offset);
 			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
-
-		}
-
+			
+		}
+		
 		$pdf->setXY($prod_left + 112, $prod_top + $offset);
 		$pdf->Cell(15, 8, '1', 1, 0, 'C');
-
+		
 		/*
 		if ($this->view['basket']['gs']['calc'] == 'w')
@@ -489,64 +482,64 @@
 		}
 		*/
-
+		
 		$gs_value_einzel = '-'.wpsg_ff($this->view['basket']['sum']['gs'], $this->get_option('wpsg_currency'));
 		$gs_value_gesamt = '-'.wpsg_ff($this->view['basket']['sum']['gs'], $this->get_option('wpsg_currency'));
-
+		
 		$pdf->setXY($prod_left + 127, $prod_top + $offset);
 		$pdf->Cell(25, 8, $gs_value_einzel, 1, 0, 'R');
-
+		
 		$pdf->setXY($prod_left + 152, $prod_top + $offset);
 		$pdf->Cell(25, 8, $gs_value_gesamt, 1, 0, 'R');
-
+		
 		$offset += 8;
-
-	}
-
+		
+	}
+	
 	// Versandkosten
 	if ($this->view['basket']['sum']['preis_shipping'] != '' && $this->view['basket']['sum']['preis_shipping'] != 0)
 	{
-
+		
 		$pdf->SetFont('Arial', '', 9);
 		$pdf->setXY($prod_left, $prod_top + $offset);
 		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
-
+		
 		$pdf->setXY($prod_left + 10, $prod_top + $offset);
 		$pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, wpsg_translate(__('Versandkosten "#1#"', 'wpsg'), $this->view['oOrder']->getShippingLabel()), 1, 0, 'L');
-
+		
 		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
 		{
-
+			
 			if ($this->arShipping[$this->view['data']['type_shipping']]['mwst_null'] == '1' && $this->view['basket']['noMwSt'] == '1')
 			{
-
+				
 				$mwst = 0;
-
+				
 			}
 			else
 			{
-
+				
 				if (isset($this->view['basket']['shipping']['tax_rata']) && $this->view['basket']['shipping']['tax_rata'] === true)
+				{
+					
+					$mwst = __('anteilig', 'wpsg');
+					
+				}
+				else
+				{
+					
+					$mwst = wpsg_ff($this->arShipping[$this->view['basket']['checkout']['shipping']]['mwst_value'], '%');
+					$mwst = wpsg_ff($this->view['basket']['shipping']['tax_value'], '%');
+					
+				}
+				
+				/*
+				if ($this->arShipping[$this->view['data']['type_shipping']]['mwst'] == '0')
 				{
 
 					$mwst = __('anteilig', 'wpsg');
-
+					
 				}
 				else
 				{
-
-					$mwst = wpsg_ff($this->arShipping[$this->view['basket']['checkout']['shipping']]['mwst_value'], '%');
-					$mwst = wpsg_ff($this->view['basket']['shipping']['tax_value'], '%');
-
-				}
-
-				/*
-				if ($this->arShipping[$this->view['data']['type_shipping']]['mwst'] == '0')
-				{
-
-					$mwst = __('anteilig', 'wpsg');
-					
-				}
-				else
-				{
 				
 					$mwst = wpsg_ff($this->arShipping[$this->view['data']['type_shipping']]['mwst_value'], '%');
@@ -554,23 +547,23 @@
 				}
 				*/
-
-			}
-
+				
+			}
+			
 			$pdf->setXY($prod_left + 97, $prod_top + $offset);
 			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
-
-		}
-
+			
+		}
+		
 		$pdf->setXY($prod_left + 112, $prod_top + $offset);
 		$pdf->Cell(15, 8, '1', 1, 0, 'C');
-
+		
 		$pdf->setXY($prod_left + 127, $prod_top + $offset);
 		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R');
-
+		
 		$pdf->setXY($prod_left + 152, $prod_top + $offset);
 		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R');
-
+		
 		$offset += 8;
-
+		
 		// Zusammengesetzte Versandarten darstellen
 		/*
@@ -612,22 +605,22 @@
 		}
 		*/
-
-
-	}
-
+		
+		
+	}
+	
 	// Zahlungskosten
 	if ($this->view['basket']['sum']['preis_payment'] != '' && $this->view['basket']['sum']['preis_payment'] != 0)
 	{
-
+		
 		$pdf->SetFont('Arial', '', 9);
 		$pdf->setXY($prod_left, $prod_top + $offset);
 		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
-
+		
 		$pdf->setXY($prod_left + 10, $prod_top + $offset);
 		$pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $this->arPayment[$this->view['data']['type_payment']]['name'], 1, 0, 'L');
-
+		
 		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
 		{
-
+			
 			if ($this->arPayment[$this->view['data']['type_payment']]['mwst_null'] == '1' && $this->view['basket']['noMwSt'] == '1')
 			{
@@ -636,27 +629,27 @@
 			else
 			{
-
+				
 				if (isset($this->view['basket']['payment']['tax_rata']) && $this->view['basket']['payment']['tax_rata'] === true)
+				{
+					
+					$mwst = __('anteilig', 'wpsg');
+					
+				}
+				else
+				{
+					
+					$mwst = wpsg_ff($this->arPayment[$this->view['basket']['checkout']['payment']]['mwst_value'], '%');
+					
+				}
+				
+				/*
+				if ($this->arPayment[$this->view['data']['type_payment']]['mwst'] == '0')
 				{
 
 					$mwst = __('anteilig', 'wpsg');
-
+					
 				}
 				else
 				{
-
-					$mwst = wpsg_ff($this->arPayment[$this->view['basket']['checkout']['payment']]['mwst_value'], '%');
-
-				}
-
-				/*
-				if ($this->arPayment[$this->view['data']['type_payment']]['mwst'] == '0')
-				{
-
-					$mwst = __('anteilig', 'wpsg');
-					
-				}
-				else
-				{
 				
 					$mwst = wpsg_ff($this->arPayment[$this->view['data']['type_payment']]['mwst_value'], '%');
@@ -664,43 +657,43 @@
 				}
 				*/
-
-			}
-
+				
+			}
+			
 			$pdf->setXY($prod_left + 97, $prod_top + $offset);
 			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
-
-		}
-
+			
+		}
+		
 		$pdf->setXY($prod_left + 112, $prod_top + $offset);
 		$pdf->Cell(15, 8, '1', 1, 0, 'C');
-
+		
 		$pdf->setXY($prod_left + 127, $prod_top + $offset);
 		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R');
-
+		
 		$pdf->setXY($prod_left + 152, $prod_top + $offset);
 		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R');
-
+		
 		$offset += 8;
-
-	}
-
+		
+	}
+	
 	// GebÃŒhr
 	if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0)
 	{
-
+		
 		$pdf->SetFont('Arial', '', 9);
 		$pdf->setXY($prod_left, $prod_top + $offset);
 		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
-
+		
 		$label = __('BearbeitungsgebÃŒhr', 'wpsg');
-
+		
 		if (strpos($this->view['storno_fee'], '%') !== false) $label .= ' ('.wpsg_ff($this->view['storno_fee'], '%').')';
-
+		
 		$pdf->setXY($prod_left + 10, $prod_top + $offset);
 		$pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $label, 1, 0, 'L');
-
+		
 		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
 		{
-
+			
 			if ($this->view['basket']['noMwSt'] == '1')
 			{
@@ -709,30 +702,30 @@
 			else
 			{
-
-
+				
+				
 				$mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%');
-
-			}
-
+				
+			}
+			
 			$pdf->setXY($prod_left + 97, $prod_top + $offset);
 			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
-
-		}
-
+			
+		}
+		
 		$pdf->setXY($prod_left + 112, $prod_top + $offset);
 		$pdf->Cell(15, 8, '1', 1, 0, 'C');
-
+		
 		$pdf->setXY($prod_left + 127, $prod_top + $offset);
 		$pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
-
+		
 		$pdf->setXY($prod_left + 152, $prod_top + $offset);
 		$pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
-
+		
 		$offset += 8;
-
-	}
-
+		
+	}
+	
 	$pdf->SetFont('Arial', '', 9);
-
+	
 	if ($this->view['kunde']['ustidnr'] != "")
 	{
@@ -742,9 +735,9 @@
 		$pdf->Cell(37, 8, $this->view['kunde']['ustidnr'], 0, 0, 'R');
 	}
-
+	
 	$offset += 10;
 	if ($this->get_option('wpsg_kleinunternehmer'))
 	{
-
+		
 		$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
 		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Summe", "wpsg"));
@@ -752,129 +745,129 @@
 		$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'] + $this->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
 		$offset += 5;
-
+		
 	}
 	else
 	{
-
+		
 		if ($this->view['basket']['noMwSt'] == '1')
 		{
-
+			
 			$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
 			$pdf->Text($prod_left + 100, $prod_top + $offset, __("BRUTTOBETRAG", "wpsg"));
 			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
-			$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+			$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_netto'] + $this->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
 			$offset += 5;
-
+			
 			$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
 			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
 			$pdf->Cell(37, 8, wpsg_ff(0, $this->get_option('wpsg_currency')), 0, 0, 'R');
-
+			
 		}
 		else
 		{
-
+			
 			$pdf->Text($prod_left, $prod_top + $offset, __("Der Gesamtbetrag setzt sich wie folgt zusammen", "wpsg"));
-
+			
 			$pdf->Text($prod_left + 100, $prod_top + $offset, __("NETTOBETRAG", "wpsg"));
 			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
-			$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-
+			$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_netto'] + $this->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+			
 			if (sizeof($this->view['basket']['mwst']) >= 1)
 			{
-
+				
 				foreach ($this->view['basket']['mwst'] as $mw)
 				{
-
+					
 					$offset += 5;
 					$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. ", "wpsg").wpsg_ff($mw['value'], '%'));
 					$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
 					$pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-
-				}
-
-			}
-
+					
+				}
+				
+			}
+			
 			if (sizeof($this->view['basket']['mwst']) > 1)
 			{
-
+				
 				$offset += 5;
 				$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
 				$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
 				$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'] - $this->view['basket']['sum']['preis_gesamt_netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-
-			}
-
-		}
-
-	}
-
+				
+			}
+			
+		}
+		
+	}
+	
 	// Rabatt
 	if ($this->view['basket']['sum']['preis_rabatt'] > 0)
 	{
-
+		
 		$offset += 5;
-
+		
 		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Rabatt", "wpsg"));
 		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
 		$pdf->Cell(37, 8, '-'.wpsg_ff($this->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-
-	}
-
+		
+	}
+	
 	$offset += 5;
 	$pdf->Text($prod_left + 100, $prod_top + $offset, __("SUMME", "wpsg"));
 	$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
 	$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-
+	
 	if ($this->get_option('wpsg_kleinunternehmer') == '1')
 	{
-
+		
 		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 5, 5, $this->get_option('wpsg_kleinunternehmer_text'));
 		$offset += 15;
-
-	}
-
+		
+	}
+	
 	if ($this->hasMod('wpsg_mod_deliverynote'))
 	{
-
+		
 		$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($this->view['data']['id']));
 		$delivery_date = $this->callMod('wpsg_mod_deliverynote', 'getDeliveryTime', array($this->view['data']['id']));
-
+		
 		// Wenn es ein Gesamtlieferdatum gibt und nur einen Lieferschein, dann unter der Bestellung anzeigen
 		if ($delivery_date !== false && sizeof($arDN_order) == 1)
 		{
-
+			
 			$offset += 10;
-
+			
 			$pdf->wpsg_MultiCell($prod_left, $prod_top + $offset, 5, wpsg_translate(__('Lieferung: #1#', 'wpsg'), date('d.m.Y', $delivery_date)));
-
+			
 			$offset += 5;
-
-		}
-
-	}
-
+			
+		}
+		
+	}
+	
 	$offset += 5;
-
+	
 	if ($this->view['fussText'] != "")
 	{
-
+		
 		//$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, utf8_encode($this->view['fussText']));		
 		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $this->view['fussText']);
 		$pdf->SetFont('Arial', 'B', 9);
 		$offset += 10;
-
-	}
-
+		
+	}
+	
 	$shipping_adress = false;
-
+	
 	if ($this->hasMod('wpsg_mod_shippingadress') && $this->callMod('wpsg_mod_shippingadress', 'check_different_shippingadress', array('k_id' => $this->view['data']['k_id'], 'o_id' => $this->view['data']['id'])))
 	{
-
+		
 		$pdf->setFont('Arial', 'B', 9);
 		$pdf->Text($prod_left, $prod_top + $offset, __("Lieferanschrift", "wpsg").":");
 		$offset += 5;
-
+		
 		$pdf->setFont('Arial', '', 9);
-
+		
 		$shipping_adress = "";
 		if ($this->view['data']['shipping_firma'] != "")
@@ -885,33 +878,33 @@
 		$shipping_adress .= $this->view['data']['shipping_strasse']."\r\n";
 		//$shipping_adress .= $this->view['data']['shipping_land']['kuerzel'].'-';
-
+		
 		$shipping_adress .= $this->view['data']['shipping_plz'].' '.$this->view['data']['shipping_ort']."\r\n";
 		$shipping_adress .= $this->view['data']['shipping_land']['name'];
-
-
+		
+		
 		$start = $pdf->getY();
 		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $shipping_adress, 0, 'L', 0, 100);
 		$offset += $pdf->getY() - $start;
-
+		
 		$shipping_adress = true;
-
-	}
-
-
+		
+	}
+	
+	
 	$offset += 5;
-
+	
 	// Bestellvariablen
 	if ($this->hasMod('wpsg_mod_ordervars') && $this->get_option('wpsg_mod_rechnungen_showov') == '1')
 	{
-
+		
 		$bvars = @unserialize($this->view['data']['bvars']);
 		if (!is_array($bvars)) $bvars = array();
-
+		
 		$strBVars = "";
 		foreach ($bvars as $bvars_id => $bvars_value)
 		{
-
+			
 			$bvars = $this->db->fetchRow("SELECT * FROM `".wpsg_q(WPSG_TBL_ORDERVARS)."` WHERE `id` = '".wpsg_q($bvars_id)."' ORDER BY `pos` ASC, `id` ASC ");
-
+			
 			if ($bvars['typ'] == "1") // Auswahl
 			{
@@ -926,41 +919,41 @@
 				if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg");
 			}
-
+			
 			$bvars_name = $this->callMod('wpsg_mod_ordervars', 'getNameById', array($bvars_id));
 			$strBVars .= "\r\n".$bvars_name.": ".$bvars_value;
-
-		}
-
+			
+		}
+		
 		$pdf->SetFont('Arial', 'B', 9);
 		$pdf->Text($prod_left, $prod_top + $offset, __("Angaben wÃ€hrend der Bestellung", "wpsg").":");
 		$pdf->SetFont('Arial', '', 9);
 		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $strBVars);
-
-	}
-
+		
+	}
+	
 	if (!file_exists($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id']))))
 	{
-
+		
 		mkdir($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id'])), 0777, true);
-
-	}
-
+		
+	}
+	
 	$this->callMods('wpsg_mod_rechnungen_pdf', array(&$pdf, &$this->view['data']['id'], &$this->view['preview'], &$this->view['invoice']));
-
+	
 	$filename = $this->view['filename'].".pdf";
-
+	
 	ob_end_clean();
-
+	
 	if ($this->view['preview']) {
-
+		
 		$pdf->Output($filename, 'I');
-
+		
 	} else {
-
+		
 		$pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id'])).$filename, 'F');
-
+		
 		// Hier wird der Dateiname an FPD ÃŒbergeben. Er soll sich aus der Rechnungsnummer ergeben, auch wenn das Dokument ÃŒber die ID gespeichert ist.
 		if ($this->view['output'] === true) $pdf->Output($this->view['filename_out'], 'I');
-
+		
 	}
 
Index: /views/order/product_table.phtml
===================================================================
--- /views/order/product_table.phtml	(revision 7242)
+++ /views/order/product_table.phtml	(revision 7243)
@@ -13,5 +13,5 @@
     
     $this->view['arCalculation'] = $arCalculation;
-    
+            
     if ($this->getBackendTaxView() === WPSG_NETTO) $display = 'netto';
     else $display = 'brutto';
@@ -30,5 +30,5 @@
 		\wpsg\wpsg_calculation::TAXMODE_SMALLBUSINESS => __('Kleinunternehmerregelung'),
 		\wpsg\wpsg_calculation::TAXMODE_B2C => __('Endkundenbesteuerung'),
-		\wpsg\wpsg_calculation::TAXMODE_B2B => __('Firmenkundenbesteuerung')
+		\wpsg\wpsg_calculation::TAXMODE_B2B => __('Firmenkundenbesteuerung (USTIdNr)')
 	], $this->view['oCalculation']->getTaxMode(), ['onchange' => 'WPSG_BE.updateCalculation();', 'help' => 'tax_mode']); ?>
 
@@ -68,6 +68,10 @@
 				<td class="wpsg_cell_name"></td>
 				<td class="wpsg_cell_preis"><?php echo wpsg_ff($product_price); ?> <?php echo $this->get_option('wpsg_currency'); ?></td>
-				<?php if (sizeof($arCalculation['tax']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
-					<td class="wpsg_cell_mwst"><?php echo $arTaxShort[$p['tax_key']]; ?></td>
+				<?php if (sizeof($arCalculation['tax']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>					
+					<td class="wpsg_cell_mwst"><?php 
+							
+						echo (($p['brutto'] === $p['netto'])?wpsg_ff(0, '%'):$arTaxShort[$p['tax_key']]);
+							
+					?></td>					
 				<?php } ?>
 				<td class="wpsg_cell_menge"><?php echo wpsg_hspc($p['amount']); ?></td>
Index: /views/warenkorb/basket.phtml
===================================================================
--- /views/warenkorb/basket.phtml	(revision 7242)
+++ /views/warenkorb/basket.phtml	(revision 7243)
@@ -112,8 +112,7 @@
 					<?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
 					<div class="product_info">
-						 
-						<?php if ($this->view['$bPicture'] == true) { ?>class="titlep"><?php } else { ?>class="title"><?php } ?>
-							<?php echo __("MwSt.", "wpsg"); ?>
-						</div>
+						
+						<?php echo __("MwSt.", "wpsg"); ?>
+						
 						<div class="valuer">
 							<?php echo wpsg_ff($product_data['mwst_value'], ' %'); ?>
