import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Invoice } from './entities/invoice.entity'; @Injectable() export class BillingService { constructor( @InjectRepository(Invoice) private readonly invoicesRepository: Repository, ) {} /** List every invoice (most recent first). */ findAll(): Promise { return this.invoicesRepository.find({ order: { issuedAt: 'DESC' } }); } /** List invoices for a given booking. */ findByBooking(bookingId: string): Promise { return this.invoicesRepository.find({ where: { bookingId }, order: { issuedAt: 'DESC' } }); } }