Implement BSB lookup
This commit is contained in:
parent
8d31fa1af6
commit
10f0cd4121
@ -38,6 +38,9 @@ ABA_BANK_CODE = 0
|
|||||||
ABA_SRC_BSB = '000-000'
|
ABA_SRC_BSB = '000-000'
|
||||||
ABA_SRC_ACC = '00000000'
|
ABA_SRC_ACC = '00000000'
|
||||||
|
|
||||||
|
# Download from http://bsb.apca.com.au/
|
||||||
|
BSB_FILE_PATH = 'sstreasury/BSBDirectoryMay20-290.csv'
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
@ -32,5 +32,6 @@ urlpatterns = [
|
|||||||
path('claims/edit/<int:id>', views.claim_edit, name='claim_edit'),
|
path('claims/edit/<int:id>', views.claim_edit, name='claim_edit'),
|
||||||
path('claims/action/<int:id>', views.claim_action, name='claim_action'),
|
path('claims/action/<int:id>', views.claim_action, name='claim_action'),
|
||||||
path('claims/processing', views.claim_processing, name='claim_processing'),
|
path('claims/processing', views.claim_processing, name='claim_processing'),
|
||||||
|
path('bsb_lookup', views.bsb_lookup, name='bsb_lookup'),
|
||||||
path('', views.index, name='treasury'),
|
path('', views.index, name='treasury'),
|
||||||
]
|
]
|
||||||
|
@ -22,7 +22,7 @@ from django.core.validators import validate_email
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Q
|
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.shortcuts import render, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -33,6 +33,7 @@ from . import models
|
|||||||
from . import xero
|
from . import xero
|
||||||
from ssmain.email import Emailer
|
from ssmain.email import Emailer
|
||||||
|
|
||||||
|
import csv
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import functools
|
import functools
|
||||||
import io
|
import io
|
||||||
@ -724,3 +725,18 @@ def claim_processing(request):
|
|||||||
return render(request, 'sstreasury/claim_processing.html', {
|
return render(request, 'sstreasury/claim_processing.html', {
|
||||||
'claims': claims
|
'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
|
||||||
|
Loading…
Reference in New Issue
Block a user