public function returnCreated(Event $event)
 {
     $return = $event->getReturn();
     $transaction = new Transaction();
     $transaction->type = Types::ORDER_RETURN;
     $transaction->records->add($return);
     foreach ($return->payments as $payment) {
         if ($return->item->order) {
             $payment = new OrderPayment($payment);
             $payment->order = $return->item->order;
         }
         $transaction->records->add($payment);
     }
     foreach ($return->refunds as $refund) {
         if ($return->item->order) {
             $refund = new OrderRefund($refund);
             $refund->order = $return->item->order;
         }
         $transaction->records->add($refund);
     }
     // Add the exchange item, if there is one
     if ($exchangeItem = $return->item->exchangeItem) {
         $transaction->records->add($exchangeItem);
         // Add the exchange item's order, if it's standalone
         if (!$return->item->order) {
             $transaction->records->add($exchangeItem->order);
         }
     }
     $this->get('order.transaction.create')->setDbTransaction($event->getTransaction())->create($transaction);
 }
 public function saveDocument(Event $event)
 {
     $return = $event->getReturn();
     $statusCode = $return->item->status->code;
     if ($statusCode === Statuses::AWAITING_RETURN) {
         $document = $this->get('file.return_slip')->save($return);
         $this->get('db.query')->run("\n\t\t\t\tUPDATE\n\t\t\t\t\t`return`\n\t\t\t\tSET\n\t\t\t\t\tdocument_id = :documentID?i\n\t\t\t\tWHERE\n\t\t\t\t\treturn_id = :returnID?i\n\t\t\t\t", ['documentID' => $document->id, 'returnID' => $return->id]);
     }
 }