Skip to content

Commit

Permalink
Handle discounts applied to shipping amounts. Fixes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
fastdivision committed Jun 1, 2018
1 parent 8057843 commit 87f614f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Model/Smartcalcs.php
Expand Up @@ -143,6 +143,8 @@ public function getTaxForOrder(
return;
}

$shipping = $address->getShippingAmount() - $address->getShippingDiscountAmount();

$shippingRegionId = $this->scopeConfig->getValue('shipping/origin/region_id',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$quote->getStoreId()
Expand Down Expand Up @@ -177,7 +179,7 @@ public function getTaxForOrder(
];

$order = array_merge($fromAddress, $toAddress, [
'shipping' => (float) $address->getShippingAmount(),
'shipping' => (float) $shipping,
'line_items' => $this->_getLineItems($quote, $quoteTaxDetails),
'nexus_addresses' => $this->_getNexusAddresses($quote->getStoreId()),
'plugin' => 'magento'
Expand Down
2 changes: 1 addition & 1 deletion Model/Transaction/Order.php
Expand Up @@ -42,7 +42,7 @@ public function build(
) {
$createdAt = new \DateTime($order->getCreatedAt());
$subtotal = (float) $order->getSubtotal();
$shipping = (float) $order->getShippingAmount();
$shipping = (float) $order->getShippingAmount() - $order->getShippingDiscountAmount();
$discount = (float) $order->getDiscountAmount();
$salesTax = (float) $order->getTaxAmount();

Expand Down
2 changes: 1 addition & 1 deletion Model/Transaction/Refund.php
Expand Up @@ -48,7 +48,7 @@ public function build(
\Magento\Sales\Model\Order\Creditmemo $creditmemo
) {
$subtotal = (float) $creditmemo->getSubtotal();
$shipping = (float) $creditmemo->getShippingAmount();
$shipping = (float) $creditmemo->getShippingAmount() - $creditmemo->getShippingDiscountAmount();
$discount = (float) $creditmemo->getDiscountAmount();
$salesTax = (float) $creditmemo->getTaxAmount();

Expand Down

0 comments on commit 87f614f

Please sign in to comment.