package com.gestoreasy.repository

import com.gestoreasy.database.dao.CommissionDao
import com.gestoreasy.database.entities.Commission
import kotlinx.coroutines.flow.Flow
import java.util.Date

class CommissionRepository(private val commissionDao: CommissionDao) {
    suspend fun insertOrUpdate(commission: Commission) {
        commissionDao.insertOrUpdate(commission)
    }
    
    suspend fun getByVendedor(vendedorId: Long): List<Commission> {
        return commissionDao.getByVendedor(vendedorId)
    }
    
    suspend fun getByPeriod(startDate: Long, endDate: Long): List<Commission> {
        return commissionDao.getByPeriod(startDate, endDate)
    }
    
    suspend fun getTotalByVendedor(vendedorId: Long): Double {
        return commissionDao.getTotalByVendedor(vendedorId)
    }
    
    fun getByVendedorFlow(vendedorId: Long): Flow<List<Commission>> {
        return commissionDao.getByVendedorFlow(vendedorId)
    }
}

