ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Lts\Taxjar\Model\Tax;
|
||||
|
||||
use Lts\Taxjar\Helper\ResaleCertificate as ResaleCertificateHelper;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Magento\Tax\Api\Data\AppliedTaxInterfaceFactory;
|
||||
use Magento\Tax\Api\Data\AppliedTaxRateInterfaceFactory;
|
||||
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
|
||||
use Magento\Tax\Api\Data\TaxDetailsInterfaceFactory;
|
||||
use Magento\Tax\Api\Data\TaxDetailsItemInterfaceFactory;
|
||||
use Magento\Tax\Api\TaxClassManagementInterface;
|
||||
use Magento\Tax\Model\Calculation;
|
||||
use Magento\Tax\Model\Calculation\CalculatorFactory;
|
||||
use Magento\Tax\Model\Config;
|
||||
|
||||
class TaxCalculation extends \Taxjar\SalesTax\Model\Tax\TaxCalculation
|
||||
{
|
||||
public function __construct(
|
||||
Calculation $calculation,
|
||||
CalculatorFactory $calculatorFactory,
|
||||
Config $config,
|
||||
TaxDetailsInterfaceFactory $taxDetailsDataObjectFactory,
|
||||
TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory,
|
||||
StoreManagerInterface $storeManager,
|
||||
TaxClassManagementInterface $taxClassManagement,
|
||||
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
|
||||
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
|
||||
AppliedTaxInterfaceFactory $appliedTaxDataObjectFactory,
|
||||
AppliedTaxRateInterfaceFactory $appliedTaxRateDataObjectFactory,
|
||||
protected ResaleCertificateHelper $resaleCertificateHelper,
|
||||
) {
|
||||
parent::__construct($calculation, $calculatorFactory, $config, $taxDetailsDataObjectFactory, $taxDetailsItemDataObjectFactory, $storeManager, $taxClassManagement, $dataObjectHelper, $priceCurrency, $appliedTaxDataObjectFactory, $appliedTaxRateDataObjectFactory);
|
||||
}
|
||||
|
||||
protected function processItemDetails(
|
||||
QuoteDetailsItemInterface $item,
|
||||
$useBaseCurrency,
|
||||
$scope
|
||||
) {
|
||||
$price = $this->priceCurrency->round($item->getUnitPrice());
|
||||
$quantity = $this->getTotalQuantity($item);
|
||||
|
||||
$extensionAttributes = $item->getExtensionAttributes();
|
||||
$isResaleCertificate = $this->resaleCertificateHelper->isResaleCertificate();
|
||||
|
||||
if ($isResaleCertificate) {
|
||||
$extensionAttributes->setTaxCollectable(0);
|
||||
$extensionAttributes->setCombinedTaxRate(0);
|
||||
}
|
||||
|
||||
$taxCollectable = $extensionAttributes ? $extensionAttributes->getTaxCollectable() : 0;
|
||||
$taxPercent = $extensionAttributes ? $extensionAttributes->getCombinedTaxRate() : 0;
|
||||
|
||||
if (!$useBaseCurrency) {
|
||||
$taxCollectable = $this->priceCurrency->convert($taxCollectable, $scope);
|
||||
}
|
||||
|
||||
$rowTotal = $price * $quantity;
|
||||
$rowTotalInclTax = $rowTotal + $taxCollectable;
|
||||
|
||||
$priceInclTax = $this->priceCurrency->round($rowTotalInclTax / $quantity);
|
||||
$discountTaxCompensationAmount = 0;
|
||||
|
||||
$appliedTaxes = $this->getAppliedTaxes($item, $scope);
|
||||
|
||||
return $this->taxDetailsItemDataObjectFactory->create()
|
||||
->setCode($item->getCode())
|
||||
->setType($item->getType())
|
||||
->setRowTax($taxCollectable)
|
||||
->setPrice($price)
|
||||
->setPriceInclTax($priceInclTax)
|
||||
->setRowTotal($rowTotal)
|
||||
->setRowTotalInclTax($rowTotalInclTax)
|
||||
->setDiscountTaxCompensationAmount($discountTaxCompensationAmount)
|
||||
->setAssociatedItemCode($item->getAssociatedItemCode())
|
||||
->setTaxPercent($taxPercent)
|
||||
->setAppliedTaxes($appliedTaxes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user