FIX phpcs nestling too high level
This commit is contained in:
parent
71c9b94b22
commit
ec19b2feef
@ -2594,7 +2594,9 @@ class Facture extends CommonInvoice
|
|||||||
if (!is_array($resBatchList)) {
|
if (!is_array($resBatchList)) {
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
$batchList = $resBatchList;
|
$batchList = $resBatchList;
|
||||||
if (empty($batchList)) {
|
if (empty($batchList)) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -2602,46 +2604,45 @@ class Facture extends CommonInvoice
|
|||||||
$warehouseStatic->fetch($idwarehouse);
|
$warehouseStatic->fetch($idwarehouse);
|
||||||
$this->error = $langs->trans('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
|
$this->error = $langs->trans('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
|
||||||
dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
|
dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
|
||||||
} else {
|
}
|
||||||
foreach ($batchList as $batch) {
|
|
||||||
if ($batch->qty <= 0) continue; // try to decrement only batches have positive quantity first
|
|
||||||
|
|
||||||
// enough quantity in this batch
|
foreach ($batchList as $batch) {
|
||||||
if ($batch->qty >= $product_qty_remain) {
|
if ($batch->qty <= 0) continue; // try to decrement only batches have positive quantity first
|
||||||
$product_batch_qty = $product_qty_remain;
|
|
||||||
}
|
// enough quantity in this batch
|
||||||
// not enough (take all in batch)
|
if ($batch->qty >= $product_qty_remain) {
|
||||||
else {
|
$product_batch_qty = $product_qty_remain;
|
||||||
$product_batch_qty = $batch->qty;
|
} // not enough (take all in batch)
|
||||||
}
|
else {
|
||||||
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
|
$product_batch_qty = $batch->qty;
|
||||||
|
}
|
||||||
|
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
$this->error = $mouvP->error;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$product_qty_remain -= $product_batch_qty;
|
||||||
|
// all product quantity was decremented
|
||||||
|
if ($product_qty_remain <= 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error && $product_qty_remain > 0) {
|
||||||
|
if ($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) {
|
||||||
|
// take in the first batch
|
||||||
|
$batch = $batchList[0];
|
||||||
|
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_qty_remain, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $mouvP->error;
|
$this->error = $mouvP->error;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$product_qty_remain -= $product_batch_qty;
|
|
||||||
// all product quantity was decremented
|
|
||||||
if ($product_qty_remain <= 0) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error && $product_qty_remain>0) {
|
|
||||||
if ($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) {
|
|
||||||
// take in the first batch
|
|
||||||
$batch = $batchList[0];
|
|
||||||
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_qty_remain, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
|
|
||||||
if ($result < 0) {
|
|
||||||
$error++;
|
|
||||||
$this->error = $mouvP->error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$error++;
|
|
||||||
$langs->load('errors');
|
|
||||||
$warehouseStatic->fetch($idwarehouse);
|
|
||||||
$this->error = $langs->trans('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
|
|
||||||
dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
$langs->load('errors');
|
||||||
|
$warehouseStatic->fetch($idwarehouse);
|
||||||
|
$this->error = $langs->trans('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
|
||||||
|
dol_syslog(__METHOD__ . ' Error: ' . $langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user