Index: /controller/wpsg_BasketController.class.php
===================================================================
--- /controller/wpsg_BasketController.class.php	(revision 7488)
+++ /controller/wpsg_BasketController.class.php	(revision 7490)
@@ -654,89 +654,99 @@
 								
 							}
-							 							
+														 							 
 							if ($bCheckDiscount) {
-							
-								// Gutschein ist von der grÃ¶Ãe des Warenkorbes begrenzt.
-								if (wpsg_tf($gs_db['minvalue']) > 0 && wpsg_tf($gs_db['minvalue']) > $arBasket['sum']['preis'])
-								{
+								
+								$oVoucher = wpsg_voucher::getInstance($gs_db['id']);
+								
+								if (!$oVoucher->isUsabel()) {
 									
-									$this->addFrontendError(wpsg_translate(__('Dieser Gutscheincode kann nicht eingelÃ¶st werden, da der Mindestbestellwert von #1# noch nicht erreicht ist.', 'wpsg'), wpsg_ff(wpsg_tf($gs_db['minvalue']), $this->shop->get_option('wpsg_currency'))));
-									$_SESSION['wpsg']['errorFields'][] = 'gutschein';
+									$this->addFrontendError(__('Gutschein kann nicht verwendet werden. Er ist nicht mehr aktiv oder verbraucht.', 'wpsg'));
 									
-								}
-								else
-								{
-								
-									$this->shop->basket->initFromSession();
-									$arProductIDsBasket = $this->shop->basket->getProductIDs();
-									
-									$wrongProducts = array();
-									
-									// ProduktgÃŒltigkeit prÃŒfen
-									$tarr = wpsg_explode(',', $gs_db['products']);
-									if (wpsg_isSizedArray($tarr))
+								} else {
+							
+									// Gutschein ist von der grÃ¶Ãe des Warenkorbes begrenzt.
+									if (wpsg_tf($gs_db['minvalue']) > 0 && wpsg_tf($gs_db['minvalue']) > $arBasket['sum']['preis'])
 									{
 										
-										if (sizeof(array_diff($arProductIDsBasket, wpsg_explode(',', $gs_db['products']))) > 0)
+										$this->addFrontendError(wpsg_translate(__('Dieser Gutscheincode kann nicht eingelÃ¶st werden, da der Mindestbestellwert von #1# noch nicht erreicht ist.', 'wpsg'), wpsg_ff(wpsg_tf($gs_db['minvalue']), $this->shop->get_option('wpsg_currency'))));
+										$_SESSION['wpsg']['errorFields'][] = 'gutschein';
+										
+									}
+									else
+									{
+																		
+										$this->shop->basket->initFromSession();
+										$arProductIDsBasket = $this->shop->basket->getProductIDs();
+										
+										$wrongProducts = array();
+										
+										// ProduktgÃŒltigkeit prÃŒfen
+										$tarr = wpsg_explode(',', $gs_db['products']);
+										if (wpsg_isSizedArray($tarr))
 										{
 											
-											$wrongProducts = array_diff($arProductIDsBasket, wpsg_explode(',', $gs_db['products']));
+											if (sizeof(array_diff($arProductIDsBasket, wpsg_explode(',', $gs_db['products']))) > 0)
+											{
+												
+												$wrongProducts = array_diff($arProductIDsBasket, wpsg_explode(',', $gs_db['products']));
+												
+											}
 											
 										}
 										
-									}
-									
-									// ProduktgruppengÃŒltigkeit prÃŒfen
-									$tarr = wpsg_explode(',', $gs_db['productgroups']);
-									if (wpsg_isSizedArray($tarr))
-									{
-										
-										$ProductGroupIDs = wpsg_explode(',', $gs_db['productgroups']);
-										
-										$arProductIDs = $this->db->fetchAssocField("
-											SELECT P.`id` FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` IN (".wpsg_implode(',', $ProductGroupIDs).")
-										");
-										
-										if (sizeof(array_diff($arProductIDsBasket, $arProductIDs)) > 0)
+										// ProduktgruppengÃŒltigkeit prÃŒfen
+										$tarr = wpsg_explode(',', $gs_db['productgroups']);
+										if (wpsg_isSizedArray($tarr))
 										{
 											
-											$wrongProducts = array_merge($wrongProducts, array_diff($arProductIDsBasket, $arProductIDs));
+											$ProductGroupIDs = wpsg_explode(',', $gs_db['productgroups']);
+											
+											$arProductIDs = $this->db->fetchAssocField("
+												SELECT P.`id` FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` IN (".wpsg_implode(',', $ProductGroupIDs).")
+											");
+											
+											if (sizeof(array_diff($arProductIDsBasket, $arProductIDs)) > 0)
+											{
+												
+												$wrongProducts = array_merge($wrongProducts, array_diff($arProductIDsBasket, $arProductIDs));
+												
+											}
 											
 										}
-										
-									}
-																
-									if (wpsg_isSizedArray($wrongProducts))
-									{
-										
-										if (sizeof($wrongProducts) === 1)
+																	
+										if (wpsg_isSizedArray($wrongProducts))
 										{
 											
-											$product = $this->shop->loadProduktArray($wrongProducts[0]);
-											$this->addFrontendError(wpsg_translate(__('Gutschein konnte nicht hinzugefÃŒgt werden, da er fÃŒr das Produkt #1# nicht zulÃ€ssig ist.', 'wpsg'), $product['name']));		
+											if (sizeof($wrongProducts) === 1)
+											{
+												
+												$product = $this->shop->loadProduktArray($wrongProducts[0]);
+												$this->addFrontendError(wpsg_translate(__('Gutschein konnte nicht hinzugefÃŒgt werden, da er fÃŒr das Produkt #1# nicht zulÃ€ssig ist.', 'wpsg'), $product['name']));		
+												
+											}
+											else
+											{
 											
+												$arProductNames = array();
+												foreach ($wrongProducts as $product_id)
+												{
+													
+													$product_data = $this->shop->loadProduktArray($product_id);
+													$arProductNames[] = $product_data['name'];
+													
+												}
+												
+												$this->addFrontendError(wpsg_translate(__('Gutschein konnte nicht hinzugefÃŒgt werden, da er fÃŒr die Produkte #1# nicht zulÃ€ssig ist.', 'wpsg'), wpsg_implode(', ', $arProductNames)));
+												
+											}
+												
 										}
 										else
 										{
-										
-											$arProductNames = array();
-											foreach ($wrongProducts as $product_id)
-											{
-												
-												$product_data = $this->shop->loadProduktArray($product_id);
-												$arProductNames[] = $product_data['name'];
-												
-											}
-											
-											$this->addFrontendError(wpsg_translate(__('Gutschein konnte nicht hinzugefÃŒgt werden, da er fÃŒr die Produkte #1# nicht zulÃ€ssig ist.', 'wpsg'), wpsg_implode(', ', $arProductNames)));
+			
+											$this->addFrontendMessage(__('Gutschein wurde der Bestellung erfolgreich hinzugefÃŒgt.', 'wpsg'));							
+											$this->shop->basket->addGutscheinToSession($gs_db['value'], $gs_db['calc_typ'], $gs_db['code'], $gs_db['id']);
 											
 										}
-											
-									}
-									else
-									{
-		
-										$this->addFrontendMessage(__('Gutschein wurde der Bestellung erfolgreich hinzugefÃŒgt.', 'wpsg'));							
-										$this->shop->basket->addGutscheinToSession($gs_db['value'], $gs_db['calc_typ'], $gs_db['code'], $gs_db['id']);
 										
 									}
Index: /controller/wpsg_OrderController.class.php
===================================================================
--- /controller/wpsg_OrderController.class.php	(revision 7488)
+++ /controller/wpsg_OrderController.class.php	(revision 7490)
@@ -1184,11 +1184,24 @@
 					
 					if ($_REQUEST['do'] === 'remove') {
+				 
+						$this->shop->view['oCalculation']->removeVoucher($_REQUEST['order_voucher_id']);
+						 
+					} else if ($_REQUEST['do'] === 'submit') {
 						
 						$this->shop->view['oCalculation']->removeVoucher($_REQUEST['order_voucher_id']);
 						
-					} else if ($_REQUEST['do'] === 'submit') {
-						
-						if (wpsg_tf($_REQUEST['be_voucher_amount']) < 0) $this->shop->view['oCalculation']->removeVoucher($_REQUEST['order_voucher_id']);
-						else $this->shop->view['oCalculation']->addVoucher($_REQUEST['be_voucher_amount'], $this->shop->getBackendTaxview(), '0', 1, $_REQUEST['be_voucher_code'], $_REQUEST['be_voucher_id']);
+						if (wpsg_tf($_REQUEST['be_voucher_amount']) > 0) {
+							
+							if (wpsg_isSizedInt($_REQUEST['be_voucher_coupon'])) {
+								
+								$this->shop->view['oCalculation']->addCoupon($_REQUEST['be_voucher_amount'], $this->shop->getBackendTaxview(), '0', 1, $_REQUEST['be_voucher_code'], $_REQUEST['be_voucher_id'], $_REQUEST['order_voucher_id']);
+								
+							} else {
+								
+								$this->shop->view['oCalculation']->addVoucher($_REQUEST['be_voucher_amount'], $this->shop->getBackendTaxview(), '0', 1, $_REQUEST['be_voucher_code'], $_REQUEST['be_voucher_id'], $_REQUEST['order_voucher_id']);
+								
+							}
+																					
+						}
 						 						
 					} else if ($_REQUEST['do'] === 'search') {
@@ -1196,12 +1209,10 @@
 						$arVoucher = $this->db->fetchAssoc("
 							SELECT
-								V.`id`, V.`value` AS `gs_value`, V.`code`, V.`calc_typ`, V.`id`, 
+								V.`id`, V.`value` AS `gs_value`, V.`code`, V.`calc_typ`, V.`id`, V.`coupon`,
 								CONCAT(V.`code`) AS `value`
 							FROM
 								`".WPSG_TBL_GUTSCHEIN."` AS V
 							WHERE
-								V.`code` LIKE '%".wpsg_q($_REQUEST['term'])."%' AND
-								(V.`o_id` <= 0 OR V.`multi` = '1') AND
-								NOW() BETWEEN V.`start_date` AND V.`end_date`
+								V.`code` LIKE '%".wpsg_q($_REQUEST['term'])."%' 
 							ORDER BY
 								V.`code` ASC 
@@ -1210,6 +1221,13 @@
 						foreach ($arVoucher as $k => $v) {
 							
-							if ($v['calc_type'] === 'p') $arVoucher[$k]['gs_value'] = wpsg_ff($arVoucher[$k]['gs_value'], '%');
-							else $arVoucher[$k]['gs_value'] = wpsg_ff($arVoucher[$k]['gs_value'], $this->shop->get_option('wpsg_currency'));
+							$oVoucher = wpsg_voucher::getInstance($v['id']);
+							
+							if (!$oVoucher->isUsabel()) unset($arVoucher[$k]);
+							else {
+							
+								if ($v['calc_type'] === 'p') $arVoucher[$k]['gs_value'] = wpsg_ff($arVoucher[$k]['gs_value'], '%');
+								else $arVoucher[$k]['gs_value'] = wpsg_ff($oVoucher->getFreeAmount(), $this->shop->get_option('wpsg_currency'));
+								
+							}
 							
 						}
@@ -1220,4 +1238,7 @@
 					
 					$this->shop->view['oCalculation']->toDB($_REQUEST['edit_id']);
+					
+					$this->shop->view['oCalculation'] = new \wpsg\wpsg_calculation();
+					$this->shop->view['oCalculation']->fromDB($_REQUEST['edit_id']); // Muss ich machen, damit ich die order_voucher_id habe
 					 					
 					wpsg_header::JSONData([
Index: /controller/wpsg_ShopController.class.php
===================================================================
--- /controller/wpsg_ShopController.class.php	(revision 7488)
+++ /controller/wpsg_ShopController.class.php	(revision 7490)
@@ -233,10 +233,15 @@
 		public function firstInstall()
 		{
-
+			
 			global $wpdb, $current_user;
 
 			$user_id = 0;
 
-			if (function_exists("get_currentuserinfo"))
+			if (function_exists('wp_get_current_user')) {
+				
+				$current_user = wp_get_current_user();
+				$user_id = $current_user->user_ID;
+				
+			} else if (function_exists("get_currentuserinfo"))
 			{
 				get_currentuserinfo();
@@ -326,4 +331,6 @@
 			$this->loadModule(true);
 
+			$this->arModule['wpsg_mod_versandarten']->install();
+			
 			// Versandzone anlegen
 			if ($this->hasMod('wpsg_mod_versandarten'))
@@ -340,5 +347,5 @@
 						"name" => wpsg_q($vz_default_name)
 					));
-
+					
 					$this->addTranslationString('vz_'.$vz_id, $vz_default_name);
 
Index: /lib/wpsg_calculation.class.php
===================================================================
--- /lib/wpsg_calculation.class.php	(revision 7488)
+++ /lib/wpsg_calculation.class.php	(revision 7490)
@@ -146,5 +146,5 @@
         	foreach ($this->arCalculationRow as $k => $cr) {
         		
-        		if (isset($cr['order_voucher_id']) && $cr['order_voucher_id'] == $order_voucher_id) {
+        		if (isset($cr['data']['order_voucher_id']) && $cr['data']['order_voucher_id'] == $order_voucher_id) {
         			
         			unset($this->arCalculationRow[$k]);
@@ -164,10 +164,10 @@
 		 */
 		public function addVoucher($set, $bruttonetto, $tax_key, $amount = 1, $code = false, $id = false, $order_voucher_id = 0) {
-		 
+			
 			$tax_key = $this->normalizeTaxKey($tax_key);
 			
 			if (strpos($set, '-') === false) $set = '-'.$set; 
 			
-			$this->arCalculationRow['voucher_'.$id] = [
+			$this->arCalculationRow['voucher_'.$id.'-'.$order_voucher_id] = [
 				'type' => 'voucher',
 				'amount' => $amount,
@@ -192,5 +192,5 @@
 			if (strpos($set, '-') === false) $set = '-'.$set;
 			
-			$this->arCalculationRow['coupon_'.$id] = [
+			$this->arCalculationRow['coupon_'.$id.'-'.$order_voucher_id] = [
 				'type' => 'coupon',
 				'amount' => $amount,
@@ -424,5 +424,5 @@
                 	             
                 	if ($cr['type'] === 'coupon') continue;
-                	
+                	 
                 	$this->addTax($cr['tax_key']);
                 	$this->calculateTaxProportionally($cr['bruttonetto']);
@@ -487,6 +487,9 @@
 							// Netto / Brutto berechnen
 							if ($cr['bruttonetto'] === WPSG_NETTO) {
-								
+																
 								$set_netto = wpsg_tf($set);
+								
+								// Kleiner 0 prÃŒfen
+								//if (($netto + $set_netto) < 0) $set_netto = -1 * $brutto;
 								
 								list($set_netto, $set_brutto) = $this->calculateTaxPart(WPSG_NETTO, $set_netto, $cr['tax_key']);
@@ -513,8 +516,12 @@
 								}
 								
+								//wpsg_Debug($brutto.":".$set_brutto);
+								// Kleiner 0 prÃŒfen
+								if (($this->arCalculation['sum']['brutto'] + $set_brutto) < 0) $set_brutto = -1 * $this->arCalculation['sum']['brutto']; 
+								 
 								list($set_netto, $set_brutto) = $this->calculateTaxPart(WPSG_BRUTTO, $set_brutto, $cr['tax_key']);
-								
+								//wpsg_debug('2: '.$set_netto.":".$set_brutto);
 							}
-																									
+							 																									
 						}
 											
@@ -523,5 +530,5 @@
 						
 					}
-	
+	 
 					$cr['set'] = array_values($cr['set'])[0];
 						
@@ -622,5 +629,5 @@
 			
 							$set_netto = wpsg_tf($set);
-			
+			 							
 							list($set_netto, $set_brutto) = $this->calculateTaxPart(WPSG_NETTO, $set_netto, $cr['tax_key']);
 			
@@ -645,7 +652,9 @@
 				
 							}
-			
-							list($set_netto, $set_brutto) = $this->calculateTaxPart(WPSG_BRUTTO, $set_brutto, $cr['tax_key']);
-							
+							
+							if (($this->arCalculation['sum']['brutto'] + $set_brutto) < 0) $set_brutto = -1 * $this->arCalculation['sum']['brutto'];
+							 			
+							list($set_netto, $set_brutto) = $this->calculateTaxPart(WPSG_BRUTTO, $set_brutto, $cr['tax_key'], true);
+											
 							if ($this->arCalculation['sum']['topay_netto'] + $set_netto < 0) {
 								
@@ -852,43 +861,41 @@
             $arOrderProductID = [-1];
             
-			// Gutscheine speichern		
-			if ($finish_order) {
-				
-				foreach ($arCalculation['voucher'] as $v) {
-				
-					$this->db->ImportQuery(WPSG_TBL_ORDER_VOUCHER, [
-						'create_time' => "NOW()",
-						'order_id' => wpsg_q($id),
-						'voucher_id' => wpsg_q($v['id']),
-						'set_value' => wpsg_q($v['set']), 
-						'sum_netto' => wpsg_q($v['netto']),
-						'sum_brutto' => wpsg_q($v['brutto']),
-						'tax_key' => wpsg_q($v['tax_key']),
-						'bruttonetto' => wpsg_q($v['bruttonetto']),
-						'code' => wpsg_q($v['code']),
-						'coupon' => '0'
-					]);
-	
-				}
-				
-				foreach ($arCalculation['coupon'] as $c) {
-					
-					$this->db->ImportQuery(WPSG_TBL_ORDER_VOUCHER, [
-						'create_time' => "NOW()",
-						'order_id' => wpsg_q($id),
-						'voucher_id' => wpsg_q($v['id']),
-						'set_value' => wpsg_q($v['set']),
-						'sum_netto' => wpsg_q($v['netto']),
-						'sum_brutto' => wpsg_q($v['brutto']),
-						'tax_key' => wpsg_q($v['tax_key']),
-						'bruttonetto' => wpsg_q($v['bruttonetto']),
-						'code' => wpsg_q($v['code']),
-						'coupon' => '1'
-					]);
-					
-				}
-						
-			}
-			
+			// Gutscheine speichern		 
+			$this->db->Query("DELETE FROM `".WPSG_TBL_ORDER_VOUCHER."` WHERE `order_id` = '".wpsg_q($id)."' ");
+			
+			foreach ($arCalculation['voucher'] as $v) {
+			
+				$this->db->ImportQuery(WPSG_TBL_ORDER_VOUCHER, [
+					'create_time' => "NOW()",
+					'order_id' => wpsg_q($id),
+					'voucher_id' => wpsg_q($v['id']),
+					'set_value' => wpsg_q($v['set']), 
+					'sum_netto' => wpsg_q($v['netto']),
+					'sum_brutto' => wpsg_q($v['brutto']),
+					'tax_key' => wpsg_q($v['tax_key']),
+					'bruttonetto' => wpsg_q($v['bruttonetto']),
+					'code' => wpsg_q($v['code']),
+					'coupon' => '0'
+				]);
+
+			}
+			
+			foreach ($arCalculation['coupon'] as $c) {
+				
+				$this->db->ImportQuery(WPSG_TBL_ORDER_VOUCHER, [
+					'create_time' => "NOW()",
+					'order_id' => wpsg_q($id),
+					'voucher_id' => wpsg_q($c['id']),
+					'set_value' => wpsg_q($c['set']),
+					'sum_netto' => wpsg_q($c['netto']),
+					'sum_brutto' => wpsg_q($c['brutto']),
+					'tax_key' => wpsg_q($c['tax_key']),
+					'bruttonetto' => wpsg_q($c['bruttonetto']),
+					'code' => wpsg_q($c['code']),
+					'coupon' => '1'
+				]);
+				
+			}
+						
             // Produkte speichern
 			foreach ($arCalculation['product'] as $p) {
@@ -1252,5 +1259,5 @@
 		 * @param $tax_key
 		 */
-        private function calculateTaxPart($bruttonetto, $val, $tax_key) {
+        private function calculateTaxPart($bruttonetto, $val, $tax_key, $noTax = false) {
 	        	
         	if (!is_numeric($val)) $val = 0;
@@ -1276,9 +1283,14 @@
 							
 						}
+						
+						//wpsg_debug($sum_netto.'('.$sum_brutto.')'.":".$val);
+						
+						//if ($sum_netto + $netto < 0) $netto = -1 * $sum_netto;
+						//if ($sum_brutto + $brutto < 0) $brutto = -1 * $sum_brutto;
 						 
 						$ret_netto += $netto;
 						$ret_brutto += $brutto;
 						
-						if ($tax_key !== $tax_key2) {
+						if ($tax_key !== $tax_key2 && !$noTax) {
 						
 							$this->arCalculation['tax'][$tax_key2]['netto'] += $netto;
Index: /mods/mod_gutschein/wpsg_voucher.php
===================================================================
--- /mods/mod_gutschein/wpsg_voucher.php	(revision 7488)
+++ /mods/mod_gutschein/wpsg_voucher.php	(revision 7490)
@@ -30,11 +30,42 @@
 
 		} // public function __construct($voucher_id)
-
-        public function getUsed()
-        {
+				
+		public function getFreeAmount() {
+			
+			$free = wpsg_tf($this->value) - $this->getUsedAmount();
+			
+			if ($free < 0) $free = 0;
+			
+			return $free;
+			
+		}
+		
+		public function isMultiUsable() {
+			
+			return wpsg_isSizedInt($this->multi);
+			
+		}
+		
+        public function getUsed() {
 
 			return intval($this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_ORDER."` WHERE `gs_id` = '".wpsg_q($this->id)."' "));
 			
         }
+        
+        public function getUsedAmount($taxView = false) {
+	
+			if ($taxView === false) $taxView = $this->shop->getBackendTaxview();
+			
+			if ($taxView === WPSG_NETTO) {
+				
+				return abs(wpsg_tf($this->db->fetchOne("SELECT SUM(`sum_netto`) FROM `".WPSG_TBL_ORDER_VOUCHER."` WHERE `voucher_id` = '".wpsg_q($this->getId())."' ")));
+				
+			} else if ($taxView === WPSG_BRUTTO) {
+				
+				return abs(wpsg_tf($this->db->fetchOne("SELECT SUM(`sum_brutto`) FROM `".WPSG_TBL_ORDER_VOUCHER."` WHERE `voucher_id` = '".wpsg_q($this->getId())."' ")));
+				
+			} else throw new \Exception(__('Nicht definiert.', 'wpsg'));
+			
+		}
         
         public function isCoupon() {
@@ -52,6 +83,19 @@
         }
         
+        public function isUsabel() {
+			
+			if (strtotime($this->start_date) > time()) return false;
+			if (strtotime($this->end_date) < time()) return false;
+			if ($this->isMultiUsable() && $this->getUsed() > 0) return false;
+			if ($this->getFreeAmount() <= 0) return false;
+			
+			return true;
+			
+		}
+        
         public function getStatusLabel()
         {
+        	
+        	if ($this->getFreeAmount() <= 0) return __('Verbraucht');
 
 			if ($this->multi === '1')
Index: /mods/wpsg_mod_basic.class.php
===================================================================
--- /mods/wpsg_mod_basic.class.php	(revision 7488)
+++ /mods/wpsg_mod_basic.class.php	(revision 7490)
@@ -203,4 +203,6 @@
 		public function mail_status(&$order, &$customer) { }
 		
+		public function mail_order_end(&$arCalculation, $html) { }
+		
 		/** Wird in der Kundenmail nach den AGB eingebaut */
 		public function kundenmail_afteragb(&$order_id) { }
Index: /mods/wpsg_mod_gutschein.class.php
===================================================================
--- /mods/wpsg_mod_gutschein.class.php	(revision 7488)
+++ /mods/wpsg_mod_gutschein.class.php	(revision 7490)
@@ -37,5 +37,5 @@
 		   		code VARCHAR(255) NOT NULL,
 		   		coupon INT(1) NOT NULL COMMENT '1 bei Wertgutscheinen',
-		   		value DOUBLE(10,2) NOT NULL,
+		   		value DOUBLE(10,2) NOT NULL, 
 		   		o_id INT(11) NOT NULL,
 		   		calc_typ ENUM('w', 'p') NOT NULL,
@@ -154,13 +154,17 @@
 						$oVoucher = wpsg_voucher::getInstance($gs['id']);
 						
-						if ($oVoucher->isCoupon()) {
+						if ($oVoucher->isUsabel()) {
+						
+							if ($oVoucher->isCoupon()) {
+								
+								$oCalculation->addCoupon($oVoucher->getFreeAmount(), $this->shop->getBackendTaxview(), '0', 1, $gs['code'], $gs['id']);
+								
+							} else {
 							
-							$oCalculation->addCoupon($gs['value'], $this->shop->getBackendTaxview(), '0', 1, $gs['code'], $gs['id']);
+								if ($gs['calc'] === 'p') $gs['value'] = $gs['value'].'%';
 							
-						} else {
-						
-							if ($gs['calc'] === 'p') $gs['value'] = $gs['value'].'%';
-						
-							$oCalculation->addVoucher($gs['value'], $this->shop->getBackendTaxview(), '0', 1, $gs['code'], $gs['id']);
+								$oCalculation->addVoucher($oVoucher->getFreeAmount(), $this->shop->getBackendTaxview(), '0', 1, $gs['code'], $gs['id']);
+								
+							}
 							
 						}
@@ -642,5 +646,16 @@
 
 		} // public function importAction()
-
+		
+		public function mail_order_end(&$arCalculation, $html) {
+			
+			if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto'] && wpsg_isSizedArray($arCalculation['coupon'])) {
+				
+				if ($html) $this->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/mail_order_end_html.phtml');
+				else $this->render(WPSG_PATH_VIEW.'/mods/mod_gutschein/mail_order_end.phtml');
+				
+			}
+			
+		}
+		
 		public function basket_row_end_coupon() {
 			
Index: /views/mailtemplates/html/customer.phtml
===================================================================
--- /views/mailtemplates/html/customer.phtml	(revision 7488)
+++ /views/mailtemplates/html/customer.phtml	(revision 7490)
@@ -132,5 +132,5 @@
 	<tr>
 		<td style="padding:2px; line-height:100%; vertical-align:middle;" class="col0"><?php echo __('Rechnungsbetrag', 'wpsg'); ?>:</td>
-		<td style="padding:2px; line-height:100%; vertical-align:middle;" class="col1"><strong><?php echo wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')); ?></strong></td>
+		<td style="padding:2px; line-height:100%; vertical-align:middle;" class="col1"><strong><?php echo wpsg_ff($this->view['basket']['arCalculation']['topay_brutto'], $this->get_option('wpsg_currency')); ?></strong></td>
 	</tr>
 	<?php if ($this->get_option('wpsg_kleinunternehmer') != '1') { ?>
Index: /views/mailtemplates/html/order.phtml
===================================================================
--- /views/mailtemplates/html/order.phtml	(revision 7488)
+++ /views/mailtemplates/html/order.phtml	(revision 7490)
@@ -1,3 +1,8 @@
-<div class="baskettable_wrap">
+<?php
+	
+	if ($this->getFrontendTaxView() === WPSG_BRUTTO) $display_brutto_netto = 'brutto';
+	else $display_brutto_netto = 'netto';
+	
+?><div class="baskettable_wrap">
 	<table class="baskettable" cellpadding="2" cellspacing="0" style="cell-padding:4px;">
 		<tr class="head">
@@ -70,16 +75,18 @@
 		<?php } ?>
 		<?php } ?>
-		<?php if (isset($this->view['basket']['gs'])) { ?>
-		<tr class="voucherrow">
-			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_pos"><?php echo $i + 1; ?>.</td>
-			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_name"><?php echo wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $this->view['basket']['gs']['code']); ?></td>
-			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_price"><?php echo wpsg_ff($this->view['basket']['gs']['value'], (($this->view['basket']['gs']['calc'] == 'w')?$this->get_option('wpsg_currency'):'%')); ?></td>
-			<?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
-			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_mwst"><?php echo __('anteilig', 'wpsg'); ?></td>		
-			<?php } ?>
-			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_amount">1</td>
-			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_sum"><?php echo '-'.wpsg_ff($this->view['basket']['sum']['gs'], $this->get_option('wpsg_currency')); ?></td> 
-		</tr>
-		<?php } ?>
+		<?php if (wpsg_isSizedArray($this->view['basket']['arCalculation']['voucher'])) { $bLine = true; ?>		
+			<?php foreach ($this->view['basket']['arCalculation']['voucher'] as $gs) { ?>
+				<tr class="voucherrow">
+					<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_pos"> <?php print_r($gs); ?></td>
+					<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_name"><?php echo wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $gs['code']); ?></td>
+					<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_price"><?php echo wpsg_ff($gs['set'], ((strpos($gs['set'], '%') !== false)?'%':$this->get_option('wpsg_currency'))); ?></td>
+					<?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
+						<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_mwst"><?php echo __('Anteilig', 'wpsg'); ?></td>
+					<?php } ?>
+					<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_amount">1</td>
+					<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_sum"><?php echo wpsg_ff($gs[$display_brutto_netto], $this->get_option('wpsg_currency')); ?></td>
+				</tr>
+			<?php } ?>
+		<?php } ?>		
 		<tr class="spacer">
 			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="td_bt" colspan="<?php echo ((sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1')?'6':'5'); ?>">&nbsp;</td>
@@ -189,4 +196,5 @@
 			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_sum"><strong><?php echo wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')); ?></strong></td>
 		</tr>
+		<?php $this->callMods('mail_order_end', [$this->view['basket']['arCalculation'], true]); ?>	
 	</table>
 </div>
Index: /views/mailtemplates/kundenmail.phtml
===================================================================
--- /views/mailtemplates/kundenmail.phtml	(revision 7488)
+++ /views/mailtemplates/kundenmail.phtml	(revision 7490)
@@ -64,5 +64,5 @@
 <?php echo wpsg_pad_right(__('Bestellnummer', 'wpsg').':', 35); ?><?php echo $this->view['basket']['checkout']['onr']; ?> 
 <?php echo wpsg_pad_right(__('Bestelldatum', 'wpsg').':', 35); ?><?php echo date("d.m.Y H:i:s", $this->view['basket']['checkout']['datum']); ?> 
-<?php echo wpsg_pad_right(__('Rechnungsbetrag', 'wpsg').':', 35); ?><?php echo wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')); ?> 
+<?php echo wpsg_pad_right(__('Rechnungsbetrag', 'wpsg').':', 35); ?><?php echo wpsg_ff($this->view['basket']['arCalculation']['topay_brutto'], $this->get_option('wpsg_currency')); ?> 
 <?php if ($this->get_option('wpsg_kleinunternehmer')) { ?>
 
Index: /views/mailtemplates/order.phtml
===================================================================
--- /views/mailtemplates/order.phtml	(revision 7488)
+++ /views/mailtemplates/order.phtml	(revision 7490)
@@ -1,3 +1,8 @@
-<?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { $prod_col = 25; } else { $prod_col = 35; } ?>
+<?php
+	
+	if ($this->getFrontendTaxView() === WPSG_BRUTTO) $display_brutto_netto = 'brutto';
+	else $display_brutto_netto = 'netto';
+
+?><?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { $prod_col = 25; } else { $prod_col = 35; } ?>
 
 <?php echo wpsg_pad_right(__('Pos', 'wpsg'), 5); ?>
@@ -30,14 +35,25 @@
 <?php } ?>
  
-<?php if (isset($this->view['basket']['gs'])) { ?>
-<?php echo wpsg_pad_right(($i + 1).'.', 5); ?>
-<?php echo wpsg_pad_right(wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $this->view['basket']['gs']['code']), $prod_col); ?>
-<?php echo wpsg_pad_left(wpsg_ff($this->view['basket']['gs']['value'], (($this->view['basket']['gs']['calc'] == 'w')?$this->get_option('wpsg_currency'):'%')).' ', 15); ?>
-<?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
-<?php echo wpsg_pad_left(__('anteilig', 'wpsg').' ', 10); ?>
-<?php } ?>
-<?php echo wpsg_pad_left('1', 6); ?>
-<?php echo wpsg_pad_left('-'.wpsg_ff($this->view['basket']['sum']['gs'], $this->get_option('wpsg_currency')), 15); ?> 
-<?php } ?>
+<?php if (wpsg_isSizedArray($this->view['basket']['arCalculation']['voucher'])) {
+	
+	foreach ($this->view['basket']['arCalculation']['voucher'] as $gs) {
+		
+		echo wpsg_pad_right(' ', 5);
+		echo wpsg_pad_right(wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $gs['code']), $prod_col);
+		echo wpsg_pad_left(wpsg_ff($gs['set'], ((strpos($gs['set'], '%') !== false)?'%':$this->get_option('wpsg_currency'))).' ', 15);
+		
+		if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') {
+			
+			echo wpsg_pad_left(__('anteilig', 'wpsg').' ', 10);
+			
+		}
+		
+		echo wpsg_pad_left('1', 6);
+		echo wpsg_pad_left(wpsg_ff($gs[$display_brutto_netto], $this->get_option('wpsg_currency')), 15);
+		echo "\r\n";
+		
+	}
+
+} ?>
 <?php if (isset($this->view['basket']['sum']['preis_rabatt']) && $this->view['basket']['sum']['preis_rabatt'] > 0) { ?>
      <?php echo wpsg_pad_right(__('AbzÃŒglich Rabatt', 'wpsg'), 40); ?>
@@ -103,5 +119,6 @@
 <?php echo wpsg_pad_left(' ', 61); ?>---------------
      <?php echo wpsg_pad_right(__('Gesamtpreis:', 'wpsg'), 37); ?>
-<?php echo wpsg_pad_left(wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 34); ?> 
+<?php echo wpsg_pad_left(wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 34); ?>
+<?php $this->callMods('mail_order_end', [$this->view['basket']['arCalculation'], false]); ?>
  
 <?php $this->callMods('mail_aftercalculation', array(&$this->view['basket']['checkout']['o_id'])); ?>
Index: /views/mods/mod_gutschein/add.phtml
===================================================================
--- /views/mods/mod_gutschein/add.phtml	(revision 7488)
+++ /views/mods/mod_gutschein/add.phtml	(revision 7490)
@@ -5,4 +5,14 @@
 	 */
  
+	$used = 0;
+	
+	if (wpsg_isSizedInt($_REQUEST['voucher_id'])) {
+		
+		$oVoucher = wpsg_voucher::getInstance($_REQUEST['voucher_id']);
+		
+		$used = $oVoucher->getUsedAmount();
+		
+	}
+	
 ?>
 
@@ -14,4 +24,5 @@
 			
 			<?php echo wpsg_drawForm_Input('wpsg_mod_gutschein_value', __('Betrag', 'wpsg'), wpsg_ff($this->view['mod_gutschein']['value'])); ?>
+			<?php echo wpsg_drawForm_Input(false, __('Bereits verwendet'), wpsg_ff($used), ['field_id' => 'wpsg_voucher_used', 'readonly' => true]); ?>
 		
 			<div style="margin-top:-15px;"> 
Index: /views/mods/mod_gutschein/basket_row_end_coupon.phtml
===================================================================
--- /views/mods/mod_gutschein/basket_row_end_coupon.phtml	(revision 7488)
+++ /views/mods/mod_gutschein/basket_row_end_coupon.phtml	(revision 7490)
@@ -26,5 +26,5 @@
 		<div class="value"><?php
 				
-				echo '-'.wpsg_ff($gs[$display_brutto_netto], $this->get_option('wpsg_currency'));
+				echo wpsg_ff($gs[$display_brutto_netto], $this->get_option('wpsg_currency'));
 				
 				if (strpos($gs['set'], '%') !== false) {
Index: /views/mods/mod_gutschein/index.phtml
===================================================================
--- /views/mods/mod_gutschein/index.phtml	(revision 7488)
+++ /views/mods/mod_gutschein/index.phtml	(revision 7490)
@@ -81,5 +81,6 @@
                     </thead>
                     <tbody>
-                        <?php foreach ($this->view['arData'] as $oVoucher) { ?>
+                        <?php /** @var wpsg_voucher $oVoucher */
+							foreach ($this->view['arData'] as $oVoucher) { ?>
                         <tr>
                             <td class="col_checkbox">
@@ -108,6 +109,8 @@
                             <td class="col_value"><span><?php
 
-                                if ($oVoucher->calc_typ == 'w') echo wpsg_ff($oVoucher->value, $this->get_option('wpsg_currency'));
+                                if ($oVoucher->calc_typ == 'w') echo wpsg_ff($oVoucher->getFreeAmount(), $this->get_option('wpsg_currency'));
                                 else if ($oVoucher->calc_typ == 'p') echo wpsg_ff($oVoucher->value, '%');
+                                
+                                if ($oVoucher->calc_typ == 'w' && $oVoucher->getUsedAmount() > 0) echo ' <span title="'.__('Original Betrag', 'wpsg').'">('.wpsg_ff($oVoucher->value, $this->get_option('wpsg_currency')).')</span>';
 
                             ?></span><?php 
Index: /views/mods/mod_gutschein/mail_order_end.phtml
===================================================================
--- /views/mods/mod_gutschein/mail_order_end.phtml	(revision 7490)
+++ /views/mods/mod_gutschein/mail_order_end.phtml	(revision 7490)
@@ -0,0 +1,27 @@
+<?php
+	 
+	/**
+	 * User: Daschmi (daschmi@daschmi.de)
+	 * Date: 31.07.2019
+	 * Time: 17:15
+	 */ 
+    
+	namespace wpsg;
+	
+	$arCalculation = $this->view['basket']['arCalculation'];
+	
+	if ($this->getFrontendTaxView() === WPSG_BRUTTO) $display_brutto_netto = 'brutto';
+	else $display_brutto_netto = 'netto';
+	
+	echo "\r\n";
+	
+	foreach ($arCalculation['coupon'] as $gs) {
+	
+		echo '     '.wpsg_pad_right(__('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($gs['code']))?'('.$gs['code'].')':''), 37);
+		echo wpsg_pad_left(wpsg_ff($gs[$display_brutto_netto], $this->get_option('wpsg_currency')), 34)."\r\n";
+		
+	}
+	
+	echo '     '.wpsg_pad_right(__('Zu zahlen', 'wpsg'), 37);
+	echo wpsg_pad_left(wpsg_ff($arCalculation['topay_brutto'], $this->get_option('wpsg_currency')), 34)."\r\n";
+	 
Index: /views/mods/mod_gutschein/mail_order_end_html.phtml
===================================================================
--- /views/mods/mod_gutschein/mail_order_end_html.phtml	(revision 7490)
+++ /views/mods/mod_gutschein/mail_order_end_html.phtml	(revision 7490)
@@ -0,0 +1,50 @@
+<?php
+	 
+	/**
+	 * User: Daschmi (daschmi@daschmi.de)
+	 * Date: 31.07.2019
+	 * Time: 17:15
+	 */ 
+    
+	namespace wpsg;
+	
+	$arCalculation = $this->view['basket']['arCalculation'];
+	
+	if ($this->getFrontendTaxView() === WPSG_BRUTTO) $display_brutto_netto = 'brutto';
+	else $display_brutto_netto = 'netto';
+	
+?>
+
+<?php foreach ($arCalculation['coupon'] as $gs) { ?>
+	
+	<tr class="totalrow">
+		<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_name" colspan="3"><?php echo __('Wertgutschein', 'wpsg'); ?> <?php echo ((wpsg_isSizedString($gs['code']))?'('.$gs['code'].')':''); ?>:</td>
+		<?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
+			<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_mwst"></td>
+		<?php } ?>
+		<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_amount">&nbsp;</td>
+		<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_sum"><?php
+				
+			echo wpsg_ff($gs[$display_brutto_netto], $this->get_option('wpsg_currency'));
+			
+			if (strpos($gs['set'], '%') !== false) {
+				
+				echo '<span class="procent_payship">('.wpsg_ff(wpsg_tf($gs['set']), '%').')</span>';
+				
+			}
+		
+		?></td>
+	</tr>
+	
+<?php } ?>
+
+<tr class="totalrow">
+	<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_name" colspan="2"><?php echo __('Zu zahlen', 'wpsg'); ?>:</td>
+	<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_price">&nbsp;</td>
+	<?php if (sizeof($this->view['basket']['mwst']) > 1 || $this->get_option('wpsg_showMwstAlways') == '1') { ?>
+		<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_mwst"></td>
+	<?php } ?>
+	<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_amount">&nbsp;</td>
+	<td style="padding:4px; line-height:100%; vertical-align:middle;" class="col_sum"><strong><?php echo wpsg_ff($this->view['basket']['arCalculation']['topay_brutto'], $this->get_option('wpsg_currency')); ?></strong></td>
+</tr>
+    
Index: /views/mods/mod_rechnungen/accounting_pdf.phtml
===================================================================
--- /views/mods/mod_rechnungen/accounting_pdf.phtml	(revision 7488)
+++ /views/mods/mod_rechnungen/accounting_pdf.phtml	(revision 7490)
@@ -30,4 +30,9 @@
 	$prod_break					= $this->get_option('wpsg_rechnungen_pdfperpage');
 	
+	$arCalculation = $this->view['basket']['arCalculation'];
+	
+	if ($this->getFrontendTaxView() === WPSG_NETTO) $taxdisplay = 'netto';
+	else $taxdisplay = 'brutto';
+	
 	// Damit die Steuer bei der Kleinunternehmerregelung nicht angezeigt wird leer ich den Array sicherheitshalber
 	if ($this->get_option('wpsg_kleinunternehmer') == '1')
@@ -430,4 +435,5 @@
  
 	// Gutschein
+	/*
 	if ((isset($this->view['basket']['gs'])) && ($this->view['basket']['gs_value'] > 0))
 	{
@@ -453,21 +459,4 @@
 		$pdf->Cell(15, 8, '1', 1, 0, 'C');		
 					
-		/*
-		if ($this->view['basket']['gs']['calc'] == 'w')
-		{
-			
-			$gs_value_einzel = '-'.wpsg_ff($this->view['basket']['gs']['value'], $this->get_option('wpsg_currency'));
-			$gs_value_gesamt = '-'.wpsg_ff($this->view['basket']['gs']['value'], $this->get_option('wpsg_currency'));
-			
-		}
-		else if ($this->view['basket']['gs']['calc'] == 'p')
-		{
-			
-			$gs_value_einzel = '-'.wpsg_ff($this->view['basket']['gs']['value'], '%');
-			$gs_value_gesamt = '-'.wpsg_ff($this->view['basket']['sum']['gs'], $this->get_option('wpsg_currency'));
-			
-		}
-		*/
-		
 		$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'));
@@ -482,4 +471,43 @@
 		
 	} 
+	*/
+	if (wpsg_isSizedArray($this->view['basket']['arCalculation']['voucher'])) {
+		
+		foreach ($this->view['basket']['arCalculation']['voucher'] as $v) {
+			
+			$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'), $v['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');
+			
+			$gs_value_einzel = wpsg_ff($v[$taxdisplay.'_single'], $this->get_option('wpsg_currency'));
+			$gs_value_gesamt = wpsg_ff($v[$taxdisplay], $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
@@ -728,5 +756,5 @@
 
 		$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
-		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Summe", "wpsg"));
+		$pdf->Text($prod_left + 80, $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->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
@@ -741,10 +769,10 @@
 			
 			$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
-			$pdf->Text($prod_left + 100, $prod_top + $offset, __("BRUTTOBETRAG", "wpsg"));
+			$pdf->Text($prod_left + 80, $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');
 			$offset += 5;
 			
-			$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
+			$pdf->Text($prod_left + 80, $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');
@@ -756,5 +784,5 @@
 			$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->Text($prod_left + 80, $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');
@@ -767,5 +795,5 @@
 					
 					$offset += 5;
-					$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. ", "wpsg").wpsg_ff($mw['value'], '%'));
+					$pdf->Text($prod_left + 80, $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');
@@ -779,5 +807,5 @@
 				
 				$offset += 5;
-				$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
+				$pdf->Text($prod_left + 80, $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');
@@ -795,21 +823,58 @@
 		$offset += 5;
 		
-		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Rabatt", "wpsg"));
+		$pdf->Text($prod_left + 80, $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);
-	
-	/* Endbetrag wird fett ausgegeben */
-	$pdf->setFont('Arial', 'B', '9');
-	$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-	$pdf->setFont('Arial', '', '9');
-	
-	/* Endbetrag wird normal ausgegeben */
-	//$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+	
+	// Wertgutschein
+	if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto']) {
+		
+		$offset += 5;
+		$pdf->Text($prod_left + 80, $prod_top + $offset, __("Bruttobetrag", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+		
+		$pdf->setFont('Arial', '', '9');
+		$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+		
+		foreach ($arCalculation['coupon'] as $c) {
+			
+			$offset += 5;
+			$pdf->Text($prod_left + 80, $prod_top + $offset, __('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($c['code']))?'('.$c['code'].')':''));
+			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+			
+			$pdf->setFont('Arial', '', '9');
+			$pdf->Cell(37, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 0, 0, 'R');
+			$pdf->setFont('Arial', '', '9');
+			
+		}
+		
+		$offset += 5;
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Text($prod_left + 80, $prod_top + $offset, __("SUMME", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+		
+		/* Endbetrag wird fett ausgegeben */
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+		
+	} else {
+	
+		$offset += 5;
+		$pdf->Text($prod_left + 100, $prod_top + $offset, __("SUMME", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+	
+		/* Endbetrag wird fett ausgegeben */
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+			
+		/* Endbetrag wird normal ausgegeben */
+		//$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')
Index: /views/mods/mod_rechnungen/invoice_pdf.phtml
===================================================================
--- /views/mods/mod_rechnungen/invoice_pdf.phtml	(revision 7488)
+++ /views/mods/mod_rechnungen/invoice_pdf.phtml	(revision 7490)
@@ -30,4 +30,9 @@
 	// Anzahl an Produkten pro Seite
 	$prod_break					= $this->get_option('wpsg_rechnungen_pdfperpage');
+	
+	$arCalculation = $this->view['basket']['arCalculation'];
+	
+	if ($this->getFrontendTaxView() === WPSG_NETTO) $taxdisplay = 'netto';
+	else $taxdisplay = 'brutto';
 	
 	// Damit die Steuer bei der Kleinunternehmerregelung nicht angezeigt wird leer ich den Array sicherheitshalber
@@ -444,4 +449,5 @@
 	
 	// Gutschein
+	/*
 	if ((isset($this->view['basket']['gs'])) && abs($this->view['basket']['gs_value']) > 0)
 	{
@@ -466,22 +472,5 @@
 		$pdf->setXY($prod_left + 112, $prod_top + $offset);
 		$pdf->Cell(15, 8, '1', 1, 0, 'C');
-		
-		/*
-		if ($this->view['basket']['gs']['calc'] == 'w')
-		{
-			
-			$gs_value_einzel = '-'.wpsg_ff($this->view['basket']['gs']['value'], $this->get_option('wpsg_currency'));
-			$gs_value_gesamt = '-'.wpsg_ff($this->view['basket']['gs']['value'], $this->get_option('wpsg_currency'));
-			
-		}
-		else if ($this->view['basket']['gs']['calc'] == 'p')
-		{
-			
-			$gs_value_einzel = '-'.wpsg_ff($this->view['basket']['gs']['value'], '%');
-			$gs_value_gesamt = '-'.wpsg_ff($this->view['basket']['sum']['gs'], $this->get_option('wpsg_currency'));
-			
-		}
-		*/
-		
+		 		
 		$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'));
@@ -496,5 +485,44 @@
 		
 	}
-	
+	*/
+	if (wpsg_isSizedArray($this->view['basket']['arCalculation']['voucher'])) {
+		
+		foreach ($this->view['basket']['arCalculation']['voucher'] as $v) {
+			 
+			$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'), $v['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');
+			
+			$gs_value_einzel = wpsg_ff($v[$taxdisplay.'_single'], $this->get_option('wpsg_currency'));
+			$gs_value_gesamt = wpsg_ff($v[$taxdisplay], $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)
@@ -742,5 +770,5 @@
 		
 		$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
-		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Summe", "wpsg"));
+		$pdf->Text($prod_left + 80, $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->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
@@ -755,10 +783,10 @@
 			
 			$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
-			$pdf->Text($prod_left + 100, $prod_top + $offset, __("BRUTTOBETRAG", "wpsg"));
+			$pdf->Text($prod_left + 80, $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->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->Text($prod_left + 80, $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');
@@ -770,5 +798,5 @@
 			$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->Text($prod_left + 80, $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->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
@@ -781,5 +809,5 @@
 					
 					$offset += 5;
-					$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. ", "wpsg").wpsg_ff($mw['value'], '%'));
+					$pdf->Text($prod_left + 80, $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');
@@ -793,5 +821,5 @@
 				
 				$offset += 5;
-				$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
+				$pdf->Text($prod_left + 80, $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');
@@ -809,21 +837,55 @@
 		$offset += 5;
 		
-		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Rabatt", "wpsg"));
+		$pdf->Text($prod_left + 80, $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);
-	
-	/* Endbetrag wird fett ausgegeben */
-	$pdf->setFont('Arial', 'B', '9');
-	$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
-	$pdf->setFont('Arial', '', '9');
-	
-	/* Endbetrag wird normal ausgegeben */
-	//$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		
+	// Wertgutschein
+	if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto']) {
+		
+		$offset += 5;
+		$pdf->Text($prod_left + 80, $prod_top + $offset, __("Bruttobetrag", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+		
+		$pdf->setFont('Arial', '', '9');
+		$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+		
+		foreach ($arCalculation['coupon'] as $c) {
+			
+			$offset += 5;
+			$pdf->Text($prod_left + 80, $prod_top + $offset, __('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($c['code']))?'('.$c['code'].')':''));
+			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+			
+			$pdf->setFont('Arial', '', '9');
+			$pdf->Cell(37, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 0, 0, 'R');
+			$pdf->setFont('Arial', '', '9');
+			
+		}
+		
+		$offset += 5;
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Text($prod_left + 80, $prod_top + $offset, __("ZU ZAHLEN", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+		
+		/* Endbetrag wird fett ausgegeben */
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+		
+	} else {
+	
+		$offset += 5;
+		$pdf->Text($prod_left + 80, $prod_top + $offset, __("SUMME", "wpsg"));
+		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
+		
+		/* Endbetrag wird fett ausgegeben */
+		$pdf->setFont('Arial', 'B', '9');
+		$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
+		$pdf->setFont('Arial', '', '9');
+				
+	}
 	
 	if ($this->get_option('wpsg_kleinunternehmer') == '1')
Index: /views/order/backendEdit/addVoucher.phtml
===================================================================
--- /views/order/backendEdit/addVoucher.phtml	(revision 7488)
+++ /views/order/backendEdit/addVoucher.phtml	(revision 7490)
@@ -20,6 +20,9 @@
 		'id' => 0,
 		'set' => 0,
-		'type' => 'voucher'
+		'type' => 'voucher',
 	];
+	
+	//wpsg_debug(array_merge($arCalculation['voucher'], $arCalculation['coupon']));
+	//wpsg_Debug($_REQUEST);
 	
 	// Voucher suchen
@@ -27,7 +30,11 @@
 		
 		if ($v['order_voucher_id'] == $_REQUEST['order_voucher_id']) {
+		
+			$order_voucher_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_ORDER_VOUCHER."` WHERE `id` = '".wpsg_q($_REQUEST['order_voucher_id'])."' ");
 			
 			$voucher = $v;
 			
+			//if ($order_voucher_db['coupon'] === '1') $voucher['type'] = 'coupon';
+						
 		}
 		
@@ -36,6 +43,6 @@
 	$strVal = ((isset($voucher['set']))?$voucher['set']:0); 
 	
-	if (strpos($strVal, '%') !== false) $strVal = wpsg_ff(wpsg_tf($strVal), '%');
-	else $strVal = wpsg_ff(wpsg_tf($strVal), $this->get_option('wpsg_currency'));
+	if (strpos($strVal, '%') !== false) $strVal = wpsg_ff(abs(wpsg_tf($strVal)), '%');
+	else $strVal = wpsg_ff(abs(wpsg_tf($strVal)), $this->get_option('wpsg_currency'));
  	
 ?>
@@ -75,4 +82,7 @@
 				jQuery('#be_voucher_amount').val(ui.item.gs_value);
 				
+				if (ui.item.coupon === '1') jQuery('#be_voucher_coupon').prop('checked', true);
+				else jQuery('#be_voucher_coupon').prop('checked', false);
+				
 				jQuery('#be_voucher_search').val('');
 				
Index: /views/order/product_table.phtml
===================================================================
--- /views/order/product_table.phtml	(revision 7488)
+++ /views/order/product_table.phtml	(revision 7490)
@@ -388,4 +388,4 @@
 </table>
 
-<?php //wpsg_debug($arCalculation);  ?>
+<?php // wpsg_debug($arCalculation);  ?>
 	
Index: /views/order/view.phtml
===================================================================
--- /views/order/view.phtml	(revision 7488)
+++ /views/order/view.phtml	(revision 7490)
@@ -70,5 +70,5 @@
 			<?php if ($this->hasMod('wpsg_mod_gutschein')) { ?>        	
 											
-				<a href="" id="LinkGutscheinNeu" onclick="return WPSG_BE_Voucher.editVoucher(<?php echo $_REQUEST['edit_id']; ?>);"><span class="glyphicon glyphicon-plus"></span>
+				<a href="" id="LinkGutscheinNeu" onclick="return WPSG_BE_Voucher.editVoucher(-1);"><span class="glyphicon glyphicon-plus"></span>
 				
 					<?php echo __("Gutschein bearbeiten", "wpsg"); ?>
Index: /views/warenkorb/basket.phtml
===================================================================
--- /views/warenkorb/basket.phtml	(revision 7488)
+++ /views/warenkorb/basket.phtml	(revision 7490)
@@ -11,5 +11,5 @@
 
 	//wpsg_debug(__('Deutschland', 'wpsg'));
-
+	
 	if ($this->getFrontendTaxView() === WPSG_BRUTTO) $display_brutto_netto = 'brutto';
 	else $display_brutto_netto = 'netto';
