Skip to content

Commit fcd3fb6

Browse files
author
Alexey Yakimovich
committed
MAGETWO-96545: Wrong calculation of invoiced items in shipment document in order with bundle product after partial invoice
- Moved logic part from template to block;
1 parent 61a6256 commit fcd3fb6

File tree

2 files changed

+33
-6
lines changed
  • app/code/Magento/Bundle

2 files changed

+33
-6
lines changed

app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public function getChildren($item)
100100
}
101101

102102
/**
103+
* Check if item can be shipped separately
104+
*
103105
* @param mixed $item
104106
* @return bool
105107
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -136,6 +138,8 @@ public function isShipmentSeparately($item = null)
136138
}
137139

138140
/**
141+
* Check if child items calculated
142+
*
139143
* @param mixed $item
140144
* @return bool
141145
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -174,6 +178,8 @@ public function isChildCalculated($item = null)
174178
}
175179

176180
/**
181+
* Retrieve selection attributes values
182+
*
177183
* @param mixed $item
178184
* @return mixed|null
179185
*/
@@ -191,6 +197,8 @@ public function getSelectionAttributes($item)
191197
}
192198

193199
/**
200+
* Retrieve order item options array
201+
*
194202
* @return array
195203
*/
196204
public function getOrderOptions()
@@ -212,6 +220,8 @@ public function getOrderOptions()
212220
}
213221

214222
/**
223+
* Retrieve order item
224+
*
215225
* @return mixed
216226
*/
217227
public function getOrderItem()
@@ -223,6 +233,8 @@ public function getOrderItem()
223233
}
224234

225235
/**
236+
* Get html info for item
237+
*
226238
* @param mixed $item
227239
* @return string
228240
*/
@@ -245,6 +257,8 @@ public function getValueHtml($item)
245257
}
246258

247259
/**
260+
* Check if we can show price info for this item
261+
*
248262
* @param object $item
249263
* @return bool
250264
*/
@@ -257,4 +271,22 @@ public function canShowPriceInfo($item)
257271
}
258272
return false;
259273
}
274+
275+
/**
276+
* Check if this iten should be shipped together
277+
*
278+
* @param object $item
279+
* @return bool
280+
*/
281+
public function isShipTogether($item)
282+
{
283+
$orderItem = $item->getOrderItem();
284+
if ($orderItem->getProductType() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
285+
$shipTogether = !$orderItem->isShipSeparately();
286+
} else {
287+
$shipTogether = !$orderItem->getParentItem()->isShipSeparately();
288+
}
289+
290+
return $shipTogether;
291+
}
260292
}

app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/create/items/renderer.phtml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@
2929

3030
<?php foreach ($items as $_item): ?>
3131
<?php
32-
$orderItem = $_item->getOrderItem();
33-
if ($orderItem->getProductType() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
34-
$shipTogether = !$orderItem->isShipSeparately();
35-
} else {
36-
$shipTogether = !$orderItem->getParentItem()->isShipSeparately();
37-
}
32+
$shipTogether = $block->isShipTogether($_item);
3833
?>
3934
<?php $block->setPriceDataObject($_item) ?>
4035
<?php if ($_item->getOrderItem()->getParentItem()): ?>

0 commit comments

Comments
 (0)