Fix: Some errors in vat management with multiprice

This commit is contained in:
Laurent Destailleur 2010-07-22 21:16:29 +00:00
parent dbc4f53f7f
commit 2db5b658f1
15 changed files with 109 additions and 102 deletions

View File

@ -701,10 +701,10 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
$prod = new Product($db, $_POST['idprod']);
$prod->fetch($_POST['idprod']);
$tva_tx = get_default_tva($mysoc,$propal->client,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc,$propal->client,$prod->id);
$localtax1_tx= get_localtax($tva_tx, 1, $propal->client); //get_default_localtax($mysoc,$propal->client,1,$prod->id);
$localtax2_tx= get_localtax($tva_tx, 2, $propal->client); //get_default_localtax($mysoc,$propal->client,2,$prod->id);
$tva_npr = get_default_npr($mysoc,$propal->client,$prod->tva_tx);
$tva_npr = get_default_npr($mysoc,$propal->client,$prod->id);
// On defini prix unitaire
if ($conf->global->PRODUIT_MULTIPRICES && $propal->client->price_level)

View File

@ -162,7 +162,7 @@ class Propal extends CommonObject
$productdesc = $prod->description;
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc,$this->client,$prod->id);
// local taxes
$localtax1_tx = get_default_localtax($mysoc,$this->client,1,$prod->tva_tx);
$localtax2_tx = get_default_localtax($mysoc,$this->client,2,$prod->tva_tx);
@ -271,7 +271,7 @@ class Propal extends CommonObject
* \param desc Description de la ligne
* \param pu_ht Prix unitaire
* \param qty Quantite
* \param txtva Taux de tva force, sinon -1
* \param txtva Taux de tva
* \param txlocaltax1 Local tax 1 rate
* \param txlocaltax2 Local tax 2 rate
* \param fk_product Id du produit/service predefini
@ -283,7 +283,7 @@ class Propal extends CommonObject
* \see add_product
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0)

View File

@ -825,7 +825,7 @@ class Commande extends CommonObject
* \see add_product
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0)
@ -962,7 +962,7 @@ class Commande extends CommonObject
$prod=new Product($this->db);
$prod->fetch($idproduct);
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc,$this->client,$prod->id);
$localtax1_tx=get_localtax($tva_tx,1,$this->client);
$localtax2_tx=get_localtax($tva_tx,2,$this->client);
// multiprix

View File

@ -394,7 +394,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
$prod = new Product($db, $_POST['idprod']);
$prod->fetch($_POST['idprod']);
$tva_tx = get_default_tva($mysoc,$commande->client,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc,$commande->client,$prod->id);
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES && $commande->client->price_level)

View File

@ -837,8 +837,8 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
$prod = new Product($db, $_POST['idprod']);
$prod->fetch($_POST['idprod']);
$tva_tx = get_default_tva($mysoc,$fac->client,$prod->tva_tx);
$tva_npr = get_default_npr($mysoc,$fac->client,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc,$fac->client,$prod->id);
$tva_npr = get_default_npr($mysoc,$fac->client,$prod->id);
// We define price for product
if ($conf->global->PRODUIT_MULTIPRICES && $fac->client->price_level)

View File

@ -298,7 +298,7 @@ class Facture extends CommonObject
$prod = new Product($this->db, $_facrec->lignes[$i]->fk_product);
$res=$prod->fetch($_facrec->lignes[$i]->fk_product);
}
$tva_tx = get_default_tva($mysoc,$soc,($prod->tva_tx?$prod->tva_tx:0));
$tva_tx = get_default_tva($mysoc,$soc,$prod->id);
$localtax1_tx=get_localtax($tva_tx,1,$soc);
$localtax2_tx=get_localtax($tva_tx,2,$soc);
@ -1586,7 +1586,7 @@ class Facture extends CommonObject
* \return int >0 if OK, <0 if KO
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0)

View File

