Example #1
0
/**
 *	Function that return localtax of a product line (according to seller, buyer and product vat rate)
 *	@param      	societe_vendeuse    	Objet societe vendeuse
 *	@param      	societe_acheteuse   	Objet societe acheteuse
 *  @param			local					Localtax to process (1 or 2)
 *	@param      	idprod					Id product
 *	@return     	float               	Taux de localtax appliquer, -1 si ne peut etre determine
 */
function get_default_localtax($societe_vendeuse, $societe_acheteuse, $local, $idprod = 0)
{
    if (!is_object($societe_vendeuse)) {
        return -1;
    }
    if (!is_object($societe_acheteuse)) {
        return -1;
    }
    if ($societe_vendeuse->pays_id == 'ES') {
        if ($local == 1) {
            // Si achatteur non assujeti a RE, localtax1 par default=0
            if (is_numeric($societe_acheteuse->localtax1_assuj) && !$societe_acheteuse->localtax1_assuj) {
                return 0;
            }
            if (!is_numeric($societe_acheteuse->localtax1_assuj) && $societe_acheteuse->localtax1_assuj == 'localtax1off') {
                return 0;
            }
        } elseif ($local == 2) {
            // Si vendeur non assujeti a IRPF, localtax2 par default=0
            if (is_numeric($societe_vendeuse->localtax2_assuj) && !$societe_vendeuse->localtax2_assuj) {
                return 0;
            }
            if (!is_numeric($societe_vendeuse->localtax2_assuj) && $societe_vendeuse->localtax2_assuj == 'localtax2off') {
                return 0;
            }
        } else {
            return -1;
        }
        if ($idprod) {
            return get_product_localtax_for_country($idprod, $local, $societe_vendeuse->pays_code);
        } else {
            return -1;
        }
    }
    return 0;
}
Example #2
0
/**
 *	Function that return localtax of a product line (according to seller, buyer and product vat rate)
 *   Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
 *	 Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle.
 *	 Sinon TVA proposee par defaut=0. Fin de regle.
 *
 *	@param	Societe		$thirdparty_seller    	Thirdparty seller
 *	@param  Societe		$thirdparty_buyer   	Thirdparty buyer
 *  @param	int			$local					Localtax to process (1 or 2)
 *	@param  int			$idprod					Id product
 *	@return float        				       	localtax, -1 si ne peut etre determine
 *  @see get_default_tva, get_default_npr
 */
function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod = 0)
{
    global $mysoc;
    if (!is_object($thirdparty_seller)) {
        return -1;
    }
    if (!is_object($thirdparty_buyer)) {
        return -1;
    }
    if ($local == 1) {
        if ($mysoc->country_code == 'ES') {
            if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
                return 0;
            }
        } else {
            // Si vendeur non assujeti a Localtax1, localtax1 par default=0
            if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
                return 0;
            }
            if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') {
                return 0;
            }
        }
    } elseif ($local == 2) {
        // Si vendeur non assujeti a Localtax2, localtax2 par default=0
        if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
            return 0;
        }
        if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') {
            return 0;
        }
    }
    if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
        return get_product_localtax_for_country($idprod, $local, $thirdparty_seller);
    }
    return 0;
}