diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 51703028142..a44ee8577ed 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2931,7 +2931,9 @@ else if ($id > 0 || ! empty($ref)) $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); if ($object->paye) + { $resteapayer = 0; + } $resteapayeraffiche = $resteapayer; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2af027e60e2..2be366cfc46 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2757,7 +2757,7 @@ class SupplierInvoiceLine extends CommonObjectLine $sql.= " VALUES (".$this->fk_facture_fourn.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " '".$this->db->escape($this->desc)."',"; + $sql.= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',"; $sql.= " '".$this->db->escape($this->ref_supplier)."',"; $sql.= " ".price2num($this->qty).","; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 61b73fabb75..a3c068e34bf 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -464,7 +464,7 @@ if (empty($reshook)) // Credit note invoice if ($_POST['type'] == FactureFournisseur::TYPE_CREDIT_NOTE) { - $sourceinvoice = GETPOST('fac_avoir'); + $sourceinvoice = GETPOST('fac_avoir','int'); if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { $error ++; @@ -1921,7 +1921,24 @@ else // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $alreadypaid=$object->getSommePaiement(); + $totalpaye = $object->getSommePaiement(); + $totalcreditnotes = $object->getSumCreditNotesUsed(); + $totaldeposits = $object->getSumDepositsUsed(); + // print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." + // selleruserrevenuestamp=".$selleruserevenustamp; + + // We can also use bcadd to avoid pb with floating points + // For example print 239.2 - 229.3 - 9.9; does not return 0. + // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); + $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + + if ($object->paye) + { + $resteapayer = 0; + } + $resteapayeraffiche = $resteapayer; + /* * View card @@ -2119,7 +2136,7 @@ else } $morehtmlref.=''; - $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2609,6 +2626,8 @@ else } else // Credit note { + $cssforamountpaymentcomplete=''; + // Total already paid back print '