From ede4453164c2432d1145626a8c5a4cf9335d07e2 Mon Sep 17 00:00:00 2001
From: fmarcet <fmarcet@2byte.es>
Date: Fri, 5 Feb 2016 12:59:32 +0100
Subject: [PATCH] Fix: Avoid errors when batch stock is negative

---
 htdocs/expedition/card.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index c7d91a28ce5..ea82a63732a 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -882,7 +882,7 @@ if ($action == 'create')
 							if ($defaultqty<=0) {
 								$defaultqty=0;
 							} else {
-								$defaultqty -= min($defaultqty,$substock);
+								$defaultqty -= ($substock > 0 ? min($defaultqty,$substock) : 0);
 							}
 							$subj++;
 						}
-- 
GitLab