summaryrefslogtreecommitdiff
path: root/postgresqleu/util/misc
diff options
context:
space:
mode:
authorMagnus Hagander2018-12-28 10:57:55 +0000
committerMagnus Hagander2018-12-28 10:57:55 +0000
commitfa2f20ee7f192a6322ae03ff8dbe2a3dea4b9fd2 (patch)
treefdeae3b196ce498c1c7deb8fb53821e3d530828f /postgresqleu/util/misc
parente4789c2dbcf52a15c792dc52f3c6795c6836b926 (diff)
Re-think how refunds are handled
Basically reverse the flow - instead of having the invoice system refund an invoice and trigger an action in the attached systems (such as confreg or membership) to remove something, have the actual end systems like confreg handle the cancelation and just tell the invoice system what the refund is. This makes the system a lot more flexible and makes it possible to handle things like multi-attendee invoices that get partially refunded more than once. Other than the order-reversal: 1. Each invoice can now have multiple refund notes. In doing this, the view of "refunded invoices" has also been retired, as it makes less sense now. 2. Refund notices now include a "previously refunded" section if they are anything except the first refund note, to track across multiple refunds. This creates a breaking change in the API for PDF generation, but recent other updates to the skinning broke them all anyway. 3. For confreg, implement "refund patterns". This is a set of rules with "refund x% minus fees of y" rules that can be applied when canceling a registration. They are applied to the individual costs being refunded. They can also be given a start/end date during which they should be used, which is used as a hint in the UI.
Diffstat (limited to 'postgresqleu/util/misc')
-rwxr-xr-xpostgresqleu/util/misc/baseinvoice.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/postgresqleu/util/misc/baseinvoice.py b/postgresqleu/util/misc/baseinvoice.py
index b60ae5a8..48a4ec44 100755
--- a/postgresqleu/util/misc/baseinvoice.py
+++ b/postgresqleu/util/misc/baseinvoice.py
@@ -316,7 +316,7 @@ class BaseInvoice(PDFBase):
class BaseRefund(PDFBase):
- def __init__(self, recipient, invoicedate, refunddate, invoicenum, invoiceamount, invoicevat, refundamount, refundvat, paymentmethod):
+ def __init__(self, recipient, invoicedate, refunddate, invoicenum, invoiceamount, invoicevat, refundamount, refundvat, paymentmethod, refundid, reason, previousamount, previousvat):
super(BaseRefund, self).__init__(recipient)
self.title = "Refund of invoice {0}".format(invoicenum)
self.recipient = recipient
@@ -328,13 +328,19 @@ class BaseRefund(PDFBase):
self.refundamount = refundamount
self.refundvat = refundvat
self.paymentmethod = paymentmethod
+ self.refundid = refundid
+ self.reason = reason
+ self.previousamount = previousamount
+ self.previousvat = previousvat
self.prepare()
def save(self):
self.draw_header()
- self.canvas.drawCentredString(cm(10.5), cm(19), "REFUND NOTE FOR INVOICE NUMBER {0}".format(self.invoicenum))
+ self.canvas.drawCentredString(cm(10.5), cm(19), "REFUND NOTE {0} FOR INVOICE NUMBER {1}".format(self.refundid, self.invoicenum))
+
+ self.canvas.drawString(cm(2), cm(18), "Reason for refund: {0}".format(self.reason))
tblpaid = [
["Amount paid"],
@@ -346,6 +352,11 @@ class BaseRefund(PDFBase):
["Item", "Amount"],
["Amount", "{0:.2f} {1}".format(self.refundamount, settings.CURRENCY_SYMBOL)],
]
+ tblprevious = [
+ ["Amount previously refunded"],
+ ["Item", "Amount"],
+ ["Amount", "{0:.2f} {1}".format(self.previousamount, settings.CURRENCY_SYMBOL)],
+ ]
if self.invoicevat:
tblpaid.extend([
["VAT", "{0:.2f} {1}".format(self.invoicevat, settings.CURRENCY_SYMBOL)],
@@ -355,6 +366,10 @@ class BaseRefund(PDFBase):
["VAT", "{0:.2f} {1}".format(self.refundvat, settings.CURRENCY_SYMBOL)],
["", "{0:.2f} {1}".format(self.refundamount + self.refundvat, settings.CURRENCY_SYMBOL)],
])
+ tblprevious .extend([
+ ["VAT", "{0:.2f} {1}".format(self.previousvat, settings.CURRENCY_SYMBOL)],
+ ["", "{0:.2f} {1}".format(self.previousamount + self.previousvat, settings.CURRENCY_SYMBOL)],
+ ])
style = [
('SPAN', (0, 0), (1, 0)),
@@ -372,17 +387,26 @@ class BaseRefund(PDFBase):
t = Table(tblpaid, [cm(10.5), cm(2.5), cm(1.5), cm(2.5)])
t.setStyle(TableStyle(style))
w, h = t.wrapOn(self.canvas, cm(10), cm(10))
- t.drawOn(self.canvas, (self.canvas._pagesize[0] - w) / 2, cm(18) - h)
+ t.drawOn(self.canvas, (self.canvas._pagesize[0] - w) / 2, cm(17) - h)
+
+ if self.previousamount:
+ t = Table(tblprevious, [cm(10.5), cm(2.5), cm(1.5), cm(2.5)])
+ t.setStyle(TableStyle(style))
+ w, h = t.wrapOn(self.canvas, cm(10), cm(10))
+ t.drawOn(self.canvas, (self.canvas._pagesize[0] - w) / 2, cm(17) - h * 2 - cm(1))
+ extraofs = h + cm(1)
+ else:
+ extraofs = 0
t = Table(tblrefunded, [cm(10.5), cm(2.5), cm(1.5), cm(2.5)])
t.setStyle(TableStyle(style))
w, h = t.wrapOn(self.canvas, cm(10), cm(10))
- t.drawOn(self.canvas, (self.canvas._pagesize[0] - w) / 2, cm(18) - h * 2 - cm(1))
+ t.drawOn(self.canvas, (self.canvas._pagesize[0] - w) / 2, cm(17) - h * 2 - cm(1) - extraofs)
- self.canvas.drawCentredString(cm(10.5), cm(17.3) - h * 2 - cm(2), "This refund was issued {0}".format(self.refunddate.strftime("%B %d, %Y")))
+ self.canvas.drawCentredString(cm(10.5), cm(16.3) - h * 2 - cm(2) - extraofs, "This refund was issued {0}".format(self.refunddate.strftime("%B %d, %Y")))
if self.paymentmethod:
- self.canvas.drawCentredString(cm(10.5), cm(17.3) - h * 2 - cm(3), "Refunded to the original form of payment: {0}.".format(self.paymentmethod))
+ self.canvas.drawCentredString(cm(10.5), cm(16.3) - h * 2 - cm(3) - extraofs, "Refunded to the original form of payment: {0}.".format(self.paymentmethod))
self.canvas.showPage()
self.canvas.save()