diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e9eb5ec753e..b1047c84903 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4424,7 +4424,7 @@ class Facture extends CommonInvoice * Set percent discount * * @param User $user User that set discount - * @param double $remise Discount + * @param float $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int Return integer <0 if KO, >0 if OK * @deprecated remise_percent is a deprecated field for object parent @@ -4437,16 +4437,16 @@ class Facture extends CommonInvoice } if ($user->hasRight('facture', 'creer')) { - $remise = price2num($remise, 2); + $remise = (float) price2num($remise, 2); $error = 0; $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= ' SET remise_percent = '.((float) $remise); + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $sql .= " SET remise_percent = ".((float) $remise); $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; + $sql .= " AND fk_statut = ".((int) self::STATUS_DRAFT); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -6295,7 +6295,8 @@ class FactureLigne extends CommonInvoiceLine // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { + $result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product); + if ($result < 0) { return $result; } else { $this->pa_ht = $result; @@ -6734,7 +6735,7 @@ class FactureLigne extends CommonInvoiceLine * * @param int $invoiceid Invoice id * @param bool $include_credit_note Include credit note or not - * @return int >= 0 + * @return float|int Reurrn previous situation percent, 0 or -1 if error */ public function get_prev_progress($invoiceid, $include_credit_note = true) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7c8e3cc2827..f204c535089 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8964,7 +8964,7 @@ abstract class CommonObject * @param float $unitPrice Product unit price * @param float $discountPercent Line discount percent * @param int $fk_product Product id - * @return float Return integer <0 if KO, buyprice if OK + * @return float|int Return buy price if OK, integer <0 if KO */ public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_product = 0) {