@ -227,8 +227,8 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
$prod = new Product($db, $_POST['p_idprod']);
$prod->fetch($_POST['p_idprod']);
$tva_tx = get_default_tva($mysoc,$contrat->client,$prod->tva_tx);
$tva_npr = get_default_npr($mysoc,$contrat->client,$prod->tva_npr);
$tva_tx = get_default_tva($mysoc,$contrat->client,$prod->id);
$tva_npr = get_default_npr($mysoc,$contrat->client,$prod->id);
// On defini prix unitaire
if ($conf->global->PRODUIT_MULTIPRICES && $contrat->client->price_level)
@ -273,7 +273,7 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
$localtax1_tx=get_localtax($tva_tx,1,$contrat->client);
$localtax2_tx=get_localtax($tva_tx,2,$contrat->client);
$info_bits=0;
if ($tva_npr) $info_bits |= 0x01;
@ -326,7 +326,7 @@ if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_PO
if ($date_start_real_update == '') $date_start_real_update=$contratline->date_ouverture;
if ($date_end_real_update == '') $date_end_real_update=$contratline->date_cloture;
$localtax1_tx=get_localtax($_POST["eltva_tx"],1,$contrat->client);
$localtax2_tx=get_localtax($_POST["eltva_tx"],2,$contrat->client);

View File

@ -2210,19 +2210,19 @@ class Form
/**
* \brief Output an HTML select vat rate
* \param name Nom champ html
* \param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
* \param societe_vendeuse Objet societe vendeuse
* \param societe_acheteuse Objet societe acheteuse
* \param taux_produit Taux par defaut du produit vendu
* \param info_bits Miscellanous information on line
* \param name Nom champ html
* \param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
* \param societe_vendeuse Objet societe vendeuse
* \param societe_acheteuse Objet societe acheteuse
* \param idprod Id product
* \param info_bits Miscellanous information on line
* \remarks 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.
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle.
* Sinon la TVA proposee par defaut=0. Fin de regle.
*/
function load_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='', $info_bits=0)
function load_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0)
{
global $langs,$conf,$mysoc;
@ -2302,8 +2302,8 @@ class Form
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || strlen($defaulttx) == 0)
{
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit);
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$taux_produit);
$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

View File

@ -713,7 +713,7 @@ class FactureFournisseur extends Facture
* \param type Type of line (0=product, 1=service)
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,idprod)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0)

View File

@ -151,7 +151,7 @@ if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer
$remise_percent = $_POST["remise_percent"] ? $_POST["remise_percent"] : $_POST["p_remise_percent"];
$tva_tx = get_default_tva($societe,$mysoc,$product->tva_tx,$product->id);
$tva_tx = get_default_tva($societe,$mysoc,$product->id);
$type = $product->type;
$result=$commande->addline(

View File

@ -329,7 +329,7 @@ if ($_GET['action'] == 'addline')
$societe->fetch($facfou->socid);
}
$tvatx=get_default_tva($societe,$mysoc,$product->tva_tx);
$tvatx=get_default_tva($societe,$mysoc,$product->id);
$type = $product->type;
$result=$facfou->addline($label, $product->fourn_pu, $tvatx, $_POST['qty'], $idprod);

View File

