Skip to content

Commit da29cd1

Browse files
authored
Update banks (#176)
1 parent 372a6a7 commit da29cd1

File tree

4 files changed

+79
-12
lines changed

4 files changed

+79
-12
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ release: test clean
5050
python setup.py sdist bdist_wheel
5151
twine upload dist/*
5252

53+
compare-banks:
54+
PYTHONPATH=. python scripts/compare_banks.py
5355

54-
.PHONY: all install-test test format lint clean release
56+
.PHONY: all install-test test format lint clean release compare-banks

clabe/banks.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
'140': '40140',
4141
'652': '90652',
4242
'688': '90688',
43-
'126': '40126',
4443
'680': '90680',
4544
'723': '90723',
4645
'722': '90722',
@@ -58,7 +57,6 @@
5857
'902': '90902',
5958
'150': '40150',
6059
'136': '40136',
61-
'686': '90686',
6260
'059': '40059',
6361
'110': '40110',
6462
'661': '90661',
@@ -70,7 +68,6 @@
7068
'600': '90600',
7169
'108': '40108',
7270
'132': '40132',
73-
'613': '90613',
7471
'135': '37135',
7572
'710': '90710',
7673
'684': '90684',
@@ -82,7 +79,6 @@
8279
'157': '40157',
8380
'728': '90728',
8481
'646': '90646',
85-
'648': '90648',
8682
'656': '90656',
8783
'617': '90617',
8884
'605': '90605',
@@ -91,6 +87,7 @@
9187
'113': '40113',
9288
'141': '40141',
9389
'715': '90715',
90+
'732': '90732',
9491
}
9592

9693

@@ -105,7 +102,7 @@
105102
'90659': 'Asp Integra Opc',
106103
'40128': 'Autofin',
107104
'40127': 'Azteca',
108-
'37166': 'Babien',
105+
'37166': 'BaBien',
109106
'40030': 'Bajio',
110107
'40002': 'Banamex',
111108
'40154': 'Banco Covalto',
@@ -130,7 +127,7 @@
130127
'90683': 'Caja Telefonist',
131128
'90715': 'Cartera Digital',
132129
'90630': 'CB Intercam',
133-
'40124': 'CBM Banco',
130+
'40124': 'Citi Mexico',
134131
'40143': 'CI Banco',
135132
'90631': 'CI Bolsa',
136133
'90901': 'Cls',
@@ -139,7 +136,6 @@
139136
'40140': 'Consubanco',
140137
'90652': 'Credicapital',
141138
'90688': 'Crediclub',
142-
'40126': 'Credit Suisse',
143139
'90680': 'Cristobal Colon',
144140
'90723': 'Cuenca',
145141
'40151': 'Donde',
@@ -156,7 +152,6 @@
156152
'90902': 'Indeval',
157153
'40150': 'Inmobiliario',
158154
'40136': 'Intercam Banco',
159-
'90686': 'Invercap',
160155
'40059': 'Invex',
161156
'40110': 'JP Morgan',
162157
'90661': 'KLAR',
@@ -169,19 +164,18 @@
169164
'90600': 'Monexcb',
170165
'40108': 'Mufg',
171166
'40132': 'Multiva Banco',
172-
'90613': 'Multiva Cbolsa',
173167
'37135': 'Nafin',
174168
'90638': 'NU MEXICO',
175169
'90710': 'NVIO',
176170
'40148': 'Pagatodo',
171+
'90732': 'Peibo',
177172
'90620': 'Profuturo',
178173
'40156': 'Sabadell',
179174
'40014': 'Santander',
180175
'40044': 'Scotiabank',
181176
'40157': 'Shinhan',
182177
'90728': 'Spin by OXXO',
183178
'90646': 'STP',
184-
'90648': 'Tactiv Cb',
185179
'90703': 'Tesored',
186180
'90684': 'Transfer',
187181
'90656': 'Unagra',

requirements-test.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ pytest-cov==4.1.0
33
black==22.8.0
44
isort==5.11.5
55
flake8==5.0.4
6-
mypy==1.4.1
6+
mypy==1.4.1
7+
requests==2.32.3

scripts/compare_banks.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from datetime import datetime
2+
3+
import requests
4+
from clabe.banks import BANK_NAMES
5+
6+
7+
def fetch_banxico_data():
8+
current_date = datetime.now().strftime('%d-%m-%Y')
9+
url = f'https://www.banxico.org.mx/cep/instituciones.do?fecha={current_date}'
10+
try:
11+
response = requests.get(url)
12+
response.raise_for_status()
13+
data = response.json()
14+
return dict(data.get('instituciones', []))
15+
except Exception as e:
16+
print(f'Error fetching data from Banxico: {e}')
17+
return {}
18+
19+
20+
def compare_bank_data():
21+
current_banks = dict(BANK_NAMES)
22+
banxico_banks = fetch_banxico_data()
23+
24+
differences = {'additions': {}, 'removals': {}, 'changes': {}}
25+
26+
print('Comparing bank data...\n')
27+
28+
# Check for additions (in Banxico but not in package)
29+
additions = {
30+
code: name for code, name in banxico_banks.items() if code not in current_banks
31+
}
32+
differences['additions'] = additions
33+
if additions:
34+
print('=== ADDITIONS (in Banxico but not in package) ===')
35+
for code, name in sorted(additions.items()):
36+
print(f' {code}: {name}')
37+
print()
38+
39+
# Check for removals (in package but not in Banxico)
40+
removals = {
41+
code: name for code, name in current_banks.items() if code not in banxico_banks
42+
}
43+
differences['removals'] = removals
44+
if removals:
45+
print('=== REMOVALS (in package but not in Banxico) ===')
46+
for code, name in sorted(removals.items()):
47+
print(f' {code}: {name}')
48+
print()
49+
50+
# Check for changes (different names for the same code)
51+
changes = {
52+
code: (current_banks[code], banxico_banks[code])
53+
for code in set(current_banks) & set(banxico_banks)
54+
if current_banks[code].upper() != banxico_banks[code].upper()
55+
}
56+
differences['changes'] = changes
57+
if changes:
58+
print('=== CHANGES (different names for the same code): Package -> Banxico ===')
59+
for code, (current_name, banxico_name) in sorted(changes.items()):
60+
print(f' {code}: {current_name} -> {banxico_name}')
61+
print()
62+
63+
if not additions and not removals and not changes:
64+
print('No differences found. The data is in sync.')
65+
66+
return differences
67+
68+
69+
if __name__ == '__main__':
70+
differences = compare_bank_data()

0 commit comments

Comments
 (0)