summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--postgresqleu/invoices/backendviews.py18
-rw-r--r--postgresqleu/urls.py1
-rw-r--r--postgresqleu/views.py3
-rw-r--r--template/adm/index.html5
-rw-r--r--template/invoices/refunds.html32
5 files changed, 57 insertions, 2 deletions
diff --git a/postgresqleu/invoices/backendviews.py b/postgresqleu/invoices/backendviews.py
index 740bd35c..1d53349d 100644
--- a/postgresqleu/invoices/backendviews.py
+++ b/postgresqleu/invoices/backendviews.py
@@ -3,7 +3,7 @@ from django.http import HttpResponseRedirect, Http404
from django.utils.html import escape
from django.shortcuts import get_object_or_404, render
from django.contrib import messages
-from django.db.models import Max, Q
+from django.db.models import Max, Q, F
from django.db import transaction
from django.conf import settings
@@ -17,6 +17,7 @@ from postgresqleu.invoices.util import InvoiceManager
from postgresqleu.accounting.models import Account
from postgresqleu.invoices.models import InvoicePaymentMethod, Invoice, InvoiceLog
+from postgresqleu.invoices.models import InvoiceRefund
from postgresqleu.invoices.models import PendingBankTransaction
from postgresqleu.invoices.models import PendingBankMatcher
from postgresqleu.invoices.models import BankTransferFees
@@ -603,3 +604,18 @@ def edit_paymentmethod(request, rest):
topadmin='Invoices',
return_url='/admin/',
)
+
+
+def refunds(request):
+ authenticate_backend_group(request, 'Invoice managers')
+
+ refund_objects = InvoiceRefund.objects.only('id', 'invoice_id', 'completed', 'issued', 'registered', 'reason').order_by(F('completed').desc(nulls_first=True), F('issued').desc(nulls_first=True), F('registered').desc())
+
+ (refunds, paginator, page_range) = simple_pagination(request, refund_objects, 20)
+
+ return render(request, 'invoices/refunds.html', {
+ 'refunds': refunds,
+ 'page_range': page_range,
+ 'breadcrumbs': [('/admin/invoices/refunds/', 'Refunds'), ],
+ 'helplink': 'payment',
+ })
diff --git a/postgresqleu/urls.py b/postgresqleu/urls.py
index f5120e63..60fc3d39 100644
--- a/postgresqleu/urls.py
+++ b/postgresqleu/urls.py
@@ -283,6 +283,7 @@ urlpatterns.extend([
url(r'^invoices/adyen_bank/(\d+)/(\d+)/(\w+)/$', postgresqleu.adyen.views.invoicepayment_secret),
url(r'^admin/invoices/vatrates/(.*/)?$', postgresqleu.invoices.backendviews.edit_vatrate),
url(r'^admin/invoices/vatcache/(.*/)?$', postgresqleu.invoices.backendviews.edit_vatvalidationcache),
+ url(r'^admin/invoices/refunds/$', postgresqleu.invoices.backendviews.refunds),
url(r'^admin/invoices/banktransactions/$', postgresqleu.invoices.backendviews.banktransactions),
url(r'^admin/invoices/banktransactions/(\d+)/$', postgresqleu.invoices.backendviews.banktransactions_match),
url(r'^admin/invoices/banktransactions/(\d+)/(\d+)/$', postgresqleu.invoices.backendviews.banktransactions_match_invoice),
diff --git a/postgresqleu/views.py b/postgresqleu/views.py
index 966a2415..317cb1d7 100644
--- a/postgresqleu/views.py
+++ b/postgresqleu/views.py
@@ -8,6 +8,7 @@ from django.conf import settings
from postgresqleu.newsevents.models import News
from postgresqleu.confreg.models import Conference, ConferenceSeries
from postgresqleu.invoices.models import PendingBankTransaction, BankFileUpload, InvoicePaymentMethod
+from postgresqleu.invoices.models import InvoiceRefund
from postgresqleu.util.db import exec_to_dict, conditional_exec_to_scalar
@@ -141,6 +142,7 @@ def admin_dashboard(request):
if permissions['invoices']:
pending_bank = PendingBankTransaction.objects.all().exists()
+ pending_refunds = InvoiceRefund.objects.filter(completed__isnull=True).exists()
ipm = list(InvoicePaymentMethod.objects.filter(active=True, config__has_key='file_upload_interval'))
if ipm:
# At least one payment method exists that *should* get uploads checked
@@ -164,6 +166,7 @@ def admin_dashboard(request):
return render(request, 'adm/index.html', {
'permissions': permissions,
'pending_bank': pending_bank,
+ 'pending_refunds': pending_refunds,
'bank_file_uploads': bank_file_uploads,
'schedalert': conditional_exec_to_scalar(request.user.is_superuser, "SELECT NOT EXISTS (SELECT 1 FROM pg_stat_activity WHERE application_name='pgeu scheduled job runner' AND datname=current_database())"),
'mailqueuealert': conditional_exec_to_scalar(request.user.is_superuser, "SELECT EXISTS (SELECT 1 FROM mailqueue_queuedmail LIMIT 1)"),
diff --git a/template/adm/index.html b/template/adm/index.html
index 73385337..8c73d80a 100644
--- a/template/adm/index.html
+++ b/template/adm/index.html
@@ -23,7 +23,10 @@
{%if permissions.invoices %}
<h1>Invoices</h1>
<div class="row">
- <div class="col-md-3 col-sm-6 col-xs-12 buttonrow"><a class="btn btn-default btn-block" href="/invoiceadmin/">Invoice Administration</a></div>
+ <div class="col-md-3 col-sm-6 col-xs-12 buttonrow"><a class="btn btn-default btn-block" href="/invoiceadmin/">Invoices</a></div>
+ <div class="col-md-3 col-sm-6 col-xs-12 buttonrow"><a class="btn btn-block btn-{%if pending_refunds%}warning{%else%}default{%endif%}" href="/admin/invoices/refunds/">Refunds</a></div>
+</div>
+<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12 buttonrow"><a class="btn btn-{%if pending_bank%}warning{%else%}default{%endif%} btn-block" href="/admin/invoices/banktransactions/">Pending bank transactions</a></div>
{%if bank_file_uploads is not None %}
<div class="col-md-3 col-sm-6 col-xs-12 buttonrow"><a class="btn btn-{%if bank_file_uploads %}warning{%else%}default{%endif%} btn-block" href="/admin/invoices/bankfiles/">Bank file uploads</a></div>
diff --git a/template/invoices/refunds.html b/template/invoices/refunds.html
new file mode 100644
index 00000000..dfc49d38
--- /dev/null
+++ b/template/invoices/refunds.html
@@ -0,0 +1,32 @@
+{%extends "adm/admin_base.html" %}
+{%load humanize%}
+{%block title%}Refunds{%endblock%}
+{%block layoutblock %}
+<h1>Invoices</h1>
+
+<div class="row">
+<table class="table table-sm table-striped table-hover">
+<tr>
+ <th>Num</th>
+ <th>Invoice</th>
+ <th>Registered</th>
+ <th>Issued</th>
+ <th>Completed</th>
+ <th>Reason</th>
+</tr>
+{%for refund in refunds.object_list %}
+<tr>
+ <td>{{refund.id}}</td>
+ <td><a href="/invoiceadmin/{{refund.invoice_id}}/">#{{refund.invoice_id}}</a></td>
+ <td>{{refund.registered|default:""}}</td>
+ <td>{{refund.issued|default:""}}</td>
+ <td>{{refund.completed|default:""}}</td>
+ <td>{{refund.reason}}</td>
+{%endfor%}
+</table>
+
+{%include "adm/include/paginator.html" with pageobjects=refunds %}
+
+</div>{#row#}
+
+{%endblock%}