本文整理汇总了Python中pyavatax.base.Document.new_sales_order方法的典型用法代码示例。如果您正苦于以下问题:Python Document.new_sales_order方法的具体用法?Python Document.new_sales_order怎么用?Python Document.new_sales_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyavatax.base.Document
的用法示例。
在下文中一共展示了Document.new_sales_order方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_posttax
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_posttax():
with LogCapture('pyavatax.api') as l:
api = get_api()
# dont pass a doccode
doc = Document.new_sales_order(DocDate=datetime.date.today(), CustomerCode='[email protected]')
to_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
from_address = Address(Line1="100 Ravine Lane NE", Line2="#220", PostalCode="98110")
doc.add_from_address(from_address)
doc.add_to_address(to_address)
line = Line(Amount=10.00)
doc.add_line(line)
# make sure i don't have a doccode
try:
doc.DocCode
except AttributeError:
assert True
else:
assert False
tax = api.post_tax(doc)
assert tax.is_success is True
assert tax.TotalTax > 0
assert len(tax.TaxAddresses) == 2
assert len(tax.TaxLines) == 1
assert len(tax.TaxLines[0].TaxDetails) > 0
assert tax.DocCode
assert doc.DocCode # make sure the doccode moved over
l.check(
('pyavatax.api', 'DEBUG', 'None setting default from address code'),
('pyavatax.api', 'DEBUG', 'None setting default to address code'),
('pyavatax.api', 'DEBUG', 'None inserting LineNo 1'),
('pyavatax.api', 'DEBUG', 'None setting origin code %s' % Address.DEFAULT_FROM_ADDRESS_CODE),
('pyavatax.api', 'DEBUG', 'None setting destination code %s' % Address.DEFAULT_TO_ADDRESS_CODE),
('pyavatax.api', 'INFO', '"POST", %s, %s%s' % (None, api.url, '/'.join([API.VERSION, 'tax', 'get']))),
('pyavatax.api', 'DEBUG', 'AvaTax assigned %s as DocCode' % doc.DocCode)
)
示例2: test_validation
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_validation():
try:
doc = Document(DocDate='foo') # testing date
except AvalaraException:
assert True
else:
assert False
try:
doc = Line(Qty='foo') # testing int
except AvalaraException:
assert True
else:
assert False
try:
doc = Line(Amount='foo') # testing float
except AvalaraException:
assert True
else:
assert False
doc = Document.new_sales_order(DocCode='1001', DocDate=datetime.date.today(), CustomerCode='[email protected]')
try:
doc.validate()
except AvalaraException:
assert True
else:
assert False
from_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
to_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
doc.add_from_address(from_address)
doc.add_to_address(to_address)
try:
doc.validate()
except AvalaraException:
assert True
else:
assert False
try:
doc.add_from_address(from_address)
except AvalaraException:
assert True
else:
assert False
try:
doc.add_to_address(from_address)
except AvalaraException:
assert True
else:
assert False
line = Line(Amount=10.00)
doc.add_line(line)
try:
doc.validate()
except AvalaraException:
assert False
示例3: test_discount
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_discount():
api = get_api()
# dont pass a doccode
amount = 10.00
doc = Document.new_sales_order(DocDate=datetime.date.today(), CustomerCode='[email protected]', Discount=amount)
doc.add_from_address(Line1="100 Ravine Lane NE", Line2="#220", PostalCode="98110")
doc.add_to_address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
doc.add_line(Amount=amount, Discounted=True)
tax = api.post_tax(doc)
assert tax.is_success is True
assert float(tax.TotalTax) == 0
assert float(tax.TotalAmount) == amount
assert float(tax.TotalDiscount) == amount
示例4: test_posttax_commit_exempt
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_posttax_commit_exempt():
random_doc_code = uuid.uuid4().hex # you can't post/cancel the same doc code over and over
api = get_api()
# G = resale, which means exempt from tax
doc = Document.new_sales_order(DocCode=random_doc_code, DocDate=datetime.date.today(), CustomerCode='[email protected]', CustomerUsageType='G')
to_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
from_address = Address(Line1="100 Ravine Lane NE", Line2="#220", PostalCode="98110")
doc.add_from_address(from_address)
doc.add_to_address(to_address)
line = Line(Amount=10.00, Qty=2)
doc.add_line(line)
doc.add_line(TaxCode='FR', Amount='12.00')
tax = api.post_tax(doc, commit=True)
assert doc.Commit
assert doc.DocType == Document.DOC_TYPE_SALE_INVOICE # make sure the doc type changes with commit
assert tax.is_success is True
assert tax.TotalTax == '0'
assert len(tax.TaxAddresses) == 2
assert len(tax.TaxLines) == 2
示例5: test_validation
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_validation():
with pytest.raises(AvalaraValidationException) as e:
doc = Document(DocDate='foo') # testing date
assert e.value.code == AvalaraException.CODE_BAD_DATE
with pytest.raises(AvalaraValidationException) as e:
line = Line(Qty='foo') # testing int
assert e.value.code == AvalaraException.CODE_BAD_FLOAT
with pytest.raises(AvalaraValidationException) as e:
line = Line(Amount='foo') # testing float
assert e.value.code == AvalaraException.CODE_BAD_FLOAT
with pytest.raises(AvalaraValidationException) as e:
line = Line(ItemCode='this string is longer than fifty characters and should be stopped') # testing length
assert e.value.code == AvalaraException.CODE_TOO_LONG
doc = Document.new_sales_order(DocCode='1001', DocDate=datetime.date.today(), CustomerCode='[email protected]')
with pytest.raises(AvalaraValidationException) as e:
doc.validate()
assert e.value.code == AvalaraException.CODE_BAD_ADDRESS
from_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
to_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
doc.add_from_address(from_address)
doc.add_to_address(to_address)
with pytest.raises(AvalaraValidationException) as e:
doc.validate()
assert e.value.code == AvalaraException.CODE_BAD_LINE
with pytest.raises(AvalaraException) as e:
doc.add_from_address(from_address)
assert e.value.code == AvalaraException.CODE_HAS_FROM
with pytest.raises(AvalaraException) as e:
doc.add_to_address(to_address)
assert e.value.code == AvalaraException.CODE_HAS_TO
line = Line(Amount=10.00)
doc.add_line(line)
doc.validate()
api = get_api()
lat = 47.627935
lng = -122.51702
with pytest.raises(AvalaraTypeException) as e:
api.get_tax(lat, lng, 'foo', None)
assert e.value.code == AvalaraException.CODE_BAD_DOC
with pytest.raises(AvalaraException) as e:
api.get_tax(lat, lng, None, None)
assert e.value.code == AvalaraException.CODE_BAD_ARGS
示例6: test_posttax
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_posttax():
with LogCapture('pyavatax.api') as l:
api = get_api()
# dont pass a doccode
doc = Document.new_sales_order(DocDate=datetime.date.today(), CustomerCode='[email protected]')
doc.add_from_address(Line1="100 Ravine Lane NE", Line2="#220", PostalCode="98110")
doc.add_to_address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
doc.add_line(Amount=10.00)
doc.add_line(Amount=10.00)
doc.add_line(TaxCode='FR', Amount='12.00')
# make sure i don't have a doccode
try:
doc.DocCode
except AttributeError:
assert True
else:
assert False
tax = api.post_tax(doc)
assert tax.is_success is True
assert tax.TotalTax > 0
assert len(tax.TaxAddresses) == 2
assert len(tax.TaxLines) == 3
assert len(tax.TaxLines[0].TaxDetails) > 0
assert tax.DocCode
assert doc.DocCode # make sure the doccode moved over
docdate = datetime.date.today().strftime('%Y-%m-%d')
l.check(
('pyavatax.api', 'DEBUG', 'None setting default from address code'),
('pyavatax.api', 'DEBUG', 'None setting default to address code'),
('pyavatax.api', 'DEBUG', 'None inserting LineNo 1'),
('pyavatax.api', 'DEBUG', 'None inserting LineNo 2'),
('pyavatax.api', 'DEBUG', 'None inserting LineNo 3'),
('pyavatax.api', 'DEBUG', 'None setting origin code %s' % Address.DEFAULT_FROM_ADDRESS_CODE),
('pyavatax.api', 'DEBUG', 'None setting destination code %s' % Address.DEFAULT_TO_ADDRESS_CODE),
('pyavatax.api', 'DEBUG', 'None setting origin code %s' % Address.DEFAULT_FROM_ADDRESS_CODE),
('pyavatax.api', 'DEBUG', 'None setting destination code %s' % Address.DEFAULT_TO_ADDRESS_CODE),
('pyavatax.api', 'DEBUG', 'None setting origin code %s' % Address.DEFAULT_FROM_ADDRESS_CODE),
('pyavatax.api', 'DEBUG', 'None setting destination code %s' % Address.DEFAULT_TO_ADDRESS_CODE),
('pyavatax.api', 'INFO', '"POST", %s, %s%s with: %s' % (None, api.url, '/'.join([API.VERSION, 'tax', 'get']), '{\'Addresses\': [{\'PostalCode\': \'98110\', \'AddressCode\': \'1\', \'Line2\': \'#220\', \'Line1\': \'100 Ravine Lane NE\'}, {\'PostalCode\': \'98110\', \'AddressCode\': \'2\', \'Line2\': \'#250\', \'Line1\': \'435 Ericksen Avenue Northeast\'}], \'DocDate\': \'' + docdate + '\', \'Lines\': [{\'DestinationCode\': \'2\', \'Amount\': 10.0, \'Qty\': 1, \'LineNo\': 1, \'OriginCode\': \'1\'}, {\'DestinationCode\': \'2\', \'Amount\': 10.0, \'Qty\': 1, \'LineNo\': 2, \'OriginCode\': \'1\'}, {\'TaxCode\': \'FR\', \'DestinationCode\': \'2\', \'Qty\': 1, \'Amount\': 12.0, \'LineNo\': 3, \'OriginCode\': \'1\'}], \'DocType\': \'SalesOrder\', \'Discount\': 0, \'CustomerCode\': \'[email protected]\', \'PaymentDate\': None, \'CompanyCode\': \'PYAVATEST\'}')),
('pyavatax.api', 'DEBUG', 'AvaTax assigned %s as DocCode' % doc.DocCode)
)
示例7: test_posttax_commit_cancel
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_posttax_commit_cancel():
random_doc_code = uuid.uuid4().hex # you can't post/cancel the same doc code over and over
api = get_api()
doc = Document.new_sales_order(DocCode=random_doc_code, DocDate=datetime.date.today(), CustomerCode='[email protected]')
to_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
from_address = Address(Line1="100 Ravine Lane NE", Line2="#220", PostalCode="98110")
doc.add_from_address(from_address)
doc.add_to_address(to_address)
line = Line(Amount=10.00, Qty=2)
doc.add_line(line)
tax = api.post_tax(doc, commit=True)
assert doc.Commit
assert doc.DocType == Document.DOC_TYPE_SALE_INVOICE # make sure the doc type changes with commit
assert tax.is_success is True
assert tax.TotalTax > 0
assert tax.total_tax == tax.TotalTax
assert len(tax.TaxAddresses) == 2
assert len(tax.TaxLines) == 1
assert len(tax.TaxLines[0].TaxDetails) > 0
cancel = api.cancel_tax(doc)
assert cancel.is_success is True
assert cancel.CancelTaxResult
示例8: test_justtozip
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_order [as 别名]
def test_justtozip():
api = get_api()
doc = Document.new_sales_order(DocDate=datetime.date.today(), CustomerCode='[email protected]')
doc.add_from_address(Line1="100 Ravine Lane NE", Line2="#220", PostalCode="98110")
doc.add_to_address(Line1="", Line2="", PostalCode="98110")
doc.add_line(Amount=10.00)
doc.add_line(Amount=10.00)
# make sure i don't have a doccode
try:
doc.DocCode
except AttributeError:
assert True
else:
assert False
tax = api.post_tax(doc)
assert tax.is_success is True
assert tax.TotalTax > 0
assert len(tax.TaxAddresses) == 2
assert len(tax.TaxLines) == 2
assert len(tax.TaxLines[0].TaxDetails) > 0
assert tax.DocCode
assert doc.DocCode # make sure the doccode moved over