Maxi debug of stock management.

This commit is contained in:
Laurent Destailleur 2008-10-24 21:36:12 +00:00
parent fc0ebfa9b5
commit d298438e66
5 changed files with 181 additions and 142 deletions

View File

@ -35,6 +35,7 @@ $langs->load("admin");
$langs->load("propal");
$langs->load("products");
// Security check
if (!$user->admin)
accessforbidden();

View File

@ -197,13 +197,15 @@ class Commande extends CommonObject
/**
* \brief Valide la commande
* \param user Utilisateur qui valide
* \return int <=0 si ko, >0 si ok
* \brief Validate order
* \param user Utilisateur qui valide
* \return int <=0 si ko, >0 si ok
*/
function valid($user)
{
global $conf,$langs;
$error=0;
// Protection
if ($this->statut == 1)
@ -228,8 +230,7 @@ class Commande extends CommonObject
$result=$soc->set_as_client();
// check if temporary number
$comref = substr($this->ref, 1, 4);
if ($comref == 'PROV')
if (eregi('^\(PROV', $this->ref))
{
$num = $this->getNextNumRef($soc);
}
@ -245,7 +246,7 @@ class Commande extends CommonObject
if ($resql)
{
// On efface le repertoire de pdf provisoire
if ($comref == 'PROV')
if (eregi('^\(PROV', $this->ref))
{
$comref = sanitize_string($this->ref);
if ($conf->commande->dir_output)
@ -276,7 +277,7 @@ class Commande extends CommonObject
}
// If stock is incremented on validate order, we must increment it
if($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
@ -286,23 +287,36 @@ class Commande extends CommonObject
// We decrement stock of product (and sub-products)
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
$result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
if ($result < 0) { $error++; }
}
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
$this->db->commit();
return $this->id;
if ($error == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
if ($error == 0)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
return -1;
}
}
else
{
$this->db->rollback();
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
return -1;
}
}

View File

