<?php

declare(strict_types=1);

namespace Australcode\Rewards\Domain\Wallet;

/**
 * Append-only persistence for ledger entries.
 */
interface TransactionRepository {

	/**
	 * Inserts a ledger entry and returns its new id.
	 */
	public function insert( Transaction $transaction ): int;

	/**
	 * @return Transaction[] Most recent first.
	 */
	public function for_user( int $user_id, int $limit = 20, int $offset = 0 ): array;

	public function count_for_user( int $user_id ): int;

	/**
	 * Active entries tied to an order (used to revert on refund/cancel).
	 *
	 * @return Transaction[]
	 */
	public function active_for_order( int $order_id ): array;

	/**
	 * Marks the given entry ids as Reverted (append-only audit; balance is
	 * adjusted separately with a compensating entry).
	 *
	 * @param int[] $ids
	 */
	public function mark_reverted( array $ids ): void;
}
