NEW Level multiprice generator based on per cent variations over base price

This commit is contained in:
Marcos García de La Fuente 2015-10-19 15:13:19 +02:00
parent bbbd5f5202
commit e7e152c122
10 changed files with 411 additions and 46 deletions

View File

@ -3,6 +3,7 @@
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2009-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -166,6 +167,15 @@ function product_admin_prepare_head()
$head[$h][2] = 'general';
$h++;
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
$head[$h] = array(
0 => DOL_URL_ROOT."/product/admin/price_rules.php",
1 => $langs->trans('MultipriceRules'),
2 => 'generator'
);
$h++;
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

View File

@ -67,6 +67,14 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128);
ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128);
ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30);
CREATE TABLE llx_product_pricerules
(
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
level INT NOT NULL, -- Which price level is this rule for?
fk_level INT NOT NULL, -- Price variations are made over price of X
var_percent FLOAT NOT NULL, -- Price variation over based price
var_min_percent FLOAT NOT NULL -- Min price discount over general price
);
ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(10000);
@ -94,3 +102,4 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath);
ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy;
ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0;

View File

@ -46,7 +46,7 @@ create table llx_product
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double(6,3), -- Default VAT rate of product
recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT
localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1
localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1
localtax2_tx double(6,3) DEFAULT 0, -- Spanish local VAT 2
fk_user_author integer DEFAULT NULL, -- user making creation
fk_user_modif integer, -- user making last change
@ -81,5 +81,6 @@ create table llx_product
import_key varchar(14), -- Import key
fk_price_expression integer, -- Link to the rule for dynamic price calculation
desiredstock integer DEFAULT 0,
fk_unit integer DEFAULT NULL
fk_unit integer DEFAULT NULL,
price_autogen TINYINT DEFAULT 0
)ENGINE=innodb;

View File

@ -0,0 +1,19 @@
-- ============================================================================
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ===========================================================================
ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level);

View File

@ -0,0 +1,26 @@
-- ============================================================================
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ===========================================================================
CREATE TABLE llx_product_pricerules
(
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
level INT NOT NULL, -- Which price level is this rule for?
fk_level INT NOT NULL, -- Price variations are made over price of X
var_percent FLOAT NOT NULL, -- Price variation over based price
var_min_percent FLOAT NOT NULL -- Min price discount over general price
);

View File

@ -173,6 +173,7 @@ ErrorFieldMustBeAnInteger=Field <b>%s</b> must be an integer
ErrorMandatoryParametersNotProvided=Mandatory parameter(s) not provided
ErrorOppStatusRequiredIfAmount=You set an estimated amount for this opportunity/lead. So you must also enter its status
ErrorBadDefinitionOfMenuArrayInModuleDescriptor=Bad Definition Of Menu Array In Module Descriptor (bad value for key fk_menu)
ErrorSavingChanges=An error has ocurred when saving the changes
# Warnings
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.

View File

@ -232,6 +232,10 @@ PriceByQuantityRange=Quantity range
ProductsDashboard=Products/Services summary
UpdateOriginalProductLabel=Modify original label
HelpUpdateOriginalProductLabel=Allows to edit the name of the product
MultipriceRules=Price level rules
UseMultipriceRules=Use price level rules
PercentVariationOver=%% variation over %s
PercentDiscountOver=%% discount over %s
### composition fabrication
Building=Production and items dispatchment
Build=Produce

View File

