import { Module, forwardRef } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { BookingHotelItemEntity } from '../../entities/booking-hotel-item.entity';
import { BookingTransportItemEntity } from '../../entities/booking-transport-item.entity';
import { BookingActivityItemEntity } from '../../entities/booking-activity-item.entity';
import { BookingSpecialItemEntity } from '../../entities/booking-special-item.entity';
import { CustomerInvoiceEntity } from '../../entities/customer-invoice.entity';
import { AuthModule } from '../../auth/auth.module';
import { BookingModule } from '../booking/booking.module';
import { AccountingController } from './accounting.controller';
import { AccountingService } from './accounting.service';
import { CustomerInvoiceRepository } from './repositories/customer-invoice.repository';

@Module({
  imports: [
    TypeOrmModule.forFeature([
      BookingHotelItemEntity,
      BookingTransportItemEntity,
      BookingActivityItemEntity,
      BookingSpecialItemEntity,
      CustomerInvoiceEntity,
    ]),
    // Brings PermissionGuard's dependencies (RolePermissionEntity
    // repo + Reflector) into scope for the @Permissions() decorator.
    AuthModule,
    // BookingService.findById hydrates the full booking + items for
    // the invoice generator. forwardRef in case BookingModule ever
    // needs accounting (it doesn't today).
    forwardRef(() => BookingModule),
  ],
  controllers: [AccountingController],
  providers: [AccountingService, CustomerInvoiceRepository],
})
export class AccountingModule {}
