package org.jpos.tcpay.db.repository;

import org.jpos.tcpay.db.entity.PosTransaction;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * Repository interface for PosTransaction entities
 * Defines contract for completed transaction database operations
 */
public interface PosTransactionRepository {
    
    /**
     * Save a completed transaction to the database
     * @param transaction the entity to save
     * @return the saved entity with generated ID
     */
    PosTransaction save(PosTransaction transaction);
    
    /**
     * Find transaction by ID
     * @param id the transaction ID
     * @return Optional containing the entity if found
     */
    Optional<PosTransaction> findById(Long id);
    
    /**
     * Find transactions by bank terminal and merchant IDs
     * @param bTid bank terminal ID
     * @param bMid bank merchant ID
     * @return list of matching transactions
     */
    List<PosTransaction> findByBankTidAndBankMid(String bTid, String bMid);
    
    /**
     * Count successful transactions since given date
     * @param since the cutoff date
     * @return count of successful transactions
     */
    long countTransactionsSince(LocalDateTime since);
    
    /**
     * Find transactions by response code
     * @param responseCode the response code to filter by
     * @return list of matching transactions
     */
    List<PosTransaction> findByResponseCode(String responseCode);
    
    /**
     * Count all successful transactions
     * @return total count
     */
    long count();
}