@ -0,0 +1,196 @@
<?php
/*
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$langs->load("admin");
$langs->load("products");
// Security check
if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled)))
accessforbidden();
/**
* Actions
*/
if ($_POST) {
$var_percent = GETPOST('var_percent', 'array');
$var_min_percent = GETPOST('var_min_percent', 'array');
$fk_level = GETPOST('fk_level', 'array');
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$check = isset($var_min_percent[$i]);
if ($i != 1) {
$check = $check && isset($var_percent[$i]) && isset($fk_level[$i]);
}
if (!$check) {
continue;
}
if ($i != 1) {
$i_var_percent = (float) price2num($var_percent[$i]);
} else {
$i_var_percent = 0;
}
$i_var_min_percent = (float) price2num($var_min_percent[$i]);
$i_fk_level = (int) $fk_level[$i];
if ($i == 1) {
$check1 = true;
$check2 = $i_var_min_percent;
} else {
$check1 = $i_fk_level >= 1 && $i_fk_level <= $conf->global->PRODUIT_MULTIPRICES_LIMIT;
$check2 = $i_var_percent && $i_var_min_percent;
}
if (!$check1 || !$check2) {
//If the level is between range but percent fields are empty, then we ensure it does not exist in DB
if ($check1 && !$check2) {
$db->query("DELETE FROM ".MAIN_DB_PREFIX."product_pricerules WHERE level = ".(int)$i);
}
continue;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_pricerules
SET level = ".(int) $i.", fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent;
if (!$db->query($sql)) {
//If we could not create, then we try updating
$sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules
SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".$i;
if (!$db->query($sql)) {
setEventMessage($langs->trans('ErrorSavingChanges'), 'errors');
}
}
}
setEventMessage($langs->trans("RecordSaved"));
}
/*
* View
*/
$sql = "SELECT * FROM ".MAIN_DB_PREFIX."product_pricerules";
$query = $db->query($sql);
$rules = array();
while ($result = $db->fetch_object($query)) {
$rules[$result->level] = $result;
}
$title = $langs->trans('ProductServiceSetup');
$tab = $langs->trans("ProductsAndServices");
if (empty($conf->produit->enabled)) {
$title = $langs->trans('ServiceSetup');
$tab = $langs->trans('Services');
} elseif (empty($conf->service->enabled)) {
$title = $langs->trans('ProductSetup');
$tab = $langs->trans('Products');
}
llxHeader('', $langs->trans('MultipriceRules'));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($title,$linkback,'title_setup');
$head = product_admin_prepare_head();
dol_fiche_head($head, 'generator', $tab, 0, 'product');
print load_fiche_titre($langs->trans('MultipriceRules'));
//Array that contains the number of prices available
$price_options = array();
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$price_options[$i] = $langs->trans('SellingPrice').' '.$i;
}
$genPriceOptions = function($level) use ($price_options) {
$return = array();
for ($i = 1; $i < $level; $i++) {
$return[$i] = $price_options[$i];
}
return $return;
};
?>
<form method="post">
<table class="noborder">
<tr class="liste_titre">
<td style="text-align: center"><?php echo $langs->trans('PriceLevel') ?></td>
<td style="text-align: center"><?php echo $langs->trans('Price') ?></td>
<td style="text-align: center"><?php echo $langs->trans('MinPrice') ?></td></tr>
<tr>
<td class="fieldrequired" style="text-align: center"><?php echo $langs->trans('SellingPrice') ?> 1</td>
<td></td>
<td style="text-align: center"><input type="text" style="text-align: right" name="var_min_percent[1]" size="5" value="<?php echo isset($rules[1]) ? price($rules[1]->var_min_percent, 2) : '' ?>"> <?php echo $langs->trans('PercentDiscountOver', $langs->trans('SellingPrice').' 1') ?></td>
</tr>
<?php for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++): ?>
<tr>
<td class="fieldrequired" style="text-align: center"><?php
echo $langs->trans('SellingPrice').' '.$i;
// Label of price
if (! empty($conf->global->{"PRODUIT_MULTIPRICES_LABEL$i"})) {
print ' - '.$langs->trans($conf->global->$keyforlabel);
}
?>
</td>
<td style="text-align: center">
<input type="text" style="text-align: right" name="var_percent[<?php echo $i ?>]" size="5" value="<?php echo isset($rules[$i]) ? price($rules[$i]->var_percent, 2) : '' ?>">
<?php echo $langs->trans('PercentVariationOver', Form::selectarray("fk_level[$i]", $genPriceOptions($i), (isset($rules[$i]) ? $rules[$i]->fk_level : null))) ?>
</td>
<td style="text-align: center">
<input type="text" style="text-align: right" name="var_min_percent[<?php echo $i ?>]" size="5" value="<?php echo isset($rules[$i]) ? price($rules[$i]->var_min_percent, 2) : '' ?>">
<?php echo $langs->trans('PercentDiscountOver', $langs->trans('SellingPrice').' '.$i) ?>
</td>
</tr>
<?php endfor ?>
</table>
<br>
<div style="text-align: center">
<input type="submit" value="<?php echo $langs->trans('Save') ?>" class="button">
</div>
</form>
<?php
llxFooter();

View File

@ -191,6 +191,12 @@ class Product extends CommonObject
*/
public $fk_unit;
/**
* Price is generated using multiprice rules
* @var int
*/
public $price_autogen = 0;
/**
* Regular product
*/
@ -710,6 +716,7 @@ class Product extends CommonObject
$sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'";
$sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null");
$sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1);
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -1337,9 +1344,10 @@ class Product extends CommonObject
* @param int $level 0=standard, >0 = level if multilevel prices
* @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT
* @param int $newpsq 1 if it has price by quantity
* @param int $ignore_autogen Used to avoid infinite loops
* @return int <0 if KO, >0 if OK
*/
function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0)
function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0, $ignore_autogen = 0)
{
global $conf,$langs;
@ -1353,6 +1361,12 @@ class Product extends CommonObject
// Check parameters
if ($newvat == '') $newvat=$this->tva_tx;
//If multiprices are enabled, then we check if the current product is subject to price autogeneration
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen) {
return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpsq);
}
if (! empty($newminprice) && ($newminprice > $newprice))
{
$this->error='ErrorPriceCantBeLowerThanMinPrice';
@ -1531,7 +1545,7 @@ class Product extends CommonObject
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
$sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit";
$sql.= " , fk_price_expression";
$sql.= " , fk_price_expression, price_autogen";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
if ($id) $sql.= " WHERE rowid = ".$this->db->escape($id);
else
@ -1608,6 +1622,7 @@ class Product extends CommonObject
$this->ref_ext = $obj->ref_ext;
$this->fk_price_expression = $obj->fk_price_expression;
$this->fk_unit = $obj->fk_unit;
$this->price_autogen = $obj->price_autogen;
$this->db->free($resql);
@ -3992,4 +4007,64 @@ class Product extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
/**
* Generates prices for a product based on product multiprice generation rules
*
* @param User $user User that updates the prices
* @param float $baseprice Base price
* @param string $price_type Base price type
* @param float $price_vat VAT % tax
* @param int $npr NPR
* @param string $psq ¿?
* @return int -1 KO, 1 OK
*/
public function generateMultiprices(User $user, $baseprice, $price_type, $price_vat, $npr, $psq)
{
global $conf, $db;
$sql = "SELECT * FROM ".MAIN_DB_PREFIX."product_pricerules";
$query = $db->query($sql);
$rules = array();
while ($result = $db->fetch_object($query)) {
$rules[$result->level] = $result;
}
//Because prices can be based on other level's prices, we temporarily store them
$prices = array(
1 => $baseprice
);
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$price = $baseprice;
$price_min = 0;
if ($i > 1) {
//We have to make sure it does exist and it is > 0
if (isset($rules[$i]->var_percent) && $rules[$i]->var_percent) {
$price = $prices[$rules[$i]->fk_level] * (1 + ($rules[$i]->var_percent/100));
}
}
$prices[$i] = $price;
//We have to make sure it does exist and it is > 0
if (isset($rules[$i]->var_min_percent) && $rules[$i]->var_min_percent) {
$price_min = $price * (1 - ($rules[$i]->var_min_percent/100));
}
if ($price == $this->multiprices[$i] && ($price_min == $this->multiprices_min[$i])) {
continue;
}
if ($this->updatePrice($price, $price_type, $user, $price_vat, $price_min, $i, $npr, $psq, true) < 0) {
return -1;
}
}
return 1;
}
}

