From d53772f21d6422514c338df4a694fb202bd3c3e4 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 17 Aug 2023 11:11:49 +0200 Subject: [PATCH 1/3] add constant to check if qty shipped not greater than qty ordered --- htdocs/expedition/card.php | 7 +++++++ htdocs/langs/en_US/sendings.lang | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 7f948153e10..f98dd26816f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -346,6 +346,13 @@ if (empty($reshook)) { } } + // check qty shipped not greater than ordered + if (dolGetGlobalInt("ErrorTooMuchShipped") && $totalqty > $objectsrc->lines[$i]->qty) { + setEventMessages($langs->trans("", $i), null, 'errors'); + $error++; + continue; + } + // Extrafields $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i); // Unset extrafield diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 84f85fb13b4..6ed59b35e89 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -78,4 +78,6 @@ DetailWarehouseFormat= W:%s (Qty: %d) ShipmentDistribution=Shipment distribution ErrorTooManyCombinationBatchcode=No dispatch for line %s as too many combination warehouse, product, batch code was found (%s). -ErrorNoCombinationBatchcode=No dispatch for line %s as no combination warehouse, product, batch code was found. \ No newline at end of file +ErrorNoCombinationBatchcode=No dispatch for line %s as no combination warehouse, product, batch code was found. + +ErrorTooMuchShipped=Quantity shipped should not be greater than quantity ordered for line %s From 6f3f75478f5c26dac9881fc8caa8ca30d8315ec3 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 17 Aug 2023 11:14:50 +0200 Subject: [PATCH 2/3] fix stupid --- htdocs/expedition/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f98dd26816f..fa07e2a170c 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -347,8 +347,8 @@ if (empty($reshook)) { } // check qty shipped not greater than ordered - if (dolGetGlobalInt("ErrorTooMuchShipped") && $totalqty > $objectsrc->lines[$i]->qty) { - setEventMessages($langs->trans("", $i), null, 'errors'); + if (getDolGlobalInt("MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $totalqty > $objectsrc->lines[$i]->qty) { + setEventMessages($langs->trans("ErrorTooMuchShipped", $i), null, 'errors'); $error++; continue; } From 6f1e9d59ca3e9add9e71fb2aee059a023f844922 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 17 Aug 2023 15:19:08 +0200 Subject: [PATCH 3/3] fix qty check --- htdocs/expedition/card.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index fa07e2a170c..f34cc2d11a5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -334,6 +334,7 @@ if (empty($reshook)) { $stockLine[$i][$j]['ix_l'] = GETPOST($idl, 'int'); $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); + $subtotalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); $j++; $stockLocation = "ent1".$i."_".$j; @@ -343,12 +344,13 @@ if (empty($reshook)) { //shipment line for product with no batch management and no multiple stock location if (GETPOST($qty, 'int') > 0) { $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); + $subtotalqty = price2num(GETPOST($qty, 'alpha'), 'MS'); } } // check qty shipped not greater than ordered - if (getDolGlobalInt("MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $totalqty > $objectsrc->lines[$i]->qty) { - setEventMessages($langs->trans("ErrorTooMuchShipped", $i), null, 'errors'); + if (getDolGlobalInt("MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) { + setEventMessages($langs->trans("ErrorTooMuchShipped", $i+1), null, 'errors'); $error++; continue; }