Skip to content

Commit

Permalink
consistency in institution keys
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Aug 13, 2024
1 parent 575172b commit 7ba57ad
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 150 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function formatBankNumber(unformattedNumber, numberLength) {
formattedNumber = formattedNumber.padStart(numberLength, '0');
return formattedNumber;
}
export default function getCanadianBankName(institutionNumber, transitNumber) {
export default function getCanadianBankName(institutionNumber, transitNumber = '00000') {
let bankName;
const institutionNumberString = formatBankNumber(institutionNumber, 3);
if (institutionNumberString === undefined) {
Expand All @@ -27,7 +27,7 @@ export default function getCanadianBankName(institutionNumber, transitNumber) {
bankName = institutions[`${transitNumberString}-${institutionNumberString}`];
}
if (bankName === undefined) {
bankName = institutions[institutionNumberString];
bankName = institutions[`00000-${institutionNumberString}`];
}
return bankName;
}
7 changes: 4 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ function formatBankNumber(
*/
export default function getCanadianBankName(
institutionNumber: string | number,
transitNumber?: string | number
transitNumber: string | number = '00000'
): string | undefined {
// eslint-disable-next-line @typescript-eslint/init-declarations
let bankName: string | undefined

const institutionNumberString = formatBankNumber(institutionNumber, 3)
Expand All @@ -52,12 +53,12 @@ export default function getCanadianBankName(
const transitNumberString = formatBankNumber(transitNumber ?? '', 5)

if (transitNumberString !== undefined) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
bankName = institutions[`${transitNumberString}-${institutionNumberString}`]
}

if (bankName === undefined) {
// eslint-disable-next-line security/detect-object-injection
bankName = institutions[institutionNumberString] as string
bankName = institutions[`00000-${institutionNumberString}`] as string
}

return bankName
Expand Down
3 changes: 2 additions & 1 deletion institutions.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export declare const institutions: Record<string, string>;
type InstitutionKey = `${number}-${number}`;
export declare const institutions: Record<InstitutionKey, string>;
export default institutions;
114 changes: 57 additions & 57 deletions institutions.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
export const institutions = {
'001': 'Bank of Montreal',
'002': 'Bank of Nova Scotia',
'003': 'Royal Bank of Canada',
'004': 'Toronto-Dominion Bank',
'006': 'Banque Nationale du Canada',
'010': 'Canadian Imperial Bank of Commerce',
'00000-001': 'Bank of Montreal',
'00000-002': 'Bank of Nova Scotia',
'00000-003': 'Royal Bank of Canada',
'00000-004': 'Toronto-Dominion Bank',
'00000-006': 'Banque Nationale du Canada',
'00000-010': 'Canadian Imperial Bank of Commerce',
'30800-010': 'Simplii Financial',
'016': 'HSBC Bank Canada',
'10930-016': 'Barclays Bank of Canada',
'030': 'Canadian Western Bank',
'039': 'Banque Laurentienne du Canada',
177: 'Bank of Canada',
241: 'Bank of America National Association',
242: 'Bank of New York Mellon',
248: 'Barclays Bank of Canada',
249: 'SBI Canada Bank',
250: 'BNP Paribas',
260: 'Citibank Canada',
265: 'Deutsche Bank AG',
270: 'JP Morgan Chase Bank, National Assoc.',
275: 'Keb Hana Bank Canada',
290: 'UBS Bank (Canada)',
303: 'AMEX Bank of Canada',
307: 'Industrial & Commercial Bank of China',
308: 'Bank of China (Canada)',
309: 'Vancity Community Investment Bank',
310: 'First Nations Bank of Canada',
314: 'JP Morgan Bank Canada',
315: 'CTBC Bank Corp. (Canada)',
320: "President's Choice Bank",
321: 'Habib Canadian Bank',
323: 'Capital One Bank (Canada Branch)',
326: "President's Choice Financial",
328: 'Citibank',
338: 'Canadian Tire Bank',
340: 'ICICI Bank Canada',
343: 'ADS Canadian Bank',
346: 'Societe Generale (Canada Branch)',
355: 'Shinhan Bank Canada',
362: 'Wells Fargo Bank NA Canadian Branch',
370: 'Wealth One Bank of Canada',
509: 'The Canada Trust Company',
540: 'Manulife Bank of Canada',
614: 'Tangerine Bank',
809: 'Central 1 Credit Union',
815: 'Federation des Caisses Desj. Quebec',
819: 'Caisse Financial Group',
828: 'Central 1 Credit Union',
'00000-016': 'HSBC Bank Canada',
'00000-030': 'Canadian Western Bank',
'00000-039': 'Banque Laurentienne du Canada',
'00000-177': 'Bank of Canada',
'00000-241': 'Bank of America National Association',
'00000-242': 'Bank of New York Mellon',
'00000-248': 'Barclays Bank of Canada',
'00000-249': 'SBI Canada Bank',
'00000-250': 'BNP Paribas',
'00000-260': 'Citibank Canada',
'00000-265': 'Deutsche Bank AG',
'00000-270': 'JP Morgan Chase Bank, National Assoc.',
'00000-275': 'Keb Hana Bank Canada',
'00000-290': 'UBS Bank (Canada)',
'00000-303': 'AMEX Bank of Canada',
'00000-307': 'Industrial & Commercial Bank of China',
'00000-308': 'Bank of China (Canada)',
'00000-309': 'Vancity Community Investment Bank',
'00000-310': 'First Nations Bank of Canada',
'00000-314': 'JP Morgan Bank Canada',
'00000-315': 'CTBC Bank Corp. (Canada)',
'00000-320': "President's Choice Bank",
'00000-321': 'Habib Canadian Bank',
'00000-323': 'Capital One Bank (Canada Branch)',
'00000-326': "President's Choice Financial",
'00000-328': 'Citibank',
'00000-330': 'Comerica Bank',
'00000-338': 'Canadian Tire Bank',
'00000-340': 'ICICI Bank Canada',
'00000-343': 'ADS Canadian Bank',
'00000-346': 'Societe Generale (Canada Branch)',
'00000-355': 'Shinhan Bank Canada',
'00000-362': 'Wells Fargo Bank NA Canadian Branch',
'00000-370': 'Wealth One Bank of Canada',
'00000-509': 'The Canada Trust Company',
'00000-540': 'Manulife Bank of Canada',
'00000-614': 'Tangerine Bank',
'00000-809': 'Central 1 Credit Union',
'00000-815': 'Federation des Caisses Desj. Quebec',
'00000-819': 'Caisse Financial Group',
'00000-828': 'Central 1 Credit Union',
'03832-828': 'Community First Credit Union',
'14492-828': 'Northern Credit Union',
'60172-828': 'Northern Credit Union',
'60182-828': 'Northern Credit Union',
'61842-828': 'Northern Credit Union',
829: "Fed. des Caisses Pop. de l'Ontario",
837: 'Meridian Credit Union Limited',
839: 'Credit Union Central of Nova Scotia',
849: 'Brunswick Cr. Union Federation Ltd.',
853: 'Concentra Bank',
865: 'Fed. des Caisses Pop. Acadiennes',
879: 'Credit Union Central of Manitoba',
889: 'Credit Union Central of Saskatchewan',
890: 'Caisse Populaire Alliance Limitee',
899: 'Central 1 Credit Union - Alberta'
'00000-829': "Fed. des Caisses Pop. de l'Ontario",
'00000-837': 'Meridian Credit Union Limited',
'00000-839': 'Credit Union Central of Nova Scotia',
'00000-849': 'Brunswick Cr. Union Federation Ltd.',
'00000-853': 'Concentra Bank',
'00000-865': 'Fed. des Caisses Pop. Acadiennes',
'00000-879': 'Credit Union Central of Manitoba',
'00000-889': 'Credit Union Central of Saskatchewan',
'00000-890': 'Caisse Populaire Alliance Limitee',
'00000-899': 'Central 1 Credit Union - Alberta'
};
export default institutions;
128 changes: 65 additions & 63 deletions institutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,91 @@
* Institutions File
* -----------------
*
* All bank name records should have keys formatted in one of two ways.
* - The three-digit institution number.
* - The five-digit transit number, a dash, the three-digit institution number.
* All bank name records should have keys formatted as
* a five-digit transit number, a dash, and a three-digit institution number.
*
* Transit numbers should only be added when the bank name changes
* based on the transit number, as is the case with many credit unions.
* The main bank record should use '00000' as the transit number.
* Additional transit numbers should only be added when the bank name changes
* as is the case with many credit unions.
*/

export const institutions: Record<string, string> = {
'001': 'Bank of Montreal',
'002': 'Bank of Nova Scotia',
'003': 'Royal Bank of Canada',
'004': 'Toronto-Dominion Bank',
'006': 'Banque Nationale du Canada',
type InstitutionKey = `${number}-${number}`

'010': 'Canadian Imperial Bank of Commerce',
export const institutions: Record<InstitutionKey, string> = {
'00000-001': 'Bank of Montreal',
'00000-002': 'Bank of Nova Scotia',
'00000-003': 'Royal Bank of Canada',
'00000-004': 'Toronto-Dominion Bank',
'00000-006': 'Banque Nationale du Canada',

'00000-010': 'Canadian Imperial Bank of Commerce',
'30800-010': 'Simplii Financial',

'016': 'HSBC Bank Canada',
'10930-016': 'Barclays Bank of Canada',
'00000-016': 'HSBC Bank Canada',

'030': 'Canadian Western Bank',
'039': 'Banque Laurentienne du Canada',
'00000-030': 'Canadian Western Bank',
'00000-039': 'Banque Laurentienne du Canada',

177: 'Bank of Canada',
'00000-177': 'Bank of Canada',

241: 'Bank of America National Association',
242: 'Bank of New York Mellon',
248: 'Barclays Bank of Canada',
249: 'SBI Canada Bank',
250: 'BNP Paribas',
260: 'Citibank Canada',
265: 'Deutsche Bank AG',
270: 'JP Morgan Chase Bank, National Assoc.',
275: 'Keb Hana Bank Canada',
290: 'UBS Bank (Canada)',
'00000-241': 'Bank of America National Association',
'00000-242': 'Bank of New York Mellon',
'00000-248': 'Barclays Bank of Canada',
'00000-249': 'SBI Canada Bank',
'00000-250': 'BNP Paribas',
'00000-260': 'Citibank Canada',
'00000-265': 'Deutsche Bank AG',
'00000-270': 'JP Morgan Chase Bank, National Assoc.',
'00000-275': 'Keb Hana Bank Canada',
'00000-290': 'UBS Bank (Canada)',

303: 'AMEX Bank of Canada',
307: 'Industrial & Commercial Bank of China',
308: 'Bank of China (Canada)',
309: 'Vancity Community Investment Bank',
310: 'First Nations Bank of Canada',
314: 'JP Morgan Bank Canada',
315: 'CTBC Bank Corp. (Canada)',
320: "President's Choice Bank",
321: 'Habib Canadian Bank',
323: 'Capital One Bank (Canada Branch)',
326: "President's Choice Financial",
328: 'Citibank',
338: 'Canadian Tire Bank',
340: 'ICICI Bank Canada',
343: 'ADS Canadian Bank',
346: 'Societe Generale (Canada Branch)',
355: 'Shinhan Bank Canada',
362: 'Wells Fargo Bank NA Canadian Branch',
370: 'Wealth One Bank of Canada',
'00000-303': 'AMEX Bank of Canada',
'00000-307': 'Industrial & Commercial Bank of China',
'00000-308': 'Bank of China (Canada)',
'00000-309': 'Vancity Community Investment Bank',
'00000-310': 'First Nations Bank of Canada',
'00000-314': 'JP Morgan Bank Canada',
'00000-315': 'CTBC Bank Corp. (Canada)',
'00000-320': "President's Choice Bank",
'00000-321': 'Habib Canadian Bank',
'00000-323': 'Capital One Bank (Canada Branch)',
'00000-326': "President's Choice Financial",
'00000-328': 'Citibank',
'00000-330': 'Comerica Bank',
'00000-338': 'Canadian Tire Bank',
'00000-340': 'ICICI Bank Canada',
'00000-343': 'ADS Canadian Bank',
'00000-346': 'Societe Generale (Canada Branch)',
'00000-355': 'Shinhan Bank Canada',
'00000-362': 'Wells Fargo Bank NA Canadian Branch',
'00000-370': 'Wealth One Bank of Canada',

509: 'The Canada Trust Company',
540: 'Manulife Bank of Canada',
'00000-509': 'The Canada Trust Company',
'00000-540': 'Manulife Bank of Canada',

614: 'Tangerine Bank',
'00000-614': 'Tangerine Bank',

809: 'Central 1 Credit Union',
815: 'Federation des Caisses Desj. Quebec',
819: 'Caisse Financial Group',
'00000-809': 'Central 1 Credit Union',
'00000-815': 'Federation des Caisses Desj. Quebec',
'00000-819': 'Caisse Financial Group',

828: 'Central 1 Credit Union',
'00000-828': 'Central 1 Credit Union',
'03832-828': 'Community First Credit Union',
'14492-828': 'Northern Credit Union',
'60172-828': 'Northern Credit Union',
'60182-828': 'Northern Credit Union',
'61842-828': 'Northern Credit Union',

829: "Fed. des Caisses Pop. de l'Ontario",
837: 'Meridian Credit Union Limited',
839: 'Credit Union Central of Nova Scotia',
849: 'Brunswick Cr. Union Federation Ltd.',
853: 'Concentra Bank',
865: 'Fed. des Caisses Pop. Acadiennes',
879: 'Credit Union Central of Manitoba',
889: 'Credit Union Central of Saskatchewan',
890: 'Caisse Populaire Alliance Limitee',
899: 'Central 1 Credit Union - Alberta'
'00000-829': "Fed. des Caisses Pop. de l'Ontario",
'00000-837': 'Meridian Credit Union Limited',
'00000-839': 'Credit Union Central of Nova Scotia',
'00000-849': 'Brunswick Cr. Union Federation Ltd.',
'00000-853': 'Concentra Bank',
'00000-865': 'Fed. des Caisses Pop. Acadiennes',
'00000-879': 'Credit Union Central of Manitoba',
'00000-889': 'Credit Union Central of Saskatchewan',
'00000-890': 'Caisse Populaire Alliance Limitee',
'00000-899': 'Central 1 Credit Union - Alberta'
}

export default institutions
Loading

0 comments on commit 7ba57ad

Please sign in to comment.