@ -2517,7 +2517,7 @@ function get_localtax($tva, $local, $societe_acheteuse="")
}
/**
* \brief Return vat rate of a product in a particular selling country
* Return vat rate of a product in a particular selling country.
* TODO May be this should be better as a method of product class
*/
function get_product_vat_for_country($idprod, $countrycode)
@ -2534,7 +2534,7 @@ function get_product_vat_for_country($idprod, $countrycode)
}
/**
* \brief Return localtax rate of a product in a particular selling country
* Return localtax rate of a product in a particular selling country
* TODO May be this should be better as a method of product class
*/
function get_product_localtax_for_country($idprod, $local, $countrycode)
@ -2560,16 +2560,15 @@ function get_product_localtax_for_country($idprod, $local, $countrycode)
* Sinon TVA proposee par defaut=0. Fin de regle.
* \param societe_vendeuse Objet societe vendeuse
* \param societe_acheteuse Objet societe acheteuse
* \param taux_produit Taux par defaut du produit vendu (old way to get product vat rate)
* \param idprod Id product (new way to get product vat rate)
* \param idprod Id product
* \return float Taux de tva a appliquer, -1 si ne peut etre determine
*/
function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $idprod=0)
function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0)
{
if (!is_object($societe_vendeuse)) return -1;
if (!is_object($societe_acheteuse)) return -1;
dol_syslog("get_default_tva vendeur_assujeti=".$societe_vendeuse->tva_assuj." pays_vendeur=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", pays_acheteur=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", taux_produit(deprecated)=".$taux_produit.", idprod=".$idprod);
dol_syslog("get_default_tva seller use vat=".$societe_vendeuse->tva_assuj." seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod);
// Si vendeur non assujeti a TVA (tva_assuj vaut 0/1 ou franchise/reel)
if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0;
@ -2578,11 +2577,10 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $
// Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
//if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && ($societe_acheteuse->tva_assuj == 1 || $societe_acheteuse->tva_assuj == 'reel'))
// Le test ci-dessus ne devrait pas etre necessaire. Me signaler l'exemple du cas juridique concerne si le test suivant n'est pas suffisant.
if ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id)
if ($societe_vendeuse->pays_code == $societe_acheteuse->pays_code) // Warning ->pays_id not always defined
{
if ($idprod) return get_product_vat_for_country($idprod,$societe_vendeuse->pays_code);
if (strlen($taux_produit) == 0) return -1; // Si taux produit = '', on ne peut determiner taux tva
return $taux_produit;
return -1; // Si produit absent, on ne peut determiner taux tva
}
// Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors 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.
@ -2605,8 +2603,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $
else
{
if ($idprod) return get_product_vat_for_country($idprod,$societe_vendeuse->pays_code);
if (strlen($taux_produit) == 0) return -1; // Si taux produit = '', on ne peut determiner taux tva
return $taux_produit;
return -1; // Si produit absent, on ne peut determiner taux tva
}
}
@ -2626,10 +2623,10 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $
* Sinon TVA proposee par defaut=0. Fin de regle.
* \param societe_vendeuse Objet societe vendeuse
* \param societe_acheteuse Objet societe acheteuse
* \param taux_produit Taux par defaut du produit vendu
* \param idprod Id product
* \return float 0 or 1
*/
function get_default_npr($societe_vendeuse, $societe_acheteuse, $taux_produit)
function get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod)
{
return 0;
}
@ -2638,8 +2635,8 @@ function get_default_npr($societe_vendeuse, $societe_acheteuse, $taux_produit)
* \brief Function that return localtax of a product line (according to seller, buyer and product vat rate)
* \param societe_vendeuse Objet societe vendeuse
* \param societe_acheteuse Objet societe acheteuse
* \param local Localtax a traiter
* \param idprod Id product (way to get product localtax1 rate)
* \param local Localtax to process (1 or 2)
* \param idprod Id product
* \return float Taux de localtax appliquer, -1 si ne peut etre determine
*/
function get_default_localtax($societe_vendeuse, $societe_acheteuse, $local, $idprod=0)

View File

@ -388,25 +388,22 @@ if ($_POST["action"] == 'addinpropal')
}
$desc = $prod->description;
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc, $soc, $prod->id);
$localtax1_tx= get_localtax($tva_tx, 1, $soc);
$localtax2_tx= get_localtax($tva_tx, 2, $soc);
$price_base_type = 'HT';
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
// multiprix
// If multiprice
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
$price_base_type = $prod->multiprices_base_type[$soc->price_level];
}
else
{
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
}
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
@ -473,23 +470,23 @@ if ($_POST["action"] == 'addincommande')
}
$desc = $prod->description;
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc, $soc, $prod->id);
$localtax1_tx= get_localtax($tva_tx, 1, $soc);
$localtax2_tx= get_localtax($tva_tx, 2, $soc);
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
$price_base_type = $prod->multiprices_base_type[$soc->price_level];
}
else
{
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
}
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
// If multiprice
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
$price_base_type = $prod->multiprices_base_type[$soc->price_level];
}
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
@ -557,23 +554,22 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
}
$desc = $prod->description;
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
$tva_tx = get_default_tva($mysoc, $soc, $prod->id);
$localtax1_tx= get_localtax($tva_tx, 1, $soc);
$localtax2_tx= get_localtax($tva_tx, 2, $soc);
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
$price_base_type = $prod->multiprices_base_type[$soc->price_level];
}
else
{
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
}
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
// If multiprice
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
$price_base_type = $prod->multiprices_base_type[$soc->price_level];
}
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).

