Merge pull request #12750 from OPEN-DSI/v10-fix-product-virtual-stock-stats-sending
FIX add product qty in shipment already sent (fix for option STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
This commit is contained in:
commit
0dafbd194f
@ -2636,12 +2636,13 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Charge tableau des stats expedition client pour le produit/service
|
||||
*
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @return array Tableau des stats
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut [=''] Ids order status separated by comma
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @param string $filterShipmentStatus [=''] Ids shipment status separated by comma
|
||||
* @return int <0 if KO, >0 if OK (Tableau des stats)
|
||||
*/
|
||||
public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
|
||||
public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $filterShipmentStatus = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf,$user;
|
||||
@ -2671,6 +2672,7 @@ class Product extends CommonObject
|
||||
if ($filtrestatut <> '') {
|
||||
$sql.= " AND c.fk_statut in (".$filtrestatut.")";
|
||||
}
|
||||
if (!empty($filterShipmentStatus)) $sql.= " AND e.fk_statut IN (" . $filterShipmentStatus . ")";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result ) {
|
||||
@ -4464,7 +4466,14 @@ class Product extends CommonObject
|
||||
}
|
||||
if (! empty($conf->expedition->enabled))
|
||||
{
|
||||
$result=$this->load_stats_sending(0, '1,2', 1);
|
||||
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
|
||||
$filterShipmentStatus = '';
|
||||
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
|
||||
$filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED;
|
||||
} elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
|
||||
$filterShipmentStatus = Expedition::STATUS_CLOSED;
|
||||
}
|
||||
$result = $this->load_stats_sending(0, '1,2', 1, $filterShipmentStatus);
|
||||
if ($result < 0) dol_print_error($this->db, $this->error);
|
||||
$stock_sending_client=$this->stats_expedition['qty'];
|
||||
}
|
||||
|
||||
@ -666,8 +666,15 @@ if ($id > 0 || $ref)
|
||||
|
||||
// Number of product from customer order already sent (partial shipping)
|
||||
if (!empty($conf->expedition->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
|
||||
$filterShipmentStatus = '';
|
||||
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
|
||||
$filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED;
|
||||
} elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
|
||||
$filterShipmentStatus = Expedition::STATUS_CLOSED;
|
||||
}
|
||||
if ($found) $helpondiff .= '<br>'; else $found = 1;
|
||||
$result = $object->load_stats_sending(0, '2', 1);
|
||||
$result = $object->load_stats_sending(0, '2', 1, $filterShipmentStatus);
|
||||
$helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent") . ': ' . $object->stats_expedition['qty'];
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user