コード例 #1
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
コード例 #2
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