SalesOrderBuilder
The `SalesOrderBuilder` is a fluent builder for creating the JSON payload needed to create or update `SalesOrder` records. It handles top-level fields as well as nested lists for details, payments, and taxes.
Importing the Builder
To get started, import the `SalesOrderBuilder` from the `easy_acumatica.models` module.
from easy_acumatica.models.sales_order_builder import SalesOrderBuilder
Builder Methods
Use the shortcut methods to set common header-level fields on the sales order. For any other field, you can use the generic `.set()` method.
so_payload = (
SalesOrderBuilder()
.order_type("SO")
.customer_id("ABCCORP")
.hold(False)
.set("Description", "Order for new project materials")
)
.add_detail(**kwargs)
Adds a detail line to the sales order. You can pass any line-level field as a keyword argument.
so_payload.add_detail(
InventoryID="ITEM01",
OrderQty=5,
UnitPrice=100.0
)
.add_payment(**kwargs)
Adds a payment to the sales order.
so_payload.add_payment(
PaymentAmount=500.00,
PaymentMethod="VISA"
)
.add_tax_detail(**kwargs)
Adds a tax detail line to the sales order, typically for tax overrides.
so_payload.add_tax_detail(
TaxID="NYSTATETAX",
TaxAmount=42.50
)
.to_body()
Once you have set all the required fields and details, call `.to_body()` to generate the final dictionary, ready to be sent as the JSON body in your API request.