using System.Collections.Generic;
using System.Data.Common;
using System.Threading.Tasks;
using GB5Shared.DTO.Framework.Login;
using GoodBooks.PAY.PAYDAL.DTO.Loyalty;
namespace GoodBooks.PAY.PAYDAL.CustomCode.Loyalty
{
///
/// Data-access contract for TLOYALTYLEDGER — append-only points ledger.
/// CRITICAL: No UPDATE methods are defined here.
/// To reverse or expire points, insert a new compensating row with negative POINTS value.
/// Any modification to existing rows would break the audit trail and balance integrity.
///
public interface ILoyaltyLedgerDAL
{
///
/// Appends a new ledger entry. LOYALTYLEDGERID must be supplied by the caller.
/// Returns rows affected.
///
Task InsertLedgerEntry(LoyaltyLedgerDTO dto, LoginDTO login, DbTransaction? tx);
///
/// Returns the live sum of non-expired points for an enrollment.
/// Executes directly against TLOYALTYLEDGER — never cached.
///
Task GetAvailablePoints(int enrollmentId, LoginDTO login);
///
/// Returns a paged JSON list of ledger entries for an enrollment, newest first.
/// Includes the PayOrderNo from TPAYORDER for display.
///
Task GetLoyaltyLedger(int enrollmentId, int pageOffset, int pageSize, LoginDTO login);
///
/// Returns enrollments that have Earn-type points (ENTRYTYPE=1) expiring today.
/// Used by the daily points-expiry background job to know which enrollments to process.
/// The job then inserts compensating negative-points rows for each returned enrollment.
///
Task> GetExpiringPoints(LoginDTO login);
}
}