Easy-Acumatica Docs

Work Calendars Service

This guide covers the `WorkCalendarsService`, which is your primary tool for creating and retrieving work calendar records through the contract-based API.

Importing Helpers

Before you start, import the necessary builders and query helpers.

python

from easy_acumatica.models.work_calendar_builder import WorkCalendarBuilder
from easy_acumatica.models.query_builder import QueryOptions
from easy_acumatica.filters import F

Service Methods

create_work_calendar(api_version, builder, options=None)

This method creates a new work calendar. You must provide a `WorkCalendarBuilder` instance containing the calendar's details.

python

# 1. Build the work calendar payload
# This assumes a WorkCalendarBuilder with methods like calendar_id, time_zone, and add_exception
calendar_payload = (
    WorkCalendarBuilder()
    .calendar_id("US-HOLIDAYS")
    .time_zone("CST")
    .add_exception(date="2024-12-25", description="Christmas Day")
)

# 2. Use the payload to create the record
try:
    new_calendar = client.work_calendars.create_work_calendar("24.200.001", builder=calendar_payload)
    print(f"Successfully created Work Calendar: {new_calendar['CalendarID']['value']}")
except Exception as e:
    print(f"Failed to create work calendar: {e}")
get_work_calendar(api_version, options=None)

This method retrieves a list of work calendars. You must use `QueryOptions` to filter for the calendar you want.

python

# 1. Define query options
query = QueryOptions(filter=F.CalendarID == 'US-HOLIDAYS')

# 2. Retrieve the work calendar(s)
try:
    calendars = client.work_calendars.get_work_calendar("24.200.001", options=query)
    for calendar in calendars:
        print(f"ID: {calendar['CalendarID']['value']}, Time Zone: {calendar['TimeZone']['value']}")
except Exception as e:
    print(f"Failed to get work calendars: {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