-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStandardBankReader.py
92 lines (74 loc) · 2.87 KB
/
StandardBankReader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import PyPDF2
import hashlib
STANDARD_FIRST_NAME_POSITION = 128
OFFSET = 0
def getCustomerName(page_content):
global OFFSET
customerName = page_content[STANDARD_FIRST_NAME_POSITION]
for word in page_content[STANDARD_FIRST_NAME_POSITION+1:]:
if word == "Reference":
break
else:
OFFSET += 1
customerName = customerName + " " + word
return customerName
def getRecipientName(page_content):
global OFFSET
recipientNamePosition = STANDARD_FIRST_NAME_POSITION+OFFSET+5
recipientName = page_content[recipientNamePosition]
for word in page_content[recipientNamePosition+1:]:
if word != "Bank":
OFFSET += 1
recipientName = recipientName + " " + word
else:
break
return recipientName
def getRecipientBankName(page_content):
global OFFSET
OFFSET += 1
recipientBankNamePosition = STANDARD_FIRST_NAME_POSITION+OFFSET+7
recipientBankName = page_content[recipientBankNamePosition]
for word in page_content[recipientBankNamePosition+1:]:
if word != "Bene®ciary":
OFFSET += 1
recipientBankName = recipientBankName + " " + word
else:
break
return recipientBankName
def getRecipientAccountNumber(page_content):
global OFFSET
accountNumberPosition = STANDARD_FIRST_NAME_POSITION + OFFSET + 11
accountNumber = page_content[accountNumberPosition]
return accountNumber
def getRecipientBranchNumber(page_content):
global OFFSET
branchNumberPosition = STANDARD_FIRST_NAME_POSITION + OFFSET + 15
branchNumber = page_content[branchNumberPosition]
return branchNumber
def getReference(page_content):
global OFFSET
referencePosition = STANDARD_FIRST_NAME_POSITION + OFFSET + 18
referenceNumber = page_content[referencePosition]
return referenceNumber
def getAmount(page_content):
global OFFSET
amountPosition = STANDARD_FIRST_NAME_POSITION + OFFSET + 20
amountText = page_content[amountPosition]
return amountText
def getPaymentDate(page_content):
global OFFSET
datePosition = STANDARD_FIRST_NAME_POSITION + OFFSET + 25
day = page_content[datePosition]
time = page_content[datePosition + 1]
return [day, time]
def getNotificationDetails(page_content):
OFFSET = 1
customerName = getCustomerName(page_content)
recipientName = getRecipientName(page_content)
recipientBankName = getRecipientBankName(page_content)
recipientAccountNumber = getRecipientAccountNumber(page_content)
recipientBranchNumber = getRecipientBranchNumber(page_content)
referenceNumber = getReference(page_content)
paymentAmount = getAmount(page_content)
paymentDate = getPaymentDate(page_content)
return [customerName, recipientName, recipientBankName, recipientAccountNumber, recipientBranchNumber, referenceNumber, paymentAmount, paymentDate]