-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
43 lines (43 loc) · 1.05 KB
/
index.js
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
import { formatToCPA005, validateCPA005 } from './formats/cpa005.js';
export class EFTGenerator {
#config;
#transactions;
constructor(config) {
this.#config = config;
this.#transactions = [];
}
getConfiguration() {
return this.#config;
}
addTransaction(transaction) {
this.#transactions.push(transaction);
}
addCreditTransaction(transactionSegment) {
this.addTransaction({
recordType: 'C',
segments: [transactionSegment]
});
}
addDebitTransaction(transactionSegment) {
this.addTransaction({
recordType: 'D',
segments: [transactionSegment]
});
}
getTransactions() {
return this.#transactions;
}
toCPA005() {
return formatToCPA005(this);
}
validateCPA005() {
try {
validateCPA005(this);
return true;
}
catch {
return false;
}
}
}
export { cpaTransactionCodes, isCPATransactionCode } from '@cityssm/cpa-codes';