Skip to main content

Generate invoice for order line items

Zuora

Generate invoice for order line items

After an order line item is created, its state is Executing by default. To generate invoices for the order line item, you must change the state to SentToBilling. For more information about the state transition flow of an order line item, see Order Line Item states, Order states, and state transitions.

To generate an invoice for an order line item, you can use one of the following ways:

  • Use the Zuora application UI.

    Make sure the state of the order line item is SentToBilling and the bill target date is set appropriately. Then, create or schedule a bill run to generate the invoice. The bill run will pick up order line items based on the Bill Target Date. See Use the Zuora application.

  • Use the REST API:
    • Update a single order line item 

      First, use the "Update an order line item" operation to update the state and the bill target date of the order line item appropriately. Then, use the "CRUD: Create a bill run" operation to create a bill run. See Update one order line item and then create a bill run.

    • Update multiple order line items in a single API

      Use the "Update order line items" operation to update both the state and billTargetDate fields of more than one order line item, as well as to generate an invoice for the referenced order line item using the single API. See Update multiple order line items and generate invoices at the same time.

Use the Zuora application

  1. Log in to the Zuora application and then navigate to Customers > Orders. The Orders page opens.
  2. Search for the order that contains the order line item to be updated and click the order number. The Order details page opens.
  3. In the Order Line Items area, on the target line of the order line item, click the pencil icon in the ACTIONS column. The Edit Order Line Item window is displayed.

    edit-order-line-item.png

  4. In the Basic Information section, change the Item State value from Executing to SentToBilling.
  5. (Optional): Update the Bill Target Date value if necessary. The subsequent bill run will pick up order line items to generate invoices based on the bill target date.
  6. Click Save. The window is closed. The state of the order line item is changed to SentToBilling.
  7. To generate the invoice, create a bill run. For instructions, see Creating Bill Runs.

Use the REST API

There are two methods to update the order line item and generate invoices.

Update one order line item and then create a bill run

To update a single order line item and then generate the invoice, use the Update an order line item operation.

  1. Determine the following values for the "Update an order line item" operation:
    • orderLineItemId: The ID of the order line item to be updated. You can obtain the order line item ID by using the Retrieve an order operation or from the URI of the Order Line Item Details page in the UI.
    • itemState: The state of the order line item. This field must be set to SentToBilling for the invoice to be generated.
    • billTargetDate: The date when the order line item is to be invoiced. The subsequent bill run will pick up order line items based on this date.
  2. Use the "Update an order line item" operation to update the order line item state and bill target date appropriately.

    The following API updates the state of an order line item to SentToBilling and sets the Bill Target Date for the order line item to 2021-02-01.

    Request PUT /v1/order-line-items/{orderLineItemId}
    Request Body
    {
       "itemState": "SentToBilling",
       "billTargetDate": "2021-02-01"
    }
  3. Use the "CRUD: Create a bill run" operation to create an ad hoc bill run.

Update multiple order line items and generate invoices at the same time

To update order line items and generate the invoice at the same time, use the Update order line items operation.

  1. Determine the following values for the "Update order line items" operation:
    • orderLineItemId: The ID of the order line item to be updated. You can obtain the order line item ID by using the Retrieve an order operation or from the URI of the Order Line Item Details page in the UI.
    • itemState: The state of the order line item. This field must be set to SentToBilling for the invoice to be generated.
    • billTargetDate: The date when the order line item is to be invoiced. 
    • runBilling: Set this field in the processingOptions section to true to generate the invoice at the same time when you update the order line items.
  2. Use the "Update order line items" operation to update the order line items and generate the invoice.

    The following API provides an array of the order line item IDs to be updated and generates the invoice when updating the order line items. The state of all order line items is changed to SentToBilling and the bill target date is set to 2021-02-01. 

    Request POST /v1/order-line-items/bulk
    Request Body
    {
        "processingOptions": {
            "runBilling": true,
            "billingOptions": {
                "targetDate": "2021-01-01"
            }
        },
        "orderLineItems": [
            {
                "id": "{{orderLineItemId}}",
                "itemState": "SentToBilling",
                "billTargetDate": "2021-02-01"
            }
        ]
    }