summaryrefslogtreecommitdiff
path: root/sstreasury/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'sstreasury/views.py')
-rw-r--r--sstreasury/views.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/sstreasury/views.py b/sstreasury/views.py
index 589d719..d3b1d7c 100644
--- a/sstreasury/views.py
+++ b/sstreasury/views.py
@@ -22,7 +22,7 @@ from django.core.validators import validate_email
from django.conf import settings
from django.db import transaction
from django.db.models import Q
-from django.http import HttpResponse
+from django.http import HttpResponse, JsonResponse
from django.shortcuts import render, redirect
from django.urls import reverse
from django.utils import timezone
@@ -33,6 +33,7 @@ from . import models
from . import xero
from ssmain.email import Emailer
+import csv
from datetime import datetime
import functools
import io
@@ -724,3 +725,18 @@ def claim_processing(request):
return render(request, 'sstreasury/claim_processing.html', {
'claims': claims
})
+
+@login_required
+def bsb_lookup(request):
+ bsb = request.GET.get('bsb', '').replace('-', '').replace(' ', '')
+ if len(bsb) != 6:
+ return JsonResponse({'result': None})
+ return JsonResponse({'result': do_bsb_lookup(bsb[:3] + '-' + bsb[-3:])})
+
+def do_bsb_lookup(bsb):
+ with open(settings.BSB_FILE_PATH, 'r', newline='') as f:
+ reader = csv.reader(f)
+ for line in reader:
+ if line[0] == bsb:
+ return '{} - {}'.format(line[1], line[2])
+ return None
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.