FIX Combo list of VAT is wrong on POS
This commit is contained in:
parent
1878647d26
commit
f591e2b1b1
@ -125,23 +125,13 @@ $langs->load("cashdesk");
|
||||
<td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtTotal" value="" disabled /></td><td></td>
|
||||
<!-- Choix du taux de TVA -->
|
||||
<td class="select_tva">
|
||||
<?php //var_dump($tab_tva); ?>
|
||||
<select name="selTva" onchange="javascript: modif();" >
|
||||
<?php
|
||||
$tva_tx = $obj_facturation->tva(); // Try to get a previously entered VAT rowid. First time, this will return empty.
|
||||
|
||||
$tab_tva_size=count($tab_tva); // $tab_tva contains list of possible vat array('rowid'=> , 'taux'=> )
|
||||
for ($i=0;$i < $tab_tva_size;$i++)
|
||||
{
|
||||
if ($tva_tx == $tab_tva[$i]['rowid'])
|
||||
$selected = 'selected';
|
||||
else
|
||||
$selected = '';
|
||||
|
||||
echo '<option '.$selected.' value="'.$tab_tva[$i]['rowid'].'">'.$tab_tva[$i]['taux'].'</option>'."\n ";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php //var_dump($tab_tva);
|
||||
$tva_tx = $obj_facturation->tva(); // Try to get a previously entered VAT rowid. First time, this will return empty.
|
||||
$buyer = new Societe($db);
|
||||
if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
|
||||
|
||||
echo $form->load_tva('selTva', (isset($_POST["selTva"])?GETPOST("selTva",'alpha',2):-1), $mysoc, $buyer, 0, 0, '', false, -1);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -4257,7 +4257,7 @@ class Form
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = "SELECT DISTINCT t.code, t.taux, t.recuperableonly";
|
||||
$sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.recuperableonly";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
|
||||
$sql.= " WHERE t.fk_pays = c.rowid";
|
||||
$sql.= " AND t.active > 0";
|
||||
@ -4273,6 +4273,7 @@ class Form
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->cache_vatrates[$i]['rowid'] = $obj->rowid;
|
||||
$this->cache_vatrates[$i]['code'] = $obj->code;
|
||||
$this->cache_vatrates[$i]['txtva'] = $obj->taux;
|
||||
$this->cache_vatrates[$i]['libtva'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or *
|
||||
@ -4302,9 +4303,9 @@ class Form
|
||||
* @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing.
|
||||
* @param Societe $societe_vendeuse Thirdparty seller
|
||||
* @param Societe $societe_acheteuse Thirdparty buyer
|
||||
* @param int $idprod Id product
|
||||
* @param int $idprod Id product. O if unknown of NA.
|
||||
* @param int $info_bits Miscellaneous information on line (1 for NPR)
|
||||
* @param int $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
|
||||
* @param int|string $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
|
||||
* Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
|
||||
* Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
|
||||
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
|
||||
@ -4312,10 +4313,10 @@ class Form
|
||||
* Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.
|
||||
* Sinon la TVA proposee par defaut=0. Fin de regle.
|
||||
* @param bool $options_only Return HTML options lines only (for ajax treatment)
|
||||
* @param int $addcode Add code into key in select list
|
||||
* @param int $mode 1=Add code into key in select list
|
||||
* @return string
|
||||
*/
|
||||
function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $addcode=0)
|
||||
function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $mode=0)
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
|
||||
@ -4427,10 +4428,13 @@ class Form
|
||||
// Keep only 0 if seller is not subject to VAT
|
||||
if ($disabled && $rate['txtva'] != 0) continue;
|
||||
|
||||
$return.= '<option value="'.$rate['txtva'];
|
||||
$return.= $rate['nprtva'] ? '*': '';
|
||||
if ($addcode && $rate['code']) $return.=' ('.$rate['code'].')';
|
||||
$return.= '"';
|
||||
// Define key to use into select list
|
||||
$key = $rate['txtva'];
|
||||
$key.= $rate['nprtva'] ? '*': '';
|
||||
if ($mode > 0 && $rate['code']) $key.=' ('.$rate['code'].')';
|
||||
if ($mode < 0) $key = $rate['rowid'];
|
||||
|
||||
$return.= '<option value="'.$key.'"';
|
||||
if (! $selectedfound)
|
||||
{
|
||||
if ($defaultcode) // If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag
|
||||
|
||||
Loading…
Reference in New Issue
Block a user