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
|
||||
$predef = '';
|
||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||
$price_ht = price2num(GETPOST('price_ht'));
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||
if ($prod_entry_mode == 'free') {
|
||||
$idprod = 0;
|
||||
@ -1175,7 +1175,7 @@ if (empty($reshook)) {
|
||||
$info_bits |= 0x01;
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
// Clean parameters
|
||||
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
|
||||
|
||||
// Define vat_rate
|
||||
@ -1183,13 +1183,13 @@ if (empty($reshook)) {
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $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
|
||||
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
|
||||
$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_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
|
||||
$predef = '';
|
||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||
if ($prod_entry_mode == 'free') {
|
||||
$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_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'));
|
||||
$pu_ht = GETPOST('price_ht');
|
||||
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
|
||||
$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
|
||||
$info_bits = 0;
|
||||
|
||||
@ -421,8 +421,8 @@ if (empty($reshook)) {
|
||||
// Set if we used free entry or predefined product
|
||||
$predef = '';
|
||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
|
||||
if ($prod_entry_mode == 'free') {
|
||||
$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_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'));
|
||||
$pu_ht = GETPOST('price_ht');
|
||||
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
|
||||
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
$qty = GETPOST('qty');
|
||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
||||
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||
|
||||
// Define info_bits
|
||||
$info_bits = 0;
|
||||
|
||||
@ -1955,8 +1955,8 @@ if (empty($reshook)) {
|
||||
// Set if we used free entry or predefined product
|
||||
$predef = '';
|
||||
$product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||
$price_ht = price2num(GETPOST('price_ht'));
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
|
||||
if ($prod_entry_mode == 'free') {
|
||||
$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_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'));
|
||||
$pu_ht = GETPOST('price_ht');
|
||||
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
|
||||
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
$qty = GETPOST('qty');
|
||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
||||
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||
|
||||
// Define info_bits
|
||||
$info_bits = 0;
|
||||
|
||||
@ -367,8 +367,8 @@ if (empty($reshook)) {
|
||||
// Set if we used free entry or predefined product
|
||||
$predef = '';
|
||||
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CU'));
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
|
||||
if (GETPOST('prod_entry_mode', 'alpha') == 'free') {
|
||||
$idprod = 0;
|
||||
$tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
|
||||
@ -651,9 +651,8 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// ajout prix d'achat
|
||||
$fk_fournprice = $_POST['fournprice'];
|
||||
if (!empty($_POST['buying_price'])) {
|
||||
$pa_ht = $_POST['buying_price'];
|
||||
if (GETPOST('buying_price')) {
|
||||
$pa_ht = price2num(GETPOST('buying_price'), '', 2);
|
||||
} else {
|
||||
$pa_ht = null;
|
||||
}
|
||||
|
||||
@ -7519,7 +7519,7 @@ abstract class CommonObject
|
||||
*/
|
||||
public function getJSListDependancies($type = '_extra')
|
||||
{
|
||||
$out .= '
|
||||
$out = '
|
||||
<script>
|
||||
jQuery(document).ready(function() {
|
||||
function showOptions'.$type.'(child_list, parent_list, orig_select)
|
||||
|
||||
@ -198,8 +198,6 @@ class DefaultValues extends CommonObject
|
||||
|
||||
// Load source object
|
||||
$result = $object->fetchCommon($fromid);
|
||||
if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
|
||||
|
||||
|
||||
// Reset some properties
|
||||
unset($object->id);
|
||||
|
||||
@ -7714,8 +7714,8 @@ class Form
|
||||
print '<td class="center">'.$objp->ref.'</td>';
|
||||
print '<td>'.$objp->ref_client.'</td>';
|
||||
print '<td class="right">';
|
||||
if ($possiblelink[label] == 'LinkToContract') {
|
||||
$form = new Form($db);
|
||||
if ($possiblelink['label'] == 'LinkToContract') {
|
||||
$form = new Form($this->db);
|
||||
print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' ';
|
||||
}
|
||||
print price($objp->total_ht).'</td>';
|
||||
@ -7732,8 +7732,6 @@ class Form
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
print '</div>';
|
||||
if ($num > 0) {
|
||||
}
|
||||
|
||||
//$linktoelem.=($linktoelem?' ':'');
|
||||
if ($num > 0) {
|
||||
|
||||
@ -710,51 +710,35 @@ function getFormeJuridiqueLabel($code)
|
||||
*/
|
||||
function getCountriesInEEC()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// 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
|
||||
$country_code_in_EEC = array(
|
||||
'AT', // Austria
|
||||
'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
|
||||
);
|
||||
global $conf, $db;
|
||||
$country_code_in_EEC = array();
|
||||
|
||||
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'
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -772,7 +756,7 @@ function isInEEC($object)
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
@ -2119,7 +2119,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
||||
global $conf, $langs;
|
||||
|
||||
if ($tzoutput === 'auto') {
|
||||
$tzoutput = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey);
|
||||
$tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver'));
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
@ -5159,12 +5159,12 @@ function price2num($amount, $rounding = '', $option = 0)
|
||||
|
||||
// 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
|
||||
//print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
|
||||
//print "\n".'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
|
||||
if (!is_numeric($amount)) {
|
||||
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount);
|
||||
}
|
||||
|
||||
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123
|
||||
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come from input data, so 1.123 is 1123
|
||||
$amount = str_replace($thousand, '', $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($dec, '.', $amount);
|
||||
}
|
||||
//print ' XX'.$amount.' '.$rounding;
|
||||
|
||||
// Now, make a rounding if required
|
||||
if ($rounding) {
|
||||
@ -5205,13 +5206,13 @@ function price2num($amount, $rounding = '', $option = 0)
|
||||
} elseif (is_numeric($rounding)) {
|
||||
$nbofdectoround = (int) $rounding;
|
||||
}
|
||||
//print "RR".$amount.' - '.$nbofdectoround.'<br>';
|
||||
//print " RR".$amount.' - '.$nbofdectoround.'<br>';
|
||||
if (dol_strlen($nbofdectoround)) {
|
||||
$amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0.
|
||||
} else {
|
||||
return 'ErrorBadParameterProvidedToFunction';
|
||||
}
|
||||
//print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
|
||||
//print ' SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
|
||||
|
||||
// Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
|
||||
// to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup.
|
||||
@ -5811,9 +5812,12 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
|
||||
if (($seller_in_cee && $buyer_in_cee)) {
|
||||
$isacompany = $thirdparty_buyer->isACompany();
|
||||
if ($isacompany) {
|
||||
if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID) && !isValidVATID($thirdparty_buyer)) {
|
||||
//print 'VATRULE 6';
|
||||
return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice);
|
||||
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';
|
||||
return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice);
|
||||
}
|
||||
}
|
||||
//print 'VATRULE 3';
|
||||
return 0;
|
||||
|
||||
@ -379,17 +379,17 @@ if (empty($reshook)) {
|
||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||
if ($prod_entry_mode == 'free') {
|
||||
$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);
|
||||
} else {
|
||||
$idprod = GETPOST('idprod', 'int');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$tva_tx = '';
|
||||
}
|
||||
|
||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
||||
$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
|
||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||
@ -711,7 +711,7 @@ if (empty($reshook)) {
|
||||
|
||||
if (GETPOST('price_ht') != '') {
|
||||
$price_base_type = 'HT';
|
||||
$ht = price2num(GETPOST('price_ht'));
|
||||
$ht = price2num(GETPOST('price_ht'), '', 2);
|
||||
} else {
|
||||
$vatratecleaned = $vat_rate;
|
||||
if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)"
|
||||
@ -719,12 +719,12 @@ if (empty($reshook)) {
|
||||
$vatratecode = $reg[2];
|
||||
}
|
||||
|
||||
$ttc = price2num(GETPOST('price_ttc'));
|
||||
$ttc = price2num(GETPOST('price_ttc'), '', 2);
|
||||
$ht = $ttc / (1 + ($vatratecleaned / 100));
|
||||
$price_base_type = 'HT';
|
||||
}
|
||||
|
||||
$pu_ht_devise = GETPOST('multicurrency_subprice');
|
||||
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
|
||||
|
||||
// Extrafields Lines
|
||||
$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;
|
||||
$entrepot = $supplierorderdispatch->fk_entrepot;
|
||||
$product = $supplierorderdispatch->fk_product;
|
||||
$price = GETPOST('price');
|
||||
$price = price2num(GETPOST('price'), '', 2);
|
||||
$comment = $supplierorderdispatch->comment;
|
||||
$eatby = $supplierorderdispatch->fk_product;
|
||||
$sellby = $supplierorderdispatch->sellby;
|
||||
$batch = $supplierorderdispatch->batch;
|
||||
|
||||
$supplierorderdispatch->qty = GETPOST('qty', 'int');
|
||||
$supplierorderdispatch->qty = price2num(GETPOST('qty', 'alpha'), 'MS', 2);
|
||||
$supplierorderdispatch->fk_entrepot = GETPOST('fk_entrepot');
|
||||
$result = $supplierorderdispatch->update($user);
|
||||
}
|
||||
|
||||
@ -1064,10 +1064,10 @@ if (empty($reshook)) {
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
|
||||
if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') {
|
||||
$up = price2num(GETPOST('price_ht'));
|
||||
$up = price2num(GETPOST('price_ht'), '', 2);
|
||||
$price_base_type = 'HT';
|
||||
} else {
|
||||
$up = price2num(GETPOST('price_ttc'));
|
||||
$up = price2num(GETPOST('price_ttc'), '', 2);
|
||||
$price_base_type = 'TTC';
|
||||
}
|
||||
|
||||
@ -1163,17 +1163,17 @@ if (empty($reshook)) {
|
||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||
if ($prod_entry_mode == 'free') {
|
||||
$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);
|
||||
} else {
|
||||
$idprod = GETPOST('idprod', 'int');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$tva_tx = '';
|
||||
}
|
||||
|
||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
||||
$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
|
||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||
|
||||
@ -425,7 +425,6 @@ if ($object->id > 0) {
|
||||
print '</tr>';
|
||||
|
||||
// Line to add a new line in inventory
|
||||
//if ($action == 'addline') {
|
||||
if ($object->status == $object::STATUS_VALIDATED) {
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
|
||||
@ -529,17 +529,17 @@ if (empty($reshook)) {
|
||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||
if ($prod_entry_mode == 'free') {
|
||||
$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);
|
||||
} else {
|
||||
$idprod = GETPOST('idprod', 'int');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU');
|
||||
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
|
||||
$tva_tx = '';
|
||||
}
|
||||
|
||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
||||
$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
|
||||
$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);
|
||||
|
||||
if (GETPOST('price_ht') != '') {
|
||||
$ht = price2num(GETPOST('price_ht'));
|
||||
$ht = price2num(GETPOST('price_ht'), '', 2);
|
||||
}
|
||||
|
||||
if (GETPOST('price_ttc') != '') {
|
||||
@ -847,7 +847,7 @@ if (empty($reshook)) {
|
||||
$vatratecode = $reg[2];
|
||||
}
|
||||
|
||||
$ttc = price2num(GETPOST('price_ttc'));
|
||||
$ttc = price2num(GETPOST('price_ttc'), '', 2);
|
||||
$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.
|
||||
|
||||
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";
|
||||
@ -1294,7 +1302,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
||||
$this->assertEquals(1000.123456, price2num('1 000.123456'));
|
||||
|
||||
// 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");
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
print __METHOD__."\n";
|
||||
@ -347,9 +351,24 @@ class SocieteTest extends PHPUnit\Framework\TestCase
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertNotEquals($result, '');
|
||||
|
||||
$localobject->country_code = 'FR';
|
||||
|
||||
$result=$localobject->isInEEC();
|
||||
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);
|
||||
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user