Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop
This commit is contained in:
commit
1f2dc448d7
@ -795,8 +795,8 @@ if (empty($reshook)) {
|
|||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef = '';
|
$predef = '';
|
||||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||||
$price_ht = price2num(GETPOST('price_ht'));
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
@ -1183,13 +1183,13 @@ if (empty($reshook)) {
|
|||||||
$vat_rate = str_replace('*', '', $vat_rate);
|
$vat_rate = str_replace('*', '', $vat_rate);
|
||||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
||||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
|
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
|
||||||
$pu_ht = GETPOST('price_ht');
|
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
|
||||||
|
|
||||||
// Add buying price
|
// Add buying price
|
||||||
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
|
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
|
||||||
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
|
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
|
||||||
|
|
||||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||||
|
|
||||||
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
||||||
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||||
|
|||||||
@ -616,8 +616,8 @@ if (empty($reshook)) {
|
|||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef = '';
|
$predef = '';
|
||||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
@ -984,9 +984,9 @@ if (empty($reshook)) {
|
|||||||
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
||||||
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||||
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
|
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
|
||||||
$pu_ht = GETPOST('price_ht');
|
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
|
||||||
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
|
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
|
||||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||||
|
|
||||||
// Define info_bits
|
// Define info_bits
|
||||||
$info_bits = 0;
|
$info_bits = 0;
|
||||||
|
|||||||
@ -421,8 +421,8 @@ if (empty($reshook)) {
|
|||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef = '';
|
$predef = '';
|
||||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
|
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
@ -719,10 +719,10 @@ if (empty($reshook)) {
|
|||||||
//$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
//$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
||||||
//$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
//$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||||
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
|
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
|
||||||
$pu_ht = GETPOST('price_ht');
|
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
|
||||||
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||||
$qty = GETPOST('qty');
|
$qty = GETPOST('qty');
|
||||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||||
|
|
||||||
// Define info_bits
|
// Define info_bits
|
||||||
$info_bits = 0;
|
$info_bits = 0;
|
||||||
|
|||||||
@ -1955,8 +1955,8 @@ if (empty($reshook)) {
|
|||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef = '';
|
$predef = '';
|
||||||
$product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
$product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||||
$price_ht = price2num(GETPOST('price_ht'));
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
|
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
@ -2299,10 +2299,10 @@ if (empty($reshook)) {
|
|||||||
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
|
||||||
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||||
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
|
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
|
||||||
$pu_ht = GETPOST('price_ht');
|
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
|
||||||
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||||
$qty = GETPOST('qty');
|
$qty = GETPOST('qty');
|
||||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||||
|
|
||||||
// Define info_bits
|
// Define info_bits
|
||||||
$info_bits = 0;
|
$info_bits = 0;
|
||||||
|
|||||||
@ -367,8 +367,8 @@ if (empty($reshook)) {
|
|||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef = '';
|
$predef = '';
|
||||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CU'));
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
if (GETPOST('prod_entry_mode', 'alpha') == 'free') {
|
if (GETPOST('prod_entry_mode', 'alpha') == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
|
$tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
|
||||||
@ -651,9 +651,8 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ajout prix d'achat
|
// ajout prix d'achat
|
||||||
$fk_fournprice = $_POST['fournprice'];
|
if (GETPOST('buying_price')) {
|
||||||
if (!empty($_POST['buying_price'])) {
|
$pa_ht = price2num(GETPOST('buying_price'), '', 2);
|
||||||
$pa_ht = $_POST['buying_price'];
|
|
||||||
} else {
|
} else {
|
||||||
$pa_ht = null;
|
$pa_ht = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7519,7 +7519,7 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getJSListDependancies($type = '_extra')
|
public function getJSListDependancies($type = '_extra')
|
||||||
{
|
{
|
||||||
$out .= '
|
$out = '
|
||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
function showOptions'.$type.'(child_list, parent_list, orig_select)
|
function showOptions'.$type.'(child_list, parent_list, orig_select)
|
||||||
|
|||||||
@ -198,8 +198,6 @@ class DefaultValues extends CommonObject
|
|||||||
|
|
||||||
// Load source object
|
// Load source object
|
||||||
$result = $object->fetchCommon($fromid);
|
$result = $object->fetchCommon($fromid);
|
||||||
if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
|
|
||||||
|
|
||||||
|
|
||||||
// Reset some properties
|
// Reset some properties
|
||||||
unset($object->id);
|
unset($object->id);
|
||||||
|
|||||||
@ -7714,8 +7714,8 @@ class Form
|
|||||||
print '<td class="center">'.$objp->ref.'</td>';
|
print '<td class="center">'.$objp->ref.'</td>';
|
||||||
print '<td>'.$objp->ref_client.'</td>';
|
print '<td>'.$objp->ref_client.'</td>';
|
||||||
print '<td class="right">';
|
print '<td class="right">';
|
||||||
if ($possiblelink[label] == 'LinkToContract') {
|
if ($possiblelink['label'] == 'LinkToContract') {
|
||||||
$form = new Form($db);
|
$form = new Form($this->db);
|
||||||
print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' ';
|
print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' ';
|
||||||
}
|
}
|
||||||
print price($objp->total_ht).'</td>';
|
print price($objp->total_ht).'</td>';
|
||||||
@ -7732,8 +7732,6 @@ class Form
|
|||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
print '</div>';
|
print '</div>';
|
||||||
if ($num > 0) {
|
|
||||||
}
|
|
||||||
|
|
||||||
//$linktoelem.=($linktoelem?' ':'');
|
//$linktoelem.=($linktoelem?' ':'');
|
||||||
if ($num > 0) {
|
if ($num > 0) {
|
||||||
|
|||||||
@ -710,51 +710,35 @@ function getFormeJuridiqueLabel($code)
|
|||||||
*/
|
*/
|
||||||
function getCountriesInEEC()
|
function getCountriesInEEC()
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
// List of all country codes that are in europe for european vat rules
|
// List of all country codes that are in europe for european vat rules
|
||||||
// List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9
|
// List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9
|
||||||
$country_code_in_EEC = array(
|
global $conf, $db;
|
||||||
'AT', // Austria
|
$country_code_in_EEC = array();
|
||||||
'BE', // Belgium
|
|
||||||
'BG', // Bulgaria
|
|
||||||
'CY', // Cyprus
|
|
||||||
'CZ', // Czech republic
|
|
||||||
'DE', // Germany
|
|
||||||
'DK', // Danemark
|
|
||||||
'EE', // Estonia
|
|
||||||
'ES', // Spain
|
|
||||||
'FI', // Finland
|
|
||||||
'FR', // France
|
|
||||||
'GB', // United Kingdom
|
|
||||||
'GR', // Greece
|
|
||||||
'HR', // Croatia
|
|
||||||
'NL', // Holland
|
|
||||||
'HU', // Hungary
|
|
||||||
'IE', // Ireland
|
|
||||||
'IM', // Isle of Man - Included in UK
|
|
||||||
'IT', // Italy
|
|
||||||
'LT', // Lithuania
|
|
||||||
'LU', // Luxembourg
|
|
||||||
'LV', // Latvia
|
|
||||||
'MC', // Monaco - Included in France
|
|
||||||
'MT', // Malta
|
|
||||||
//'NO', // Norway
|
|
||||||
'PL', // Poland
|
|
||||||
'PT', // Portugal
|
|
||||||
'RO', // Romania
|
|
||||||
'SE', // Sweden
|
|
||||||
'SK', // Slovakia
|
|
||||||
'SI', // Slovenia
|
|
||||||
'UK', // United Kingdom
|
|
||||||
//'CH', // Switzerland - No. Swizerland in not in EEC
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) {
|
if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) {
|
||||||
// For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK'
|
// For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK'
|
||||||
$country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC);
|
$country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC);
|
||||||
}
|
} elseif (!empty($conf->cache['country_code_in_EEC'])) {
|
||||||
|
// Use of cache to reduce number of database requests
|
||||||
|
$country_code_in_EEC = $conf->cache['country_code_in_EEC'];
|
||||||
|
} else {
|
||||||
|
$sql = "SELECT cc.code FROM ".MAIN_DB_PREFIX."c_country as cc";
|
||||||
|
$sql .= " WHERE cc.eec = 1";
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num) {
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
|
$country_code_in_EEC[] = $objp->code;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
$conf->cache['country_code_in_EEC'] = $country_code_in_EEC;
|
||||||
|
}
|
||||||
return $country_code_in_EEC;
|
return $country_code_in_EEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,7 +756,7 @@ function isInEEC($object)
|
|||||||
|
|
||||||
$country_code_in_EEC = getCountriesInEEC();
|
$country_code_in_EEC = getCountriesInEEC();
|
||||||
|
|
||||||
//print "dd".$this->country_code;
|
//print "dd".$object->country_code;
|
||||||
return in_array($object->country_code, $country_code_in_EEC);
|
return in_array($object->country_code, $country_code_in_EEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2119,7 +2119,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
if ($tzoutput === 'auto') {
|
if ($tzoutput === 'auto') {
|
||||||
$tzoutput = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey);
|
$tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
@ -5159,7 +5159,7 @@ function price2num($amount, $rounding = '', $option = 0)
|
|||||||
|
|
||||||
// Convert value to universal number format (no thousand separator, '.' as decimal separator)
|
// Convert value to universal number format (no thousand separator, '.' as decimal separator)
|
||||||
if ($option != 1) { // If not a PHP number or unknown, we change or clean format
|
if ($option != 1) { // If not a PHP number or unknown, we change or clean format
|
||||||
//print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
|
//print "\n".'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
|
||||||
if (!is_numeric($amount)) {
|
if (!is_numeric($amount)) {
|
||||||
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount);
|
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount);
|
||||||
}
|
}
|
||||||
@ -5188,6 +5188,7 @@ function price2num($amount, $rounding = '', $option = 0)
|
|||||||
$amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
$amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||||
$amount = str_replace($dec, '.', $amount);
|
$amount = str_replace($dec, '.', $amount);
|
||||||
}
|
}
|
||||||
|
//print ' XX'.$amount.' '.$rounding;
|
||||||
|
|
||||||
// Now, make a rounding if required
|
// Now, make a rounding if required
|
||||||
if ($rounding) {
|
if ($rounding) {
|
||||||
@ -5811,10 +5812,13 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
|
|||||||
if (($seller_in_cee && $buyer_in_cee)) {
|
if (($seller_in_cee && $buyer_in_cee)) {
|
||||||
$isacompany = $thirdparty_buyer->isACompany();
|
$isacompany = $thirdparty_buyer->isACompany();
|
||||||
if ($isacompany) {
|
if ($isacompany) {
|
||||||
if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID) && !isValidVATID($thirdparty_buyer)) {
|
if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
if (!isValidVATID($thirdparty_buyer)) {
|
||||||
//print 'VATRULE 6';
|
//print 'VATRULE 6';
|
||||||
return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice);
|
return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//print 'VATRULE 3';
|
//print 'VATRULE 3';
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -379,17 +379,17 @@ if (empty($reshook)) {
|
|||||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||||
} else {
|
} else {
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$tva_tx = '';
|
$tva_tx = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
||||||
$remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
|
$remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||||
@ -711,7 +711,7 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
if (GETPOST('price_ht') != '') {
|
if (GETPOST('price_ht') != '') {
|
||||||
$price_base_type = 'HT';
|
$price_base_type = 'HT';
|
||||||
$ht = price2num(GETPOST('price_ht'));
|
$ht = price2num(GETPOST('price_ht'), '', 2);
|
||||||
} else {
|
} else {
|
||||||
$vatratecleaned = $vat_rate;
|
$vatratecleaned = $vat_rate;
|
||||||
if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)"
|
if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)"
|
||||||
@ -719,12 +719,12 @@ if (empty($reshook)) {
|
|||||||
$vatratecode = $reg[2];
|
$vatratecode = $reg[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ttc = price2num(GETPOST('price_ttc'));
|
$ttc = price2num(GETPOST('price_ttc'), '', 2);
|
||||||
$ht = $ttc / (1 + ($vatratecleaned / 100));
|
$ht = $ttc / (1 + ($vatratecleaned / 100));
|
||||||
$price_base_type = 'HT';
|
$price_base_type = 'HT';
|
||||||
}
|
}
|
||||||
|
|
||||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||||
|
|
||||||
// Extrafields Lines
|
// Extrafields Lines
|
||||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||||
|
|||||||
@ -441,13 +441,13 @@ if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionne
|
|||||||
$qty = $supplierorderdispatch->qty;
|
$qty = $supplierorderdispatch->qty;
|
||||||
$entrepot = $supplierorderdispatch->fk_entrepot;
|
$entrepot = $supplierorderdispatch->fk_entrepot;
|
||||||
$product = $supplierorderdispatch->fk_product;
|
$product = $supplierorderdispatch->fk_product;
|
||||||
$price = GETPOST('price');
|
$price = price2num(GETPOST('price'), '', 2);
|
||||||
$comment = $supplierorderdispatch->comment;
|
$comment = $supplierorderdispatch->comment;
|
||||||
$eatby = $supplierorderdispatch->fk_product;
|
$eatby = $supplierorderdispatch->fk_product;
|
||||||
$sellby = $supplierorderdispatch->sellby;
|
$sellby = $supplierorderdispatch->sellby;
|
||||||
$batch = $supplierorderdispatch->batch;
|
$batch = $supplierorderdispatch->batch;
|
||||||
|
|
||||||
$supplierorderdispatch->qty = GETPOST('qty', 'int');
|
$supplierorderdispatch->qty = price2num(GETPOST('qty', 'alpha'), 'MS', 2);
|
||||||
$supplierorderdispatch->fk_entrepot = GETPOST('fk_entrepot');
|
$supplierorderdispatch->fk_entrepot = GETPOST('fk_entrepot');
|
||||||
$result = $supplierorderdispatch->update($user);
|
$result = $supplierorderdispatch->update($user);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1064,10 +1064,10 @@ if (empty($reshook)) {
|
|||||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||||
|
|
||||||
if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') {
|
if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') {
|
||||||
$up = price2num(GETPOST('price_ht'));
|
$up = price2num(GETPOST('price_ht'), '', 2);
|
||||||
$price_base_type = 'HT';
|
$price_base_type = 'HT';
|
||||||
} else {
|
} else {
|
||||||
$up = price2num(GETPOST('price_ttc'));
|
$up = price2num(GETPOST('price_ttc'), '', 2);
|
||||||
$price_base_type = 'TTC';
|
$price_base_type = 'TTC';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1163,17 +1163,17 @@ if (empty($reshook)) {
|
|||||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||||
} else {
|
} else {
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$tva_tx = '';
|
$tva_tx = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
||||||
$remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
|
$remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||||
|
|||||||
@ -425,7 +425,6 @@ if ($object->id > 0) {
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Line to add a new line in inventory
|
// Line to add a new line in inventory
|
||||||
//if ($action == 'addline') {
|
|
||||||
if ($object->status == $object::STATUS_VALIDATED) {
|
if ($object->status == $object::STATUS_VALIDATED) {
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
|
|||||||
@ -529,17 +529,17 @@ if (empty($reshook)) {
|
|||||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||||
} else {
|
} else {
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||||
$tva_tx = '';
|
$tva_tx = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
||||||
$remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
|
$remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
|
||||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
|
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||||
@ -836,7 +836,7 @@ if (empty($reshook)) {
|
|||||||
$localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty);
|
$localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty);
|
||||||
|
|
||||||
if (GETPOST('price_ht') != '') {
|
if (GETPOST('price_ht') != '') {
|
||||||
$ht = price2num(GETPOST('price_ht'));
|
$ht = price2num(GETPOST('price_ht'), '', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST('price_ttc') != '') {
|
if (GETPOST('price_ttc') != '') {
|
||||||
@ -847,7 +847,7 @@ if (empty($reshook)) {
|
|||||||
$vatratecode = $reg[2];
|
$vatratecode = $reg[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ttc = price2num(GETPOST('price_ttc'));
|
$ttc = price2num(GETPOST('price_ttc'), '', 2);
|
||||||
$ht = $ttc / (1 + ($vatratecleaned / 100));
|
$ht = $ttc / (1 + ($vatratecleaned / 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -108,7 +108,15 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
|||||||
//$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
//$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||||
|
|
||||||
if (! function_exists('mb_substr')) {
|
if (! function_exists('mb_substr')) {
|
||||||
print "\n".__METHOD__." function mb_substr must be enabled.\n"; die();
|
print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf->global->MAIN_MAX_DECIMALS_UNIT != 5) {
|
||||||
|
print "\n".__METHOD__." bad setup for number of digits for unit amount. Must be 5 for this test.\n"; die(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf->global->MAIN_MAX_DECIMALS_TOT != 2) {
|
||||||
|
print "\n".__METHOD__." bad setup for number of digits for unit amount. Must be 2 for this test.\n"; die(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
print __METHOD__."\n";
|
print __METHOD__."\n";
|
||||||
@ -1294,7 +1302,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
|||||||
$this->assertEquals(1000.123456, price2num('1 000.123456'));
|
$this->assertEquals(1000.123456, price2num('1 000.123456'));
|
||||||
|
|
||||||
// Round down
|
// Round down
|
||||||
$this->assertEquals(1000.12, price2num('1 000.123452', 'MT'));
|
$this->assertEquals(1000.12, price2num('1 000.123452', 'MT'), 'Error in round down with MT');
|
||||||
$this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU");
|
$this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU");
|
||||||
|
|
||||||
// Round up
|
// Round up
|
||||||
|
|||||||
@ -91,6 +91,10 @@ class SocieteTest extends PHPUnit\Framework\TestCase
|
|||||||
print "\n".__METHOD__." constant MAIN_DISABLEPROFIDRULES must be empty (if a module set it, disable module).\n"; die();
|
print "\n".__METHOD__." constant MAIN_DISABLEPROFIDRULES must be empty (if a module set it, disable module).\n"; die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($langs->defaultlang != 'en_US') {
|
||||||
|
print "\n".__METHOD__." default language of company must be set to autodetect.\n"; die();
|
||||||
|
}
|
||||||
|
|
||||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||||
|
|
||||||
print __METHOD__."\n";
|
print __METHOD__."\n";
|
||||||
@ -347,9 +351,24 @@ class SocieteTest extends PHPUnit\Framework\TestCase
|
|||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
$this->assertNotEquals($result, '');
|
$this->assertNotEquals($result, '');
|
||||||
|
|
||||||
|
$localobject->country_code = 'FR';
|
||||||
|
|
||||||
$result=$localobject->isInEEC();
|
$result=$localobject->isInEEC();
|
||||||
print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
|
||||||
$this->assertTrue(true, $result);
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
$localobject->country_code = 'US';
|
||||||
|
|
||||||
|
$result=$localobject->isInEEC();
|
||||||
|
print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
|
||||||
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
/*$localobject->country_code = 'GB';
|
||||||
|
|
||||||
|
$result=$localobject->isInEEC();
|
||||||
|
print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
|
||||||
|
$this->assertTrue($result);
|
||||||
|
*/
|
||||||
|
|
||||||
$localobject->info($localobject->id);
|
$localobject->info($localobject->id);
|
||||||
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
|
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user