Easy-Acumatica Docs

WorkCalendarBuilder

The `WorkCalendarBuilder` is your primary tool for creating the JSON payload needed to create `WorkCalendar` records with the `WorkCalendarsService`.

Importing the Builder

To get started, import the `WorkCalendarBuilder` from the `easy_acumatica.models` module.

python

from easy_acumatica.models.work_calendar_builder import WorkCalendarBuilder

Builder Methods

Shortcut Methods

Use the shortcut methods to set the most common fields for a work calendar.

python

calendar_payload = (
    WorkCalendarBuilder()
    .work_calendar_id("STANDARD")
    .description("Standard Mon-Fri Work Week")
    .time_zone("GMTM0600C") # Example: US Central Time
)
.set(field_name, value)

This is the general-purpose method for setting any other field on the work calendar record.

python

builder = WorkCalendarBuilder()
builder.set("WorkCalendarID", "24-7-OPS")
builder.set("Description", "24/7 Operations Calendar")
.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.

python

# Build the work calendar
calendar_payload = (
    WorkCalendarBuilder()
    .work_calendar_id("STANDARD")
    .description("Standard Mon-Fri Work Week")
)

# Get the final dictionary
json_body = calendar_payload.to_body()

# The json_body will look like this:
# {
#   "WorkCalendarID": {"value": "STANDARD"},
#   "Description": {"value": "Standard Mon-Fri Work Week"}
# }

Complete Example with WorkCalendarsService

Here is a complete example of how to use the `WorkCalendarBuilder` to create a new work calendar record.

python

from easy_acumatica.models.work_calendar_builder import WorkCalendarBuilder

# 1. Build the work calendar payload
calendar_to_create = (
    WorkCalendarBuilder()
    .work_calendar_id("24-7-OPS")
    .description("24/7 Operations Calendar")
    .time_zone("GMT")
)

# 2. Use the payload with the WorkCalendarsService to create the record
try:
    new_calendar = client.work_calendars.create_work_calendar(
        "24.200.001",
        builder=calendar_to_create
    )
    print(f"Successfully created work calendar: {new_calendar['WorkCalendarID']['value']}")
except Exception as e:
    print(f"Failed to create work calendar: {e}")
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