Easy-Acumatica Docs

Sales Orders Service

The `SalesOrdersService` is your primary tool for interacting with `SalesOrder` records. It provides methods for managing the entire sales order lifecycle, from creation and updates to executing actions like applying discounts and creating shipments.

Importing Helpers

To create and query sales orders, you'll need the `SalesOrderBuilder`, `QueryOptions`, and `F` filter factory.

python

from easy_acumatica.models.sales_order_builder import SalesOrderBuilder
from easy_acumatica.models.query_builder import QueryOptions
from easy_acumatica.models.filter_builder import F

CRUD Methods

get_sales_orders(api_version, options=None)

Retrieves a list of sales orders. Use `QueryOptions` to filter, select, and expand the results to get the exact data you need.

python

# Create a filter for open orders
opts = QueryOptions(
    filter=F.Status == "Open",
    select="OrderType,OrderNbr,CustomerID,OrderTotal",
    expand="Customer"
)

# Fetch the sales orders
open_orders = client.sales_orders.get_sales_orders("24.200.001", options=opts)
create_sales_order(api_version, builder, ...)

Creates a new sales order using a `SalesOrderBuilder` instance to define the order's properties and line items.

python

# Build the sales order payload
order_payload = (
    SalesOrderBuilder()
    .order_type("SO")
    .customer_id("ABCCORP")
    .description("New order for project supplies")
    .add_detail(inventory_id="ITEM01", OrderQty=5, UnitPrice=100.0)
)

# Create the sales order
new_order = client.sales_orders.create_sales_order(
    "24.200.001", 
    builder=order_payload
)
update_sales_order(api_version, builder, ...)

Updates an existing sales order. You must include the `OrderType` and `OrderNbr` in the builder to identify which record to modify.

python

# Build the update payload to add a new line item
update_payload = (
    SalesOrderBuilder()
    .order_type("SO")
    .order_nbr("SO005555") # The order to update
    .add_detail(inventory_id="ITEM02", OrderQty=2) # The new line
)

# Update the sales order
updated_order = client.sales_orders.update_sales_order(
    "24.200.001", 
    builder=update_payload
)

Executing Actions

The service also provides helpers to execute common business logic actions on sales orders, which are wrappers around the `ActionsService`.

apply_discounts(api_version, order_type, order_nbr)

Triggers the `AutoRecalculateDiscounts` action for a specific sales order.

python

client.sales_orders.apply_discounts(
    "24.200.001",
    order_type="SO",
    order_nbr="SO005555"
)
create_shipment(api_version, order_id, ...)

Executes the `SalesOrderCreateShipment` action. Note that this requires the `id` (GUID) of the sales order, not the human-readable `OrderNbr`.

python

# Assume 'new_order' is the response from a create_sales_order call
order_guid = new_order['id']['value']
shipment_date = "2023-10-27T00:00:00"
warehouse_id = "MAIN"

client.sales_orders.create_shipment(
    "24.200.001",
    order_id=order_guid,
    shipment_date=shipment_date,
    warehouse_id=warehouse_id
)
Easy-Acumatica v0.3.9 — Created and Developed by Matthew Hirstius (Nioron07).
Significant Contributions made by Chris Xu
Want to see the NPM version? See it here