diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql
index 80e3f90b828..83e8882caa7 100644
--- a/htdocs/install/mysql/tables/llx_product.sql
+++ b/htdocs/install/mysql/tables/llx_product.sql
@@ -40,8 +40,8 @@ create table llx_product
customcode varchar(32), -- Optionnal custom code
fk_country integer DEFAULT NULL, -- Optionnal id of original country
fk_state integer DEFAULT NULL, -- Optionnal id of original state/province
- price double(24,8) DEFAULT 0,
- price_ttc double(24,8) DEFAULT 0,
+ price double(24,8) DEFAULT 0, -- price without tax
+ price_ttc double(24,8) DEFAULT 0, -- price inc vat (but not localtax1 nor localtax2)
price_min double(24,8) DEFAULT 0,
price_min_ttc double(24,8) DEFAULT 0,
price_base_type varchar(3) DEFAULT 'HT',
diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql
index 77a00939428..2a64fc92c30 100644
--- a/htdocs/install/mysql/tables/llx_product_price.sql
+++ b/htdocs/install/mysql/tables/llx_product_price.sql
@@ -29,8 +29,8 @@ create table llx_product_price
fk_product integer NOT NULL,
date_price datetime NOT NULL,
price_level smallint NULL DEFAULT 1,
- price double(24,8) DEFAULT NULL,
- price_ttc double(24,8) DEFAULT NULL,
+ price double(24,8) DEFAULT NULL, -- price without tax
+ price_ttc double(24,8) DEFAULT NULL, -- price inc vat (but not localtax1 nor localtax2)
price_min double(24,8) default NULL,
price_min_ttc double(24,8) default NULL,
price_base_type varchar(3) DEFAULT 'HT',
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index 47322e2c692..02a9c0bb712 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -1602,6 +1602,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
}
$sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
// $sql .= $db->plimit();
+ //print $sql;
$result = $db->query($sql);
if ($result) {
@@ -1640,8 +1641,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png');
}
- print '
';
- print '
';
+ print ''."\n";
+ print ''."\n";
+ print '
'."\n";
print '';
print ''.$langs->trans("AppliedPricesFrom").' ';
@@ -1659,6 +1661,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
}
print ''.$langs->trans("HT").' ';
print ''.$langs->trans("TTC").' ';
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
+ print ''.$langs->trans("INCT").' ';
+ }
if (!empty($conf->dynamicprices->enabled)) {
print ''.$langs->trans("PriceExpressionSelected").' ';
}
@@ -1725,6 +1730,24 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
print "";
}
+ // Line for default price
+ if ($object->price_base_type == 'HT') {
+ $pu = $objp->price;
+ } else {
+ $pu = $objp->price_ttc;
+ }
+
+ // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code.
+ $localtaxarray = getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc);
+ // Define part of HT, VAT, TTC
+ $resultarray = calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly, $object->type, $mysoc, $localtaxarray);
+ // Calcul du total ht sans remise
+ $total_ht = $resultarray[0];
+ $total_vat = $resultarray[1];
+ $total_localtax1 = $resultarray[9];
+ $total_localtax2 = $resultarray[10];
+ $total_ttc = $resultarray[2];
+
// Price
if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) {
$price_expression = new PriceExpression($db);
@@ -1732,32 +1755,46 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
$title = $price_expression->title;
print ' ';
print ' ';
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
+ print ' ';
+ }
print ''.$title." ";
} else {
+ // Price HT
print '';
if (empty($objp->price_by_qty)) {
print price($objp->price);
}
print " ";
+ // Price TTC
print '';
if (empty($objp->price_by_qty)) {
- print price($objp->price_ttc);
+ $price_ttc = $objp->price_ttc;
+ print price($price_ttc);
}
print " ";
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
+ print '';
+ print $resultarray[2];
+ print ' ';
+ }
if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled
print ' ';
}
}
+ // Price min
print '';
if (empty($objp->price_by_qty)) {
print price($objp->price_min);
}
print ' ';
+ // Price min inc tax
print '';
if (empty($objp->price_by_qty)) {
- print price($objp->price_min_ttc);
+ $price_min_ttc = $objp->price_min_ttc;
+ print price($price_min_ttc);
}
print ' ';
@@ -2154,12 +2191,15 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print ' ';
print ' ';
- print '';
- print '
';
+ print ''."\n";
+ print ''."\n";
+ print '
'."\n";
if (count($prodcustprice->lines) > 0 || $search_soc) {
$colspan = 9;
- //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++;
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
+ $colspan++;
+ }
print '';
print ' ';
@@ -2179,13 +2219,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print ''.$langs->trans("PriceBase").' ';
print ''.$langs->trans("DefaultTaxRate").' ';
print ''.$langs->trans("HT").' ';
+ print ''.$langs->trans("TTC").' ';
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
- //print '' . $langs->trans("INCVATONLY") . ' ';
print ''.$langs->trans("INCT").' ';
- } else {
- print ''.$langs->trans("TTC").' ';
}
-
print ''.$langs->trans("MinPrice").' '.$langs->trans("HT").' ';
print ''.$langs->trans("MinPrice").' '.$langs->trans("TTC").' ';
print ''.$langs->trans("ChangedBy").' ';
@@ -2199,7 +2236,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$pu = $object->price_ttc;
}
- // Local tax is not saved into table of product. We use value linked to VAT code.
+ // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code.
$localtaxarray = getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc);
// Define part of HT, VAT, TTC
$resultarray = calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray);
@@ -2237,14 +2274,12 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print ''.price($object->price)." ";
+ print ''.price($object->price_ttc)." ";
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
//print '' . price($object->price_ttc) . " ";
print ''.price($resultarray[2]).' ';
- } else {
- print ''.price($object->price_ttc)." ";
}
-
print ''.price($object->price_min).' ';
print ''.price($object->price_min_ttc).' ';
print '';