Fix transaction

This commit is contained in:
Laurent Destailleur 2019-02-25 15:09:56 +01:00
parent 7b2f4771f0
commit dde18e803d

View File

@ -940,7 +940,6 @@ class Invoices extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
$this->db->begin();
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if( ! $result ) { if( ! $result ) {
@ -958,8 +957,12 @@ class Invoices extends DolibarrApi
if (! $this->invoice->paye) // protection against multiple submit if (! $this->invoice->paye) // protection against multiple submit
{ {
$this->db->begin();
$this->invoice->fetch_lines(); $this->invoice->fetch_lines();
$amount_ht = $amount_tva = $amount_ttc = array();
// Loop on each vat rate // Loop on each vat rate
$i=0; $i=0;
foreach($this->invoice->lines as $line) foreach($this->invoice->lines as $line)
@ -1009,14 +1012,14 @@ class Invoices extends DolibarrApi
} }
else else
{ {
throw new RestException(500, 'Could not set paid');
$this->db->rollback(); $this->db->rollback();
throw new RestException(500, 'Could not set paid');
} }
} }
else else
{ {
throw new RestException(500, 'Discount creation error');
$this->db->rollback(); $this->db->rollback();
throw new RestException(500, 'Discount creation error');
} }
} }