Skip to content

Instantly share code, notes, and snippets.

@KushalP
Created June 9, 2015 14:47
Show Gist options
  • Save KushalP/2b4eb3743b114700d6a0 to your computer and use it in GitHub Desktop.
Save KushalP/2b4eb3743b114700d6a0 to your computer and use it in GitHub Desktop.
A small script to add the VAT rate to the open register. It requires the python-requests library to be installed: http://docs.python-requests.org/en/latest/
import json
import requests
import os
class OpenRegister(object):
def __init__(self, endpoint):
self.endpoint = endpoint
def create(self, data):
create_path = self.endpoint + "create"
print create_path
return requests.post(create_path,
data=json.dumps(data),
headers={"Content-Type": "application/json"},
auth=(os.environ["REGISTER_USER"],
os.environ["REGISTER_PASS"]))
if __name__ == "__main__":
rates = [
{"rate": "15",
"start-date": "1979-06-18",
"end-date": "1991-03-18"},
{"rate": "17.5",
"start-date": "1991-03-19",
"end-date": "2008-11-30"},
{"rate": "15",
"start-date": "2008-12-01",
"end-date": "2009-12-31"},
{"rate": "17.5",
"start-date": "2010-01-01",
"end-date": "2011-01-03"},
]
register = OpenRegister("http://vat-rate.openregister.org/")
for i, v in enumerate(rates):
v["vat-rate"] = str(i + 2)
print v
print register.create(v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment