New: Add default label into stock movement label
This commit is contained in:
parent
a76e377f59
commit
5440ad97c6
@ -1412,10 +1412,10 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme validee + appel trigger BILL_VALIDATE
|
* Tag invoice as validated + call trigger BILL_VALIDATE
|
||||||
* \param user Utilisateur qui valide la facture
|
* @param user Object user that validate
|
||||||
* \param force_number Reference a forcer de la facture
|
* @param force_number Reference to force on invoice
|
||||||
* \return int <0 si ko, >0 si ok
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function validate($user, $force_number='')
|
function validate($user, $force_number='')
|
||||||
{
|
{
|
||||||
@ -1493,7 +1493,7 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date
|
if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date
|
||||||
{
|
{
|
||||||
$this->date=gmmktime();
|
$this->date=dol_now();
|
||||||
$this->date_lim_reglement=$this->calculate_date_lim_reglement();
|
$this->date_lim_reglement=$this->calculate_date_lim_reglement();
|
||||||
}
|
}
|
||||||
$num = $this->getNextNumRef($this->client);
|
$num = $this->getNextNumRef($this->client);
|
||||||
@ -1547,10 +1547,11 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($this->lines[$i]->fk_product > 0 && $this->lines[$i]->product_type == 0)
|
if ($this->lines[$i]->fk_product > 0 && $this->lines[$i]->product_type == 0)
|
||||||
{
|
{
|
||||||
|
$langs->load("agenda");
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
// We decrease stock for product
|
// We decrease stock for product
|
||||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
||||||
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice);
|
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1647,7 +1648,7 @@ class Facture extends CommonObject
|
|||||||
dol_syslog("Facture::set_draft sql=".$sql, LOG_DEBUG);
|
dol_syslog("Facture::set_draft sql=".$sql, LOG_DEBUG);
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
// Si active on decremente le produit principal et ses composants a la validation de facture
|
// Si on decremente le produit principal et ses composants a la validation de facture, on réincrement
|
||||||
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL)
|
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||||
@ -1656,10 +1657,11 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0)
|
if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0)
|
||||||
{
|
{
|
||||||
|
$langs->load("agenda");
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
// We decrease stock for product
|
// We decrease stock for product
|
||||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
||||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice);
|
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -606,10 +606,10 @@ class FactureFournisseur extends Facture
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set supplier ref
|
* Set supplier ref
|
||||||
* \param user User that make change
|
* @param user User that make change
|
||||||
* \param ref_supplier Supplier ref
|
* @param ref_supplier Supplier ref
|
||||||
* \return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function set_ref_supplier($user, $ref_supplier)
|
function set_ref_supplier($user, $ref_supplier)
|
||||||
{
|
{
|
||||||
@ -687,11 +687,11 @@ class FactureFournisseur extends Facture
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme non payee completement + appel trigger BILL_UNPAYED
|
* Tag la facture comme non payee completement + appel trigger BILL_UNPAYED
|
||||||
* Fonction utilisee quand un paiement prelevement est refuse,
|
* Fonction utilisee quand un paiement prelevement est refuse,
|
||||||
* ou quand une facture annulee et reouverte.
|
* ou quand une facture annulee et reouverte.
|
||||||
* \param user Object user that change status
|
* @param user Object user that change status
|
||||||
* \return int <0 si ok, >0 si ok
|
* @return int <0 si ok, >0 si ok
|
||||||
*/
|
*/
|
||||||
function set_unpaid($user)
|
function set_unpaid($user)
|
||||||
{
|
{
|
||||||
@ -737,11 +737,12 @@ class FactureFournisseur extends Facture
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set invoice status as validated
|
* Tag invoice as validated + call trigger BILL_VALIDATE
|
||||||
* @param user Object user
|
* @param user Object user that validate
|
||||||
* @return int <0 if KO, =0 if nothing to do, >0 if OK
|
* @param force_number Reference to force on invoice
|
||||||
|
* @return int <0 if KO, =0 if nothing to do, >0 if OK
|
||||||
*/
|
*/
|
||||||
function validate($user)
|
function validate($user, $force_number='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
@ -763,7 +764,21 @@ class FactureFournisseur extends Facture
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
|
// Define new ref
|
||||||
|
if ($force_number)
|
||||||
|
{
|
||||||
|
$num = $force_number;
|
||||||
|
}
|
||||||
|
else if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||||
|
{
|
||||||
|
$num = $this->getNextNumRef($this->client);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$num = $this->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
|
||||||
$sql.= " SET fk_statut = 1, fk_user_valid = ".$user->id;
|
$sql.= " SET fk_statut = 1, fk_user_valid = ".$user->id;
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
@ -771,7 +786,7 @@ class FactureFournisseur extends Facture
|
|||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Si activé on décrémente le produit principal et ses composants à la validation de facture
|
// Si on incrémente le produit principal et ses composants à la validation de facture fournisseur
|
||||||
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)
|
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||||
@ -780,10 +795,11 @@ class FactureFournisseur extends Facture
|
|||||||
{
|
{
|
||||||
if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0)
|
if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0)
|
||||||
{
|
{
|
||||||
$mouvP = new MouvementStock($this->db);
|
$langs->load("agenda");
|
||||||
|
$mouvP = new MouvementStock($this->db);
|
||||||
// We increase stock for product
|
// We increase stock for product
|
||||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
||||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->pu_ht);
|
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->pu_ht, $langs->trans("InvoiceValidatedInDolibarr",$num));
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -820,9 +836,9 @@ class FactureFournisseur extends Facture
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set draft status
|
* Set draft status
|
||||||
* \param user Object user that modify
|
* @param user Object user that modify
|
||||||
* \param int <0 if KO, >0 if OK
|
* @param int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function set_draft($user)
|
function set_draft($user)
|
||||||
{
|
{
|
||||||
@ -845,7 +861,7 @@ class FactureFournisseur extends Facture
|
|||||||
dol_syslog("FactureFournisseur::set_draft sql=".$sql, LOG_DEBUG);
|
dol_syslog("FactureFournisseur::set_draft sql=".$sql, LOG_DEBUG);
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
// Si active on decremente le produit principal et ses composants a la validation de facture
|
// Si on incremente le produit principal et ses composants a la validation de facture fournisseur, on decremente
|
||||||
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)
|
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||||
@ -854,10 +870,11 @@ class FactureFournisseur extends Facture
|
|||||||
{
|
{
|
||||||
if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0)
|
if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0)
|
||||||
{
|
{
|
||||||
$mouvP = new MouvementStock($this->db);
|
$langs->load("agenda");
|
||||||
|
$mouvP = new MouvementStock($this->db);
|
||||||
// We increase stock for product
|
// We increase stock for product
|
||||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
||||||
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice);
|
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ AgendaExtSitesDesc=This page allows to configure external calendars.
|
|||||||
ActionsEvents= Events for which Dolibarr will create an action in agenda automatically
|
ActionsEvents= Events for which Dolibarr will create an action in agenda automatically
|
||||||
PropalValidatedInDolibarr= Proposal %s validated
|
PropalValidatedInDolibarr= Proposal %s validated
|
||||||
InvoiceValidatedInDolibarr= Invoice %s validated
|
InvoiceValidatedInDolibarr= Invoice %s validated
|
||||||
|
InvoiceBackToDraftInDolibarr=Invoice %s go back to draft status
|
||||||
OrderValidatedInDolibarr= Order %s validated
|
OrderValidatedInDolibarr= Order %s validated
|
||||||
InterventionValidatedInDolibarr=Intervention %s validated
|
InterventionValidatedInDolibarr=Intervention %s validated
|
||||||
ProposalSentByEMail=Commercial proposal %s sent by EMail
|
ProposalSentByEMail=Commercial proposal %s sent by EMail
|
||||||
|
|||||||
@ -35,6 +35,7 @@ AgendaExtSitesDesc=Cette page permet de configurer les calendriers externes.
|
|||||||
ActionsEvents=Événements pour lesquels Dolibarr doit créer une action dans l'agenda en automatique.
|
ActionsEvents=Événements pour lesquels Dolibarr doit créer une action dans l'agenda en automatique.
|
||||||
PropalValidatedInDolibarr=Proposition %s validée
|
PropalValidatedInDolibarr=Proposition %s validée
|
||||||
InvoiceValidatedInDolibarr=Facture %s validée
|
InvoiceValidatedInDolibarr=Facture %s validée
|
||||||
|
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
|
||||||
OrderValidatedInDolibarr=Commande %s validée
|
OrderValidatedInDolibarr=Commande %s validée
|
||||||
InterventionValidatedInDolibarr=Intervention %s validée
|
InterventionValidatedInDolibarr=Intervention %s validée
|
||||||
ProposalSentByEMail=Proposition commerciale %s envoyée par EMail
|
ProposalSentByEMail=Proposition commerciale %s envoyée par EMail
|
||||||
|
|||||||
@ -331,8 +331,9 @@ class MouvementStock
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Increase stock for product and subproducts
|
* Increase stock for product and subproducts
|
||||||
* \return int <0 if KO, >0 if OK
|
* @param label Label of stock movement
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function reception($user, $fk_product, $entrepot_id, $qty, $price=0, $label='')
|
function reception($user, $fk_product, $entrepot_id, $qty, $price=0, $label='')
|
||||||
{
|
{
|
||||||
@ -342,7 +343,6 @@ class MouvementStock
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return nb of subproducts lines for a product
|
* Return nb of subproducts lines for a product
|
||||||
*
|
|
||||||
* @param $id
|
* @param $id
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user