# InvoiceResponse

## Example Usage

```typescript
import { InvoiceResponse } from "@flexprice/sdk/sdk/models";

let value: InvoiceResponse = {
  subscription: {
    couponAssociations: [
      {
        subscriptionLineItem: {
          price: {
            addon: {
              prices: [
                {
                  addon: {},
                  meter: {
                    createdAt: new Date("2024-03-20T15:04:05Z"),
                    eventName: "api_request",
                    id: "550e8400-e29b-41d4-a716-446655440000",
                    name: "API Usage Meter",
                    status: "published",
                    tenantId: "tenant123",
                    updatedAt: new Date("2024-03-20T15:04:05Z"),
                  },
                  plan: {},
                },
              ],
            },
            meter: {
              createdAt: new Date("2024-03-20T15:04:05Z"),
              eventName: "api_request",
              id: "550e8400-e29b-41d4-a716-446655440000",
              name: "API Usage Meter",
              status: "published",
              tenantId: "tenant123",
              updatedAt: new Date("2024-03-20T15:04:05Z"),
            },
            plan: {},
          },
        },
      },
    ],
    entitlements: [
      {
        feature: {
          meter: {
            createdAt: new Date("2024-03-20T15:04:05Z"),
            eventName: "api_request",
            id: "550e8400-e29b-41d4-a716-446655440000",
            name: "API Usage Meter",
            status: "published",
            tenantId: "tenant123",
            updatedAt: new Date("2024-03-20T15:04:05Z"),
          },
        },
      },
    ],
    latestInvoice: {
      subscription: {
        couponAssociations: [
          {
            subscriptionLineItem: {
              price: {
                addon: {
                  prices: [
                    {
                      addon: {},
                      meter: {
                        createdAt: new Date("2024-03-20T15:04:05Z"),
                        eventName: "api_request",
                        id: "550e8400-e29b-41d4-a716-446655440000",
                        name: "API Usage Meter",
                        status: "published",
                        tenantId: "tenant123",
                        updatedAt: new Date("2024-03-20T15:04:05Z"),
                      },
                      plan: {},
                    },
                  ],
                },
                meter: {
                  createdAt: new Date("2024-03-20T15:04:05Z"),
                  eventName: "api_request",
                  id: "550e8400-e29b-41d4-a716-446655440000",
                  name: "API Usage Meter",
                  status: "published",
                  tenantId: "tenant123",
                  updatedAt: new Date("2024-03-20T15:04:05Z"),
                },
                plan: {},
              },
            },
          },
        ],
        entitlements: [
          {
            feature: {
              meter: {
                createdAt: new Date("2024-03-20T15:04:05Z"),
                eventName: "api_request",
                id: "550e8400-e29b-41d4-a716-446655440000",
                name: "API Usage Meter",
                status: "published",
                tenantId: "tenant123",
                updatedAt: new Date("2024-03-20T15:04:05Z"),
              },
            },
          },
        ],
        plan: {},
      },
    },
    plan: {},
  },
};
```

## Fields

