import { Injectable } from '@nestjs/common';
import { DataSource } from 'typeorm';
import { TenantAwareRepository } from '@it0/database';
import { StandingOrder } from '../../domain/entities/standing-order.entity';

@Injectable()
export class StandingOrderRepository extends TenantAwareRepository<StandingOrder> {
  constructor(dataSource: DataSource) {
    super(dataSource, StandingOrder);
  }

  async findByStatus(status: string): Promise<StandingOrder[]> {
    return this.withRepository((repo) =>
      repo.find({ where: { status } as any }),
    );
  }
}
