diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 11fd6ac83ba..e1828076786 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1877,6 +1877,9 @@ class Commande extends CommonOrder $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $line->fetch_optionals(); + + $this->lines[$i] = $line; $i++; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f90505a58d9..8897d98cb1a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1379,7 +1379,7 @@ class Facture extends CommonInvoice } else { - $this->error='Bill with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; + $this->error='Invoice with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); return 0; } @@ -1485,7 +1485,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - // TODO Fetch optional like done in fetch line of facture_rec ? + $line->fetch_optionals(); $this->lines[$i] = $line; @@ -4845,17 +4845,17 @@ class FactureLigne extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); - + $returnPercent = floatval($res['situation_percent']); - + if($include_credit_note) { - + $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; $sql.= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed $sql.= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; - + $res = $this->db->query($sql); if($res) { while($obj = $this->db->fetch_object($res)) { @@ -4863,7 +4863,7 @@ class FactureLigne extends CommonInvoiceLine } } } - + return $returnPercent; } else { $this->error = $this->db->error(); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 949b586e940..671a3d6cbc3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -447,15 +447,15 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target } else { $companytouseforaddress = $targetcompany; - // Contact on a thirdparty that is a different thirdparty than the thirdparty of object - if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) - { - $targetcontact->fetch_thirparty(); + // Contact on a thirdparty that is a different thirdparty than the thirdparty of object + if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) + { + $targetcontact->fetch_thirdparty(); $companytouseforaddress = $targetcontact->thirdparty; } - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); - } + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); + } // Country if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code));