summaryrefslogtreecommitdiff
path: root/postgresqleu/util/misc
diff options
context:
space:
mode:
authorMagnus Hagander2017-09-20 13:20:01 +0000
committerMagnus Hagander2017-09-20 13:23:46 +0000
commit7a0140658bebffd0e307e8a27c38ab16effdcaa6 (patch)
tree17a7f5a2f6b510ab74a724505d74752c2c67df32 /postgresqleu/util/misc
parent1bc3475625ea47e151cb058135ffe909fd85e7cb (diff)
Add support for EU reverse vat, and change sponsor invoice generation
Per the new instructions from the tax authorities, we should do 100% opposite of their previous instructions, and instead actually issue reverse VAT invoices for sponsorship. To do this, we implement a new flag on each invoice that indicates if it should have reverse VAT. If this is used, the actual VAT must be zero, and instead it will trigger text about it on the invoice. Sponsors inside the EU and with a valid VAT number, but *not* inside France, will get reverse VAT. Any sponsor without a VAT number *or* a sponsor in France with a VAT number will get regular VAT. No invoices are issued without VAT. Based on this we no longer keep track of VAT number separately from "in vat area" as our previous instructions required, so drop this field from the database. Finally, uses screen scraping to validate VAT numbers on the EU websites since their SOAP service is basically broken. This can easily be turned off in the config file (and is turned off by default) in case the service stops working.
Diffstat (limited to 'postgresqleu/util/misc')
-rwxr-xr-xpostgresqleu/util/misc/pgeuinvoice.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/postgresqleu/util/misc/pgeuinvoice.py b/postgresqleu/util/misc/pgeuinvoice.py
index 0af0f6c3..e5212dbb 100755
--- a/postgresqleu/util/misc/pgeuinvoice.py
+++ b/postgresqleu/util/misc/pgeuinvoice.py
@@ -100,7 +100,7 @@ E-mail: treasurer@postgresql.eu""",
class PDFInvoice(PDFBase):
- def __init__(self, title, recipient, invoicedate, duedate, invoicenum=None, imagedir=None, currency='€', preview=False, receipt=False, bankinfo=True, totalvat=0, paymentlink=None, **kw):
+ def __init__(self, title, recipient, invoicedate, duedate, invoicenum=None, imagedir=None, currency='€', preview=False, receipt=False, bankinfo=True, totalvat=0, reverse_vat=None, paymentlink=None, **kw):
super(PDFInvoice, self).__init__(recipient, invoicenum, imagedir, currency)
self.title = title
@@ -110,6 +110,7 @@ class PDFInvoice(PDFBase):
self.receipt = receipt
self.bankinfo = bankinfo
self.totalvat = totalvat
+ self.reverse_vat = reverse_vat
self.paymentlink = paymentlink
self.rows = []
@@ -122,7 +123,7 @@ class PDFInvoice(PDFBase):
self.rows.append((title, cost, count, vatrate, vatrate and vatrate.vatpercent or 0))
- ROWS_PER_PAGE=16
+ ROWS_PER_PAGE=14
def save(self):
# We can fit ROWS_PER_PAGE rows on one page. We might want to do something
# cute to avoid a single row on it's own page in the future, but
@@ -181,9 +182,18 @@ class PDFInvoice(PDFBase):
if self.totalvat>0 and totalvat != self.totalvat:
raise Exception("Specified total VAT {0} does not match calculated VAT {1}".format(self.totalvat, totalvat))
+ if self.reverse_vat:
+ if totalvat != 0:
+ raise Exception("Can't use reverse VAT and specified VAT at the same time!")
+ vathdr = 'Total VAT *'
+ vatstr = "0 %s *" % (self.currency)
+ else:
+ vathdr = 'Total VAT'
+ vatstr = '%.2f %s' % (totalvat, self.currency)
+
tbldata.extend([
('Total excl VAT', '', '','' , '%.2f %s' % (totalexcl, self.currency)),
- ('Total VAT', '', '', '', '%.2f %s' % (totalvat, self.currency)),
+ (vathdr, '', '', '', vatstr),
('Total incl VAT', '', '', '', '%.2f %s' % (totalincl, self.currency)),
])
style.extend([
@@ -250,6 +260,13 @@ BIC: CMCIFR2A
2*cm, 1.8*cm,
1.5*cm, 1.5*cm)
+ if self.reverse_vat:
+ t = self.canvas.beginText()
+ t.setTextOrigin(2*cm, 4.8*cm)
+ t.setFont("DejaVu Serif", 6)
+ self.textlines(t, "* Services subject to the reverse charge - VAT to be accounted for by the recipient as per Article 196 of Council Directive 2006/112/EC")
+ self.canvas.drawText(t)
+
# Finish this page off, and optionally loop to another one
self.canvas.showPage()