function calculateTaxList($price)
 {
     $cart = $this->getCart();
     $jshopConfig = JSFactory::getConfig();
     if ($this->tax_id == -1) {
         $prodtaxes = getPriceTaxRatioForProducts($cart->products);
         $prices = array();
         foreach ($prodtaxes as $k => $v) {
             $prices[] = array('tax' => $k, 'price' => $price * $v);
         }
         $taxes = array();
         if ($jshopConfig->display_price_front_current == 0) {
             foreach ($prices as $v) {
                 $taxes[$v['tax']] = $v['price'] * $v['tax'] / (100 + $v['tax']);
             }
         } else {
             foreach ($prices as $v) {
                 $taxes[$v['tax']] = $v['price'] * $v['tax'] / 100;
             }
         }
     } else {
         $taxes = array();
         $taxes[$this->getTax()] = $this->calculateTax($price);
     }
     return $taxes;
 }
Exemple #2
0
function getPriceCalcParamsTax($price, $tax_id, $products = array())
{
    $jshopConfig = JSFactory::getConfig();
    $taxes = JSFactory::getAllTaxes();
    if ($tax_id == -1) {
        $prodtaxes = getPriceTaxRatioForProducts($products);
    }
    if ($jshopConfig->display_price_admin == 0 && $tax_id > 0) {
        $price = getFixBrutopriceToTax($price, $tax_id);
    }
    if ($jshopConfig->display_price_admin == 0 && $tax_id == -1) {
        $prices = array();
        $prodtaxesid = getPriceTaxRatioForProducts($products, 'tax_id');
        foreach ($prodtaxesid as $k => $v) {
            $prices[$k] = getFixBrutopriceToTax($price * $v, $k);
        }
        $price = array_sum($prices);
    }
    if ($tax_id > 0) {
        $tax = $taxes[$tax_id];
    } elseif ($tax_id == -1) {
        $prices = array();
        foreach ($prodtaxes as $k => $v) {
            $prices[] = array('tax' => $k, 'price' => $price * $v);
        }
    } else {
        $taxlist = array_values($taxes);
        $tax = $taxlist[0];
    }
    if ($jshopConfig->display_price_admin == 1 && $jshopConfig->display_price_front_current == 0) {
        if ($tax_id == -1) {
            $price = 0;
            foreach ($prices as $v) {
                $price += $v['price'] * (1 + $v['tax'] / 100);
            }
        } else {
            $price = $price * (1 + $tax / 100);
        }
    }
    if ($jshopConfig->display_price_admin == 0 && $jshopConfig->display_price_front_current == 1) {
        if ($tax_id == -1) {
            $price = 0;
            foreach ($prices as $v) {
                $price += $v['price'] / (1 + $v['tax'] / 100);
            }
        } else {
            $price = $price / (1 + $tax / 100);
        }
    }
    return $price;
}