Skip to content

Commit

Permalink
20.18.14 SHQ18-438 Implement rounding for decimal quantities under 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Bernard committed Jul 17, 2018
1 parent 8010a3a commit 8ed3dad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,7 @@ SHQ18-289 Fetch rates if out of stock item allows backorders
SHQ18-344 correct variable names for time slot and pickup location name


## 20.18.14 (2018-07-17)
SHQ18-438 Implement rounding for decimal quantities under 1


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,7 @@ SHQ18-289 Fetch rates if out of stock item allows backorders
SHQ18-344 correct variable names for time slot and pickup location name


## 20.18.14 (2018-07-17)
SHQ18-438 Implement rounding for decimal quantities under 1


2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-shipper",
"description": "Magento Shipping integration with ShipperHQ",
"type": "magento2-module",
"version": "20.18.13",
"version": "20.18.14",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
16 changes: 15 additions & 1 deletion src/Model/Carrier/Processor/ShipperMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,24 @@ public function getFormattedItems($request, $magentoItems, $childItems = false)
$baseDiscountAmount = $magentoItem->getBaseDiscountAmount();
}

$qty = $magentoItem->getQty() ? floatval($magentoItem->getQty()) : 0;

if ($qty < 1 && $qty > 0) {
$qty = 1; //SHQ18-438
$weight = $weight * $magentoItem->getQty();

$this->shipperLogger->postInfo(
'ShipperHQ_Shipper',
'Item quantity is decimal and less than 1, rounding quantity up to 1.'.
'Setting weight to fractional value',
'SKU: '.$magentoItem->getSku(). ' Weight: '. $weight
);
}

$formattedItem = $this->itemFactory->create([
'id' => $id,
'sku' => $magentoItem->getSku(),
'qty' => $magentoItem->getQty() ? floatval($magentoItem->getQty()) : 0,
'qty' => $qty,
'weight' => $weight,
'rowTotal' => $magentoItem->getRowTotal(),
'basePrice' => $magentoItem->getBasePrice(),
Expand Down
2 changes: 1 addition & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-shipper",
"description": "Magento Shipping integration with ShipperHQ",
"type": "magento2-module",
"version": "20.18.13",
"version": "20.18.14",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<ws_timeout>30</ws_timeout>
<use_cache>0</use_cache>
<always_use_cache>1</always_use_cache>
<extension_version>20.18.13</extension_version>
<extension_version>20.18.14</extension_version>
<allowed_methods></allowed_methods>
<magento_version></magento_version>
</shipper>
Expand Down

0 comments on commit 8ed3dad

Please sign in to comment.