public function checkForSalesItemMovement(SalesItem $salesItem, SalesItemDataTransferObject $dto)
 {
     $move = null;
     if ($salesItem->getBin() !== $dto->bin) {
         $move = new InventorySalesItemMovement();
         $move->setSalesItem($salesItem);
         $move->setByUser($this->getUser());
         $move->setMovedAt(new \DateTime());
         $move->setFromBin($salesItem->getBin());
         $move->setToBin($dto->bin);
         $this->getDoctrine()->getManager()->persist($move);
     }
     return $move;
 }
 public function getLogEntityForSalesItem(SalesItem $salesItem, User $user)
 {
     switch ($this->type) {
         case 'edit':
             $logEntity = new InventorySalesItemEdit();
             $logEntity->setOldAttributes($this->oldAttributes);
             $logEntity->setNewAttributes($this->newAttributes);
             $logEntity->setEditedAt(new \DateTime());
             $logEntity->setByUser($user);
             $logEntity->setSalesItem($salesItem);
             return $logEntity;
         case 'move':
             $logEntity = new InventorySalesItemMovement();
             $logEntity->fromBin($this->fromBin);
             $logEntity->toBin($this->toBin);
             $logEntity->setMovedAt(new \DateTime());
             $logEntity->setByUser($user);
             $logEntity->setSalesItem($salesItem);
             return $logEntity;
         default:
             throw new \Exception("Must Supply a type('edit','move') for a Mass Sales Item Update");
     }
 }