diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 57ddc994bf53c..937fde076c150 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -990,7 +990,7 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva,0, $this->societe ,$mysoc); + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1,'', $localtaxes_type); $total_ht = $tabprice[0]; @@ -1136,7 +1136,7 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($tvatx,0, $this->societe ,$mysoc); + $localtaxes_type=getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc); $tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1, '', $localtaxes_type); $total_ht = $tabprice[0]; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index ad301f09d92fa..d71c26af29cc3 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -776,32 +776,37 @@ function get_input_id_prof($idprof,$htmlname,$preselected,$country_code) return $out; } - + /** - * Return a select with localtax values for thirds - * - * @param int $local LocalTax - * @param int $selected Preselected value - * @param varchar $htmlname HTML select name + * Return a HTML select with localtax values for thirdparties + * + * @param int $local LocalTax + * @param int $selected Preselected value + * @param varchar $htmlname HTML select name + * @return void */ function select_localtax($local, $selected, $htmlname) { $tax=get_localtax_by_third($local); - + $num = $this->db->num_rows($tax); $i = 0; if ($num) { $valors=explode(":", $tax); - - if(count($valors)>1) + + if (count($valors) > 1) { //montar select print ''; - } } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index aa52be4d8442a..b1f11590bdca9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2894,7 +2894,7 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="") if (empty($thirdparty_seller) || ! is_object($thirdparty_seller)) $thirdparty_seller=$mysoc; dol_syslog("get_localtax tva=".$tva." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer)?$thirdparty_buyer->id:'')."/country_code=".(is_object($thirdparty_buyer)?$thirdparty_buyer->country_code:'')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj); - + if($thirdparty_buyer->country_code!=$thirdparty_seller->country_code) { return 0; @@ -2911,7 +2911,7 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="") } else { - if (! $thirdparty_seller->localtax1_assuj) return 0; + if (! $thirdparty_seller->localtax1_assuj) return 0; } } @@ -2978,9 +2978,9 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="") } } } - - - + + + $sql = "SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$thirdparty_seller->country_code."'"; @@ -3001,7 +3001,7 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="") /** * Return true if LocalTax is unique - * + * * @param int $local Local taxt to test * @return boolean True if LocalTax have multiple values, False if not */ @@ -3010,7 +3010,7 @@ function isOnlyOneLocalTax($local) $tax=get_localtax_by_third($local); $valors=explode(":", $tax); - + if(count($valors)>1) { return false; @@ -3023,7 +3023,7 @@ function isOnlyOneLocalTax($local) /** * Get values of localtaxes - * + * * @param int $local LocalTax to get * @return number Values of localtax */ @@ -3043,7 +3043,7 @@ function get_localtax_by_third($local) if ($local==1) return $obj->localtax1; elseif ($local==2) return $obj->localtax2; } - + return 0; } @@ -3058,7 +3058,8 @@ function get_localtax_by_third($local) * * @param float $vatrate VAT Rate * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) - * @param int $thirdparty Company object + * @param int $buyer Company object + * @param int $seller Company object * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) */ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller) @@ -3078,13 +3079,13 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller) { $obj = $db->fetch_object($resql); if ($local == 1) - { + { if (! isOnlyOneLocalTax(1)) { return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy); } else - { + { return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell,$obj->accountancy_code_buy); } } @@ -3095,7 +3096,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller) return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy); } else - { + { return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); } } @@ -3122,8 +3123,8 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller) { return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); } - } - + } + if(! isOnlyOneLocalTax(2)) { if(! isOnlyOneLocalTax(1)) @@ -3146,7 +3147,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller) return array($obj->localtax2_type, $obj->localtax2, $obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell,$obj->accountancy_code_buy); } } - + } }