Package: django-oscar-avalara
This package provides integration betweenAvalaraandOscar.  Avalara is a
service that provides accurate sales tax calculations in the US.Useful documentation:Avalara docsStatus:InstallationInstall from PyPI:$ pip install django-oscar-avalaraor Github:$ pip install git+https://github.com/tangentlabs/django-oscar-avalara.gitthen add'avalara'toINSTALLED_APPS.Specify the following settings:AVALARA_ACCOUNT_NUMBERAVALARA_LICENSE_KEYAVALARA_COMPANY_CODEYou should have been provided with these details when you signed up with Avalara.When not in production, setAVALARA_TEST_MODE = Trueto make requests
to the Avalara development server.This package uses a named logger'avalara'so it is normally useful to
define handlers to this logger.UsageTo integrate Avalara into checkout, you need to override two methods from the
checkout view classPaymentDetailsView.First overridebuild_submissionto apply taxes to the basket and shipping
method:fromoscar.apps.checkoutimportviewsfromdjango.contribimportmessagesfromdjango.templateimportloaderimportavalaraclassPaymentDetailsView(views.PaymentDetailsView):...defbuild_submission(self,**kwargs):submission=super(PaymentDetailsView,self).build_submission(**kwargs)# Fetch and apply taxes to submission dicttry:avalara.apply_taxes_to_submission(submission)exceptavalara.InvalidAddress,e:msg=loader.render_to_string('avalara/messages/invalid_address.html',{'error':e.message})messages.error(self.request,msg,extra_tags="safe noicon")returnsubmissionHere we are passing the submission dict toapply_taxes_to_submissionwhich
will look up the appropriate taxes and apply them in place to the basket and
shipping method instances.We also watch out forInvalidAddressexceptions which will be raised if
Avalara is unable to find a tax jurisdiction for the passed shipping address.Finally, overridehandle_successful_orderto submit the placed order to
Avalara:fromoscar.apps.checkoutimportviewsfromdjango.contribimportmessagesfromdjango.templateimportloaderimportavalaraclassPaymentDetailsView(views.PaymentDetailsView):...defhandle_successful_order(self,order):response=super(PaymentDetailsView,self).handle_successful_order(order)# Submit tax information to Avalaratry:avalara.submit(order)exceptException:# Tax can be re-submitted later so we swallow all possible# exceptions and log them.logger.error("Unable to submit tax information for order%s",order.number,exc_info=True)returnresponseHere we pass the order instance tosubmitwhich will submit the tax
information to Avalara for reporting.  We also catch and log any exception as
we don’t want order placement to show an error screen.  If there is a problem
talking to Avalara, we can manually resubmit the order later on.ContributingClone the repo, create a virtualenv and run:make installto install all dependencies.  Run the tests with:./runtests.pyThere is a sandbox site that you can browse and use to test the Avalara
integration.  Create it using:make sandboxand browse it after:cd sandbox
./manage.py runserverNote that you will need to have test credentials for Avalara in a privateintegration.pymodule.Changelog0.2.1Fix a few issues with submitting orders.0.2Support Oscar 1.0 and solve a cache key issue.0.1.1Patch release to limit support todjango-oscar>=0.6,<1.0.0.1Initial version - supportsdjango-oscar>=0.6.