本文整理汇总了Python中pyavatax.base.Document.new_sales_invoice方法的典型用法代码示例。如果您正苦于以下问题:Python Document.new_sales_invoice方法的具体用法?Python Document.new_sales_invoice怎么用?Python Document.new_sales_invoice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyavatax.base.Document
的用法示例。
在下文中一共展示了Document.new_sales_invoice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recorder
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_invoice [as 别名]
def test_recorder():
try:
from pyavatax.models import AvaTaxRecord
except ImportError: # no django
pytest.mark.xfail('This can only be run inside a django environment')
return
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_invoice(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)
doc.add_line(line)
setattr(doc, '_testing_ignore_validate', True) # passthrough I put in to allow this test, never actually use this
orig_doc_type = doc.DocType
doc.DocType = 'DoesntExist' # forcing error
tax = api.post_tax(doc)
assert tax.is_success == False
assert 1 == AvaTaxRecord.failures.filter(doc_code=random_doc_code).count()
assert 0 == AvaTaxRecord.successes.filter(doc_code=random_doc_code).count()
doc.DocType = orig_doc_type
tax = api.post_tax(doc, commit=True)
assert tax.is_success == True
assert 0 == AvaTaxRecord.failures.filter(doc_code=random_doc_code).count()
assert 1 == AvaTaxRecord.successes.filter(doc_code=random_doc_code).count()
tax = api.post_tax(doc, commit=True)
assert tax.is_success == False
assert 1 == AvaTaxRecord.failures.filter(doc_code=random_doc_code).count()
assert 1 == AvaTaxRecord.successes.filter(doc_code=random_doc_code).count()
示例2: test_return
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_invoice [as 别名]
def test_return():
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_invoice(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)
doc.add_line(line)
tax = api.post_tax(doc)
assert tax.is_success
assert tax.total_tax > 0
# and return invoice
doc = Document.new_return_invoice(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)
doc.add_line(line)
tax_date = datetime.date.today() - datetime.timedelta(days=5)
doc.add_override(TaxOverrideType=TaxOverride.OVERRIDE_DATE, TaxDate=tax_date, Reason="Tax Date change",)
tax = api.post_tax(doc)
assert tax.is_success
assert float(tax.total_tax) < 0
示例3: test_override
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_invoice [as 别名]
def test_override():
import uuid
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_invoice(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)
doc.add_line(line)
tax = api.post_tax(doc)
assert tax.is_success
assert tax.total_tax > 0
# now the soap part
soap_api = get_soap_api()
tax_date = datetime.date.today() - datetime.timedelta(days=5)
tax = soap_api.tax_override(doc, tax_date=tax_date, tax_amt=0, reason="Tax Date change", override_type='TaxDate')
assert tax.is_success
assert tax.total_tax > 0
示例4: test_override_failure
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import new_sales_invoice [as 别名]
def test_override_failure():
try:
from pyavatax.models import AvaTaxRecord
except ImportError: # no django
pytest.mark.xfail('This can only be run inside a django environment')
return
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_invoice(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)
doc.add_line(line)
doc.DocType = 'FooBar' # forcing error
tax_date = datetime.date.today() - datetime.timedelta(days=5)
doc.add_override(TaxOverrideType=TaxOverride.OVERRIDE_DATE, TaxDate=tax_date, Reason="Tax Date change",)
tax = api.post_tax(doc)
assert tax.is_success == False
assert 1 == AvaTaxRecord.failures.filter(doc_code=random_doc_code).count()
assert 0 == AvaTaxRecord.successes.filter(doc_code=random_doc_code).count()