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/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 53a488a7323..9a751157c4a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -144,6 +144,9 @@ class FactureRec extends CommonInvoice $sql.= ", nb_gen_max"; $sql.= ", auto_validate"; $sql.= ", generate_pdf"; + $sql.= ", fk_multicurrency"; + $sql.= ", multicurrency_code"; + $sql.= ", multicurrency_tx"; $sql.= ") VALUES ("; $sql.= "'".$this->db->escape($this->titre)."'"; $sql.= ", ".$facsrc->socid; @@ -168,12 +171,20 @@ class FactureRec extends CommonInvoice $sql.= ", ".$this->nb_gen_max; $sql.= ", ".$this->auto_validate; $sql.= ", ".$this->generate_pdf; + $sql.= ", ".$facsrc->fk_multicurrency; + $sql.= ", '".$facsrc->multicurrency_code."'"; + $sql.= ", ".$facsrc->multicurrency_tx; $sql.= ")"; if ($this->db->query($sql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec"); + // Fields used into addline later + $this->fk_multicurrency = $facsrc->fk_multicurrency; + $this->multicurrency_code = $facsrc->multicurrency_code; + $this->multicurrency_tx = $facsrc->multicurrency_tx; + // Add lines $num=count($facsrc->lines); for ($i = 0; $i < $num; $i++) @@ -198,7 +209,8 @@ class FactureRec extends CommonInvoice $facsrc->lines[$i]->rang, $facsrc->lines[$i]->special_code, $facsrc->lines[$i]->label, - $facsrc->lines[$i]->fk_unit + $facsrc->lines[$i]->fk_unit, + $facsrc->lines[$i]->multicurrency_subprice ); if ($result_insert < 0) @@ -287,7 +299,8 @@ class FactureRec extends CommonInvoice $sql.= ', f.fk_account'; $sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; $sql.= ', f.generate_pdf'; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; @@ -358,6 +371,14 @@ class FactureRec extends CommonInvoice $this->auto_validate = $obj->auto_validate; $this->generate_pdf = $obj->generate_pdf; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; // Retreive all extrafield for thirdparty @@ -413,6 +434,12 @@ class FactureRec extends CommonInvoice { $this->lines=array(); + // Retreive all extrafield for line + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafieldsline=new ExtraFields($line->db); + $extrafieldsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true); + $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; @@ -421,7 +448,7 @@ class FactureRec extends CommonInvoice $sql.= ' l.rang, l.special_code,'; //$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.fk_unit, l.fk_contract_line,'; - //$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; @@ -477,13 +504,15 @@ class FactureRec extends CommonInvoice $line->price = $objp->price; $line->remise = $objp->remise; - // Retreive all extrafield for thirdparty - // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafieldsline=new ExtraFields($line->db); - $extrafieldsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true); $extralabelsline = $line->fetch_optionals($line->id,$extrafieldsline); + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $this->lines[$i] = $line; @@ -575,15 +604,16 @@ class FactureRec extends CommonInvoice * @param int $special_code Special code * @param string $label Label of the line * @param string $fk_unit Unit + * @param double $pu_ht_devise Unit price in currency * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null, $pu_ht_devise=0) { global $mysoc; $facid=$this->id; - dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit,pu_ht_devise=$pu_ht_devise", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters @@ -629,13 +659,19 @@ class FactureRec extends CommonInvoice // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; + $pu_ht = $tabprice[3]; + + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; $product_type=$type; if ($fk_product) @@ -670,6 +706,7 @@ class FactureRec extends CommonInvoice $sql.= ", rang"; $sql.= ", special_code"; $sql.= ", fk_unit"; + $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; $sql.= ") VALUES ("; $sql.= "'".$facid."'"; $sql.= ", ".(! empty($label)?"'".$this->db->escape($label)."'":"null"); @@ -694,7 +731,14 @@ class FactureRec extends CommonInvoice $sql.= ", ".price2num($total_ttc); $sql.= ", ".$rang; $sql.= ", ".$special_code; - $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")"; + $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".price2num($pu_ht_devise); + $sql.= ", ".price2num($multicurrency_total_ht); + $sql.= ", ".price2num($multicurrency_total_tva); + $sql.= ", ".price2num($multicurrency_total_ttc); + $sql.= ")"; dol_syslog(get_class($this)."::addline", LOG_DEBUG); if ($this->db->query($sql)) @@ -733,15 +777,17 @@ class FactureRec extends CommonInvoice * @param int $special_code Special code * @param string $label Label of the line * @param string $fk_unit Unit + * @param double $pu_ht_devise Unit price in currency + * @param int $notrigger disable line update trigger * @return int <0 if KO, Id of line if OK */ - function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) + function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null, $pu_ht_devise = 0, $notrigger=0) { global $mysoc; $facid=$this->id; - dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -771,6 +817,13 @@ class FactureRec extends CommonInvoice $txtva=price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); + if (empty($txlocaltax1)) $txlocaltax1=0; + if (empty($txlocaltax2)) $txlocaltax2=0; + + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; if ($price_base_type=='HT') { @@ -785,13 +838,22 @@ class FactureRec extends CommonInvoice // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; + + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; $product_type=$type; if ($fk_product) @@ -809,9 +871,9 @@ class FactureRec extends CommonInvoice $sql.= ", qty=".price2num($qty); $sql.= ", tva_tx=".price2num($txtva); $sql.= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; - $sql.= ", localtax1_tx=".price2num($txlocaltax1); + $sql.= ", localtax1_tx=".$txlocaltax1; $sql.= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; - $sql.= ", localtax2_tx=".price2num($txlocaltax2); + $sql.= ", localtax2_tx=".$txlocaltax2; $sql.= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; $sql.= ", fk_product=".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", product_type=".$product_type; @@ -825,6 +887,10 @@ class FactureRec extends CommonInvoice $sql.= ", rang=".$rang; $sql.= ", special_code=".$special_code; $sql.= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); + $sql.= ', multicurrency_subprice = '.$pu_ht_devise; + $sql.= ', multicurrency_total_ht = '.$multicurrency_total_ht; + $sql.= ', multicurrency_total_tva = '.$multicurrency_total_tva; + $sql.= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; $sql.= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 234b047464f..b5e18948b38 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -615,7 +615,8 @@ class Facture extends CommonInvoice $line->array_options, $line->situation_percent, $line->fk_prev_id, - $line->fk_unit + $line->fk_unit, + $line->pu_ht_devise ); if ($result < 0) { @@ -673,7 +674,8 @@ class Facture extends CommonInvoice empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, '', - $_facrec->lines[$i]->fk_unit + $_facrec->lines[$i]->fk_unit, + $_facrec->lines[$i]->pu_ht_devise ); if ( $result_insert < 0) @@ -1434,6 +1436,8 @@ 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 ? + $this->lines[$i] = $line; $i++; @@ -2756,7 +2760,7 @@ class Facture extends CommonInvoice global $mysoc,$langs; - dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code fk_unit=$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); if ($this->brouillon) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index f360266f296..ddaf073e964 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -225,8 +225,8 @@ if (empty($reshook)) $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); $object->date_when = $date_next_execution; - // Get first contract linked to invoice used to generate template - if ($id > 0) + // Get first contract linked to invoice used to generate template (facid is id of source invoice) + if (GETPOST('facid','int') > 0) { $srcObject = new Facture($db); $srcObject->fetch(GETPOST('facid','int')); @@ -246,7 +246,7 @@ if (empty($reshook)) $db->begin(); $oldinvoice = new Facture($db); - $oldinvoice->fetch($id); + $oldinvoice->fetch(GETPOST('facid','int')); $result = $object->create($user, $oldinvoice->id); if ($result > 0) @@ -288,7 +288,8 @@ if (empty($reshook)) if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) { $object->delete($user); - header("Location: " . $_SERVER['PHP_SELF'] ); + + header("Location: " . DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); exit; } @@ -784,6 +785,7 @@ if (empty($reshook)) $pu_ht = GETPOST('price_ht'); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $qty = GETPOST('qty'); + $pu_ht_devise = GETPOST('multicurrency_subprice'); // Define info_bits $info_bits = 0; @@ -898,7 +900,8 @@ if (empty($reshook)) 0, $special_code, $label, - GETPOST('units') + GETPOST('units'), + $pu_ht_devise ); if ($result >= 0) 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 '