FIX error managent and db transaction balance

This commit is contained in:
Laurent Destailleur
2021-01-14 19:09:57 +01:00
parent ee7aacae54
commit 0d704b0714
4 changed files with 25 additions and 7 deletions

View File

@@ -2896,19 +2896,21 @@ class Commande extends CommonOrder
* Classify the order as invoiced
*
* @param User $user Object user making the change
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
* @param int $notrigger 1=Does not execute triggers, 0=execute triggers
* @return int <0 if KO, 0 if already billed, >0 if OK
*/
public function classifyBilled(User $user, $notrigger = 0)
{
$error = 0;
$this->db->begin();
if ($this->billed)
{
return 0;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;