Giter Club home page Giter Club logo

sageintacct-sdk-py's Introduction

Sage Intacct SDK

Python SDK to access Sage Intacct web services

Installation

This project requires Python 3+ and Requests library (pip install requests).

  1. Download this project and use it (copy it in your project, etc).

  2. Install it from pip.

     $ pip install sageintacctsdk
    

Usage

To use this SDK you'll need these Sage Intacct credentials used for authentication: sender ID, sender password, user ID, company ID and user password.

This SDK is very easy to use.

  1. First you'll need to create a connection using the main class SageIntacctSDK.
from sageintacctsdk import SageIntacctSDK

connection = SageIntacctSDK(
    sender_id='<YOUR SENDER ID>',
    sender_password='<YOUR SENDER PASSWORD>',
    user_id='<YOUR USER ID>',
    company_id='<YOUR COMPANY ID>',
    user_password='<YOUR USER PASSWORD>'
)
  1. After that you'll be able to access any of the 28 API classes: accounts, ap_payments, ar_invoices, ar_payments, attachments, bills, charge_card_accounts, charge_card_transactions, checking_accounts, classes, contacts, customers, departments, employees, expense_payment_types, expense_reports, expense_types, gl_detail, items, locations, order_entry_transactions, projects, reimbursements, revenue_recognition_schedules, revenue_recognition_schedule_entries, savings_accounts, tasks and vendors.
"""
USAGE: <SageIntacctSDK INSTANCE>.<API_NAME>.<API_METHOD>(<PARAMETERS>)
"""

# Create a new Expense Report of 3800 USD, spent at 2019-28-11 and from employee with employee id E101
data = {
    'employeeid': 'E101',
    'datecreated': {
        'year': 2019,
        'month': 11,
        'day': 28
    },
    'state': 'Approved',
    'description': 'Team lunch',
    'expenses': {
        'expense': [
            {
                'expensetype': 'Food',
                'amount': 3800,
                'expensedate': {
                    'year': 2019,
                    'month': 11,
                    'day': 28
                }
            }
        ]
    }
}
response = connection.employees.post(data)

# Use get_all methods to get all objects of certain types
response = connection.accounts.get_all()

# Get details of Employee with EMPLOYEEID E101
response = connection.employees.get(field='EMPLOYEEID', value='E101')

Advanced Queries

Several methods of querying the Sage Inacct API exists within the SDK. <get_by_query> allows you to specify multiple critera using textual mathematical operators and logical filters.

Arguments are passed to and_filter, or_filter, or both. The and_filter is the default operator to pass filters to. For example if you want to pass a single operator without a logical context you would pass it to and_filter.

You must pass multiple operators to or_filter.

You may also format your own filter payload in accordance with API documentation and pass to the function.

See query structures here: https://developer.intacct.com/web-services/queries/

Warning: Operators can only be used once in a given logical context. and_filter cannot accept multiple 'equalto' operators for example. This is an API limitation.

#
# Returns Data Structure of object to perform query on.  Helpful to identify field keys.
print(connection.gl_detail.get_lookup())

# Returns records between specified dates
query_tuple_between = [('between','ENTRY_DATE',['01/01/2020','12/31/2020'])]
fields = ['RECORDNO','ENTRY_DATE','BATCH_NO','ACCOUNTNO','DEBITAMOUNT']
response = connection.gl_detail.get_by_query(fields=fields,and_filter=query_tuple_between)

# Returns records between specified accounts
query_tuple_multiple =[('greaterthan','ACOUNTNO','6000'),('lessthan','ACCOUNTNO','7000')]
response = connection.gl_detail.get_by_query(fields=fields,and_filter=query_tuple_multiple)

# Returns records that match list
in_list = ['1000','1100','1200']
query_tuple_in = [('in','ACCOUNTNO',in_list)]
response = connection.gl_detail.get_by_query(fields=fields,and_filter=query_tuple_in)

payload = {'and':{'equalto':{'field':'ACCOUNTNO','value':'1000'}}}
response = connnection.gl_detail.get_by_query(filter_payload=payload)

See more details about the usage into the wiki pages of this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

sageintacct-sdk-py's People

Contributors

ashutosh619-sudo avatar ashwin1111 avatar being-aerys avatar cpaanalytics avatar dependabot[bot] avatar eraliod avatar fibonacci- avatar harshithaputtaswamy avatar jtruty avatar labhvam5 avatar nileshpant1999 avatar panasenco avatar pysanders avatar resba avatar ruuushhh avatar shwetabhk avatar snarayanank2 avatar sravanksk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sageintacct-sdk-py's Issues

GL Detail API

Hey guys I'm using your SDK to move data between powerbi and Intacct and noticed that you are missing a class to pull from the GL detail. Let me know if you would like me to contribute the class I wrote.

How to work with the Sandbox Account?

Hi, thanks for sharing the code.
I couldn't find the variables to pass the Sandbox Credentials?
I wonder if the password-less logic would require a change in the SDK logic, or is just a small adjustment to allow these fields, or perhaps use one of the existing parameters in the initializer.

Development Docs