View File

@ -196,7 +196,13 @@ if($conf->global->PRODUIT_MULTIPRICES)
{
for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{
print '<tr><td>'.$langs->trans("SellingPrice").' '.$i.'</td>';
// TVA
if ($i == 1) // We show only price for level 1
{
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.vatrate($product->multiprices_tva_tx[1],true).'</td></tr>';
}
print '<tr><td>'.$langs->trans("SellingPrice").' '.$i.'</td>';
if ($product->multiprices_base_type["$i"] == 'TTC')
{
@ -228,15 +234,15 @@ if($conf->global->PRODUIT_MULTIPRICES)
print price($product->multiprices_min["$i"]).' '.$langs->trans($product->multiprices_base_type["$i"]);
}
print '</td></tr>';
// TVA
print '<tr><td>'.$langs->trans("VATRate").' '.$i.'</td><td>'.vatrate($product->multiprices_tva_tx["$i"],true).'</td></tr>';
}
}
}
else
{
// Prix
// TVA
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.vatrate($product->tva_tx,true).'</td></tr>';
// Price
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>';
if ($product->price_base_type == 'TTC')
{
@ -248,7 +254,7 @@ else
}
print '</td></tr>';
// Prix mini
// Price minimum
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
if ($product->price_base_type == 'TTC')
{
@ -259,9 +265,6 @@ else
print price($product->price_min).' '.$langs->trans($product->price_base_type);
}
print '</td></tr>';
// TVA
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.vatrate($product->tva_tx,true).'</td></tr>';
}
// Statut
@ -311,6 +314,11 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%">';
// VAT
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,'');
print '</td></tr>';
// Price base
print '<tr><td width="15%">';
print $langs->trans('PriceBase');
@ -335,6 +343,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
}
print '</td></tr>';
// Price minimum
print '<tr><td>' ;
$text=$langs->trans('MinPrice') ;
print $html->textwithpicto($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
@ -348,11 +357,6 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
}
print '</td></tr>';
// VAT
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,'');
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
@ -360,13 +364,27 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
}
else
{
for($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{
print '<form action="price.php?id='.$product->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_price">';
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%">';
// VAT
if ($i == 1)
{
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,'');
print '</td></tr>';
}
else
{ // We always use the vat rate of price level 1 (A vat rate does not depends on customer)
print '<input type="hidden" name="tva_tx_'.$i.'" value="'.$product->multiprices_tva_tx[1].'">';
}
// Selling price
print '<tr><td width="20%">';
$text=$langs->trans('SellingPrice').' '.$i;
print $html->textwithpicto($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
@ -382,6 +400,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
print $html->select_PriceBaseType($product->multiprices_base_type["$i"], "multiprices_base_type_".$i);
print '</td></tr>';
// Min price
print '<tr><td>';
$text=$langs->trans('MinPrice').' '.$i;
print $html->textwithpicto($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
@ -395,11 +414,6 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user->
}
print '</td></tr>';
// VAT
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,'');
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';

View File

@ -209,14 +209,14 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
if ( $soc->client == 1 )
{
Header("Location: comm/fiche.php?socid=".$soc->id);
Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id);
return;
}
else
{
if ( $soc->fournisseur == 1 )
{
Header("Location: fourn/fiche.php?socid=".$soc->id);
Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id);
return;
}
else