mirumee/django-prices-vatlayer

Name: django-prices-vatlayer

Owner: Mirumee Labs

Description: Vatlayer API support for django-prices

Created: 2017-01-17 11:01:47.0

Updated: 2018-05-14 06:19:29.0

Pushed: 2018-04-10 10:55:55.0

Homepage: null

Size: 74

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

django-prices-vatlayer: Vatlayer API support for prices

Build Status codecov.io

 prices import Money
 django_prices_vatlayer.utils import (
get_tax_for_rate, get_tax_rates_for_country)

ax_rates = get_tax_rates_for_country('DE')
s_tax = get_tax_for_rate(de_tax_rates, 'books')

e_with_vat = books_tax(Money(10, 'EUR'))
t(price_with_vat)
xedMoney(net=Money('10', 'EUR'), gross=Money('11', 'EUR'))

e_with_vat = books_tax(
TaxedMoney(net=Money(10, 'EUR'), gross=Money(10, 'EUR')))
t(price_with_vat)
xedMoney(net=Money('10', 'EUR'), gross=Money('11', 'EUR'))

Installation

The package can easily be installed via pip:

install django-prices-vatlayer

After installation, you'll also need to setup your site to use it. To do that, open your settings.py and do the following:

  1. Add 'django_prices_vatlayer', to your INSTALLED_APPS
  2. Add VATLAYER_ACCESS_KEY = 'YOUR_API_KEY_HERE' line
  3. Replace YOUR_API_KEY_HERE with the API key that you have obtained from vatlayer API

Lastly, run manage.py migrate to create new tables in your database and manage.py get_vat_rates to populate them with initial data.

Forcing non-secure API connection in production

By default, django-prices-vatlayer uses the unsafe HTTP connection during development (DEBUG = True) and changes to HTTPS in production, to keep communication with the vatlayer API secure.

However as HTTPS unavailable in vatlayer's free plan, you may preffer to force unsafe HTTP on your live site as well. To do so, just add following line to your settings.py:

VATLAYER_API = 'http://apilayer.net/api/'

Remember that doing so may expose you to DNS poisoning and man-in-the-middle attacks and we recommend that VATLAYER_API is set to use the HTTPS.

Updating VAT rates

To get current VAT rates from the API run the get_vat_rates management command.

You may also set cron job for running this task daily to always be up to date with current tax rates.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.