import { Injectable } from '@nestjs/common';
import { AvicennaTenant, CostType, Tariff, TariffGroup } from '@prisma/client';
import { TariffRepository } from './tariff.repository';

@Injectable()
export class TariffService {
  constructor(private readonly repository: TariffRepository) {}

  async findTenant(
    healthInsurance: string,
    ordinanceType: string,
  ): Promise<AvicennaTenant> {
    return this.repository.findTenant(healthInsurance, ordinanceType);
  }

  async findByTariffGroupDescription(
    description: string,
    ordinanceType: string,
    dateValid: Date,
  ): Promise<Tariff & { tariffGroup: TariffGroup; costTypes: CostType[] }> {
    return this.repository.findByTariffGroupDescription(
      description,
      ordinanceType,
      dateValid,
    );
  }

  async findByTenantId(
    tenantId: string,
    ordinanceType: string,
    dateValid: Date,
  ): Promise<Tariff & { tariffGroup: TariffGroup; costTypes: CostType[] }> {
    return this.repository.findByTenantId(tenantId, ordinanceType, dateValid);
  }
}
