Time Entries Service - Nioron07/Easy-Acumatica GitHub Wiki
This guide covers the TimeEntriesService
, which is your primary tool for creating and retrieving time entry records through the contract-based API.
[!WARNING] This service is currently untested due to limitations in the development environment. Please contact the library maintainers on GitHub if you encounter any issues with this specific endpoint.
1. Importing Helpers
Before you start, import the necessary builders and query helpers.
from easy_acumatica.models.time_entry_builder import TimeEntryBuilder
from easy_acumatica.models.query_builder import QueryOptions
from easy_acumatica.filters import F
2. Understanding the Service's Purpose
The TimeEntriesService
provides methods for creating new time entries and retrieving existing ones. It interacts with the TimeEntry
endpoint.
3. TimeEntriesService Methods
The following table summarizes the primary methods available in the TimeEntriesService
.
Method | Description | Key Parameters |
---|---|---|
.create_time_entry() |
Creates a new time entry record. | api_version , builder , options |
.get_time_entries() |
Retrieves a list of time entries based on query options. | api_version , options |
4. Creating and Retrieving Time Entries
The primary workflow involves creating new time entries or querying for existing ones.
create_time_entry(api_version, builder, options)
This method creates a new time entry. You must provide a TimeEntryBuilder
instance containing the entry's details.
Example: Create a new time entry
from easy_acumatica.models.time_entry_builder import TimeEntryBuilder
# 1. Build the time entry payload
time_entry_payload = (
TimeEntryBuilder()
.summary("Worked on API integration task")
.date("2022-08-18T10:00:00")
.employee("EP00000026")
.project_id("INTERNAL")
.project_task_id("DEV")
.earning_type("RG")
.time_spent("02:00")
.billable_time("02:00")
)
# 2. Use the payload to create the record
try:
new_entry = client.time_entries.create_time_entry("24.200.001", builder=time_entry_payload)
print(f"Successfully created Time Entry with ID: {new_entry['TimeEntryID']['value']}")
except Exception as e:
print(f"Failed to create time entry: {e}")
get_time_entries(api_version, options)
This method retrieves a list of time entries. You must use QueryOptions
to filter, select, and expand the results.
Example: Get all of an employee's time entries for a specific week
# 1. Define query options
query = QueryOptions(
filter=(F.Employee == 'EP00000026') & (F.Date >= '2022-08-15') & (F.Date < '2022-08-22'),
select="Date,ProjectID,TimeSpent,Summary"
)
# 2. Retrieve the time entries
try:
time_entries = client.time_entries.get_time_entries("24.200.001", options=query)
for entry in time_entries:
print(f"Date: {entry['Date']['value']}, Project: {entry['ProjectID']['value']}, Time: {entry['TimeSpent']['value']}")
except Exception as e:
print(f"Failed to get time entries: {e}")