![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/StripeIntegration/Tax/Helper/ |
<?php namespace StripeIntegration\Tax\Helper; class ShippingCost { private $currencyHelper; private $taxHelper; private $invoiceHelper; public function __construct( Currency $currencyHelper, Tax $taxHelper, Invoice $invoiceHelper ) { $this->currencyHelper = $currencyHelper; $this->taxHelper = $taxHelper; $this->invoiceHelper = $invoiceHelper; } public function getAmount($amount, $currency) { return $this->currencyHelper->magentoAmountToStripeAmount($amount, $currency); } public function getShippingCostForInvoiceTax($order, $invoice) { $shippingCost = 0; if ($this->invoiceHelper->canIncludeShipping($invoice)) { $shippingCost = $order->getShippingAmount(); if ($this->taxHelper->isShippingTaxInclusive()) { $shippingCost = $order->getShippingInclTax(); } if ($order->getShippingDiscountAmount()) { $shippingCost -= $order->getShippingDiscountAmount(); } } return $shippingCost; } public function getShippingCostForReversal($creditMemo) { $shippingCost = $creditMemo->getShippingAmount(); if ($this->taxHelper->isShippingTaxInclusive()) { $shippingCost = $creditMemo->getShippingInclTax(); } $stripeAmount = $this->getAmount($shippingCost, $creditMemo->getOrderCurrencyCode()); return -$stripeAmount; } public function getShippingCostTaxForReversal($creditMemo) { $shippingTax = $creditMemo->getShippingTaxAmount(); $stripeAmount = $this->getAmount($shippingTax, $creditMemo->getOrderCurrencyCode()); return -$stripeAmount; } }