View File

@ -82,39 +82,37 @@ $parameters=array('id'=>$id, 'ref'=>$ref);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if ($action == 'update_price' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer))
{
if (empty($reshook)) {
if ($action == 'update_price' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
$maxpricesupplier = $object->min_recommended_price();
$object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression
// MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
if (isset($_POST ["price_" . $i]))
{
//Shall we generate prices using price rules?
$object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false;
$object->update($object->id, $user);
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
if (isset($_POST ["price_".$i])) {
$level = $i;
$newprice = price2num($_POST ["price_" . $i], 'MU');
$newprice_min = price2num($_POST ["price_min_" . $i], 'MU');
$newpricebase = $_POST ["multiprices_base_type_" . $i];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx_" . $i]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx_" . $i]);
$newprice = price2num($_POST ["price_".$i], 'MU');
$newprice_min = price2num($_POST ["price_min_".$i], 'MU');
$newpricebase = $_POST ["multiprices_base_type_".$i];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx_".$i]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx_".$i]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
break; // We found submited price
}
}
}
else
{
} else {
$level = 0;
$newprice = price2num($_POST ["price"], 'MU');
$newprice_min = price2num($_POST ["price_min"], 'MU');
@ -125,42 +123,39 @@ if (empty($reshook))
$newpsq = empty($newpsq) ? 0 : $newpsq;
}
if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier)
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='edit_price';
if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) {
setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors');
$error ++;
$action = 'edit_price';
}
if ($newprice < $newprice_min && ! empty($object->fk_price_expression))
{
if ($newprice < $newprice_min && !empty($object->fk_price_expression)) {
$newprice = $newprice_min; //Set price same as min, the user will not see the
}
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0)
{
$res = $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq);
if ($res) {
if ($object->fk_price_expression != 0) {
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
$price_result = $priceparser->parseProduct($object);
if ($price_result < 0) { //Expression is not valid
$error++;
$action='edit_price';
$error ++;
$action = 'edit_price';
setEventMessage($priceparser->translatedError(), 'errors');
}
}
if (empty($error) && ! empty($conf->dynamicprices->enabled))
{
$ret=$object->setPriceExpression($object->fk_price_expression);
if ($ret < 0)
{
$error++;
$action='edit_price';
if (empty($error) && !empty($conf->dynamicprices->enabled)) {
$ret = $object->setPriceExpression($object->fk_price_expression);
if ($ret < 0) {
$error ++;
$action = 'edit_price';
setEventMessage($object->error, 'errors');
}
}
if (empty($error))
{
if (empty($error)) {
$action = '';
setEventMessage($langs->trans("RecordSaved"));
}
@ -170,6 +165,7 @@ if (empty($reshook))
}
}
if ($action == 'delete' && $user->rights->produit->supprimer)
{
$result = $object->log_price_delete($user, $_GET ["lineid"]);
@ -785,6 +781,33 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
}
else
{
?>
<script>
var showHidePriceRules = function () {
var otherPrices = $('div.fiche form:not(:first)');
var minPrice1 = $('div.fiche form:first tr:eq(3)');
console.log('e');
if (jQuery('input#usePriceRules').prop('checked')) {
otherPrices.hide();
minPrice1.hide();
} else {
otherPrices.show();
minPrice1.show();
}
};
jQuery(document).ready(function () {
showHidePriceRules();
jQuery('input#usePriceRules').click(showHidePriceRules);
});
</script>
<?php
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
@ -798,6 +821,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
// VAT
if ($i == 1) {
print '<tr><td>' . $langs->trans('UseMultipriceRules'). '</td><td><input type="checkbox" id="usePriceRules" name="usePriceRules" '.($object->price_autogen ? 'checked' : '').'></td></tr>';
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx ["$i"], $mysoc, '', $object->id);
print '</td></tr>';