-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
87 lines (79 loc) · 2.38 KB
/
index.ts
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
import {
getCPAReturnCode,
getCPAReturnCodeCategoryByCode,
getCPAReturnCodesByAbbreviation,
isCPAReturnCode
} from './cpaCodes/returns.js'
import {
getCPATransactionCode,
getCPATransactionCodeCategoryByCode,
getCPATransactionCodesByAbbreviation,
isCPATransactionCode
} from './cpaCodes/transactions.js'
import type { CPACode, CPACodeCategory } from './types.js'
/**
* Retrieves the CPA code category object.
* @param cpaCode - A CPA code.
* @returns The CPA code category object, when available.
*/
export function getCPACodeCategoryByCode(
cpaCode: string
): CPACodeCategory | undefined {
return (
getCPATransactionCodeCategoryByCode(cpaCode) ??
getCPAReturnCodeCategoryByCode(cpaCode)
)
}
/**
* Tests if a CPA code is valid.
* @param cpaCode - A possible CPA code.
* @returns `true` when the CPA code is valid.
*/
export function isCPACode(cpaCode: string): boolean {
return isCPATransactionCode(cpaCode) || isCPAReturnCode(cpaCode)
}
/**
* Retrieves a CPA code object.
* @param cpaCode - A CPA code.
* @returns The CPA Code object, when available.
*/
export function getCPACode(cpaCode: string): CPACode | undefined {
return getCPATransactionCode(cpaCode) ?? getCPAReturnCode(cpaCode)
}
/**
* Retrieves a list of CPA code objects that correspond to a given abbreviation.
* @param cpaCodeAbbreviation - A two or three letter CPA code abbreviation.
* @returns A list of CPA code objects.
*/
export function getCPACodesByAbbreviation(
cpaCodeAbbreviation: string
): CPACode[] {
const cpaCodes = getCPATransactionCodesByAbbreviation(cpaCodeAbbreviation)
cpaCodes.push(...getCPAReturnCodesByAbbreviation(cpaCodeAbbreviation))
return cpaCodes
}
export {
cpaTransactionCodeCategories,
cpaTransactionCodes,
cpaTransactionCodesCommercial,
cpaTransactionCodesFederal,
cpaTransactionCodesPreauthorized,
cpaTransactionCodesProvincialLocal,
getCPATransactionCodeCategoryByCode,
getCPATransactionCode,
getCPATransactionCodesByAbbreviation,
isCPATransactionCode
} from './cpaCodes/transactions.js'
export {
cpaReturnCodeCategories,
cpaReturnCodes,
cpaReturnCodesCreditReturn,
cpaReturnCodesDishonoured,
cpaReturnCodesCustomerInitiated,
cpaReturnCodesDefault,
getCPAReturnCodeCategoryByCode,
getCPAReturnCode,
getCPAReturnCodesByAbbreviation,
isCPAReturnCode
} from './cpaCodes/returns.js'
export type { CPACodeCategory, CPACode } from './types.js'