Get last by transaction

@access public
@param Transaction $transaction
@return array $transaction_logs
161597
public static function get_last_by_transaction(Transaction $transaction) {
		$db = Database::Get();
		$id = $db->get_one('SELECT id FROM transaction_log WHERE transaction_id=? ORDER BY created DESC LIMIT 1', [ $transaction->id ]);
		if ($id === null) {
			throw new \Exception('No transaction_log yet');
		}

		return self::get_by_id($id);;
	}
108786
protected function getCommand(Transaction $transaction)
    {
        switch ($transaction->getType()->getValue()) {
            case Transaction\TransactionType::SALE:
                return 'ECheck.ProcessPayment';

            case Transaction\TransactionType::AUTH:
                return 'ECheck.Authorize';

            case Transaction\TransactionType::CAPTURE:
                return 'ECheck.Capture';

            case Transaction\TransactionType::REFUND:
                return 'ECheck.Refund';

            case Transaction\TransactionType::VOID:
                return 'ECheck.Void';

            case Transaction\TransactionType::QUERY:
                return 'ECheckReports.StatusTrackingQuery';

            case Transaction\TransactionType::UPDATE:
                return 'ECheck.Update';
        }
    }
417063
private function getUnprocessedCapture($payment, $transaction)
    {
        $processedCaptures = $this->getProcessedCaptures($payment);
        return @end(array_filter(
                $transaction->captures,
                function($capture) use ($processedCaptures) {
                    return !in_array($capture->id, $processedCaptures) && $capture->status == 'succeeded';
                })
        );
    }
839615
public function getTransaction() {
        if(!$this->isInTransaction()) {
            throw new \Exception('This transaction has already been rolled back, or committed, or has not began yet');
        }
        $transactions = $this->getTransactions();
        return $transactions[$this->getDbService()];
    }
347291
public function getTransaction( $transaction = self::TRANSACTION_LAST_USED, $throwExceptionIfNotFound = true )
    {

        if( $transaction === self::TRANSACTIONS_ALL ) {
            return array_keys( $this->queue );
        }

        if( $transaction === self::TRANSACTION_LAST_CREATED ) {
            if( !$this->queue) {
                $this->newTransaction();
            }
            $queue = array_keys( $this->queue );
            return array_pop( $queue );
        }

        if( $transaction === self::TRANSACTION_LAST_USED ) {
            if( !$this->queue) {
                $this->newTransaction();
            }
            return $this->lastTransaction;
        }

        if( $transaction === self::TRANSACTION_NEW ) {
            return $this->newTransaction();
        }

        if( !array_key_exists( $transaction, $this->queue ) ) {
            if( $throwExceptionIfNotFound ) {
                throw new TransactionDoesNotExistException(
                    "Transaction with this name `{$transaction}` doesn't exist. Sorry."
                );
            }
            return null;
        }

        return $transaction;

    }
140871
public function isCurrentUserOwner(Transaction $transaction)
    {
        if($this->securityContext->getToken()->getUser()->isGranted('ROLE_ADMIN')){
            return true;
        }
        
        $currentUserId = $this->securityContext->getToken()->getUser()->getId();
        //actor owner
        if($transaction->getActor() instanceof Actor){
            if($currentUserId ==  $transaction->getActor()->getId()){
                return true;
            }elseif($currentUserId == $transaction->getItems()->first()->getProduct()->getActor()->getId()){
                return true;
            }
        }
        
        return false;
    }
1102693
public static function run_transaction(Transaction $transaction) {
		ob_start();
		echo date('[r] ') . 'Running ' . $transaction->classname . ' - ' . $transaction->id . "\n";

		$failed = false;
		try {
			$transaction->run();
		} catch (\Throwable $e) {
			$failed = true;
		} catch (\Exception $e) {
			$failed = true;
		}
		echo "\n";
		echo date('[r] ') . 'Finished ' . $transaction->classname . ' - ' . $transaction->id . "\n";

		$content = ob_get_contents();
		ob_get_clean();

		if ($failed) {
			$transaction->mark_failed($content, $e);
		} else {
			$transaction->mark_completed($content);
		}
	}
12601
static public function calculateForTransaction(Transaction $transaction)
    {
        // generate each content fee accordingly
        $msgFee = self::calculateForMessage($transaction->message());

        // default content fee is XEM amount transfer fee
        $contentFee = Fee::FEE_FACTOR * self::calculateForXEM($transaction->amount()->toMicro() / Amount::XEM);

        // get the Transaction extension fee
        $extensionFee = $transaction->extendFee();

        if ($extensionFee > 0) {
            $contentFee = (int) $extensionFee;
        }

        return $msgFee + $contentFee;
    }
