import 'package:niogu_app/core/database/app_database.dart';
import 'package:niogu_app/core/enums/transaction_reference_type.dart';
import 'package:niogu_app/features/report/transaction/domain/entities/transaction_report.dart';
import 'package:niogu_app/features/report/transaction/domain/repositories/i_transaction_report_repository.dart';

class TransactionReportRepositoryImpl implements ITransactionReportRepository {
  final AppDatabase _appDatabase;

  TransactionReportRepositoryImpl(this._appDatabase);

  @override
  Stream<List<TransactionReportItem>> watchTransactionItems({
    String? outletId,
    TransactionType? type,
    DateTime? startDate,
    DateTime? endDate,
  }) {
    return _appDatabase.transactionDao.watchAllTransactionItems(
      outletId: outletId,
      type: type,
      startDate: startDate,
      endDate: endDate,
    );
  }

  @override
  Future<OrderDetail> getOrderDetail(String orderId) async {
    return await _appDatabase.orderDao.getOrderDetail(orderId);
  }

  @override
  Future<PurchaseDetail> getPurchaseDetail(String purchaseId) async {
    return await _appDatabase.purchaseDao.getPurchaseDetail(purchaseId);
  }

  @override
  Future<int> cancelOrder(String orderId) async {
    return await _appDatabase.orderDao.cancelOrder(orderId);
  }

  @override
  Future<int> cancelPurchase(String purchaseId) async {
    return await _appDatabase.purchaseDao.cancelPurchase(purchaseId);
  }
}
