EmployeeBuilder
The `EmployeeBuilder` is your primary tool for creating the JSON payload needed to create new Employee records with the `EmployeesService`. It simplifies the process by handling the nested JSON structure required by the Employee endpoint, including the `ContactInfo`, `FinancialSettings`, and `EmployeeSettings` objects.
Importing the Builder
To get started, import the `EmployeeBuilder` from the `easy_acumatica.models` module.
from easy_acumatica.models.employee_builder import EmployeeBuilder
Builder Methods
The builder provides dedicated methods for each section of the employee record.
.status(status)
Sets the top-level status of the employee (e.g., 'Active', 'Inactive').
builder = EmployeeBuilder().status('Active')
.contact_info(...)
Sets fields within the nested `ContactInfo` object. Common fields are available as named arguments, and any others can be passed as keyword arguments (kwargs).
builder.contact_info(
first_name="Jane",
last_name="Doe",
email="jane.doe@example.com",
Title="Lead Developer" # Passed as a kwarg
)
.financial_settings(...)
Sets fields within the nested `FinancialSettings` object, such as payment information and GL accounts.
builder.financial_settings(
ap_account="20000",
payment_method="CHECK",
terms="NET30"
)
.employee_settings(...)
Sets fields within the nested `EmployeeSettings` object, including organizational details like department and class.
builder.employee_settings(
branch_id="HEADOFFICE",
department_id="RND",
employee_class="EMPSALARIED"
)
.to_body()
Once you have set all the required fields, call `.to_body()` to generate the final dictionary, ready to be sent as the JSON body in your API request.
# Build a complete employee payload
employee_payload = (
EmployeeBuilder()
.status("Active")
.contact_info(first_name="Jane", last_name="Doe")
.financial_settings(payment_method="DIRECT")
.employee_settings(department_id="SUPPORT")
)
# Get the final dictionary
json_body = employee_payload.to_body()
# Use with the EmployeesService
# client.employees.create_employee("24.200.001", builder=employee_payload)