Skip to content

Commit

Permalink
Fix: We allow to add credit not higher than invoice amount.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 15, 2012
1 parent 1f0cddc commit bc94ec9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
3 changes: 2 additions & 1 deletion htdocs/compta/facture.php
Expand Up @@ -2371,7 +2371,8 @@
{
// Remise dispo de type avoir
if (! $absolute_discount) print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
//$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0); // We must allow credit not even if amount is higher
}
}
if (! $absolute_discount && ! $absolute_creditnote)
Expand Down
46 changes: 23 additions & 23 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -82,7 +82,7 @@ function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='st
global $conf,$langs;

$ret='';

// TODO change for compatibility
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;/',$typeofdata))
{
Expand Down Expand Up @@ -1961,7 +1961,7 @@ function load_PriceBaseType($selected='',$htmlname='price_base_type')
* @param string $filtre To filter list
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param string $moreattrib To add more attribute on select
* @return void
* @return void
*/
function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',$useempty=0,$moreattrib='')
{
Expand Down Expand Up @@ -2575,7 +2575,7 @@ function form_modes_reglement($page, $selected='', $htmlname='mode_reglement_id'
* @param string $more More string to add
* @return void
*/
function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid, $amount, $filter='', $maxvalue=0, $more='')
function form_remise_dispo($page, $selected='', $htmlname='remise_id', $socid, $amount, $filter='', $maxvalue=0, $more='')
{
global $conf,$langs;
if ($htmlname != "none")
Expand Down Expand Up @@ -2721,7 +2721,7 @@ function select_currency($selected='',$htmlname='currency_id')
{
print $this->selectcurrency($selected,$htmlname);
}

/**
* Load into the cache all currencies
*
Expand All @@ -2730,16 +2730,16 @@ function select_currency($selected='',$htmlname='currency_id')
function load_cache_currencies()
{
global $langs;

$langs->load("dict");

if (count($this->cache_currencies)) return 0; // Cache deja charge

$sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code_iso ASC";

dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
Expand All @@ -2749,14 +2749,14 @@ function load_cache_currencies()
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);

// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) dol_json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++;
}

array_multisort($label, SORT_ASC, $this->cache_currencies);

return $num;
Expand All @@ -2773,14 +2773,14 @@ function load_cache_currencies()
*
* @param string $selected preselected currency code
* @param string $htmlname name of HTML select list
* @return void
* @return void
*/
function selectcurrency($selected='',$htmlname='currency_id')
{
global $conf,$langs,$user;

$langs->load("dict");

$this->load_cache_currencies();

$out='';
Expand Down Expand Up @@ -2829,7 +2829,7 @@ function select_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='',
{
print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type);
}

/**
* Load into the cache vat rates of a country
*
Expand All @@ -2839,14 +2839,14 @@ function select_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='',
function load_cache_vatrates($country_code)
{
if (count($this->cache_vatrates)) return 0; // Cache deja charge

$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE t.fk_pays = p.rowid";
$sql.= " AND t.active = 1";
$sql.= " AND p.code IN (".$country_code.")";
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";

$resql=$this->db->query($sql);
if ($resql)
{
Expand All @@ -2860,7 +2860,7 @@ function load_cache_vatrates($country_code)
$this->cache_vatrates[$i]['libtva'] = $obj->taux.'%';
$this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly;
}

return $num;
}
else
Expand Down Expand Up @@ -2963,10 +2963,10 @@ function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $
}
}
}

// Now we get list
$num = $this->load_cache_vatrates($code_pays);

if ($num > 0)
{
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
Expand All @@ -2975,16 +2975,16 @@ function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod);
}

// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{
$defaulttx = $this->cache_vatrates[$num-1]['txtva'];
}

if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';

foreach ($this->cache_vatrates as $rate)
{
$return.= '<option value="'.$rate['txtva'];
Expand All @@ -2997,12 +2997,12 @@ function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $
$return.= '>'.vatrate($rate['libtva']);
$return.= $rate['nprtva'] ? ' *': '';
$return.= '</option>';

$this->tva_taux_value[] = $rate['txtva'];
$this->tva_taux_libelle[] = $rate['libtva'];
$this->tva_taux_npr[] = $rate['nprtva'];
}

if (! $options_only) $return.= '</select>';
}
else
Expand Down

0 comments on commit bc94ec9

Please sign in to comment.