import { Controller, Get, Param, ParseUUIDPipe } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";

import { FreightAdmin } from "../../common/booking-guards";
import { BillingService } from "./billing.service";

@ApiTags("billing")
@Controller("billing")
@FreightAdmin()
export class BillingController {
  constructor(private readonly billingService: BillingService) {}

  @Get("invoices")
  @ApiOperation({ summary: "List all invoices" })
  findAll() {
    return this.billingService.findAll();
  }

  @Get("invoices/booking/:bookingId")
  @ApiOperation({ summary: "List invoices for a booking" })
  findByBooking(@Param("bookingId", ParseUUIDPipe) bookingId: string) {
    return this.billingService.findByBooking(bookingId);
  }
}
