Fix: price should not be used to compare amounts. Price is a formated

string, not an amount.
This commit is contained in:
Laurent Destailleur 2013-11-15 22:15:48 +01:00
parent c8f1a26d25
commit d0d9cce146
2 changed files with 18 additions and 17 deletions

View File

@ -1929,7 +1929,7 @@ if ($action == 'update_extras')
$ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !! // FIXME le hook fait double emploi avec le trigger !!
@ -1946,7 +1946,7 @@ if ($action == 'update_extras')
} }
else if ($reshook < 0) $error++; else if ($reshook < 0) $error++;
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }
@ -2320,8 +2320,9 @@ if ($action == 'create')
print $langs->trans('OutstandingBill'); print $langs->trans('OutstandingBill');
print '</td><td align=right>'; print '</td><td align=right>';
print price($outstandigBills); print price($outstandigBills);
if (price($outstandigBills)>price($soc->outstanding_limit)) print img_warning($langs->trans("OutstandingBillReached")); if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
print ' / '.price($soc->outstanding_limit).'</td>'; print ' / '.price($soc->outstanding_limit);
print '</td>';
print '</tr>'; print '</tr>';
} }
@ -3444,9 +3445,9 @@ else if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="attribute" value="'.$key.'">'; print '<input type="hidden" name="attribute" value="'.$key.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print $extrafields->showInputField($key,$value); print $extrafields->showInputField($key,$value);
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
} }
@ -3792,7 +3793,7 @@ else if ($id > 0 || ! empty($ref))
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
$i++; $i++;
} }
print '</table>'; print '</table>';
@ -3804,10 +3805,10 @@ else if ($id > 0 || ! empty($ref))
{ {
dol_print_error($db); dol_print_error($db);
} }
print '</div>'; print '</div>';
} }
// Link for paypal payment // Link for paypal payment
if (! empty($conf->paypal->enabled) && $object->statut != 0) if (! empty($conf->paypal->enabled) && $object->statut != 0)
{ {

View File

@ -2820,9 +2820,9 @@ class Societe extends CommonObject
$this->db->begin(); $this->db->begin();
$now=dol_now(); $now=dol_now();
$outstanding = price2num($this->outstanding_limit); $outstanding = price2num($this->outstanding_limit);
// Positionne l'encours de facturaiton // Positionne l'encours de facturaiton
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
$sql.= " outstanding_limit=".$outstanding; $sql.= " outstanding_limit=".$outstanding;
@ -2843,13 +2843,13 @@ class Societe extends CommonObject
} }
/** /**
* return amount of bill not paid * Return amount of bill not paid
* *
* @return boolean Yes or no * @return int Amount in debt for thirdparty
*/ */
function get_OutstandingBill() function get_OutstandingBill()
{ {
/* Accurate value of remain to pay is to sum remaintopay for each invoice /* Accurate value of remain to pay is to sum remaintopay for each invoice
$paiement = $invoice->getSommePaiement(); $paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed(); $creditnotes=$invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed(); $deposits=$invoice->getSumDepositsUsed();
@ -2857,7 +2857,7 @@ class Societe extends CommonObject
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
*/ */
$sql = "SELECT sum(total) as amount FROM ".MAIN_DB_PREFIX."facture as f"; $sql = "SELECT sum(total) as amount FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE fk_soc = ". $this->id; $sql .= " WHERE fk_soc = ". $this->id;
$sql .= " AND paye = 0"; $sql .= " AND paye = 0";
$sql .= " AND fk_statut <> 0"; $sql .= " AND fk_statut <> 0";
@ -2873,9 +2873,9 @@ class Societe extends CommonObject
} }
/** /**
* Return label of status customer is prospect/customer * Return label of status customer is prospect/customer
* *
* @return string Libelle * @return string Label
*/ */
function getLibCustProspStatut() function getLibCustProspStatut()
{ {