BillBuilder
The BillBuilder
is your primary tool for creating the JSON payload needed to create or update Bill
records with the BillsService
. It provides a fluent, chainable interface for setting the fields of a bill record, including linking to purchase orders or receipts.
Importing the Builder
To get started, import the BillBuilder
from the models directory.
from easy_acumatica.models.bill_builder import BillBuilder
Builder Methods
The builder provides both general-purpose and shortcut methods for constructing a valid JSON payload. Most bills will also include one or more detail lines.
For common fields like vendor and vendor reference, you can use built-in shortcuts:
bill_payload = (
BillBuilder()
.vendor("VENDACME")
.vendor_ref("INV-12345")
.type("Bill")
)
set(field_name, value)
Use this to set any field that doesn't have a dedicated shortcut method.
builder = BillBuilder()
builder.set("Status", "Balanced")
builder.set("Terms", "Net30")
to_body()
Generates the final dictionary formatted for use in your API request.
bill_payload = (
BillBuilder()
.vendor("VENDACME")
.vendor_ref("INV-12345")
.add_detail(inventory_id="ITEM01", qty=10, unit_cost=5.00)
)
json_body = bill_payload.to_body()
Adding Details
add_detail_from_pr(po_receipt_nbr)
The most common method, used for linking bills to received goods.
bill_payload = (
BillBuilder()
.type("Bill")
.vendor("VENDACME")
.vendor_ref("INV-12345")
.description("Bill for received goods")
.add_detail_from_pr(po_receipt_nbr="PR000789")
)
add_detail(**kwargs)
Use this when the bill is not tied to a PO or receipt, like utility or service bills.
expense_payload = (
BillBuilder()
.vendor("UTILITIES")
.vendor_ref("ACCT-555")
.add_detail(
expense_account="700100",
tran_desc="Monthly electricity bill",
qty=1,
unit_cost=250.75
)
)