@ -47,9 +47,9 @@ class CommandeFournisseur extends Commande
var $id ;
var $brouillon;
/** \brief Constructeur
* \param DB Handler d'accès aux bases de données
* \param DB Handler d'acc<EFBFBD>s aux bases de donn<EFBFBD>es
*/
function CommandeFournisseur($DB)
{
@ -90,7 +90,7 @@ class CommandeFournisseur extends Commande
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->socid = $obj->fk_soc;
@ -100,12 +100,12 @@ class CommandeFournisseur extends Commande
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->tva;
$this->total_ttc = $obj->total_ttc;
$this->date_commande = $obj->date_commande; // date à laquelle la commande a été transmise
$this->date_commande = $obj->date_commande; // date <EFBFBD> laquelle la commande a <20>t<EFBFBD> transmise
$this->date = $obj->date_creation;
$this->remise_percent = $obj->remise_percent;
$this->methode_commande_id = $obj->fk_methode_commande;
$this->methode_commande = $obj->methode_commande;
$this->source = $obj->source;
$this->facturee = $obj->facture;
$this->fk_project = $obj->fk_project;
@ -113,14 +113,14 @@ class CommandeFournisseur extends Commande
$this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf;
$this->db->free();
if ($this->statut == 0) $this->brouillon = 1;
// Now load lines
$this->lignes = array();
$sql = "SELECT l.rowid, l.ref as ref_fourn, l.fk_product, l.label, l.description, l.qty,";
$sql.= " l.tva_tx, l.remise_percent, l.subprice,";
$sql.= " l.total_ht, l.total_tva, l.total_ttc,";
@ -130,7 +130,7 @@ class CommandeFournisseur extends Commande
$sql.= " WHERE l.fk_commande = ".$this->id;
$sql.= " ORDER BY l.rowid";
//print $sql;
dolibarr_syslog("CommandeFournisseur::fetch sql=".$sql,LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
@ -141,9 +141,9 @@ class CommandeFournisseur extends Commande
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
$ligne = new CommandeFournisseurLigne($this->db);
$ligne->id = $objp->rowid;
$ligne->desc = $objp->description; // Description ligne
$ligne->qty = $objp->qty;
@ -153,14 +153,14 @@ class CommandeFournisseur extends Commande
$ligne->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva;
$ligne->total_ttc = $objp->total_ttc;
$ligne->fk_product = $objp->product_id; // Id du produit
$ligne->libelle = $objp->label; // Label produit
$ligne->product_desc = $objp->description; // Description produit
$ligne->ref = $objp->ref; // Reference
$ligne->ref_fourn = $objp->ref_fourn; // Reference supplier
$this->lignes[$i] = $ligne;
//dolibarr_syslog("1 ".$ligne->desc);
//dolibarr_syslog("2 ".$ligne->product_desc);
@ -186,7 +186,7 @@ class CommandeFournisseur extends Commande
}
/**
* \brief Insère ligne de log
* \brief Ins<EFBFBD>re ligne de log
* \param user Utilisateur qui modifie la commande
* \param statut Statut de la commande
* \param datelog Date de modification
@ -206,6 +206,7 @@ class CommandeFournisseur extends Commande
return -1;
}
}
/**
* \brief Valide la commande
* \param user Utilisateur qui valide
@ -214,56 +215,83 @@ class CommandeFournisseur extends Commande
{
global $langs,$conf;
dolibarr_syslog("CommandeFournisseur.class::Valid");
$error=0;
dolibarr_syslog("CommandeFournisseur::Valid");
$result = 0;
if ($user->rights->fournisseur->commande->valider)
{
$this->db->begin();
// Definition du nom de module de numerotation de commande
$soc = new Societe($this->db);
$soc->fetch($this->fourn_id);
$num=$this->getNextNumRef($soc);
// on vérifie si la commande est en numérotation provisoire
$comref = substr($this->ref, 1, 4);
if ($comref == 'PROV')
{
$num = $this->getNextNumRef($soc);
}
else
{
$num = $this->ref;
}
// Check if object has a temporary ref
if (eregi('^\(PROV', $this->ref))
{
$num = $this->getNextNumRef($soc);
}
else
{
$num = $this->ref;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur SET ref='$num', fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=$user->id";
$sql .= " WHERE rowid = $this->id AND fk_statut = 0";
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET ref='$num', fk_statut = 1, date_valid=".$this->db->idate(mktime()).", fk_user_valid=$user->id";
$sql.= " WHERE rowid = $this->id AND fk_statut = 0";
$resql=$this->db->query($sql);
if ($resql)
{
$result = 1;
$this->log($user, 1, time()); // Statut 1
$this->ref = $num;
$resql=$this->db->query($sql);
if ($resql)
{
$result = 1;
$this->log($user, 1, time()); // Statut 1
$this->ref = $num;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// If stock is incremented on validate order, we must increment it
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER == 1)
{
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
{
$mouvP = new MouvementStock($this->db);
// We decrement stock of product (and sub-products)
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
if ($result < 0) { $error++; }
}
}
dolibarr_syslog("CommandeFournisseur::valid Success");
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->error();
dolibarr_syslog("CommandeFournisseur::valid ".$this->error);
$this->db->rollback();
return -1;
}
if ($error == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
if ($error == 0)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
return -1;
}
}
else
{
$this->error=$this->db->lasterror();
dolibarr_syslog("CommandeFournisseur::valid ".$this->error);
$this->db->rollback();
return -1;
}
}
else
{
@ -276,7 +304,7 @@ class CommandeFournisseur extends Commande
/**
* \brief Annule la commande
* \param user Utilisateur qui demande annulation
* \remarks L'annulation se fait après la validation
* \remarks L'annulation se fait apr<EFBFBD>s la validation
*/
function Cancel($user)
{
@ -320,8 +348,8 @@ class CommandeFournisseur extends Commande
/**
* \brief Retourne le libellé du statut d'une commande (brouillon, validée, abandonnée, payée)
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
* \brief Retourne le libell<EFBFBD> du statut d'une commande (brouillon, valid<EFBFBD>e, abandonn<EFBFBD>e, pay<EFBFBD>e
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long
* \return string Libelle
*/
function getLibStatut($mode=0)
@ -330,10 +358,10 @@ class CommandeFournisseur extends Commande
}
/**
* \brief Renvoi le libellé d'un statut donné
* \brief Renvoi le libell<EFBFBD> d'un statut donn<EFBFBD>
* \param statut Id statut
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
* \return string Libellé du statut
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long, 5=Libell<EFBFBD> court + Picto
* \return string Libell<EFBFBD> du statut
*/
function LibStatut($statut,$mode=0)
{
@ -414,8 +442,8 @@ class CommandeFournisseur extends Commande
/**
* \brief Renvoie la référence de commande suivante non utilisée en fonction du module
* de numérotation actif fini dans COMMANDE_SUPPLIER_ADDON
* \brief Renvoie la r<EFBFBD>f<EFBFBD>rence de commande suivante non utilis<EFBFBD>e en fonction du modul
* de num<EFBFBD>rotation actif d<EFBFBD>fini dans COMMANDE_SUPPLIER_ADDON
* \param soc objet societe
* \return string reference libre pour la facture
*/
@ -431,7 +459,7 @@ class CommandeFournisseur extends Commande
if (defined('COMMANDE_SUPPLIER_ADDON') && COMMANDE_SUPPLIER_ADDON)
{
$file = COMMANDE_SUPPLIER_ADDON.'.php';
if (is_readable($dir.'/'.$file))
{
// Definition du nom de module de numerotation de commande fournisseur
@ -494,9 +522,9 @@ class CommandeFournisseur extends Commande
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
$subject = "Votre commande ".$this->ref." a été approuvée";
$subject = "Votre commande ".$this->ref." a <EFBFBD>t<EFBFBD> approuv<75>e";
$message = "Bonjour,\n\n";
$message .= "Votre commande ".$this->ref." a été approuvée, par $user->fullname";
$message .= "Votre commande ".$this->ref." a <EFBFBD>t<EFBFBD> approuv<75>e, par $user->fullname";
$message .= "\n\nCordialement,\n\n";
$this->_NotifyCreator($user, $subject, $message);
@ -530,14 +558,14 @@ class CommandeFournisseur extends Commande
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 9";
$sql .= " WHERE rowid = ".$this->id;
if ($this->db->query($sql) )
{
$result = 0;
$this->log($user, 9, time());
$subject = "Votre commande ".$this->ref." a été refusée";
$message = "Votre commande ".$this->ref." a été refusée, par $user->fullname";
$subject = "Votre commande ".$this->ref." a <EFBFBD>t<EFBFBD> refus<75>e";
$message = "Votre commande ".$this->ref." a <EFBFBD>t<EFBFBD> refus<75>e, par $user->fullname";
$this->_NotifyCreator($user, $subject, $message);
}
@ -590,7 +618,7 @@ class CommandeFournisseur extends Commande
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 3, fk_methode_commande=".$methode.",date_commande=".$this->db->idate("$date");
$sql .= " WHERE rowid = ".$this->id." AND fk_statut = 2 ;";
if ($this->db->query($sql) )
{
$result = 0;
@ -610,8 +638,8 @@ class CommandeFournisseur extends Commande
}
/**
* \brief Créé la commande au statut brouillon
* \param user Utilisateur qui crée
* \brief Cr<EFBFBD><EFBFBD> la commande au statut brouillon
* \param user Utilisateur qui cr<EFBFBD>e
* \return int <0 si ko, >0 si ok
*/
function create($user)
@ -631,7 +659,7 @@ class CommandeFournisseur extends Commande
if ( $this->db->query($sql) )
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande_fournisseur");
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET ref='(PROV".$this->id.")'";
$sql.= " WHERE rowid=".$this->id;
@ -672,7 +700,7 @@ class CommandeFournisseur extends Commande
* \brief Ajoute une ligne de commande
* \param desc Description
* \param pu Prix unitaire
* \param qty Quantité
* \param qty Quantit<EFBFBD>
* \param txtva Taux tva
* \param fk_product Id produit
* \param remise_percent Remise
@ -713,7 +741,7 @@ class CommandeFournisseur extends Commande
if ($this->statut == 0)
{
$this->db->begin();
if ($fk_product > 0)
{
$prod = new Product($this->db, $fk_product);
@ -728,7 +756,7 @@ class CommandeFournisseur extends Commande
}
if ($result == 0 || $result == -1)
{
$this->error="Aucun tarif trouvé pour cette quantité. Quantité saisie insuffisante ?";
$this->error="Aucun tarif trouv<EFBFBD> pour cette quantit<69>. Quantit<69> saisie insuffisante ?";
$this->db->rollback();
dolibarr_syslog("FournisseurCommande::addline result=".$result." - ".$this->error, LOG_DEBUG);
return -1;
@ -747,7 +775,7 @@ class CommandeFournisseur extends Commande
return -1;
}
}
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
@ -758,7 +786,7 @@ class CommandeFournisseur extends Commande
$total_ttc = $tabprice[2];
$subprice = price2num($pu,'MU');
// \TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
$remise = 0;
@ -766,7 +794,7 @@ class CommandeFournisseur extends Commande
{
$remise = round(($pu * $remise_percent / 100), 2);
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet";
$sql.= " (fk_commande,label, description,";
$sql.= " fk_product,";
@ -848,7 +876,7 @@ class CommandeFournisseur extends Commande
{
$error = -1;
}
// Si module stock géré et que expedition faite depuis un entrepot
// Si module stock g<EFBFBD>r<EFBFBD> et que expedition faite depuis un entrepot
if (!$error && $conf->stock->enabled && $entrepot)
{
/*
@ -1026,7 +1054,7 @@ class CommandeFournisseur extends Commande
{
$result = 0;
$result=$this->log($user, $statut, $date);
$this->db->commit();
}
else
@ -1050,9 +1078,9 @@ class CommandeFournisseur extends Commande
return $result ;
}
/** \brief Créé la commande depuis une propale existante
\param user Utilisateur qui crée
\param propale_id id de la propale qui sert de modèle
/** \brief Cr<EFBFBD><EFBFBD> la commande depuis une propale existante
\param user Utilisateur qui cr<EFBFBD>e
\param propale_id id de la propale qui sert de mod<EFBFBD>le
*/
function updateFromCommandeClient($user, $idc, $comclientid)
{
@ -1071,7 +1099,7 @@ class CommandeFournisseur extends Commande
$libelle = $prod->libelle;
$ref = $prod->ref;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet";
$sql .= " (fk_commande,label,description,fk_product, price, qty, tva_tx, remise_percent, subprice, remise, ref)";
$sql .= " VALUES (".$idc.", '" . addslashes($libelle) . "','" . addslashes($comclient->lignes[$i]->desc) . "'";
@ -1208,11 +1236,11 @@ class CommandeFournisseur extends Commande
/**
* \brief Mets à jour une ligne de commande
* \brief Mets <EFBFBD> jour une ligne de commande
* \param rowid Id de la ligne de facture
* \param desc Description de la ligne
* \param pu Prix unitaire
* \param qty Quantité
* \param qty Quantit<EFBFBD>
* \param remise_percent Pourcentage de remise de la ligne
* \param tva_tx Taux TVA
* \param info_bits Miscellanous informations
@ -1226,8 +1254,8 @@ class CommandeFournisseur extends Commande
if ($this->brouillon)
{
$this->db->begin();
// Nettoyage paramètres
// Nettoyage param<EFBFBD>tres
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
if (! $qty) $qty=1;
@ -1274,18 +1302,18 @@ class CommandeFournisseur extends Commande
$result = $this->db->query( $sql);
if ($result > 0)
{
// Mise a jour info denormalisees au niveau facture
$this->update_price();
$this->db->commit();
return $result;
// Mise a jour info denormalisees au niveau facture
$this->update_price();
$this->db->commit();
return $result;
}
else
{
$this->error=$this->db->error();
dolibarr_syslog("CommandeFournisseur::updateline ".$this->error);
$this->db->rollback();
return -1;
$this->error=$this->db->error();
dolibarr_syslog("CommandeFournisseur::updateline ".$this->error);
$this->db->rollback();
return -1;
}
}
else
@ -1298,8 +1326,8 @@ class CommandeFournisseur extends Commande
/**
* \brief Initialise la commande avec valeurs fictives aléatoire
* Sert à générer une commande pour l'aperu des modèles ou demo
* \brief Initialise la commande avec valeurs fictives al<EFBFBD>atoire
* Sert <EFBFBD> g<EFBFBD>n<EFBFBD>rer une commande pour l'aperu des mod<EFBFBD>les ou demo
*/
function initAsSpecimen()
{
@ -1307,7 +1335,7 @@ class CommandeFournisseur extends Commande
dolibarr_syslog("CommandeFournisseur::initAsSpecimen");
// Charge tableau des id de société socids
// Charge tableau des id de soci<EFBFBD>t<EFBFBD> socids
$socids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE fournisseur=1 LIMIT 10";
$resql = $this->db->query($sql);
@ -1340,7 +1368,7 @@ class CommandeFournisseur extends Commande
}
}
// Initialise paramètres
// Initialise param<EFBFBD>tres
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
@ -1396,7 +1424,7 @@ class CommandeFournisseurLigne extends CommandeLigne
var $product_desc; // Description produit
// From llx_product_fournisseur
var $ref_fourn; // Référence fournisseur
var $ref_fourn; // R<EFBFBD>f<EFBFBD>rence fournisseur
function CommandeFournisseurLigne($DB)
{
@ -1433,11 +1461,11 @@ class CommandeFournisseurLigne extends CommandeLigne
$this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva;
$this->total_ttc = $objp->total_ttc;
$this->ref = $objp->product_ref;
$this->product_libelle = $objp->product_libelle;
$this->product_desc = $objp->product_desc;
$this->db->free($result);
}
else

View File

@ -15,24 +15,20 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file htdocs/product/stock/mouvementstock.class.php
\ingroup stock
\brief Fichier de la classe de gestion des mouvements de stocks
\version $Revision$
* \file htdocs/product/stock/mouvementstock.class.php
* \ingroup stock
* \brief Fichier de la classe de gestion des mouvements de stocks
* \version $Revision$
*/
/**
\class MouvementStock
\brief Classe permettant la gestion des mouvements de stocks
* \class MouvementStock
* \brief Classe permettant la gestion des mouvements de stocks
*/
class MouvementStock
{
@ -51,7 +47,7 @@ class MouvementStock
global $conf;
$error = 0;
dolibarr_syslog("MouvementStock::_Create $user->id, $fk_product, $entrepot_id, $qty, $type, $price");
dolibarr_syslog("MouvementStock::_Create $user->id, $fk_product, $entrepot_id, qty=$qty, type=$type, $price");
$this->db->begin();
@ -71,7 +67,7 @@ class MouvementStock
}
else
{
dolibarr_syslog("MouvementStock::_Create echec insert ".$this->error);
dolibarr_syslog("MouvementStock::_Create ".$this->error);
$error = -1;
}
@ -116,7 +112,7 @@ class MouvementStock
}
else
{
dolibarr_syslog("MouvementStock::_Create echec update ".$this->error);
dolibarr_syslog("MouvementStock::_Create ".$this->error, LOG_ERR);
$error = -3;
}
}
@ -147,8 +143,8 @@ class MouvementStock
else
{
$this->db->rollback();
$this->error=$this->db->error() . " - $sql";
dolibarr_syslog("MouvementStock::_Create ERROR : ".$this->error);
$this->error=$this->db->error();
dolibarr_syslog("MouvementStock::_Create ".$this->error);
return -2;
}
}
@ -183,14 +179,14 @@ class MouvementStock
}
else
{
dolibarr_syslog("MouvementStock::_createSubProduct echec update ".$this->error, LOG_ERROR);
dolibarr_syslog("MouvementStock::_createSubProduct ".$this->error, LOG_ERROR);
$error = -2;
}
// Create movement for each subproduct
foreach($pids as $key => $value)
{
$this->_create($user, $pids[$key], $entrepot_id, $pqtys[$key], $type, $price);
$this->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, $price);
}
return $error;

View File

@ -676,7 +676,7 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'51','Soci
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'52','Société en nom collectif');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'53','Société en commandite');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'54','Société à responsabilité limitée (SARL)');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'55','Société anonyme à conseil d\'administration');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'55','Société anonyme à conseil d administration');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'56','Société anonyme à directoire');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'57','Société par actions simplifiée');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'58','Entreprise Unipersonnelle à Responsabilité Limitée (EURL)');
@ -684,18 +684,18 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'58','Entre
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'61','Caisse d\'épargne et de prévoyance');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'62','Groupement d\'intérêt économique (GIE)');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'63','Société coopérative agricole');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'64','Société non commerciale d\'assurances');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'64','Société non commerciale d assurances');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'65','Société civile');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'69','Autres personnes de droit privé inscrites au RCS');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'71','Administration de l\'état');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'71','Administration de l état');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'72','Collectivité territoriale');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'73','Établissement public administratif');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'74','Autre personne morale de droit public administratif');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'81','Organisme gérant régime de protection social à adhésion obligatoire');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'82','Organisme mutualiste');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'83','Comité d\'entreprise');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'83','Comité d entreprise');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'84','Organisme professionnel');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'85','Organisme de retraite à adhésion non obligatoire');
@ -714,8 +714,8 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '205', 'SC
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '206', 'SCS - Société en commandite simple');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '207', 'SCA - Société en commandite par action');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '208', 'SNC - Société en nom collectif');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '209', 'GIE - Groupement d\'intérêt économique');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '210', 'GEIE - Groupement européen d\'intérêt économique');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '209', 'GIE - Groupement d intérêt économique');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '210', 'GEIE - Groupement européen d intérêt économique');
-- Pour la Suisse
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (6, '600', 'Raison Individuelle');