import 'package:niogu_app/core/database/app_database.dart';
import 'package:niogu_app/core/enums/item_type.dart';
import 'package:niogu_app/features/report/stock_report/domain/entities/stok_report.dart';
import 'package:niogu_app/features/report/stock_report/domain/repositories/i_stock_report_repository.dart';

class StockReportRepositoryImpl implements IStockReportRepository {
  final AppDatabase _appDatabase;

  StockReportRepositoryImpl(this._appDatabase);

  @override
  Stream<List<StockReportItem>> watchStockReports({
    String? outletId,
    ItemType? itemType,
    DateTime? startDate,
    DateTime? endDate,
  }) {
    return _appDatabase.stockCardDao.watchAllStockReports(
      outletId: outletId,
      itemType: itemType,
      startDate: startDate,
      endDate: endDate
    );
  }

  @override
  Future<StockReportDetail> getStockReportById({
    required String id,
    required ItemType itemType,
    DateTime? startDate,
    DateTime? endDate,
  }) async {
    return await _appDatabase.stockCardDao.getStockReportById(
      id: id,
      itemType: itemType,
      startDate: startDate,
      endDate: endDate,
    );
  }
}
