getTaxRule example

$builder->setFirstResult($this->Request()->getParam('start'))
            ->setMaxResults($this->Request()->getParam('limit'))
            ->orderBy('details.id', 'ASC');

        $result = $builder->execute()->fetchAllAssociative();

        $total = (int) $builder->getConnection()->fetchOne('SELECT FOUND_ROWS()');

        $result = $this->addAdditionalTextForVariant($result);

        foreach ($result as $index => $variant) {
            $taxRule = $shopContext->getTaxRule($variant['taxId']);
            if ($taxRule instanceof TaxStruct) {
                $result[$index]['tax'] = (float) $taxRule->getTax();
            }

            $result[$index]['price'] = $customerGroup->getTax() === true ? round((float) $variant['price'] / 100 * (100 + $result[$index]['tax']), 2) : round((float) $variant['price'], 2);
        }

        $this->View()->assign(['success' => true, 'data' => $result, 'total' => $total]);
    }
}
$dispatch['shippingfree'] = round($dispatch['shippingfree'] / (100 + $discount_tax) * 100, 2);
        }

        if ((!empty($dispatch['shippingfree']) && $dispatch['shippingfree'] <= $basket['amount_display'])
            || empty($basket['count_article'])
            || (!empty($basket['shippingfree']) && empty($dispatch['bind_shippingfree']))
        ) {
            if (empty($dispatch['surcharge_calculation']) && !empty($payment['surcharge'])) {
                $tax = (float) $basket['max_tax'];

                if (!empty($dispatch['tax_calculation'])) {
                    $taxRule = $this->contextService->getShopContext()->getTaxRule($dispatch['tax_calculation']);
                    if ($taxRule instanceof Tax) {
                        $tax = $taxRule->getTax();
                    }
                }

                return [
                    'brutto' => $payment['surcharge'],
                    'netto' => round($payment['surcharge'] * 100 / (100 + $tax), 2),
                    'tax' => $tax,
                    'value' => '0',
                    'factor' => '0',
                    
return $price;
    }

    /** * @param int $taxId * * @return string|false */
    public function getTaxRateByConditions($taxId)
    {
        $taxRate = $this->contextService->getShopContext()->getTaxRule($taxId);
        if ($taxRate) {
            return number_format($taxRate->getTax(), 2);
        }

        return false;
    }

    /** * Product price calculation un-formatted return * * @param float $price * @param float $tax * @param bool $doNotRound * @param bool $ignoreTax * @param int $taxId * @param bool $ignoreCurrency * @param array $article product data as an array * * @throws Enlight_Exception * * @return float $price price non-formatted */

        $this->priceCalculatorService = $priceCalculatorService;
    }

    /** * {@inheritdoc} */
    public function calculateProduct(
        ListProduct $product,
        ShopContextInterface $context
    ) {
        $tax = $context->getTaxRule($product->getTax()->getId());
        if (!$tax instanceof Tax) {
            throw new StructNotFoundException(Tax::class$product->getTax()->getId());
        }

        $rules = $product->getPriceRules();

        $prices = [];
        foreach ($rules as $rule) {
            $prices[] = $this->calculatePriceStruct($rule$tax$context);
        }

        

                'sessionId' => $sessionId,
                'queryBuilder' => $qb,
            ]
        );

        $maxTaxId = $qb->execute()->fetchOne();
        if (!$maxTaxId) {
            return false;
        }

        $tax = $this->contextService->getShopContext()->getTaxRule($maxTaxId);

        return $tax->getTax();
    }

    /** * Add voucher to cart * Used in several places * * @param string $voucherCode Voucher code * @param string $basket * * @throws \Exception * @throws \Enlight_Exception * @throws \Enlight_Event_Exception * @throws \Zend_Db_Adapter_Exception * * @return array|bool True if successful, false if stopped by an event, array with error data if one occurred */
            return 0.0;
        }

        /* * This case is a fallback, in case the tax mode associated with the * voucher is none of the known ones. The value will then be * interpreted as a tax ID and the corresponding tax rate is * selected based on it. */
        if ((int) $voucherTaxMode) {
            // Fix defined tax             $taxRule = $this->contextService->getContext()->getTaxRule((int) $voucherTaxMode);

            if ($taxRule instanceof Tax) {
                return $taxRule->getTax();
            }
        }

        return null;
    }
}
private function getListProductData(ListProduct $product): array
    {
        $createDate = null;
        if ($product->getCreatedAt()) {
            $createDate = $product->getCreatedAt()->format('Y-m-d');
        }
        $updateDate = null;
        if ($product->getUpdatedAt()) {
            $updateDate = $product->getUpdatedAt()->format('Y-m-d');
        }
        $tax = $product->getTax();
        $taxRule = $this->contextService->getShopContext()->getTaxRule($product->getTax()->getId());
        if ($taxRule instanceof Tax) {
            $tax = $taxRule;
        }

        $data = [
            'articleID' => $product->getId(),
            'articleDetailsID' => $product->getVariantId(),
            'ordernumber' => $product->getNumber(),
            'highlight' => $product->highlight(),
            'description' => $product->getShortDescription(),
            'description_long' => $product->getLongDescription(),
            
if (empty($taxId)) {
            unset($data['tax']);

            return $data;
        }
        $tax = $this->getManager()->find(Tax::class$taxId);
        if ($tax instanceof Tax) {
            $data['tax'] = $tax;
            $data['taxRate'] = (float) $tax->getTax();
        }

        $taxRule = $shopContext->getTaxRule($taxId);
        if ($taxRule instanceof TaxStruct) {
            $data['taxRate'] = (float) $taxRule->getTax();
        }

        return $data;
    }

    private function hasProductGraduatedPrices(string $productNumber, Order $order): bool
    {
        $customerGroupKey = $this->getCustomerGroupKey($order);

        
Home | Imprint | This part of the site doesn't use cookies.