コード例 #1
0
def mt_trans():
    """Create an instance of Transaction Builder object."""
    client = AvataxClient('test app', 'ver 0.0', 'test machine', 'sandbox')
    login_key, login_val = cred_determine()
    client.add_credentials(login_key, login_val)
    trans = TransactionBuilder(client, 'DEFAULT', 'SalesInvoice', 'ABC123')
    return trans
コード例 #2
0
def single_transaction():
    """Create an instance of AvataxClient with authentication and created transaction."""
    client = AvataxClient('test app', 'ver 0.0', 'test machine', 'sandbox')
    login_key, login_val = cred_determine()
    client.add_credentials(login_key, login_val)
    tax_document = default_trans_model()
    r = client.create_transaction(tax_document, 'DEFAULT')
    trans_code = r.json()['code']
    return trans_code
コード例 #3
0
def auth_client():
    """Create an instance of SanboxClient with authentification using username/password pair."""

    try:
        login_key, login_val = cred_determine()
    except ValueError:
        raise ValueError('No testing credentials are in the environment.')
    client = AvataxClient('test app', 'ver 0.0', 'test machine', 'sandbox')
    client.add_credentials(login_key, login_val)
    return client
コード例 #4
0
def five_transactions():
    """Create an instance of AvataxClient with authentication and created transaction."""
    trans_codes = []
    client = AvataxClient('test app', 'ver 0.0', 'test machine', 'sandbox')
    login_key, login_val = cred_determine()
    client.add_credentials(login_key, login_val)
    addresses = [('Seattle', '600 5th Ave', '98104', 'WA'),
                 ('Poulsbo', '200 Moe St Ne', '98370', 'WA'),
                 ('Los Angeles', '1945 S Hill St', '90007', 'CA'),
                 ('Chicago', '50 W Washington St', '60602', 'IL'),
                 ('Irvine', '123 Main Street', '92615', 'CA')]
    for city, line1, postal, region in addresses:
        tax_document = {
            'addresses': {
                'SingleLocation': {
                    'city': city,
                    'country': 'US',
                    'line1': line1,
                    'postalCode': postal,
                    'region': region
                }
            },
            'commit':
            False,
            'companyCode':
            'DEFAULT',
            'currencyCode':
            'USD',
            'customerCode':
            'ABC',
            'date':
            '2017-04-12',
            'description':
            'Yarn',
            'lines': [{
                'amount': 100,
                'description': 'Yarn',
                'itemCode': 'Y0001',
                'number': '1',
                'quantity': 1,
                'taxCode': 'PS081282'
            }],
            'purchaseOrderNo':
            '2017-04-12-001',
            'type':
            'SalesInvoice'
        }
        r = client.create_transaction(tax_document, None)
        trans_codes.append(r.json()['code'])
    return trans_codes
コード例 #5
0
def test_client_can_obtain_their_own_base_url():
    """Test the client can input a url as the base url."""
    client = AvataxClient('test app', 'ver 0.0', 'test machine',
                          'https://myurl.com')
    assert client.base_url == 'https://myurl.com'
コード例 #6
0
def test_client_can_obtain_production_url_as_base_url():
    """Test the default option for base url is production url."""
    client = AvataxClient('test app', 'ver 0.0', 'test machine')
    assert client.base_url == 'https://rest.avatax.com'
コード例 #7
0
def unauth_client():
    """Create an instance of SanboxClient without authentification."""
    return AvataxClient('test app', 'ver 0.0', 'test machine', 'sandbox')
with addresses and creates locations based on that list.
Then it generates a tax file based on the locations and given
list of tax codes.

Writing the files requires a folder named "taxfiles" to be
created prior to running this script.
"""
from avatax.client import AvataxClient
from tax_code_list import sample_codes as tax_codes
import os
import sys
import time
import datetime

# Creates a client object using dummy company "tugboat"
tugboat = AvataxClient(None, None, None, "sandbox")
tugboat.add_credentials(os.environ["USERNAME"], os.environ["PASSWORD"])

comp_id = os.environ["COMPANY"]
comp_code = tugboat.get_company(comp_id).json()["companyCode"]
# get list of all zip codes with address by date
address_gen = tugboat.download_tax_rates_by_zip_code(
    datetime.date.today().isoformat())

# List comprehension to create array of all addresses from generator
#  slicing only address information
address_array = [
    item.decode("utf-8").split(",")[:4] for item in address_gen.iter_lines()
][1:]

# create variables for analytic data to be sent to
コード例 #9
0
This script generates a tax file for each location in a
company, based on a supplied tax code list.

Writing the files requires a folder named "taxfiles" to be
created prior to running this script.
"""
from avatax.client import AvataxClient
from tax_code_list import sample_codes as tax_codes
import os
import sys
import time
import datetime

# Creates a client object using dummy company "new_client"
new_client = AvataxClient(None, None, None, "sandbox")
new_client.add_credentials(os.environ["USERNAME"], os.environ["PASSWORD"])

# create variables for analytic data to be sent to
analytics = []
analysis = open("./taxfiles/analytics.txt", "a")
iter_count = 0
total_start_time = time.time()
tax_file_list = []
comp_id = os.environ["COMPANY"]

# get all the locations belonging to the target company.
location_list = new_client.list_locations_by_company(
    comp_id).json()["value"]
# get the company code for the target company.
comp_code = new_client.get_company(comp_id).json()["companyCode"]