Skip to content

Commit

Permalink
FIX #7885
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 5, 2017
1 parent 22d6142 commit 93311e3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions htdocs/compta/facture/card.php
Expand Up @@ -2931,7 +2931,9 @@
$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
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/class/fournisseur.facture.class.php
Expand Up @@ -2757,7 +2757,7 @@ public function insert($notrigger=0)
$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).",";

Expand Down
27 changes: 23 additions & 4 deletions htdocs/fourn/facture/card.php
Expand Up @@ -464,7 +464,7 @@
// 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 ++;
Expand Down Expand Up @@ -1921,7 +1921,24 @@
// 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
Expand Down Expand Up @@ -2119,7 +2136,7 @@
}
$morehtmlref.='</div>';

$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);

Expand Down Expand Up @@ -2609,6 +2626,8 @@
}
else // Credit note
{
$cssforamountpaymentcomplete='';

// Total already paid back
print '<tr><td colspan="' . $nbcols . '" align="right">';
print $langs->trans('AlreadyPaidBack');
Expand All @@ -2624,7 +2643,7 @@
else
print $langs->trans('ExcessPaydBack');
print ' :</td>';
print '<td align="right" bgcolor="#f0f0f0"><b>' . price($sign * $resteapayeraffiche) . '</b></td>';
print '<td align="right"'.($resteapayeraffiche?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>' . price($sign * $resteapayeraffiche) . '</td>';
print '<td class="nowrap">&nbsp;</td></tr>';

// Sold credit note
Expand Down

0 comments on commit 93311e3

Please sign in to comment.