Index: /mods/mod_rechnungen/wpsg_invoice.php
===================================================================
--- /mods/mod_rechnungen/wpsg_invoice.php	(revision 8215)
+++ /mods/mod_rechnungen/wpsg_invoice.php	(revision 8216)
@@ -79,11 +79,4 @@
 		public function getFilePath() {
 
-            /*
-					if (file_exists($this->getFilePath($order_id).$r_id.'.pdf')) { $file = $this->getFilePath($order_id).$r_id.'.pdf'; }
-					else if (file_exists($this->getFilePath($order_id).$rnr.'.pdf')) { $file = $this->getFilePath($order_id).$rnr.'.pdf'; }
-					else if (file_exists($this->getFilePath($order_id).'R'.$r_id.'.pdf')) { $file = $this->getFilePath($order_id).'R'.$r_id.'.pdf'; }
-					else { $file = $this->getFilePath($order_id).'R'.$rnr.'.pdf'; }
-             */
-
             $ym = date('Y/m', strtotime($this->__get('datum')));
 
@@ -100,21 +93,45 @@
                 if (!file_exists($path.$this->getId().'.pdf')) {
 
-                    if ($this->__get('gnr') !== '') {
-
-                        if (file_exists($path.'G'.$this->__get('gnr').'.pdf')) $path .= 'G'.$this->__get('gnr').'.pdf';
-                        else if (file_exists($path.'G'.$this->getId().'.pdf')) $path .= 'G'.$this->getId().'.pdf';
-                        else if (file_exists($path.$this->__get('gnr').'.pdf')) $path .= $this->__get('gnr').'.pdf';
-                        else $path .= $this->getId().'.pdf';
-
-                    } else if ($this->__get('rnr') !== '') {
-
-                        if (file_exists($path.'R'.$this->__get('rnr').'.pdf')) $path .= 'R'.$this->__get('rnr').'.pdf';
-                        else if (file_exists($path.'R'.$this->getId().'.pdf')) $path .= 'R'.$this->getId().'.pdf';
-                        else if (file_exists($path.$this->__get('rnr').'.pdf')) $path .= $this->__get('rnr').'.pdf';
-                        else $path .= $this->getId().'.pdf';
-
-                    } else $path .= $this->getId().'.pdf';
-
-                } else $path .= $this->getId().'.pdf';
+					if (file_exists($path.($this->getOrderIds()[0])) && is_dir($path.($this->getOrderIds()[0]))) {
+
+						$path = ($path.$this->getOrderIds()[0]).'/';
+
+						if ($this->__get('gnr') !== '') {
+
+							if (file_exists($path . 'G' . $this->__get('gnr') . '.pdf')) $path .= 'G' . $this->__get('gnr') . '.pdf';
+							else if (file_exists($path . 'G' . $this->getId() . '.pdf')) $path .= 'G' . $this->getId() . '.pdf';
+							else if (file_exists($path . $this->__get('gnr') . '.pdf')) $path .= $this->__get('gnr') . '.pdf';
+							else $path .= $this->getId() . '.pdf';
+
+						} else if ($this->__get('rnr') !== '') {
+
+							if (file_exists($path . 'R' . $this->__get('rnr') . '.pdf')) $path .= 'R' . $this->__get('rnr') . '.pdf';
+							else if (file_exists($path . 'R' . $this->getId() . '.pdf')) $path .= 'R' . $this->getId() . '.pdf';
+							else if (file_exists($path . $this->__get('rnr') . '.pdf')) $path .= $this->__get('rnr') . '.pdf';
+							else $path .= $this->getId() . '.pdf';
+
+						} else $path .= $this->getId() . '.pdf';
+
+					} else {
+
+						if ($this->__get('gnr') !== '') {
+
+							if (file_exists($path.'G'.$this->__get('gnr').'.pdf')) $path .= 'G'.$this->__get('gnr').'.pdf';
+							else if (file_exists($path.'G'.$this->getId().'.pdf')) $path .= 'G'.$this->getId().'.pdf';
+							else if (file_exists($path.$this->__get('gnr').'.pdf')) $path .= $this->__get('gnr').'.pdf';
+							else $path .= $this->getId().'.pdf';
+
+						} else if ($this->__get('rnr') !== '') {
+
+							if (file_exists($path.'R'.$this->__get('rnr').'.pdf')) $path .= 'R'.$this->__get('rnr').'.pdf';
+							else if (file_exists($path.'R'.$this->getId().'.pdf')) $path .= 'R'.$this->getId().'.pdf';
+							else if (file_exists($path.$this->__get('rnr').'.pdf')) $path .= $this->__get('rnr').'.pdf';
+							else $path .= $this->getId().'.pdf';
+
+						} else $path .= $this->getId().'.pdf';
+
+					}
+
+				} else $path .= $this->getId().'.pdf';
 
             }
