79 $this->weeeCodeToItemMap = [];
92 \
Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
96 $this->_store =
$quote->getStore();
97 if (!$this->weeeData->isEnabled($this->_store)) {
101 $address = $shippingAssignment->getShipping()->getAddress();
102 $items = $shippingAssignment->getItems();
107 $this->weeeTotalExclTax = 0;
108 $this->weeeBaseTotalExclTax = 0;
110 if (
$item->getParentItem()) {
114 if (
$item->getHasChildren() &&
$item->isChildrenCalculated()) {
115 foreach (
$item->getChildren() as $child) {
124 $total->setWeeeCodeToItemMap($this->weeeCodeToItemMap);
125 $total->setWeeeTotalExclTax($this->weeeTotalExclTax);
126 $total->setWeeeBaseTotalExclTax($this->weeeBaseTotalExclTax);
145 $attributes = $this->weeeData->getProductWeeeAttributes(
148 $address->getQuote()->getBillingAddress(),
149 $this->_store->getWebsiteId()
154 $totalValueInclTax = 0;
155 $baseTotalValueInclTax = 0;
156 $totalRowValueInclTax = 0;
157 $baseTotalRowValueInclTax = 0;
159 $totalValueExclTax = 0;
160 $baseTotalValueExclTax = 0;
161 $totalRowValueExclTax = 0;
162 $baseTotalRowValueExclTax = 0;
164 $associatedTaxables =
$item->getAssociatedTaxables();
165 if (!$associatedTaxables) {
166 $associatedTaxables = [];
169 foreach ($associatedTaxables as $iTaxable => $taxable) {
171 unset($associatedTaxables[$iTaxable]);
179 $baseValueExclTax = $baseValueInclTax =
$attribute->getAmount();
180 $valueExclTax = $valueInclTax = $this->priceCurrency->round(
181 $this->priceCurrency->convert($baseValueExclTax, $this->_store)
184 $rowValueInclTax = $rowValueExclTax = $this->priceCurrency->round($valueInclTax *
$item->getTotalQty());
185 $baseRowValueInclTax = $this->priceCurrency->round($baseValueInclTax *
$item->getTotalQty());
186 $baseRowValueExclTax = $baseRowValueInclTax;
188 $totalValueInclTax += $valueInclTax;
189 $baseTotalValueInclTax += $baseValueInclTax;
190 $totalRowValueInclTax += $rowValueInclTax;
191 $baseTotalRowValueInclTax += $baseRowValueInclTax;
193 $totalValueExclTax += $valueExclTax;
194 $baseTotalValueExclTax += $baseValueExclTax;
195 $totalRowValueExclTax += $rowValueExclTax;
196 $baseTotalRowValueExclTax += $baseRowValueExclTax;
200 'base_amount' => $baseValueExclTax,
201 'amount' => $valueExclTax,
202 'row_amount' => $rowValueExclTax,
203 'base_row_amount' => $baseRowValueExclTax,
204 'base_amount_incl_tax' => $baseValueInclTax,
205 'amount_incl_tax' => $valueInclTax,
206 'row_amount_incl_tax' => $rowValueInclTax,
207 'base_row_amount_incl_tax' => $baseRowValueInclTax,
210 if ($this->weeeData->isTaxable($this->_store)) {
212 $weeeItemCode .=
'-' .
$title;
214 $associatedTaxables[] = [
222 $this->weeeCodeToItemMap[$weeeItemCode] =
$item;
225 $item->setAssociatedTaxables($associatedTaxables);
227 $item->setWeeeTaxAppliedAmount($totalValueExclTax)
228 ->setBaseWeeeTaxAppliedAmount($baseTotalValueExclTax)
229 ->setWeeeTaxAppliedRowAmount($totalRowValueExclTax)
230 ->setBaseWeeeTaxAppliedRowAmnt($baseTotalRowValueExclTax);
232 $item->setWeeeTaxAppliedAmountInclTax($totalValueInclTax)
233 ->setBaseWeeeTaxAppliedAmountInclTax($baseTotalValueInclTax)
234 ->setWeeeTaxAppliedRowAmountInclTax($totalRowValueInclTax)
235 ->setBaseWeeeTaxAppliedRowAmntInclTax($baseTotalRowValueInclTax);
239 $totalRowValueExclTax,
240 $baseTotalRowValueExclTax,
241 $totalRowValueInclTax,
242 $baseTotalRowValueInclTax
245 $this->weeeData->setApplied(
$item, array_merge($this->weeeData->getApplied(
$item), $productTaxes));
261 $baseRowValueExclTax,
265 if (!$this->weeeData->isTaxable($this->_store)) {
267 $this->weeeTotalExclTax += $this->priceCurrency->round($rowValueExclTax);
268 $this->weeeBaseTotalExclTax += $this->priceCurrency->round($baseRowValueExclTax);
272 $total->setSubtotalInclTax(
273 $total->getSubtotalInclTax() + $this->priceCurrency->round($rowValueInclTax)
275 $total->setBaseSubtotalInclTax(
276 $total->getBaseSubtotalInclTax() + $this->priceCurrency->round($baseRowValueInclTax)
302 $associatedTaxables = [];
303 foreach (
$item->getChildren() as $child) {
304 $associatedTaxables = array_merge($associatedTaxables, $child->getAssociatedTaxables());
306 $item->setAssociatedTaxables($associatedTaxables);
317 $this->weeeData->setApplied(
$item, []);
319 $item->setAssociatedTaxables([]);
321 $item->setBaseWeeeTaxDisposition(0);
322 $item->setWeeeTaxDisposition(0);
324 $item->setBaseWeeeTaxRowDisposition(0);
325 $item->setWeeeTaxRowDisposition(0);
327 $item->setBaseWeeeTaxAppliedAmount(0);
328 $item->setBaseWeeeTaxAppliedRowAmnt(0);
330 $item->setWeeeTaxAppliedAmount(0);
331 $item->setWeeeTaxAppliedRowAmount(0);
processConfigArray($config, $store)
const KEY_ASSOCIATED_TAXABLE_CODE
collect(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total)
fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
const KEY_ASSOCIATED_TAXABLE_UNIT_PRICE
const KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE
collect(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total)
recalculateParent(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
processTotalAmount( $total, $rowValueExclTax, $baseRowValueExclTax, $rowValueInclTax, $baseRowValueInclTax)
const KEY_ASSOCIATED_TAXABLE_TYPE
const KEY_ASSOCIATED_TAXABLE_QUANTITY
process(\Magento\Quote\Model\Quote\Address $address, \Magento\Quote\Model\Quote\Address\Total $total, $item)
const ITEM_CODE_WEEE_PREFIX
__construct(\Magento\Weee\Helper\Data $weeeData, PriceCurrencyInterface $priceCurrency)
const KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID