| ';
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 6c311224ba0..d1607912c1d 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1502,7 +1502,7 @@ if (empty($reshook))
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
- // Ecrase $txtva par celui du produit
+ // Ecrase $tva_tx par celui du produit
// Ecrase $base_price_type par celui du produit
// Replaces $fk_unit with the product's
if (! empty($idprod))
@@ -1513,102 +1513,105 @@ if (empty($reshook))
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
// Update if prices fields are defined
- $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
- $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
- if (empty($tva_tx)) $tva_npr=0;
+ $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
+ $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
+ if (empty($tva_tx)) $tva_npr=0;
- $pu_ht = $prod->price;
- $pu_ttc = $prod->price_ttc;
- $price_min = $prod->price_min;
- $price_base_type = $prod->price_base_type;
+ $pu_ht = $prod->price;
+ $pu_ttc = $prod->price_ttc;
+ $price_min = $prod->price_min;
+ $price_base_type = $prod->price_base_type;
- // We define price for product
- if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
+ // We define price for product
+ if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
+ {
+ $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
+ $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
+ $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
+ $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
+ if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
{
- $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
- $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
- $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
- $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
- if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
- {
- if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
- if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
- if (empty($tva_tx)) $tva_npr=0;
+ if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
+ if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
+ if (empty($tva_tx)) $tva_npr=0;
+ }
+ }
+ elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+ {
+ require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
+
+ $prodcustprice = new Productcustomerprice($db);
+
+ $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
+
+ $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
+ if ($result) {
+ if (count($prodcustprice->lines) > 0) {
+ $pu_ht = price($prodcustprice->lines[0]->price);
+ $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
+ $price_base_type = $prodcustprice->lines[0]->price_base_type;
+ $tva_tx = $prodcustprice->lines[0]->tva_tx;
}
}
- elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+ }
+
+ $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
+ $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
+
+ // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
+ if (! empty($price_ht))
+ {
+ $pu_ht = price2num($price_ht, 'MU');
+ $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
+ }
+ // 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).
+ elseif ($tmpvat != $tmpprodvat)
+ {
+ if ($price_base_type != 'HT')
{
- require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
-
- $prodcustprice = new Productcustomerprice($db);
-
- $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
-
- $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
- if ($result) {
- if (count($prodcustprice->lines) > 0) {
- $pu_ht = price($prodcustprice->lines[0]->price);
- $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
- $price_base_type = $prodcustprice->lines[0]->price_base_type;
- $tva_tx = $prodcustprice->lines[0]->tva_tx;
- }
- }
+ $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
}
-
- // if price ht was forced (ie: from gui when calculated by margin rate and cost price)
- if (! empty($price_ht))
+ else
{
- $pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
+ $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
}
- // 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).
- elseif ($tva_tx != $prod->tva_tx)
- {
- if ($price_base_type != 'HT')
- {
- $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU');
- }
- else
- {
- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
- }
+ }
+
+ $desc = '';
+
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
+ $outputlangs = $langs;
+ $newlang = '';
+ if (empty($newlang) && GETPOST('lang_id'))
+ $newlang = GETPOST('lang_id');
+ if (empty($newlang))
+ $newlang = $object->thirdparty->default_lang;
+ if (! empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
}
- $desc = '';
+ $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
+ } else {
+ $desc = $prod->description;
+ }
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
- $outputlangs = $langs;
- $newlang = '';
- if (empty($newlang) && GETPOST('lang_id'))
- $newlang = GETPOST('lang_id');
- if (empty($newlang))
- $newlang = $object->thirdparty->default_lang;
- if (! empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- }
+ $desc = dol_concatdesc($desc, $product_desc);
- $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
- } else {
- $desc = $prod->description;
- }
-
- $desc = dol_concatdesc($desc, $product_desc);
-
- // Add custom code and origin country into description
- if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) {
- $tmptxt = '(';
- if (! empty($prod->customcode))
- $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
- if (! empty($prod->customcode) && ! empty($prod->country_code))
- $tmptxt .= ' - ';
- if (! empty($prod->country_code))
- $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
- $tmptxt .= ')';
- $desc = dol_concatdesc($desc, $tmptxt);
- }
+ // Add custom code and origin country into description
+ if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) {
+ $tmptxt = '(';
+ if (! empty($prod->customcode))
+ $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
+ if (! empty($prod->customcode) && ! empty($prod->country_code))
+ $tmptxt .= ' - ';
+ if (! empty($prod->country_code))
+ $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
+ $tmptxt .= ')';
+ $desc = dol_concatdesc($desc, $tmptxt);
+ }
$type = $prod->type;
$fk_unit = $prod->fk_unit;
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 41fe096d974..c858a2cda1f 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -456,7 +456,7 @@ if (empty($reshook))
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
- // Ecrase $txtva par celui du produit
+ // Ecrase $tva_tx par celui du produit
// Ecrase $base_price_type par celui du produit
// Replaces $fk_unit with the product's
if (! empty($idprod))
@@ -511,23 +511,26 @@ if (empty($reshook))
}
}
- // if price ht was forced (ie: from gui when calculated by margin rate and cost price)
+ $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
+ $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
+
+ // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
if (! empty($price_ht))
{
$pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
+ $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
}
// 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).
- elseif ($tva_tx != $prod->tva_tx)
+ elseif ($tmpvat != $tmpprodvat)
{
if ($price_base_type != 'HT')
{
- $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU');
+ $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
}
else
{
- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
+ $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
}
}
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index bc32d090f84..d7489b8aca0 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1594,7 +1594,7 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
// $XML_DEBITOR .=' '.($row_facnumber.'/'.$Rowing.'/'.$Rum).''.$CrLf;
- $XML_DEBITOR .=' '.$row_facnumber.''.$CrLf;
+ $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).''.$CrLf; // 140 max
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
return $XML_DEBITOR;
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 1b72b794c1f..f95a60ab130 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -407,21 +407,21 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef='';
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
+ $price_ht = GETPOST('price_ht');
+ $price_ht_devise = GETPOST('multicurrency_price_ht');
if (GETPOST('prod_entry_mode') == 'free')
{
$idprod=0;
- $price_ht = GETPOST('price_ht');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
}
else
{
$idprod=GETPOST('idprod', 'int');
- $price_ht = '';
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
- $remise_percent=GETPOST('remise_percent'.$predef);
+ $remise_percent = GETPOST('remise_percent'.$predef);
if ($qty == '')
{
@@ -455,13 +455,14 @@ if (empty($reshook))
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
- // Ecrase $txtva par celui du produit
+ // Ecrase $tva_tx par celui du produit
// Ecrase $base_price_type par celui du produit
if ($idprod > 0)
{
$prod = new Product($db);
$prod->fetch($idprod);
+ // Update if prices fields are defined
$tva_tx = get_default_tva($mysoc,$object->thirdparty,$prod->id);
$tva_npr = get_default_npr($mysoc,$object->thirdparty,$prod->id);
if (empty($tva_tx)) $tva_npr=0;
@@ -498,17 +499,20 @@ if (empty($reshook))
}
}
- // On reevalue prix selon taux tva car taux tva transaction peut etre different
+ $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
+ $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
+
+ // 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).
- if ($tva_tx != $prod->tva_tx)
+ if ($tmpvat != $tmpprodvat)
{
if ($price_base_type != 'HT')
{
- $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU');
+ $pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU');
}
else
{
- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU');
+ $pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU');
}
}
@@ -626,7 +630,7 @@ if (empty($reshook))
}
}
- else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST('cancel'))
+ else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel'))
{
$objectline = new ContratLigne($db);
if ($objectline->fetch(GETPOST('elrowid')))
@@ -636,9 +640,27 @@ if (empty($reshook))
if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture;
if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture;
- $localtax1_tx=get_localtax(GETPOST('eltva_tx'),1,$object->thirdparty);
- $localtax2_tx=get_localtax(GETPOST('eltva_tx'),2,$object->thirdparty);
-
+ $vat_rate = GETPOST('eltva_tx');
+ // Define info_bits
+ $info_bits = 0;
+ if (preg_match('/\*/', $vat_rate))
+ $info_bits |= 0x01;
+
+ // Define vat_rate
+ $vat_rate = str_replace('*', '', $vat_rate);
+ $localtax1_tx=get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
+ $localtax2_tx=get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
+
+ $txtva = $vat_rate;
+
+ // Clean vat code
+ $vat_src_code='';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
+
// ajout prix d'achat
$fk_fournprice = $_POST['fournprice'];
if ( ! empty($_POST['buying_price']) )
@@ -653,7 +675,8 @@ if (empty($reshook))
$objectline->subprice=GETPOST('elprice');
$objectline->qty=GETPOST('elqty');
$objectline->remise_percent=GETPOST('elremise_percent');
- $objectline->tva_tx=GETPOST('eltva_tx')?GETPOST('eltva_tx'):0; // Field may be disabled, so we use vat rate 0
+ $objectline->tva_tx=($txtva?$txtva:0); // Field may be disabled, so we use vat rate 0
+ $objectline->vat_src_code=$vat_src_code;
$objectline->localtax1_tx=is_numeric($localtax1_tx)?$localtax1_tx:0;
$objectline->localtax2_tx=is_numeric($localtax2_tx)?$localtax2_tx:0;
$objectline->date_ouverture_prevue=$date_start_update;
@@ -1444,7 +1467,7 @@ else
{
print ' |