def apply()

in src/main/scala/com/gu/invoicing/invoice/Model.scala [36:56]


    def apply(
        invoice: Invoice,
        paymentMethod: PaymentMethod,
    ): InvoiceWithPayment = {
      // Currently we handle only invoices with single subscription, so any invoice item should do for getting the subscription name
      val subscriptionName =
        invoice.invoiceItems.headOption
          .getOrElse(
            throw new AssertionError(s"At least one invoice item should always exist: $invoice"),
          )
          .subscriptionName

      new InvoiceWithPayment(
        subscriptionName = subscriptionName,
        date = invoice.invoiceDate,
        paymentMethod = paymentMethod,
        price = invoice.amount.toDouble,
        pdfPath = s"invoices/${invoice.id}",
        invoiceId = invoice.id,
      )
    }