public static function getAllTaxes() { static $rows; if (!is_array($rows)) { $jshopConfig = JSFactory::getConfig(); $dispatcher = JDispatcher::getInstance(); $_tax = JSFactory::getTable('tax', 'jshop'); $rows = JSFactory::getAllTaxesOriginal(); if ($jshopConfig->use_extend_tax_rule) { $country_id = 0; $adv_user = JSFactory::getUserShop(); $country_id = $adv_user->country; if ($jshopConfig->tax_on_delivery_address && $adv_user->delivery_adress && $adv_user->d_country) { $country_id = $adv_user->d_country; } $client_type = $adv_user->client_type; $enter_tax_id = $adv_user->tax_number != ""; if (!$country_id) { $adv_user = JSFactory::getUserShopGuest(); $country_id = $adv_user->country; if ($jshopConfig->tax_on_delivery_address && $adv_user->delivery_adress && $adv_user->d_country) { $country_id = $adv_user->d_country; } $client_type = $adv_user->client_type; $enter_tax_id = $adv_user->tax_number != ""; } if ($country_id) { $_rowsext = $_tax->getExtTaxes(); $dispatcher->trigger('beforeGetAllTaxesRowsext', array(&$_rowsext, &$country_id, &$adv_user, &$rows)); foreach ($_rowsext as $v) { if (in_array($country_id, $v->countries)) { if ($jshopConfig->ext_tax_rule_for == 1) { if ($enter_tax_id) { $rows[$v->tax_id] = $v->firma_tax; } else { $rows[$v->tax_id] = $v->tax; } } else { if ($client_type == 2) { $rows[$v->tax_id] = $v->firma_tax; } else { $rows[$v->tax_id] = $v->tax; } } } } $dispatcher->trigger('afterGetAllTaxesRowsext', array(&$_rowsext, &$country_id, &$adv_user, &$rows)); unset($_rowsext); } } $dispatcher->trigger('afterGetAllTaxes', array(&$rows)); } return $rows; }
function getFixBrutopriceToTax($price, $tax_id) { $jshopConfig = JSFactory::getConfig(); if ($jshopConfig->no_fix_brutoprice_to_tax == 1) { return $price; } $taxoriginal = JSFactory::getAllTaxesOriginal(); $taxes = JSFactory::getAllTaxes(); $tax = $taxes[$tax_id]; $tax2 = $taxoriginal[$tax_id]; if ($tax != $tax2) { $price = $price / (1 + $tax2 / 100); $price = $price * (1 + $tax / 100); } return $price; }
function getFixBrutopriceToTax($price, $tax_id) { $taxoriginal = JSFactory::getAllTaxesOriginal(); $taxes = JSFactory::getAllTaxes(); $tax = $taxes[$tax_id]; $tax2 = $taxoriginal[$tax_id]; if ($tax != $tax2) { $price = $price / (1 + $tax2 / 100); $price = $price * (1 + $tax / 100); } return $price; }