import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.dart';
import '../models/billing_period.dart';
import '../repositories/billing_repository.dart';

/// Use case for fetching the spending breakdown items.
///
/// This use case encapsulates the logic for retrieving the spending breakdown by category or item.
/// It delegates the data retrieval to the [BillingRepository].
class GetSpendingBreakdownUseCase
    extends UseCase<BillingPeriod, List<InvoiceItem>> {
  /// Creates a [GetSpendingBreakdownUseCase].
  GetSpendingBreakdownUseCase(this._repository);

  final BillingRepository _repository;

  @override
  Future<List<InvoiceItem>> call(BillingPeriod period) =>
      _repository.getSpendingBreakdown(period);
}
