protected function scannedUPC($entry) { $upcID = $entry->objectID; Log::debug("upcID: {$upcID}"); // gather relevant data $podID = Session::get('podID'); $articleID = Session::get('articleID'); Log::debug("podID: {$podID}, articleID: {$articleID}"); $pod = $this->purchaseOrderDetailRepository->find($podID); $article = $this->articleRepository->find($articleID); //$upc = $this->upcRepository->find($upcID); $locationID = $this->findLocationID(); // produce error message if $upcID not part of this pod & article $upcs = $this->upcRepository->getArticleUPCs($articleID, 0); foreach ($upcs as $individual) { if ($individual->objectID == $upcID) { $upc = $individual; break; } } if (!isset($upc)) { $responseKey = ['key' => 'scannedUPC', 'upcID' => $upcID, 'error' => Lang::get('internal.errors.upc.notOfArticle', ['Text' => $entry->Text, 'article' => $article->Client_SKU]), 'mode' => self::RECEIVE_UPC, 'time' => Carbon::now()]; return $responseKey; } Log::debug("build our responseKey"); // build our responseKey $responseKey = ['key' => 'scannedUPC', 'upcID' => $upcID, 'Description' => $upc->Description, 'mode' => self::RECEIVE_UPC, 'time' => Carbon::now()]; // is there any received inventory for this UPC in this Location? $filter = ['Status' => Config::get('constants.inventory.status.received'), 'locationID' => $locationID]; if (isset($article->split) and $article->split == 'N') { $filter['articleID'] = $article->objectID; } else { $filter['Item'] = $upc->objectID; $filter['Order_Line'] = $pod->objectID; } $inventory = $this->inventoryRepository->filterOn($filter, 1); Log::debug("looking for inventory: "); Log::debug($inventory); if (isset($inventory)) { // what tote is this inventory in? $totes = $this->toteRepository->filterOn(['THOU.container.child' => $inventory->objectID]); if (isset($totes) and count($totes) > 0) { $responseKey['key'] = 'scannedUPCinTote'; $responseKey['cartonID'] = $totes[0]->Carton_ID; } } Log::debug("return our responseKey"); // return our responseKey return $responseKey; }
/** * Confirm a Purchase Order * 1. VITaL receives ONLY “expected” inventory on UPC level (no over or short receipts) * 2. VITaL processes required +/- adjustments using HH reason code * Adjustments processed under user ID that executed PO close * 3. VITaL stores / writes PO / article / UPC / variance details for vendor compliance reporting * Report to be scoped * @param $podID */ public function confirm($poID) { Log::debug(__METHOD__ . "(" . __LINE__ . "): confirm: {$poID}"); $purchaseOrder = $this->purchaseOrderRepository->find($poID); //dd($po); // scan each Purchase Order Detail line $filter = ['Order_Number' => $purchaseOrder->objectID]; $purchaseOrderDetails = $this->purchaseOrderDetailRepository->filterOn($filter); //dd(count($purchaseOrderDetails)); if (isset($purchaseOrderDetails) && count($purchaseOrderDetails)) { // foreach purchaseOrderDetail record, merge with Article foreach ($purchaseOrderDetails as $purchaseOrderDetail) { //scan each UPC in the Article $article = $this->articleRepository->find($purchaseOrderDetail->SKU); // $received is calculated from Inventory in status received $invFilter = ['Status' => [Config::get('constants.inventory.status.received'), Config::get('constants.inventory.status.putAway')], 'Order_Line' => $purchaseOrderDetail->objectID]; $upcs = $this->upcRepository->getArticleUPCs($article->objectID); foreach ($upcs as $upc) { # accumulate expected and received $expected = $purchaseOrderDetail->Expected_Qty * $upc->Quantity; $invFilter['Item'] = $upc->objectID; // $received is calculated from ReceiptHistory counting Received UPC into Tote... entries $filter = ['POD' => $purchaseOrderDetail->objectID, 'UPC' => $upc->objectID, 'Activity' => preg_replace('/ - .*/', '', Lang::get('internal.receiptHistory.putUPCinTote', ['time' => '%', 'upcSKU' => '%', 'n' => '%', 'ofn' => '%']))]; $received = $this->receiptHistoryRepository->countOn($filter); # where expected and received differ, insert an adjustment record for the differences if ($expected != $received) { $objectID = $purchaseOrderDetail->objectID; // attempt to get an Inventory->objectID $inventory = $this->inventoryRepository->filterOn($invFilter, 1); if (isset($inventory) && count($inventory) > 0 && isset($inventory[0]->objectID)) { $objectID = $inventory[0]->objectID; } // insert an adjustment $this->insertAdjustment($objectID, $expected, $received, $poID); } $this->insertVendorCompliance($purchaseOrder->Purchase_Order, $purchaseOrderDetail->objectID, $article->objectID, $upc->objectID, $expected, $received); } // we are done with the Purchase Order Detail $status = Config::get('constants.purchaseOrderDetail.status.confirmed'); $this->purchaseOrderDetailRepository->update($purchaseOrderDetail->objectID, ['Status' => $status]); } } // we are done with the Purchase Order $status = Config::get('constants.purchaseOrder.status.confirmed'); $this->purchaseOrderRepository->update($purchaseOrder->objectID, ['Status' => $status]); }
/** * Implement destroy($id) */ public function destroy($id) { Log::debug(__METHOD__ . "(" . __LINE__ . "): id: " . $id); $article = $this->articleRepository->find($id); $deleted = false; if (isset($article)) { /* * In the case of an Article delete request * 1. make sure there are no UPCs for this Article * 2. make sure there are no Inventory records that reference this Article * 3. make sure there are no Inbound_Order_Detail lines that reference this Article * ok to delete */ $upcs = $this->upcRepository->getArticleUPCs($id); Log::debug(__METHOD__ . "(" . __LINE__ . "): UPCs: " . (isset($upcs) ? count($upcs) : 'none')); if (isset($upcs) and count($upcs) > 0) { $children = Lang::get('labels.titles.UPCs'); $model = Lang::get('labels.titles.Article'); $errors = [[Lang::get('internal.errors.deleteHasChildren', ['Model' => $model, 'Children' => $children])]]; return Redirect::back()->withErrors($errors)->withInput(); } $inventories = $this->inventoryRepository->filterOn(['THOU.articleID' => $id]); Log::debug(__METHOD__ . "(" . __LINE__ . "): Inventories: " . (isset($inventories) ? count($inventories) : 'none')); if (isset($inventories) and count($inventories) > 0) { $children = Lang::get('labels.titles.Inventories'); $model = Lang::get('labels.titles.Article'); $errors = [[Lang::get('internal.errors.deleteHasChildren', ['Model' => $model, 'Children' => $children])]]; return Redirect::back()->withErrors($errors)->withInput(); } $pods = $this->purchaseOrderDetailRepository->filterOn(['SKU' => $id]); Log::debug(__METHOD__ . "(" . __LINE__ . "): PODs: " . (isset($pods) ? count($pods) : 'none')); if (isset($pods) and count($pods) > 0) { $children = Lang::get('labels.titles.PurchaseOrderDetails'); $model = Lang::get('labels.titles.Article'); $errors = [[Lang::get('internal.errors.deleteHasChildren', ['Model' => $model, 'Children' => $children])]]; return Redirect::back()->withErrors($errors)->withInput(); } //dd(__METHOD__."(".__LINE__.")",compact('id','article','upcs','inventories','pods')); Log::debug(__METHOD__ . "(" . __LINE__ . "): delete: " . $id); $deleted = $this->articleRepository->delete($id); } Log::debug(__METHOD__ . "(" . __LINE__ . "): deleted: " . ($deleted ? 'yes' : 'no')); return $this->index(); }