Index: /controller/wpsg_OrderController.class.php
===================================================================
--- /controller/wpsg_OrderController.class.php	(revision 5726)
+++ /controller/wpsg_OrderController.class.php	(revision 5728)
@@ -511,7 +511,18 @@
 							{
 
-								$this->shop->callMod('wpsg_mod_rechnungen', 'writeRechnung', array($k, false, false));
-								$arIDs[] = $k;
-								$nWriteRechnung ++;
+								try
+								{
+									
+									$this->shop->callMod('wpsg_mod_rechnungen', 'writeRechnung', array($k, false, false));
+									$arIDs[] = $k;
+									$nWriteRechnung ++;
+									
+								}
+								catch (Exception $e)
+								{
+									
+									die($e->getMessage());
+									
+								}
 
 							}
Index: /mods/wpsg_mod_rechnungen.class.php
===================================================================
--- /mods/wpsg_mod_rechnungen.class.php	(revision 5726)
+++ /mods/wpsg_mod_rechnungen.class.php	(revision 5728)
@@ -345,5 +345,16 @@
 			{
 				
-				$this->writeRechnung($_REQUEST['edit_id'], false);
+				try
+				{
+				
+					$this->writeRechnung($_REQUEST['edit_id'], false);
+					
+				} 
+				catch (Exception $e)
+				{
+					
+					die($e->getMessage());
+					
+				}
 				
 				die();
@@ -804,4 +815,19 @@
 		public function writeRechnung($order_id, $preview, $bOutput = true)
 		{
+			
+			// PrÃŒfen ob schon eine Rechnung zu dieser Bestellung existiert und eventuell Fehler werfen
+			if (!$preview)
+			{
+			
+				$lastEntry = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `o_id` = '".wpsg_q($order_id)."' ORDER BY `id` DESC LIMIT 1");
+				 
+				if (strtotime($lastEntry['datum']) > 0 && strtotime($lastEntry['storno']) === false)
+				{
+					
+					throw new \Exception(wpsg_translate(__('Rechnung konnte nicht geschrieben werden, da fÃÂŒr diese Bestellung (ID:#1#) bereits eine Rechnung (NR:#2#) geschrieben wurde.'), $order_id, $lastEntry['rnr']));
+					
+				} 
+				
+			}
 			
 			$this->shop->view['output'] = $bOutput;
@@ -1596,7 +1622,18 @@
  			}
  			
- 			$this->writeRechnung($order_id, $preview = false, $bOutput = false);
+		    try
+		    {
  			
- 		} // private function writeAutoRechnung()
+			    $this->writeRechnung($order_id, false, false);
+			    
+		    } 
+		    catch (Exception $e)
+		    {
+			    
+			    die($e->getMessage());
+			    
+		    }
+ 			
+ 		} // private function riteAutoRechnung()
  		
 	} // class wpsg_mod_rechnungen extends wpsg_mod_basic
