Transactions Sub Service - Nioron07/Easy-Acumatica GitHub Wiki

This guide covers the TransactionsService, which provides methods for retrieving financial transaction data from Acumatica ERP.

1. Accessing the Service

The TransactionsService is available as an attribute on your main AcumaticaClient instance.

Assuming 'client' is an initialized AcumaticaClient

transactions_service = client.transactions

2. Fetching General Ledger Transactions

get_ledger_transactions(api_version, start_date, end_date, options=None)

This method retrieves general ledger transactions for a specified period by using the AccountDetailsForPeriodInquiry form.

Important: Unlike other endpoints, this inquiry requires a PUT request. The start_date and end_date are sent in the request body, while any QueryOptions (like $expand) are sent as URL parameters. The easy-acumatica library handles this distinction for you.

Parameters:

  • api_version (str): The contract API version (e.g., "24.200.001").
  • start_date (datetime): The starting month and year for the transaction period. The day is ignored.
  • end_date (datetime): The ending month and year for the transaction period. The day is ignored.
  • options (QueryOptions, optional): Use this to pass parameters like $expand. For this inquiry, you will almost always want to set expand=["Results"].

Example: Get all ledger transactions for April 2024

from datetime import datetime  
from easy_acumatica.models.query_builder import QueryOptions

# Define the start and end of the period  
start = datetime(2024, 4, 1)  
end = datetime(2024, 4, 30)

# The 'Results' entity must be expanded to get the actual transaction lines  
opts = QueryOptions(expand=["Results"])

# Call the service  
try:  
    ledger_transactions = client.transactions.get_ledger_transactions(  
        "24.200.001",  
        start_date=start,  
        end_date=end,  
        options=opts  
    )

    # The actual transactions are in the 'Results' list  
    for trx in ledger_transactions.get("Results", []):  
        print(f"Ref: {trx['RefNumber']['value']}, Desc: {trx['TransactionDescription']['value']}")

except Exception as e:  
    print(f"Failed to retrieve transactions: {e}")