Easy-Acumatica Docs

TimeEntryBuilder

The `TimeEntryBuilder` is your primary tool for creating the JSON payload needed to create `TimeEntry` records with the `TimeEntriesService`. It provides a fluent, chainable interface for setting the fields of a time entry.

Importing the Builder

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

python

from easy_acumatica.models.time_entry_builder import TimeEntryBuilder

Builder Methods

Shortcut Methods

Use the shortcut methods to set the most common fields for a time entry.

python

time_entry_payload = (
    TimeEntryBuilder()
    .summary("Initial project setup and configuration")
    .date("2022-08-17T09:00:00")
    .employee("EP00000026")
    .project_id("TOMYUM1")
    .project_task_id("PHASE1")
    .earning_type("RG")
    .time_spent("03:00")
    .billable_time("02:30")
)
.set(field_name, value)

This is the general-purpose method for setting any other field on the time entry record.

python

builder = TimeEntryBuilder()
builder.set("CostCode", "00-000")
.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 time entry
time_entry_payload = (
    TimeEntryBuilder()
    .summary("Team meeting")
    .date("2022-08-17T14:00:00")
    .employee("EP00000026")
    .time_spent("00:30")
)

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

# The json_body will look like this:
# {
#   "Summary": {"value": "Team meeting"},
#   "Date": {"value": "2022-08-17T14:00:00"},
#   "Employee": {"value": "EP00000026"},
#   "TimeSpent": {"value": "00:30"}
# }

Complete Example with TimeEntriesService

Here is a complete example of how to use the `TimeEntryBuilder` to create a new time entry record.

python

from easy_acumatica.models.time_entry_builder import TimeEntryBuilder

# 1. Build the time entry payload
time_entry_to_create = (
    TimeEntryBuilder()
    .summary("Finalizing documentation for Phase 1")
    .date("2022-08-17T15:00:00")
    .employee("EP00000026")
    .project_id("TOMYUM1")
    .project_task_id("PHASE1")
    .earning_type("RG")
    .time_spent("01:00")
    .billable_time("01:00")
)

# 2. Use the payload with the TimeEntriesService to create the record
try:
    new_entry = client.time_entries.create_time_entry(
        "24.200.001",
        builder=time_entry_to_create
    )
    print(f"Successfully created time entry: {new_entry['TimeEntryID']['value']}")
except Exception as e:
    print(f"Failed to create time entry: {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