Skip to content

Commit

Permalink
Merge pull request #5121 from fmarcet/3.7
Browse files Browse the repository at this point in the history
Fix: Not filtering correctly on supplier invoice's list
  • Loading branch information
eldy committed Apr 29, 2016
2 parents 211d217 + 7380676 commit b0b1056
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
23 changes: 22 additions & 1 deletion htdocs/commande/class/commande.class.php
Expand Up @@ -8,6 +8,7 @@
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -2372,7 +2373,7 @@ function classer_facturee()
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0)
{
global $conf, $mysoc;
global $conf, $mysoc, $langs;

dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
Expand Down Expand Up @@ -2426,6 +2427,26 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocalt
$line = new OrderLine($this->db);
$line->fetch($rowid);

if (!empty($line->fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($line->fk_product);
$product_type=$product->type;

if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
{
$this->error=$langs->trans('ErrorStockIsNotEnough');
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
$this->db->rollback();
unset($_POST['productid']);
unset($_POST['tva_tx']);
unset($_POST['price_ht']);
unset($_POST['qty']);
unset($_POST['buying_price']);
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
}
}

$staticline = clone $line;

$line->oldline = $staticline;
Expand Down
14 changes: 14 additions & 0 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -12,6 +12,7 @@
* Copyright (C) 2012-2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -2199,6 +2200,19 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
$line = new FactureLigne($this->db);
$line->fetch($rowid);

if (!empty($line->fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($line->fk_product);
$product_type=$product->type;

if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) {
$this->error=$langs->trans('ErrorStockIsNotEnough');
$this->db->rollback();
return -3;
}
}

$staticline = clone $line;

$line->oldline = $staticline;
Expand Down
11 changes: 9 additions & 2 deletions htdocs/expedition/class/expedition.class.php
Expand Up @@ -8,6 +8,7 @@
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Francis Appels <francis.appels@yahoo.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -763,13 +764,19 @@ function addline($entrepot_id, $id, $qty)
return -1;
}

if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) // FIXME Check is done for stock of product, it must be done for stock of product into warehouse if $entrepot_id defined
if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT)
{
$product=new Product($this->db);
$result=$product->fetch($fk_product);
if ($entrepot_id > 0) {
$product->load_stock();
$product_stock = $product->stock_warehouse[$entrepot_id]->real;
}
else
$product_stock = $product->stock_reel;
$product_type=$product->type;

if ($product_type == 0 && $product->stock_reel < $qty)
if ($product_type == 0 && $product_stock < $qty)
{
$this->error=$langs->trans('ErrorStockIsNotEnough');
$this->db->rollback();
Expand Down
2 changes: 1 addition & 1 deletion htdocs/index.php
Expand Up @@ -440,7 +440,7 @@
$board->load_board($user);
$board->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24;
$board->label=$langs->trans("SupplierBillsToPay");
$board->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0';
$board->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0,fk_statut:1';
$board->img=img_object($langs->trans("Bills"),"bill");
$rowspan++;
$dashboardlines[]=$board;
Expand Down

0 comments on commit b0b1056

Please sign in to comment.