Amélioration sécurité sur l'édition d'un facture validée
This commit is contained in:
parent
5bf8ab56b4
commit
74847f56de
@ -161,27 +161,19 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repasse la facture en mode brouillon
|
||||||
if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->global->FACTURE_ENABLE_EDITDELETE)
|
if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->global->FACTURE_ENABLE_EDITDELETE)
|
||||||
{
|
{
|
||||||
/*
|
$fac = new Facture($db);
|
||||||
* Repasse la facture en mode brouillon
|
|
||||||
*/
|
|
||||||
$fac = new Facture($db);
|
|
||||||
$fac->fetch($_GET['facid']);
|
$fac->fetch($_GET['facid']);
|
||||||
|
|
||||||
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
||||||
$ventilExportCompta = 0 ;
|
$ventilExportCompta = $fac->getVentilExportCompta();
|
||||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
|
||||||
{
|
|
||||||
if ($fac->lignes[$i]->export_compta <> 0 && $fac->lignes[$i]->code_ventilation <> 0)
|
|
||||||
{
|
|
||||||
$ventilExportCompta++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ventilExportCompta == 0)
|
// On vérifie si aucun paiement n'a été effectué
|
||||||
{
|
if ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0)
|
||||||
$fac->reopen($user);
|
{
|
||||||
|
$fac->reopen($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2111,14 +2103,7 @@ else
|
|||||||
if ($fac->statut == 1)
|
if ($fac->statut == 1)
|
||||||
{
|
{
|
||||||
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
||||||
$ventilExportCompta = 0 ;
|
$ventilExportCompta = $fac->getVentilExportCompta();
|
||||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
|
||||||
{
|
|
||||||
if ($fac->lignes[$i]->export_compta <> 0 && $fac->lignes[$i]->code_ventilation <> 0)
|
|
||||||
{
|
|
||||||
$ventilExportCompta++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier
|
if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier
|
||||||
&& ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0))
|
&& ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0))
|
||||||
|
|||||||
@ -1835,13 +1835,41 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi si une facture peut etre supprimée complètement
|
* \brief Renvoi si les lignes de facture sont ventilées et/ou exportées en compta
|
||||||
|
* \param user Utilisateur créant la demande
|
||||||
|
* \return int <0 si ko, 0=non, 1=oui
|
||||||
|
*/
|
||||||
|
function getVentilExportCompta()
|
||||||
|
{
|
||||||
|
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
||||||
|
$ventilExportCompta = 0 ;
|
||||||
|
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
||||||
|
{
|
||||||
|
if ($this->lignes[$i]->export_compta <> 0 && $this->lignes[$i]->code_ventilation <> 0)
|
||||||
|
{
|
||||||
|
$ventilExportCompta++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ventilExportCompta <> 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Renvoi si une facture peut etre supprimée complètement
|
||||||
* La règle est la suivante:
|
* La règle est la suivante:
|
||||||
* Si facture dernière, non provisoire, sans paiement et non exporté en compta -> oui fin de règle
|
* Si facture dernière, non provisoire, sans paiement et non exporté en compta -> oui fin de règle
|
||||||
* Si facture brouillon et provisoire -> oui
|
* Si facture brouillon et provisoire -> oui
|
||||||
* \param user Utilisateur créant la demande
|
* \param user Utilisateur créant la demande
|
||||||
* \return int <0 si ko, 0=non, 1=oui
|
* \return int <0 si ko, 0=non, 1=oui
|
||||||
*/
|
*/
|
||||||
function is_erasable()
|
function is_erasable()
|
||||||
{
|
{
|
||||||
global $conf, $db;
|
global $conf, $db;
|
||||||
@ -1863,15 +1891,7 @@ class Facture extends CommonObject
|
|||||||
$maxfacnumber = $db->fetch_row($resql);
|
$maxfacnumber = $db->fetch_row($resql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
$ventilExportCompta = $this->getVentilExportCompta();
|
||||||
$ventilExportCompta = 0 ;
|
|
||||||
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
|
||||||
{
|
|
||||||
if ($this->lignes[$i]->export_compta <> 0 && $this->lignes[$i]->code_ventilation <> 0)
|
|
||||||
{
|
|
||||||
$ventilExportCompta++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si derniere facture et si non ventilée, on peut supprimer
|
// Si derniere facture et si non ventilée, on peut supprimer
|
||||||
if ($maxfacnumber[0] == $this->ref && $ventilExportCompta == 0)
|
if ($maxfacnumber[0] == $this->ref && $ventilExportCompta == 0)
|
||||||
@ -1889,10 +1909,10 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Créé une demande de prélèvement
|
* \brief Créé une demande de prélèvement
|
||||||
* \param user Utilisateur créant la demande
|
* \param user Utilisateur créant la demande
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function demande_prelevement($user)
|
function demande_prelevement($user)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Facture::demande_prelevement $this->statut $this->paye $this->mode_reglement_id");
|
dolibarr_syslog("Facture::demande_prelevement $this->statut $this->paye $this->mode_reglement_id");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user