From f1e4c8077119fb9ced89c5dce71e77dc7b43f5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Feb 2019 16:39:15 +0100 Subject: [PATCH 1/3] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index afecfd33b45..cf3bb133558 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -587,7 +587,7 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param array $request_data InvoiceLine data - * + *$this->db->begin(); * @url POST {id}/lines * * @return int @@ -940,8 +940,6 @@ class Invoices extends DolibarrApi throw new RestException(401); } - $this->db->begin(); - $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Invoice not found'); @@ -958,10 +956,14 @@ class Invoices extends DolibarrApi if (! $this->invoice->paye) // protection against multiple submit { + $this->db->begin(); $this->invoice->fetch_lines(); // Loop on each vat rate $i=0; + $amount_ht = array(); + $amount_tva = array(); + $amount_ttc = array(); foreach($this->invoice->lines as $line) { $amount_ht[$line->tva_tx]+=$line->total_ht; @@ -1009,14 +1011,14 @@ class Invoices extends DolibarrApi } else { - throw new RestException(500, 'Could not set paid'); $this->db->rollback(); + throw new RestException(500, 'Could not set paid'); } } else { - throw new RestException(500, 'Discount creation error'); $this->db->rollback(); + throw new RestException(500, 'Discount creation error'); } } From 0e093ffb243b72eeb8044df4c12464520ff4c282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Feb 2019 16:41:40 +0100 Subject: [PATCH 2/3] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index cf3bb133558..7f97658fe8a 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -239,7 +239,7 @@ class Invoices extends DolibarrApi * * @param int $orderid Id of the order * - * @url POST /createfromorder/{orderid} +$this->db->begin(); * @url POST /createfromorder/{orderid} * * @return int * @throws 400 @@ -393,7 +393,7 @@ class Invoices extends DolibarrApi } $result = $this->invoice->fetch($id); - +$this->db->begin(); if(!$result) { throw new RestException(404, 'Invoice not found'); } @@ -587,7 +587,7 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param array $request_data InvoiceLine data - *$this->db->begin(); + * * @url POST {id}/lines * * @return int From 4b0b8e1c1f1e6882123694e15cd26f57f3a0ad81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Feb 2019 16:44:36 +0100 Subject: [PATCH 3/3] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 7f97658fe8a..0ec6dc19c2f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -239,7 +239,7 @@ class Invoices extends DolibarrApi * * @param int $orderid Id of the order * -$this->db->begin(); * @url POST /createfromorder/{orderid} + * @url POST /createfromorder/{orderid} * * @return int * @throws 400 @@ -393,7 +393,7 @@ $this->db->begin(); * @url POST /createfromorder/{orderid} } $result = $this->invoice->fetch($id); -$this->db->begin(); + if(!$result) { throw new RestException(404, 'Invoice not found'); }