vendorName: sandbox
integrationKey: hJYxsw7HLbj40cB8udES8CDRFLhuJ8G54O6rDpUXvE6hYDrria
integrationPassword: o2iHSrFybYMZpmWOQMuhsXP52V4fBtpuSDshrKDSWsBY1OiN6hwd9Kb12z4j5Us5u

Thanks!

API operation CREATE cannot be performed on objects of type gldetail

When running connection.gl_detail.post(data), getting the following error response:

{'error': [{'errorno': 'PL04000005', 'description': None, 'description2': 'API operation CREATE cannot be performed on objects of type gldetail [Support ID: qBFGYEB060~Y_5k6P0W2Ei-9X1WdgCLBwAAAAA]', 'correction': None}]}

After looking at the source code, it looks like the post method calls __construct_post_payload creates payload XML of form <create><gldetail>data</gldetail></create>, whereas the actual GL Detail API expects payloads of form <create_sotransaction>data</create_sotransaction>.

It looks like there are similar workarounds already existing in the form of "post_legacy_method", so the simplest fix is probably to set post_legacy_method='create_sotransaction' for GL Details.

I'll create a fork and a pull request for this.

get_by_query offset bug

Will be issuing a pull request to fix get by query function.

Line 436 data['offset'] should be data['query']['offset].

Bug causes get_by_query to loop through first 2000 results instead of incrementing.

Can't get a session

Hello,

When trying to get a session using this sdk, I get the following:

`
from configparser import ConfigParser

from sageintacctsdk import SageIntacctSDK

INTACCT = CONFIG["intacct"]

SENDER_ID = INTACCT["SENDER_ID"]
SENDER_PW = INTACCT["SENDER_PW"]
COMPANY_ID = INTACCT["COMPANY_ID"]
USER_ID = INTACCT["USER_ID"]
USER_PW = INTACCT["USER_PW"]

connection = SageIntacctSDK(
sender_id=SENDER_ID,
sender_password=SENDER_PW,
user_id=USER_ID,
company_id=COMPANY_ID,
user_password=USER_PW
)
print()`

Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/ddow/dev/simple_pix/intacct_client.py", line 29, in
connection = SageIntacctSDK(
File "/Users/ddow/venv_simple_pix/lib/python3.9/site-packages/sageintacctsdk/sageintacctsdk.py", line 71, in init
self.update_session_id()
File "/Users/ddow/venv_simple_pix/lib/python3.9/site-packages/sageintacctsdk/sageintacctsdk.py", line 155, in update_session_id
self.__session_id = self.api_base.get_session_id(
File "/Users/ddow/venv_simple_pix/lib/python3.9/site-packages/sageintacctsdk/apis/api_base.py", line 85, in get_session_id
response = self.__post_request(dict_body, self.__api_url)
File "/Users/ddow/venv_simple_pix/lib/python3.9/site-packages/sageintacctsdk/apis/api_base.py", line 237, in __post_request
raise WrongParamsError('Some of the parameters are wrong', parsed_response)
sageintacctsdk.exceptions.WrongParamsError: 'Some of the parameters are wrong'

However, when using a different SDK I get a valid session:

`from pyintacct import IntacctAPI

INTACCT = CONFIG["intacct"]

SENDER_ID = INTACCT["SENDER_ID"]
SENDER_PW = INTACCT["SENDER_PW"]
COMPANY_ID = INTACCT["COMPANY_ID"]
USER_ID = INTACCT["USER_ID"]
USER_PW = INTACCT["USER_PW"]

KEYS = {'SENDER_ID': INTACCT["SENDER_ID"],
'SENDER_PW': INTACCT["SENDER_PW"],
'COMPANY_ID': INTACCT["COMPANY_ID"],
'USER_ID': INTACCT["USER_ID"],
'USER_PW': INTACCT["USER_PW"]
}

INT = IntacctAPI(KEYS)
print()

`

Is there something I'm maybe missing?

Thanks!

Update issue

I can not update customer data using the update method. If it is possible to make good documentation for this SDK on updating custom fields using CUSTOMERID, it will be beneficial for users.

Posting Issue

Hello,

I've gone through the steps mentioned in the readme file, and I've successfully executed the GET calls. However, I'm facing an issue when trying to use the pos example provided in the readme file with one of our employee details. Additionally, I have attempted to post projects and AR invoices, but I encounter the same error.

data = {
'employeeid': '001',
'datecreated': {
'year': 2023,
'month': 7,
'day': 10
},
'state': 'Approved',
'description': 'Team lunch',
'expenses': {
'expense': [
{
'expensetype': 'Food',
'amount': 3800,
'expensedate': {
'year': 2023,
'month': 8,
'day': 28
}
}
]
}
}
response = connection.employees.post(data)

ERROR:
", line 220, in __post_request
raise WrongParamsError('Error during {0}'.format(api_response['result']['function']), exception_msg)
sageintacctsdk.exceptions.WrongParamsError: 'Error during create'

Error with employee creation.

Hi, I am trying to create a new employee using this data:

employee = { 'EMPLOYEE': { 'PERSONALINFO': { 'CONTACTNAME': 'John Doe', } } }

I am calling it using sage_client.employees.post(employee)

However I am getting An error occurred: 'Error during create'

Can you please assist?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.