diff --git a/ChangeLog b/ChangeLog
index 82c2b13c337..a7e647fcc99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,10 +43,11 @@ For users:
- New: [ task #498 ] Improvement of the block to add products/services lines.
- New: ECM autodir works also for files joined to products and services.
- New: Add a selection module for emailing to enter a recipient from gui.
+- New: Allow to search product from barcodes directly from the permanent mini search left box
+- New: Allow to search product from barcodes directly from invoices, proposals... through AJAX
New experimental modules:
- New: Add margin and commissions management module.
- New: Add holiday module.
-- New: Allow to search product from barcodes directly from the permanent mini search left box
- Fix: [ bug #499 ]: Supplier order input method not translated
- Fix: No images into product description lines as PDF generation does
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index c859e80e553..346d316b5d3 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -373,17 +373,19 @@ elseif ($action == 'edit')
print '
'.$langs->trans('MenuModule').' '.$menu->module.' '.$langs->trans('DetailMenuModule').' ';
// Handler
- print ''.$langs->trans('MenuHandler').' '.$menu->menu_handler.' '.$langs->trans('DetailMenuHandler').' ';
+ if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus');
+ else $handler = $menu->menu_handler;
+ print ''.$langs->trans('MenuHandler').' '.$handler.' '.$langs->trans('DetailMenuHandler').' ';
// User
print ''.$langs->trans('MenuForUsers').' ';
- print 'user==2?' selected="true"':'').'>'.$langs->trans("All").' ';
- print 'user==0?' selected="true"':'').'>'.$langs->trans('Interne').' ';
- print 'user==1?' selected="true"':'').'>'.$langs->trans('Externe').' ';
+ print 'user==2?' selected="true"':'').'>'.$langs->trans("AllMenus").' ';
+ print 'user==0?' selected="true"':'').'>'.$langs->trans('Internal').' ';
+ print 'user==1?' selected="true"':'').'>'.$langs->trans('External').' ';
print ' '.$langs->trans('DetailUser').' ';
// Type
- print ''.$langs->trans('Type').' '.$menu->type.' '.$langs->trans('DetailType').' ';
+ print ''.$langs->trans('Type').' '.$langs->trans(ucfirst($menu->type)).' '.$langs->trans('DetailType').' ';
// MenuId Parent
print ''.$langs->trans('MenuIdParent').' ';
diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index e1174df4f2b..501e7d6968e 100755
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -269,7 +269,9 @@ else // Show
if ($resql)
{
$obj=$db->fetch_object($resql);
- $pdfformatlabel=$obj->label.' - '.round($obj->width).'x'.round($obj->height).' '.$obj->unit;
+ $paperKey = $langs->trans('PaperFormat'.$obj->code);
+ $unitKey = $langs->trans('SizeUnit'.$obj->unit);
+ $pdfformatlabel = ($paperKey == 'PaperFormat'.$obj->code ? $obj->label : $paperKey).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
}
}
print $pdfformatlabel;
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index d14eadca5b5..dbf3bd849cb 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -110,6 +110,8 @@ class Facture extends CommonInvoice
var $nbtodolate;
var $specimen;
+ var $fac_rec;
+
/**
* Constructor
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 1901ff59652..4af811aeb7c 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -12,6 +12,7 @@
* Copyright (C) 2010 Juanjo Menent
* Copyright (C) 2010 Philippe Grand
* Copyright (C) 2011 Herve Prot
+ * Copyright (C) 2012 Marcos García
*
* 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
@@ -1196,6 +1197,11 @@ class Form
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '%".$filterkey."%'";
$sql.=")";
}
+
+ if (! empty($conf->barcode->enabled))
+ {
+ $sql .= " OR p.barcode LIKE '".$filterkey."'";
+ }
}
$sql.= $db->order("p.ref");
$sql.= $db->plimit($limit);
@@ -1441,6 +1447,11 @@ class Form
{
$sql.=" AND (pfp.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')";
}
+
+ if (! empty($conf->barcode->enabled))
+ {
+ $sql .= " OR p.barcode LIKE '".$filterkey."'";
+ }
}
$sql.= " ORDER BY pfp.ref_fourn DESC";
diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php
index e91c47fbb10..f3af3b8a010 100644
--- a/htdocs/core/class/html.formadmin.class.php
+++ b/htdocs/core/class/html.formadmin.class.php
@@ -339,7 +339,9 @@ class FormAdmin
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
- $paperformat[$obj->code]= $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.$obj->unit;
+ $unitKey = $langs->trans('SizeUnit'.$obj->unit);
+
+ $paperformat[$obj->code]= $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
$i++;
}
diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php
index f241182b465..8e7d951514c 100644
--- a/htdocs/core/lib/price.lib.php
+++ b/htdocs/core/lib/price.lib.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2002-2006 Rodolphe Quiedeville
* Copyright (C) 2006-2008 Laurent Destailleur
* Copyright (C) 2010 Juanjo Menent
+ * Copyright (C) 2012 Christophe Battarel
*
* 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
@@ -19,109 +20,194 @@
/**
* \file htdocs/core/lib/price.lib.php
- * \brief Librairie contenant les fonctions pour calculer un prix.
+ * \brief Library with functions to calculate prices
*/
/**
* Calculate totals (net, vat, ...) of a line.
+ * Value for localtaxX_type are '0' : local tax not applied
+ * '1' : local tax apply on products and services without vat (vat is not applied on local tax)
+ * '2' : local tax apply on products and services before vat (vat is calculated on amount + localtax)
+ * '3' : local tax apply on products without vat (vat is not applied on local tax)
+ * '4' : local tax apply on products before vat (vat is calculated on amount + localtax)
+ * '5' : local tax apply on services without vat (vat is not applied on local tax)
+ * '6' : local tax apply on services before vat (vat is calculated on amount + localtax)
+ * '7' : local tax is a fix amount applied on global invoice
*
* @param int $qty Quantity
- * @param float $pu Unit price (HT or TTC selon price_base_type)
- * @param float $remise_percent_ligne Discount for line
- * @param float $txtva Vat rate
- * @param float $txlocaltax1 Localtax1 rate (used for some countries only, like spain)
- * @param float $txlocaltax2 Localtax2 rate (used for some countries only, like spain)
+ * @param float $pu Unit price (HT or TTC selon price_base_type)
+ * @param float $remise_percent_ligne Discount for line
+ * @param float $txtva Vat rate
+ * @param float $localtax1_rate Localtax1 rate (used for some countries only, like spain). Can also be negative
+ * @param float $localtax2_rate Localtax2 rate (used for some countries only, like spain). Can also be negative
* @param float $remise_percent_global 0
* @param string $price_base_type HT=on calcule sur le HT, TTC=on calcule sur le TTC
* @param int $info_bits Miscellanous informations on line
- * @return result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
+ * @param int $type 0/1=Product/service
+ * @param string $localtax1_type Localtax1 type (used for some countries only, like spain)
+ * @param string $localtax2_type Localtax2 type (used for some countries only, like spain)
+ * @return result[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount, ...)
*/
-function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $txlocaltax1=0, $txlocaltax2=0, $remise_percent_global=0, $price_base_type='HT', $info_bits=0)
+function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $localtax1_rate=0, $localtax2_rate=0, $remise_percent_global=0, $price_base_type='HT', $info_bits=0, $type=0, $localtax1_type = '?', $localtax2_type = '?')
{
global $conf,$mysoc;
$result=array();
- // We work to define prices using the price without tax
+ // TODO Remove this code. Added for backward compatibility. To remove once localtaxX_type is provided by caller.
+ if ($localtax1_type == '?')
+ {
+ if ($mysoc->country_code=='ES') $localtax1_type='1';
+ else $localtax1_type='0';
+ }
+ if ($localtax2_type == '?')
+ {
+ if ($mysoc->country_code=='ES') $localtax2_type='1';
+ else $localtax2_type='0';
+ }
+
+ // initialize total (may be HT or TTC depending on price_base_type)
$tot_sans_remise = $pu * $qty;
$tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100));
$tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100));
+ // initialize result
+ for ($i=0; $i <= 15; $i++)
+ $result[$i] = 0;
+
+ // if there's some localtax including vat, we calculate localtaxes (we will add later)
+ $localtaxes = array(0,0,0);
+ $apply_tax = false;
+ switch($localtax1_type) {
+ case '2': // localtax on product or service
+ $apply_tax = true;
+ break;
+ case '4': // localtax on product
+ if ($type == 0) $apply_tax = true;
+ break;
+ case '6': // localtax on service
+ if ($type == 1) $apply_tax = true;
+ break;
+ }
+ if ($apply_tax) {
+ $result[14] = price2num(($tot_sans_remise * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise, 'MT');
+ $localtaxes[0] += $result[14];
+
+ $result[9] = price2num(($tot_avec_remise * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise, 'MT');
+ $localtaxes[1] += $result[9];
+
+ $result[11] = price2num(($pu * (1 + ( $localtax1_rate / 100))) - $pu, 'MU');
+ $localtaxes[2] += $result[11];
+ }
+
+ $apply_tax = false;
+ switch($localtax2_type) {
+ case '2': // localtax on product or service
+ $apply_tax = true;
+ break;
+ case '4': // localtax on product
+ if ($type == 0) $apply_tax = true;
+ break;
+ case '6': // localtax on service
+ if ($type == 1) $apply_tax = true;
+ break;
+ }
+ if ($apply_tax) {
+ $result[15] = price2num(($tot_sans_remise * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise, 'MT');
+ $localtaxes[0] += $result[15];
+
+ $result[10] = price2num(($tot_avec_remise * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise, 'MT');
+ $localtaxes[1] += $result[10];
+
+ $result[12] = price2num(($pu * (1 + ( $localtax2_rate / 100))) - $pu, 'MU');
+ $localtaxes[2] += $result[12];
+ }
+
//dol_syslog("price.lib::calcul_price_total $qty, $pu, $remise_percent_ligne, $txtva, $price_base_type $info_bits");
if ($price_base_type == 'HT')
{
+ // We work to define prices using the price without tax
$result[6] = price2num($tot_sans_remise, 'MT');
- $result[8] = price2num($tot_sans_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
- $result8bis= price2num($tot_sans_remise * (1 + ( $txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
- $result[7] = price2num($result8bis - $result[6], 'MT');
+ $result[8] = price2num(($tot_sans_remise + $localtaxes[0]) * (1 + ( (($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
+ $result8bis= price2num(($tot_sans_remise + $localtaxes[0]) * (1 + ( $txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
+ $result[7] = price2num($result8bis - ($result[6] + $localtaxes[0]), 'MT');
$result[0] = price2num($tot_avec_remise, 'MT');
- $result[2] = price2num($tot_avec_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
- $result2bis= price2num($tot_avec_remise * (1 + ( $txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
-
- $result[1] = price2num($result2bis - $result[0], 'MT'); // Total VAT = TTC - HT
+ $result[2] = price2num(($tot_avec_remise + $localtaxes[1]) * (1 + ( (($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
+ $result2bis= price2num(($tot_avec_remise + $localtaxes[1]) * (1 + ( $txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
+ $result[1] = price2num($result2bis - ($result[0] + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax)
$result[3] = price2num($pu, 'MU');
- $result[5] = price2num($pu * (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non
- $result5bis= price2num($pu * (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR)
- $result[4] = price2num($result5bis - $result[3], 'MU');
+ $result[5] = price2num(($pu + $localtaxes[2]) * (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non
+ $result5bis= price2num(($pu + $localtaxes[2]) * (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR)
+ $result[4] = price2num($result5bis - ($result[3] + $localtaxes[2]), 'MU');
}
else
{
- $result[8] = price2num($tot_sans_remise, 'MT');
- $result[6] = price2num($tot_sans_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
- $result6bis= price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
- $result[7] = price2num($result[8] - $result6bis, 'MT');
+ // We work to define prices using the price with tax
+ $result[8] = price2num($tot_sans_remise + $localtaxes[0], 'MT');
+ $result[6] = price2num(($tot_sans_remise + $localtaxes[0]) / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
+ $result6bis= price2num(($tot_sans_remise + $localtaxes[0]) / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
+ $result[7] = price2num($result[8] - ($result6bis + $localtaxes[0]), 'MT');
- $result[2] = price2num($tot_avec_remise, 'MT');
- $result[0] = price2num($tot_avec_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
- $result0bis= price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
+ $result[2] = price2num($tot_avec_remise + $localtaxes[1], 'MT');
+ $result[0] = price2num(($tot_avec_remise + $localtaxes[1]) / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
+ $result0bis= price2num(($tot_avec_remise + $localtaxes[1]) / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
+ $result[1] = price2num($result[2] - ($result0bis + $localtaxes[1]), 'MT'); // Total VAT = TTC - HT
- $result[1] = price2num($result[2] - $result0bis, 'MT'); // Total VAT = TTC - HT
-
- $result[5] = price2num($pu, 'MU');
- $result[3] = price2num($pu / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non
- $result3bis= price2num($pu / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR)
- $result[4] = price2num($result[5] - $result3bis, 'MU');
+ $result[5] = price2num(($pu + $localtaxes[2]), 'MU');
+ $result[3] = price2num(($pu + $localtaxes[2]) / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non
+ $result3bis= price2num(($pu + $localtaxes[2]) / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR)
+ $result[4] = price2num($result[5] - ($result3bis + $localtaxes[2]), 'MU');
}
- // Local taxes 1. Local tax1 is a second tax that is added after standard one)
- if ($txlocaltax1 > 0)
- {
- $result[14] = price2num(($result[6] * ( 1 + ( $txlocaltax1 / 100))) - $result[6], 'MT'); // amount tax1 for total_ht_without_discount
- $result[9] = price2num(($result[0] * ( 1 + ( $txlocaltax1 / 100))) - $result[0], 'MT'); // amount tax1 for total_ht
- $result[11] = price2num(($result[3] * ( 1 + ( $txlocaltax1 / 100))) - $pu, 'MU'); // amount tax1 for pu_ht
+ // if there's some localtax without vat, we calculate localtaxes (we will add them at end)
+ $apply_tax = false;
+ switch($localtax1_type) {
+ case '1': // localtax on product or service
+ $apply_tax = true;
+ break;
+ case '3': // localtax on product
+ if ($type == 0) $apply_tax = true;
+ break;
+ case '5': // localtax on service
+ if ($type == 1) $apply_tax = true;
+ break;
+ }
+ if ($apply_tax) {
+ $result[14] = price2num(($tot_sans_remise * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount
+ $result[8] += $result[14]; // total_ttc_without_discount + tax1
- $result[8] = price2num($result[8] + $result[14], 'MT'); // total_ttc_without_discount + tax1
- $result[2] = price2num($result[2] + $result[9], 'MT'); // total_ttc + tax1
- $result[5] = price2num($result[5] + $result[11], 'MU'); // pu_ht + tax1
- }
- else
- {
- $result[14] = 0;
- $result[9] = 0;
- $result[11] = 0;
- }
+ $result[9] = price2num(($tot_avec_remise * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht
+ $result[2] += $result[9]; // total_ttc + tax1
- // Local taxes 2. Local tax2 is a second tax that is substracted after standard one)
- // Example: Country = Spain, localtax2 is IRPF
- if ($txlocaltax2 > 0)
- {
- $result[15] = price2num(($result[6] * ( 1 + ( $txlocaltax2 / 100))) - $result[6], 'MT'); // amount tax2 for total_ht_without_discount
- $result[10] = price2num(($result[0] * ( 1 + ( $txlocaltax2 / 100))) - $result[0], 'MT'); // amount tax2 for total_ht
- $result[12] = price2num(($result[3] * ( 1 + ( $txlocaltax2 / 100))) - $pu, 'MU'); // amount tax2 for pu_ht
+ $result[11] = price2num(($pu * (1 + ( $localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht
+ $result[5] += $result[11]; // pu_ht + tax1
+ }
- $result[8] = price2num($result[8] - $result[15], 'MT'); // total_ttc_without_discount + tax2
- $result[2] = price2num($result[2] - $result[10], 'MT'); // total_ttc + tax2
- $result[5] = price2num($result[5] - $result[12], 'MU'); // pu_ttc + tax2
- }
- else
- {
- $result[15] = 0;
- $result[10] = 0;
- $result[12] = 0;
- }
+ $apply_tax = false;
+ switch($localtax2_type) {
+ case '1': // localtax on product or service
+ $apply_tax = true;
+ break;
+ case '3': // localtax on product
+ if ($type == 0) $apply_tax = true;
+ break;
+ case '5': // localtax on service
+ if ($type == 1) $apply_tax = true;
+ break;
+ }
+ if ($apply_tax) {
+ $result[15] = price2num(($tot_sans_remise * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount
+ $result[8] += $result[15]; // total_ttc_without_discount + tax2
+
+ $result[10] = price2num(($tot_avec_remise * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht
+ $result[2] += $result[10]; // total_ttc + tax2
+
+ $result[12] = price2num(($pu * (1 + ( $localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht
+ $result[5] += $result[12]; // pu_ht + tax2
+ }
// If rounding is not using base 10 (rare)
if (! empty($conf->global->MAIN_ROUNDING_RULE_TOT))
diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql
index 82348a15f89..a24c419f2f7 100644
--- a/htdocs/install/mysql/data/llx_c_tva.sql
+++ b/htdocs/install/mysql/data/llx_c_tva.sql
@@ -176,24 +176,24 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (18
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1883,188, '0','0','VAT Rate 0', 1);
-- SAN SALVADOR (id country=86)
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (861, 86, '13', '0', 'IVA 13', 1);
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (862, 86, '0', '0', 'SIN IVA', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (861, 86, '13', '0', 'IVA 13', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (862, 86, '0', '0', 'SIN IVA', 1);
-- SLOVAKIA (id country=201)
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (2011, 201, '19', '0', 'VAT standard rate', 1);
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (2012, 201, '10', '0', 'VAT reduced rate', 1);
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (2013, 201, '0', '0', 'VAT Rate 0', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2011, 201, '19', '0', 'VAT standard rate', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2012, 201, '10', '0', 'VAT reduced rate', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2013, 201, '0', '0', 'VAT Rate 0', 1);
-- SLOVENIA (id country=202)
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (2021, 202, '20', '0', 'VAT standard rate', 1);
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (2022, 202,'8.5', '0', 'VAT reduced rate', 1);
-INSERT INTO llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) VALUES (2023, 202, '0', '0', 'VAT Rate 0', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2021, 202, '20', '0', 'VAT standard rate', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2022, 202,'8.5', '0', 'VAT reduced rate', 1);
+INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2023, 202, '0', '0', 'VAT Rate 0', 1);
-- SPAIN (id country=4)
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,note,active) values ( 41, 4, '21','0','5.2','VAT standard rate',1);
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,note,active) values ( 42, 4, '10','0','1.4','VAT reduced rate',1);
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,note,active) values ( 43, 4, '4','0','0.5','VAT super-reduced rate',1);
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 44, 4, '0','0','VAT Rate 0',1);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values ( 41, 4, '21','0','5.2','1','VAT standard rate',1);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values ( 42, 4, '10','0','1.4','1','VAT reduced rate',1);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values ( 43, 4, '4','0','0.5','1','VAT super-reduced rate',1);
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 44, 4, '0','0','VAT Rate 0',1);
-- SWEDEN (id country=20)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (201,20, '25','0','VAT standard rate',1);
@@ -208,13 +208,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 6
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 64, 6, '0','0','VAT Rate 0', 1);
-- TUNISIA (id country=10)
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1, localtax1_type, localtax2, localtax2_type) values (101,10, '6','0','VAT 6%', 1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1, localtax1_type, localtax2, localtax2_type) values (102,10, '12','0','VAT 12%',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1, localtax1_type, localtax2, localtax2_type) values (103,10, '18','0','VAT 18%',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1, localtax1_type, localtax2, localtax2_type) values (104,10, '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1, localtax1_type, localtax2, localtax2_type) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1, localtax1_type, localtax2, localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0.4, '7');
-insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1, localtax1_type, localtax2, localtax2_type) values (107,10, '0','0','VAT Rate 0', 1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10, '6','0','VAT 6%', 1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (102,10, '12','0','VAT 12%',1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (103,10, '18','0','VAT 18%',1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (104,10, '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0.4, '7');
+insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10, '0','0','VAT Rate 0', 1, 1, '4', 0.4, '7');
-- UKRAINE (id country=226)
INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2261,226, '20','0','VAT standart rate',1);
diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang
index 330efc3f346..0e15d03b8d8 100644
--- a/htdocs/langs/es_ES/admin.lang
+++ b/htdocs/langs/es_ES/admin.lang
@@ -1259,7 +1259,7 @@ DetailMainmenu=Grupo al cual pertenece (obsoleto)
DetailUrl=URL de la página hacia la cual el menú apunta
DetailLeftmenu=Condición de visualización o no (obsoleto)
DetailEnabled=Condición de mostrar o no
-DetailRight=Condición de visualización completa o cristálida
+DetailRight=Condición de visualización completa o restringida
DetailLangs=Archivo .lang para la traducción del título
DetailUser=Interno / Externo / Todos
Target=Objetivo
diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php
index d0be9c47e27..4029704d0bb 100755
--- a/test/phpunit/PricesTest.php
+++ b/test/phpunit/PricesTest.php
@@ -124,31 +124,30 @@ class PricesTest extends PHPUnit_Framework_TestCase
*/
public function testCalculPriceTotal()
{
- // Line 1
- // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT'
+ global $conf,$user,$langs,$db;
+ $this->savconf=$conf;
+ $this->savuser=$user;
+ $this->savlangs=$langs;
+ $this->savdb=$db;
+
+ // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT'
$result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0);
+ print __METHOD__." result1=".join(', ',$result1)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
+ $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1);
- print __METHOD__." value0=1.24 result0=".$result1[0]."\n";
- $this->assertEquals(1.24,$result1[0]);
- print __METHOD__." value1=0.12 result1=".$result1[1]."\n";
- $this->assertEquals(0.12,$result1[1]);
- print __METHOD__." value2=1.36 result2=".$result1[2]."\n";
- $this->assertEquals(1.36,$result1[2]);
+ // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 1, 0% localtax2 type 0
+ $result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0, 1, 0);
+ print __METHOD__." result2=".join(', ',$result2)."\n";
+ $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2);
- print __METHOD__." value3=1.24 result3=".$result1[3]."\n";
- $this->assertEquals(1.24, $result1[3]);
- print __METHOD__." value4=0.124 result4=".$result1[4]."\n";
- $this->assertEquals(0.124,$result1[4]);
- print __METHOD__." value5=1.364 result5=".$result1[5]."\n";
- $this->assertEquals(1.364,$result1[5]);
-
- print __METHOD__." value6=1.24 result6=".$result1[6]."\n";
- $this->assertEquals(1.24,$result1[6]);
- print __METHOD__." value7=0.12 result7=".$result1[7]."\n";
- $this->assertEquals(0.12,$result1[7]);
- print __METHOD__." value8=1.36 result8=".$result1[8]."\n";
- $this->assertEquals(1.36,$result1[8]);
+ // Old function for spain countries. To check backward compatibility.
+ global $mysoc;
+ $mysoc=new Societe($db);
+ $mysoc->country_code='ES';
+ $result3=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
+ print __METHOD__." result3=".join(', ',$result3)."\n";
+ $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result3);
return true;
}