1188793
public function last_affected_rows( Statement $statement = NULL ) {

		if ( $statement && ! $this->last_statement === $statement )
			return FALSE;

		return $this->last_affected_rows;
	}
177890
protected function getFirstUnprocessedTransactionStatusLog($idSalesOrder, $idSalesOrderItem, $status)
    {
        $transactionStatusLogs = $this->getUnprocessedTransactionStatusLogs($idSalesOrder, $idSalesOrderItem);

        if (empty($transactionStatusLogs)) {
            return null;
        }

        while (count($transactionStatusLogs)) {
            /** @var \Orm\Zed\Payone\Persistence\SpyPaymentPayoneTransactionStatusLog $transactionStatusLog */
            $transactionStatusLog = array_shift($transactionStatusLogs);

            if ($transactionStatusLog->getStatus() == $status) {
                return $transactionStatusLog;
            }
        }

        return null;
    }
271225
public function getLast()
    {
        $query = $this->table()->where('batch', $this->getLastBatchNumber());

        return $query->orderBy('migration', 'desc')->get()->all();
    }
1296902
private function extractSales($transactions) {
		$out = [];
		
		foreach ($transactions as $trx) {
			foreach ($trx->related_resources as $src) {
				if (isset($src->sale)) {
					$out[] = $src->sale;
				}
			}
		}
		
		return $out;
	}
639942
public function _send($transaction)
        {
            $storeId        = $this->getConfigData('store_id');
            $apiToken       = $this->getConfigData('api_token');

            $request        = new mpgRequest($transaction);

            $mpgHttpsPost   = new mpgHttpsPost($storeId, $apiToken, $request);

            return $mpgHttpsPost->getMpgResponse();
        }
1361762
public function setDataFromTransaction($transaction)
    {
        foreach ($this->owner->config()->get('customer_map') as $type => $map) {
            switch ($type) {
                case 'int':
                    foreach ($map as $foxyField => $foxyStripeField) {
                        if ((int)$transaction->{$foxyField}) {
                            $this->owner->{$foxyStripeField} = (int)$transaction->{$foxyField};
                        }
                    }
                    break;
                case 'string':
                    foreach ($map as $foxyField => $foxyStripeField) {
                        if ((string)$transaction->{$foxyField}) {
                            $this->owner->{$foxyStripeField} = (string)$transaction->{$foxyField};
                        }
                    }
                    break;
            }
        }
        $this->owner->PasswordEncryption = 'none';

        return $this->owner;
    }
977962
protected function doTransact(Transaction $transaction, array $options = array())
    {
        $this->validateTransaction($transaction);
        $params = $this->buildParams($transaction, $options);
        $result = $transaction->getResult();
        $result->setTransactor($this);

        $postUrl = $options['post_url'];
        $client = $this->getClient();

        $request = $client->post($postUrl)
            ->addPostFields($params);

        try {
            $response = $request->send();
            $data = array();
            parse_str($response->getBody(true), $data);
        } catch (BadResponseException $e) {
            $data = array(
                'response' => '3',
                'message' => $e->getMessage()
            );
        }

        if (empty($data['response']) || '1' != $data['response']) {
            $result->setStatus(new Result\ResultStatus((!empty($data['response']) && '2' == $data['response']) ? Result\ResultStatus::DECLINED : Result\ResultStatus::ERROR));
            $result->setMessage(empty($data['responsetext']) ? 'An error occurred while processing the payment. Please try again.' : $data['responsetext']);

            if (!empty($data['transactionid'])) {
                $result->setExternalId($data['transactionid']);
            }
        } else {
            $result->setStatus(new Result\ResultStatus(Result\ResultStatus::APPROVED));
            $result->setExternalId($data['transactionid']);
        }

        $result->setData('request', $params);
        $result->setData('response', $data);

        return $result;
    }
368846
def get_last(self):
        
        query = self.table().where('batch', self.get_last_batch_number())

        return query.order_by('migration', 'desc').get()
226172
private function getBoltTransactionStatus($transactionState)
    {
        return [
            self::TS_ZERO_AMOUNT => 'ZERO AMOUNT COMPLETED',
            self::TS_PENDING => 'UNDER REVIEW',
            self::TS_AUTHORIZED => 'AUTHORIZED',
            self::TS_CAPTURED => 'CAPTURED',
            self::TS_COMPLETED => 'COMPLETED',
            self::TS_CANCELED => 'CANCELED',
            self::TS_REJECTED_REVERSIBLE => 'REVERSIBLE REJECTED',
            self::TS_REJECTED_IRREVERSIBLE => 'IRREVERSIBLE REJECTED',
            self::TS_CREDIT_COMPLETED => Hook::$fromBolt ? 'REFUNDED UNSYNCHRONISED' : 'REFUNDED'
        ][$transactionState];
    }