Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046165
D47.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jun 27, 9:08 PM
Size
2 KB
Mime Type
text/x-diff
Expires
Sat, Jun 28, 9:08 PM (4 h, 7 m)
Engine
blob
Format
Raw Data
Handle
676310
Attached To
D47: MINC-117 - Update Backorder Flag, when reserving products in the order
D47.id.diff
View Options
Index: branches/5.2.x/units/orders/orders_event_handler.php
===================================================================
--- branches/5.2.x/units/orders/orders_event_handler.php
+++ branches/5.2.x/units/orders/orders_event_handler.php
@@ -1693,27 +1693,37 @@
$inv_object =& $this->getInventoryObject($product_object, $combination_item, $combinations[ $rec['ProductId'].'_'.$rec['OptionsSalt'] ]);
$lack = $rec['Quantity'] - $rec['QuantityReserved'];
- if ($lack > 0) {
- // reserve lack or what is available (in case if we need to reserve anything, by Alex)
- $to_reserve = min($lack, $inv_object->GetDBField('QtyInStock') - $product_object->GetDBField('QtyInStockMin'));
- if ($to_reserve < $lack) $event->status = kEvent::erFAIL; // if we can't reserve the full lack
+ if ( $lack > 0 ) {
+ // Reserve lack or what is available (in case if we need to reserve anything, by Alex).
+ $to_reserve = min(
+ $lack,
+ $inv_object->GetDBField('QtyInStock') - $product_object->GetDBField('QtyInStockMin')
+ );
- //reserve in order
- $order_item->SetDBFieldsFromHash($rec);
- $order_item->SetDBField('QuantityReserved', $rec['QuantityReserved'] + $to_reserve);
- $order_item->SetId($rec['OrderItemId']);
- $order_item->Update();
+ // If we can't reserve the full lack.
+ if ( $to_reserve < $lack ) {
+ $event->status = kEvent::erFAIL;
+ }
+
+ // Reserve in order.
+ $order_item->SetDBFieldsFromHash($rec);
+ $order_item->SetDBField('QuantityReserved', $rec['QuantityReserved'] + $to_reserve);
+ $new_lack = $order_item->GetDBField('Quantity') - $order_item->GetDBField('QuantityReserved');
+ $order_item->SetDBField('BackOrderFlag', abs($new_lack) <= 0.0001 ? 0 : 1);
+ $order_item->SetId($rec['OrderItemId']);
+ $order_item->Update();
- //update product - increase reserved, decrease in stock
+ // Update product - increase reserved, decrease in stock.
$inv_object->SetDBField('QtyReserved', $inv_object->GetDBField('QtyReserved') + $to_reserve);
$inv_object->SetDBField('QtyInStock', $inv_object->GetDBField('QtyInStock') - $to_reserve);
$inv_object->SetDBField('QtyBackOrdered', $inv_object->GetDBField('QtyBackOrdered') - $to_reserve);
$inv_object->Update();
- if ($product_object->GetDBField('InventoryStatus') == 2) {
- // inventory by options, then restore changed combination values back to common $combinations array !!!
- $combinations[ $rec['ProductId'].'_'.$rec['OptionsSalt'] ] = $inv_object->GetFieldValues();
+ if ( $product_object->GetDBField('InventoryStatus') == 2 ) {
+ // Inventory by options, then restore changed combination
+ // values back to common $combinations array !!!
+ $combinations[$rec['ProductId'] . '_' . $rec['OptionsSalt']] = $inv_object->GetFieldValues();
}
}
$order_items->GoNext();
Event Timeline
Log In to Comment