| Field                                                                                                                                                                                                                             | Type                                                                                                                                                                                                                              | Required                                                                                                                                                                                                                          | Description                                                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `adjustmentAmount`                                                                                                                                                                                                                | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | adjustment_amount is the total sum of credit notes of type "adjustment".<br/>These are non-cash reductions applied to the invoice (e.g. goodwill credit, billing correction).                                                     |
| `amountDue`                                                                                                                                                                                                                       | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | amount_due is the total amount that needs to be paid for this invoice                                                                                                                                                             |
| `amountPaid`                                                                                                                                                                                                                      | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | amount_paid is the amount that has already been paid towards this invoice                                                                                                                                                         |
| `amountRemaining`                                                                                                                                                                                                                 | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | amount_remaining is the outstanding amount still owed on this invoice (calculated as amount_due minus amount_paid)                                                                                                                |
| `billingPeriod`                                                                                                                                                                                                                   | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | billing_period describes the billing period this invoice covers (e.g., "January 2024", "Q1 2024")                                                                                                                                 |
| `billingReason`                                                                                                                                                                                                                   | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | billing_reason indicates why this invoice was generated (e.g., "subscription_billing", "manual_charge")                                                                                                                           |
| `billingSequence`                                                                                                                                                                                                                 | *number*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | billing_sequence is the sequential number indicating the billing cycle for subscription invoices                                                                                                                                  |
| `couponApplications`                                                                                                                                                                                                              | [models.CouponApplicationResponse](../../sdk/models/coupon-application-response.md)[]                                                                                                                                             | :heavy_minus_sign:                                                                                                                                                                                                                | coupon_applications contains the coupon applications associated with this invoice (overrides embedded field)                                                                                                                      |
| `createdAt`                                                                                                                                                                                                                       | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `createdBy`                                                                                                                                                                                                                       | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `currency`                                                                                                                                                                                                                        | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | currency is the three-letter ISO currency code (e.g., USD, EUR, GBP) that applies to all monetary amounts on this invoice                                                                                                         |
| `customer`                                                                                                                                                                                                                        | [models.CustomerResponse](../../sdk/models/customer-response.md)                                                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                                                                                | Customer response object containing all customer information                                                                                                                                                                      |
| `customerId`                                                                                                                                                                                                                      | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | customer_id is the ID of the customer who will receive this invoice                                                                                                                                                               |
| `description`                                                                                                                                                                                                                     | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | description is an optional description or notes about this invoice                                                                                                                                                                |
| `dueDate`                                                                                                                                                                                                                         | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | due_date is the date when payment for this invoice is due                                                                                                                                                                         |
| `environmentId`                                                                                                                                                                                                                   | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | environment_id is the ID of the environment this invoice belongs to (for multi-environment setups)                                                                                                                                |
| `finalizedAt`                                                                                                                                                                                                                     | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | finalized_at is the timestamp when this invoice was finalized and made ready for payment                                                                                                                                          |
| `id`                                                                                                                                                                                                                              | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | id is the unique identifier for this invoice                                                                                                                                                                                      |
| `idempotencyKey`                                                                                                                                                                                                                  | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | idempotency_key is a unique key used to prevent duplicate invoice creation when retrying API calls                                                                                                                                |
| `invoiceNumber`                                                                                                                                                                                                                   | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | invoice_number is the human-readable invoice number displayed to customers (e.g., INV-2024-001)                                                                                                                                   |
| `invoicePdfUrl`                                                                                                                                                                                                                   | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | invoice_pdf_url is the URL where customers can download the PDF version of this invoice                                                                                                                                           |
| `invoiceStatus`                                                                                                                                                                                                                   | [models.InvoiceStatus](../../sdk/models/invoice-status.md)                                                                                                                                                                        | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `invoiceType`                                                                                                                                                                                                                     | [models.InvoiceType](../../sdk/models/invoice-type.md)                                                                                                                                                                            | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `isManuallyEdited`                                                                                                                                                                                                                | *boolean*                                                                                                                                                                                                                         | :heavy_minus_sign:                                                                                                                                                                                                                | is_manually_edited is true once a user has manually added, edited, or removed a line item on this draft invoice.<br/>Once set, automated recomputation of this invoice's line items must no-op rather than overwrite the manual edit. |
| `issueDate`                                                                                                                                                                                                                       | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | issue_date is the user-facing date of the invoice. Defaults to created_at if not set.                                                                                                                                             |
| `lastComputedAt`                                                                                                                                                                                                                  | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | last_computed_at is the timestamp when this invoice was last computed by ComputeInvoice                                                                                                                                           |
| `lineItems`                                                                                                                                                                                                                       | [models.InvoiceLineItemResponse](../../sdk/models/invoice-line-item-response.md)[]                                                                                                                                                | :heavy_minus_sign:                                                                                                                                                                                                                | line_items contains the individual items that make up this invoice (overrides embedded field)                                                                                                                                     |
| `metadata`                                                                                                                                                                                                                        | Record<string, *string*>                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `overpaidAmount`                                                                                                                                                                                                                  | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | overpaid_amount is the amount overpaid if payment_status is OVERPAID (amount_paid - total)                                                                                                                                        |
| `paidAt`                                                                                                                                                                                                                          | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | paid_at is the timestamp when this invoice was fully paid                                                                                                                                                                         |
| `paymentStatus`                                                                                                                                                                                                                   | [models.PaymentStatus](../../sdk/models/payment-status.md)                                                                                                                                                                        | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `periodEnd`                                                                                                                                                                                                                       | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | period_end is the end date of the billing period covered by this invoice                                                                                                                                                          |
| `periodStart`                                                                                                                                                                                                                     | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | period_start is the start date of the billing period covered by this invoice                                                                                                                                                      |
| `recalculatedInvoiceId`                                                                                                                                                                                                           | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | recalculated_invoice_id is the ID of the replacement invoice created when this invoice was voided and recalculated.<br/>When set, it forms a parent→child link from this (voided) invoice to the new replacement invoice.         |
| `refundedAmount`                                                                                                                                                                                                                  | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | refunded_amount is the total sum of credit notes of type "refund".<br/>These are actual refunds issued to the customer.                                                                                                           |
| `status`                                                                                                                                                                                                                          | [models.Status](../../sdk/models/status.md)                                                                                                                                                                                       | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `subscription`                                                                                                                                                                                                                    | [models.SubscriptionResponse](../../sdk/models/subscription-response.md)                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `subscriptionCustomerId`                                                                                                                                                                                                          | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | subscription_customer_id is the subscription owner's customer ID (Subscription.CustomerID).<br/>It may differ from customer_id when the subscription uses an invoicing customer. Set internally; nullable in DB.                  |
| `subscriptionId`                                                                                                                                                                                                                  | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | subscription_id is the ID of the subscription this invoice is associated with (only present for subscription-based invoices)                                                                                                      |
| `subtotal`                                                                                                                                                                                                                        | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | subtotal is the sum of all line items before any taxes, discounts, or additional fees                                                                                                                                             |
| `taxes`                                                                                                                                                                                                                           | [models.TaxAppliedResponse](../../sdk/models/tax-applied-response.md)[]                                                                                                                                                           | :heavy_minus_sign:                                                                                                                                                                                                                | tax_applied_records contains the tax applied records associated with this invoice                                                                                                                                                 |
| `tenantId`                                                                                                                                                                                                                        | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `total`                                                                                                                                                                                                                           | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | total is the final amount including taxes, fees, and discounts                                                                                                                                                                    |
| `totalDiscount`                                                                                                                                                                                                                   | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | total_discount is the sum of all coupon discounts applied to the invoice                                                                                                                                                          |
| `totalPrepaidCreditsApplied`                                                                                                                                                                                                      | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | total_prepaid_credits_applied is the total amount of prepaid credits applied to this invoice.                                                                                                                                     |
| `totalTax`                                                                                                                                                                                                                        | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | total_tax is the sum of all taxes combined at the invoice level.                                                                                                                                                                  |
| `updatedAt`                                                                                                                                                                                                                       | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `updatedBy`                                                                                                                                                                                                                       | *string*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | N/A                                                                                                                                                                                                                               |
| `version`                                                                                                                                                                                                                         | *number*                                                                                                                                                                                                                          | :heavy_minus_sign:                                                                                                                                                                                                                | version is the version number for tracking changes to this invoice                                                                                                                                                                |
| `voidedAt`                                                                                                                                                                                                                        | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)                                                                                                                                     | :heavy_minus_sign:                                                                                                                                                                                                                | voided_at is the timestamp when this invoice was voided or cancelled                                                                                                                                                              |