@develit-services/bank 0.0.28 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/schema.cjs +10 -1
- package/dist/database/schema.d.cts +1 -1
- package/dist/database/schema.d.mts +1 -1
- package/dist/database/schema.d.ts +1 -1
- package/dist/database/schema.mjs +8 -1
- package/dist/export/worker.cjs +888 -575
- package/dist/export/worker.d.cts +210 -12
- package/dist/export/worker.d.mts +210 -12
- package/dist/export/worker.d.ts +210 -12
- package/dist/export/worker.mjs +859 -546
- package/dist/export/wrangler.cjs +1 -11
- package/dist/export/wrangler.d.cts +8 -9
- package/dist/export/wrangler.d.mts +8 -9
- package/dist/export/wrangler.d.ts +8 -9
- package/dist/export/wrangler.mjs +1 -11
- package/dist/shared/{bank.Cy_TcyKb.cjs → bank.BMRBXGF1.cjs} +347 -106
- package/dist/shared/{bank.CEZKAEiY.d.cts → bank.BchnXQDL.d.cts} +2 -2
- package/dist/shared/{bank.CEZKAEiY.d.mts → bank.BchnXQDL.d.mts} +2 -2
- package/dist/shared/{bank.CEZKAEiY.d.ts → bank.BchnXQDL.d.ts} +2 -2
- package/dist/shared/bank.CtUeOz8i.d.ts +1648 -0
- package/dist/shared/bank.D8o86NLF.d.mts +1648 -0
- package/dist/shared/bank.DUalSuEK.d.cts +1648 -0
- package/dist/shared/bank.DbNuuGvb.mjs +9 -0
- package/dist/shared/bank.DuY4d2y_.cjs +11 -0
- package/dist/shared/{bank.BuNG2S8h.d.cts → bank.Nf6oaNfB.d.cts} +547 -11
- package/dist/shared/{bank.BuNG2S8h.d.mts → bank.Nf6oaNfB.d.mts} +547 -11
- package/dist/shared/{bank.BuNG2S8h.d.ts → bank.Nf6oaNfB.d.ts} +547 -11
- package/dist/shared/{bank.DnDcNEvX.mjs → bank.YCUhOduX.mjs} +330 -107
- package/dist/types.cjs +32 -20
- package/dist/types.d.cts +496 -35
- package/dist/types.d.mts +496 -35
- package/dist/types.d.ts +496 -35
- package/dist/types.mjs +5 -4
- package/package.json +1 -1
- package/dist/shared/bank.BkLncGmL.d.ts +0 -122
- package/dist/shared/bank.C9jAvwna.mjs +0 -90
- package/dist/shared/bank.DWVLVMDa.d.mts +0 -122
- package/dist/shared/bank.DmypH3Au.d.cts +0 -122
- package/dist/shared/bank.P9gDUycr.cjs +0 -98
package/dist/export/worker.cjs
CHANGED
|
@@ -3,100 +3,57 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
|
-
const
|
|
6
|
+
const database_schema = require('../shared/bank.BMRBXGF1.cjs');
|
|
7
7
|
const cloudflare_workers = require('cloudflare:workers');
|
|
8
8
|
const d1 = require('drizzle-orm/d1');
|
|
9
9
|
const zod = require('zod');
|
|
10
10
|
const generalCodes = require('@develit-io/general-codes');
|
|
11
|
-
const database_schema = require('../shared/bank.P9gDUycr.cjs');
|
|
12
11
|
require('jose');
|
|
13
12
|
const drizzleOrm = require('drizzle-orm');
|
|
13
|
+
const mockCobs_connector = require('../shared/bank.DuY4d2y_.cjs');
|
|
14
14
|
const superjson = require('superjson');
|
|
15
|
-
require('
|
|
15
|
+
require('drizzle-zod');
|
|
16
16
|
require('drizzle-orm/sqlite-core');
|
|
17
|
+
require('date-fns');
|
|
17
18
|
require('drizzle-orm/relations');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
20
21
|
|
|
21
22
|
const superjson__default = /*#__PURE__*/_interopDefaultCompat(superjson);
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
debtorAccountNumberWithBankCode: zod.z.string(),
|
|
37
|
-
debtorIban: zod.z.string()
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const getAuthUriInputSchema = zod.z.object({
|
|
41
|
-
accountId: zod.z.string()
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const authorizeAccountInputSchema = zod.z.object({
|
|
45
|
-
ott: zod.z.string(),
|
|
46
|
-
urlParams: zod.z.string()
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const simulateDepositInputSchema = zod.z.object({
|
|
50
|
-
amount: zod.z.number(),
|
|
51
|
-
currency: zod.z.enum(generalCodes.CURRENCY_CODES),
|
|
52
|
-
bankingVs: zod.z.string().max(10),
|
|
53
|
-
bankingSs: zod.z.string().max(10).optional(),
|
|
54
|
-
bankingKs: zod.z.string().max(10).optional(),
|
|
55
|
-
message: zod.z.string(),
|
|
56
|
-
creditorIban: zod.z.string().max(34),
|
|
57
|
-
creditorHolderName: zod.z.string(),
|
|
58
|
-
debtorIban: zod.z.string().max(34),
|
|
59
|
-
debtorHolderName: zod.z.string()
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const setLastSyncAtInputSchema = zod.z.object({
|
|
63
|
-
iban: zod.z.string(),
|
|
64
|
-
lastSyncedAt: zod.z.coerce.date()
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const initiateConnectorInputSchema = zod.z.object({
|
|
68
|
-
connectorKey: zod.z.enum(database_schema.CONNECTOR_KEYS)
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const getBatchesInputSchema = zod.z.object({
|
|
72
|
-
limit: zod.z.number().positive().optional().default(100),
|
|
73
|
-
offset: zod.z.number().min(0).optional().default(0)
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const processBatchInputSchema = zod.z.object({
|
|
77
|
-
connectorKey: zod.z.enum(database_schema.CONNECTOR_KEYS),
|
|
78
|
-
batch: zod.z.custom()
|
|
79
|
-
});
|
|
24
|
+
const upsertAccountCommand = (db, { account }) => {
|
|
25
|
+
const id = account.id || backendSdk.uuidv4();
|
|
26
|
+
const command = db.insert(database_schema.tables.account).values({ ...account, id }).onConflictDoUpdate({
|
|
27
|
+
target: database_schema.tables.account.iban,
|
|
28
|
+
set: {
|
|
29
|
+
...account
|
|
30
|
+
}
|
|
31
|
+
}).returning();
|
|
32
|
+
return {
|
|
33
|
+
id,
|
|
34
|
+
command
|
|
35
|
+
};
|
|
36
|
+
};
|
|
80
37
|
|
|
81
|
-
const createPaymentCommand = (db
|
|
38
|
+
const createPaymentCommand = (db, { payment }) => {
|
|
82
39
|
return {
|
|
83
|
-
command: db
|
|
40
|
+
command: db.insert(database_schema.tables.payment).values(payment).returning()
|
|
84
41
|
};
|
|
85
42
|
};
|
|
86
43
|
|
|
87
|
-
const updatePaymentCommand = (db
|
|
44
|
+
const updatePaymentCommand = (db, { payment }) => {
|
|
88
45
|
return {
|
|
89
|
-
command: db
|
|
46
|
+
command: db.update(database_schema.tables.payment).set(payment).where(drizzleOrm.eq(database_schema.tables.payment.id, payment.id)).returning()
|
|
90
47
|
};
|
|
91
48
|
};
|
|
92
49
|
|
|
93
|
-
const upsertBatchCommand = (db
|
|
50
|
+
const upsertBatchCommand = (db, { batch }) => {
|
|
94
51
|
const id = batch.id || backendSdk.uuidv4();
|
|
95
|
-
const command = db
|
|
52
|
+
const command = db.insert(database_schema.tables.batch).values({
|
|
96
53
|
...batch,
|
|
97
54
|
id
|
|
98
55
|
}).onConflictDoUpdate({
|
|
99
|
-
target:
|
|
56
|
+
target: database_schema.tables.batch.id,
|
|
100
57
|
set: {
|
|
101
58
|
...batch
|
|
102
59
|
}
|
|
@@ -107,112 +64,237 @@ const upsertBatchCommand = (db$1, { batch }) => {
|
|
|
107
64
|
};
|
|
108
65
|
};
|
|
109
66
|
|
|
110
|
-
const createOneTimeTokenCommand = (db
|
|
67
|
+
const createOneTimeTokenCommand = (db, {
|
|
111
68
|
ott,
|
|
112
|
-
|
|
69
|
+
refId,
|
|
113
70
|
tokenType
|
|
114
71
|
}) => {
|
|
115
72
|
const id = backendSdk.uuidv4();
|
|
116
73
|
const expiresAt = new Date(Date.now() + 1e3 * 60 * 60) ;
|
|
117
|
-
const command = db
|
|
74
|
+
const command = db.insert(database_schema.tables.ott).values({
|
|
118
75
|
id,
|
|
119
76
|
oneTimeToken: ott,
|
|
120
77
|
tokenType,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
expiresAt
|
|
78
|
+
expiresAt,
|
|
79
|
+
refId
|
|
124
80
|
}).returning();
|
|
125
81
|
return { id, command };
|
|
126
82
|
};
|
|
127
83
|
|
|
128
|
-
const
|
|
129
|
-
|
|
84
|
+
const expireOneTimeTokenCommand = (db, {
|
|
85
|
+
ott
|
|
86
|
+
}) => {
|
|
87
|
+
return {
|
|
88
|
+
command: db.update(database_schema.tables.ott).set({
|
|
89
|
+
expiresAt: /* @__PURE__ */ new Date()
|
|
90
|
+
}).where(drizzleOrm.eq(database_schema.tables.ott.oneTimeToken, ott))
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const createAccountCredentialsCommand = (db, { credentials }) => {
|
|
95
|
+
const id = credentials.id || backendSdk.uuidv4();
|
|
96
|
+
const command = db.insert(database_schema.tables.accountCredentials).values({ ...credentials, id }).returning();
|
|
97
|
+
return {
|
|
98
|
+
id,
|
|
99
|
+
command
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const deleteAccountCredentialsCommand = (db, { accountId }) => {
|
|
104
|
+
const command = db.delete(database_schema.tables.accountCredentials).where(drizzleOrm.eq(database_schema.tables.accountCredentials.accountId, accountId));
|
|
105
|
+
return {
|
|
106
|
+
command
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const getPaymentByRefIdQuery = async (db, { refId }) => {
|
|
111
|
+
const payment = await db.select().from(database_schema.tables.payment).where(drizzleOrm.eq(database_schema.tables.payment.refId, refId)).limit(1).get();
|
|
130
112
|
return payment;
|
|
131
113
|
};
|
|
132
114
|
|
|
133
|
-
const getOpenBatchByAccountIdQuery = async (db
|
|
134
|
-
const batch = await db
|
|
115
|
+
const getOpenBatchByAccountIdQuery = async (db, { accountId }) => {
|
|
116
|
+
const batch = await db.select().from(database_schema.tables.batch).where(
|
|
135
117
|
drizzleOrm.and(
|
|
136
|
-
drizzleOrm.eq(
|
|
137
|
-
drizzleOrm.eq(
|
|
118
|
+
drizzleOrm.eq(database_schema.tables.batch.accountId, accountId),
|
|
119
|
+
drizzleOrm.eq(database_schema.tables.batch.status, "OPEN")
|
|
138
120
|
)
|
|
139
121
|
).limit(1).get();
|
|
140
122
|
return batch;
|
|
141
123
|
};
|
|
142
124
|
|
|
143
|
-
const getPaymentsByBankRefIdsQuery = async (db
|
|
144
|
-
return await db
|
|
125
|
+
const getPaymentsByBankRefIdsQuery = async (db, { ids }) => {
|
|
126
|
+
return await db.select().from(database_schema.tables.payment).where(drizzleOrm.inArray(database_schema.tables.payment.bankRefId, ids));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const getOttQuery = async (db, { ott }) => {
|
|
130
|
+
return await db.select().from(database_schema.tables.ott).where(drizzleOrm.eq(database_schema.tables.ott.oneTimeToken, ott)).get();
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const getAllPendingBatchesQuery = (db) => {
|
|
134
|
+
return db.select().from(database_schema.tables.batch).where(
|
|
135
|
+
drizzleOrm.inArray(database_schema.tables.batch.status, [
|
|
136
|
+
"PROCESSING",
|
|
137
|
+
"READY_TO_SIGN",
|
|
138
|
+
"WAITING_FOR_PROCESSING"
|
|
139
|
+
])
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const getCredentialsByAccountId = async (db, { accountId }) => {
|
|
144
|
+
const cred = await db.select().from(database_schema.tables.accountCredentials).where(drizzleOrm.eq(database_schema.tables.accountCredentials.accountId, accountId)).get();
|
|
145
|
+
return cred;
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
const
|
|
148
|
-
return await db
|
|
148
|
+
const getAccountByIbanQuery = async (db, { iban }) => {
|
|
149
|
+
return await db.select().from(database_schema.tables.account).where(drizzleOrm.eq(database_schema.tables.account.iban, iban)).get();
|
|
149
150
|
};
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
const getAllAccountsQuery = async (db) => {
|
|
153
|
+
const accountsWithExpiration = await db.select().from(database_schema.tables.account).leftJoin(
|
|
154
|
+
database_schema.tables.accountCredentials,
|
|
155
|
+
drizzleOrm.eq(database_schema.tables.accountCredentials.accountId, database_schema.tables.account.id)
|
|
156
|
+
);
|
|
157
|
+
return accountsWithExpiration.map(({ account, account_credentials }) => {
|
|
158
|
+
return {
|
|
159
|
+
...account,
|
|
160
|
+
expiresAt: account_credentials?.expiresAt
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const buildMultiFilterConditions = (column, value) => {
|
|
166
|
+
if (value === void 0) return void 0;
|
|
167
|
+
if (Array.isArray(value)) {
|
|
168
|
+
return value.length > 0 ? drizzleOrm.inArray(column, value) : void 0;
|
|
169
|
+
}
|
|
170
|
+
return drizzleOrm.eq(column, value);
|
|
171
|
+
};
|
|
172
|
+
const buildRangeFilterConditions = (column, minValue, maxValue) => {
|
|
173
|
+
const conditions = [];
|
|
174
|
+
if (minValue !== void 0) {
|
|
175
|
+
conditions.push(drizzleOrm.gte(column, minValue));
|
|
176
|
+
}
|
|
177
|
+
if (maxValue !== void 0) {
|
|
178
|
+
conditions.push(drizzleOrm.lte(column, maxValue));
|
|
179
|
+
}
|
|
180
|
+
if (conditions.length === 0) return void 0;
|
|
181
|
+
if (conditions.length === 1) return conditions[0];
|
|
182
|
+
return drizzleOrm.and(...conditions);
|
|
183
|
+
};
|
|
184
|
+
const resolveColumn = (table, column, fallback = "updatedAt") => {
|
|
185
|
+
const key = column && column in table ? column : fallback;
|
|
186
|
+
return table[key];
|
|
187
|
+
};
|
|
188
|
+
const getPaymentsWithPaginationQuery = async (db, {
|
|
189
|
+
limit,
|
|
190
|
+
page,
|
|
191
|
+
sort,
|
|
192
|
+
filterPaymentAccountId,
|
|
193
|
+
filterPaymentAmount,
|
|
194
|
+
filterPaymentCurrency,
|
|
195
|
+
filterPaymentDateFrom,
|
|
196
|
+
filterPaymentDateTo,
|
|
197
|
+
filterPaymentStatus,
|
|
198
|
+
filterPaymentyDirection
|
|
199
|
+
}) => {
|
|
200
|
+
const whereConditions = drizzleOrm.and(
|
|
201
|
+
buildMultiFilterConditions(
|
|
202
|
+
database_schema.tables.payment.accountId,
|
|
203
|
+
filterPaymentAccountId
|
|
204
|
+
),
|
|
205
|
+
buildMultiFilterConditions(database_schema.tables.payment.amount, filterPaymentAmount),
|
|
206
|
+
buildMultiFilterConditions(database_schema.tables.payment.currency, filterPaymentCurrency),
|
|
207
|
+
buildRangeFilterConditions(
|
|
208
|
+
database_schema.tables.payment.createdAt,
|
|
209
|
+
filterPaymentDateFrom,
|
|
210
|
+
filterPaymentDateTo
|
|
211
|
+
),
|
|
212
|
+
buildMultiFilterConditions(database_schema.tables.payment.status, filterPaymentStatus),
|
|
213
|
+
buildMultiFilterConditions(
|
|
214
|
+
database_schema.tables.payment.direction,
|
|
215
|
+
filterPaymentyDirection
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
const sortColumn = resolveColumn(database_schema.tables.payment, sort.column);
|
|
219
|
+
const [{ totalCount }] = await db.select({
|
|
220
|
+
totalCount: drizzleOrm.sql`count(*)`
|
|
221
|
+
}).from(database_schema.tables.payment).where(whereConditions);
|
|
222
|
+
const payments = await db.select().from(database_schema.tables.payment).where(whereConditions).limit(limit).offset((page - 1) * limit).orderBy(sort.direction === "asc" ? drizzleOrm.asc(sortColumn) : drizzleOrm.desc(sortColumn));
|
|
223
|
+
return {
|
|
224
|
+
payments,
|
|
225
|
+
totalCount
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
class CreditasConnector extends database_schema.FinbricksConnector {
|
|
152
230
|
constructor(config) {
|
|
153
231
|
super("CREDITAS", config);
|
|
154
232
|
}
|
|
155
233
|
}
|
|
156
234
|
|
|
157
|
-
class FioConnector extends
|
|
235
|
+
class FioConnector extends database_schema.FinbricksConnector {
|
|
158
236
|
constructor(config) {
|
|
159
237
|
super("FIO", config);
|
|
160
238
|
}
|
|
161
239
|
}
|
|
162
240
|
|
|
163
|
-
class MonetaConnector extends
|
|
241
|
+
class MonetaConnector extends database_schema.FinbricksConnector {
|
|
164
242
|
constructor(config) {
|
|
165
243
|
super("MONETA", config);
|
|
166
244
|
}
|
|
167
245
|
}
|
|
168
246
|
|
|
169
|
-
const initiateConnector = (
|
|
247
|
+
const initiateConnector = ({
|
|
248
|
+
bank,
|
|
249
|
+
env,
|
|
250
|
+
connectedAccounts
|
|
251
|
+
}) => {
|
|
170
252
|
switch (bank) {
|
|
171
253
|
case "ERSTE":
|
|
172
|
-
return new
|
|
254
|
+
return new database_schema.ErsteConnector({
|
|
173
255
|
API_KEY: env.ERSTE_API_KEY,
|
|
174
256
|
CLIENT_ID: env.ERSTE_CLIENT_ID,
|
|
175
257
|
CLIENT_SECRET: env.ERSTE_CLIENT_SECRET,
|
|
176
|
-
REDIRECT_URI: env.
|
|
258
|
+
REDIRECT_URI: env.REDIRECT_URI,
|
|
177
259
|
AUTH_URI: env.ERSTE_AUTH_URI,
|
|
178
260
|
PAYMENTS_URI: env.ERSTE_PAYMENTS_URI,
|
|
179
261
|
ACCOUNTS_URI: env.ERSTE_ACCOUNTS_URI,
|
|
180
|
-
|
|
262
|
+
connectedAccounts
|
|
181
263
|
});
|
|
182
264
|
case "CREDITAS":
|
|
183
265
|
return new CreditasConnector({
|
|
184
266
|
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
185
267
|
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
186
268
|
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
187
|
-
REDIRECT_URI: env.
|
|
188
|
-
|
|
269
|
+
REDIRECT_URI: env.REDIRECT_URI,
|
|
270
|
+
connectedAccounts
|
|
189
271
|
});
|
|
190
272
|
case "MOCK_COBS":
|
|
191
|
-
return new
|
|
273
|
+
return new mockCobs_connector.MockCobsConnector({
|
|
192
274
|
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
193
275
|
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
194
276
|
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
195
|
-
REDIRECT_URI: env.
|
|
196
|
-
|
|
277
|
+
REDIRECT_URI: env.REDIRECT_URI,
|
|
278
|
+
connectedAccounts
|
|
197
279
|
});
|
|
198
280
|
case "FIO":
|
|
199
281
|
return new FioConnector({
|
|
200
282
|
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
201
283
|
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
202
284
|
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
203
|
-
REDIRECT_URI: env.
|
|
204
|
-
|
|
285
|
+
REDIRECT_URI: env.REDIRECT_URI,
|
|
286
|
+
connectedAccounts
|
|
205
287
|
});
|
|
206
288
|
case "MONETA":
|
|
207
289
|
return new MonetaConnector({
|
|
208
290
|
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
209
291
|
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
210
292
|
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
211
|
-
REDIRECT_URI: env.
|
|
212
|
-
|
|
293
|
+
REDIRECT_URI: env.REDIRECT_URI,
|
|
294
|
+
connectedAccounts
|
|
213
295
|
});
|
|
214
296
|
default:
|
|
215
|
-
return new
|
|
297
|
+
return new database_schema.MockConnector();
|
|
216
298
|
}
|
|
217
299
|
};
|
|
218
300
|
|
|
@@ -221,7 +303,7 @@ const useSync = (kv) => {
|
|
|
221
303
|
account
|
|
222
304
|
}) => {
|
|
223
305
|
const [rawSync, rawSyncError] = await backendSdk.useResult(
|
|
224
|
-
kv.get(`sync-log:${account.
|
|
306
|
+
kv.get(`sync-log:${account.iban}:${account.currency}`)
|
|
225
307
|
);
|
|
226
308
|
if (rawSyncError) throw backendSdk.createInternalError(rawSyncError);
|
|
227
309
|
if (!rawSync) return null;
|
|
@@ -233,7 +315,7 @@ const useSync = (kv) => {
|
|
|
233
315
|
}) => {
|
|
234
316
|
const [_, error] = await backendSdk.useResult(
|
|
235
317
|
kv.put(
|
|
236
|
-
`sync-log:${account.
|
|
318
|
+
`sync-log:${account.iban}:${account.currency}`,
|
|
237
319
|
superjson__default.stringify(log)
|
|
238
320
|
)
|
|
239
321
|
);
|
|
@@ -249,7 +331,7 @@ const seperateSupportedPayments = (mappedPayments, accounts) => {
|
|
|
249
331
|
const [supportedPayments, unsupportedPayments] = mappedPayments.reduce(
|
|
250
332
|
([valid, invalid], payment) => {
|
|
251
333
|
const isValid = accounts.some(
|
|
252
|
-
(acc) => acc.
|
|
334
|
+
(acc) => acc.iban === payment.debtorIban && acc.currency === payment.currency
|
|
253
335
|
);
|
|
254
336
|
if (isValid) {
|
|
255
337
|
valid.push(payment);
|
|
@@ -266,6 +348,91 @@ const seperateSupportedPayments = (mappedPayments, accounts) => {
|
|
|
266
348
|
};
|
|
267
349
|
};
|
|
268
350
|
|
|
351
|
+
const sendPaymentInputSchema = zod.z.object({
|
|
352
|
+
refId: zod.z.string(),
|
|
353
|
+
amount: zod.z.number().positive(),
|
|
354
|
+
paymentType: zod.z.enum(database_schema.PAYMENT_TYPES),
|
|
355
|
+
currency: zod.z.enum(generalCodes.CURRENCY_CODES),
|
|
356
|
+
vs: zod.z.string().nullable().optional(),
|
|
357
|
+
ss: zod.z.string().nullable().optional(),
|
|
358
|
+
ks: zod.z.string().nullable().optional(),
|
|
359
|
+
message: zod.z.string().nullable().optional(),
|
|
360
|
+
creditorHolderName: zod.z.string(),
|
|
361
|
+
creditorAccountNumberWithBankCode: zod.z.string(),
|
|
362
|
+
creditorIban: zod.z.string(),
|
|
363
|
+
debtorHolderName: zod.z.string(),
|
|
364
|
+
debtorAccountNumberWithBankCode: zod.z.string(),
|
|
365
|
+
debtorIban: zod.z.string()
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
const getAuthUriInputSchema = zod.z.object({
|
|
369
|
+
connectorKey: zod.z.enum(database_schema.CONNECTOR_KEYS)
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
const authorizeAccountInputSchema = zod.z.object({
|
|
373
|
+
ott: zod.z.string(),
|
|
374
|
+
urlParams: zod.z.string()
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
const simulateDepositInputSchema = zod.z.object({
|
|
378
|
+
amount: zod.z.number(),
|
|
379
|
+
currency: zod.z.enum(generalCodes.CURRENCY_CODES),
|
|
380
|
+
bankingVs: zod.z.string().max(10),
|
|
381
|
+
bankingSs: zod.z.string().max(10).optional(),
|
|
382
|
+
bankingKs: zod.z.string().max(10).optional(),
|
|
383
|
+
message: zod.z.string(),
|
|
384
|
+
creditorIban: zod.z.string().max(34),
|
|
385
|
+
creditorHolderName: zod.z.string(),
|
|
386
|
+
debtorIban: zod.z.string().max(34),
|
|
387
|
+
debtorHolderName: zod.z.string(),
|
|
388
|
+
connectorKey: zod.z.enum(database_schema.CONNECTOR_KEYS)
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const setLastSyncAtInputSchema = zod.z.object({
|
|
392
|
+
iban: zod.z.string(),
|
|
393
|
+
lastSyncedAt: zod.z.coerce.date()
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
const initiateConnectorInputSchema = zod.z.object({
|
|
397
|
+
connectorKey: zod.z.enum(database_schema.CONNECTOR_KEYS),
|
|
398
|
+
withAuth: zod.z.boolean().default(true).optional()
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
const getBatchesInputSchema = zod.z.object({
|
|
402
|
+
limit: zod.z.number().positive().optional().default(100),
|
|
403
|
+
offset: zod.z.number().min(0).optional().default(0)
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
const processBatchInputSchema = zod.z.object({
|
|
407
|
+
connectorKey: zod.z.enum(database_schema.CONNECTOR_KEYS),
|
|
408
|
+
batch: zod.z.custom()
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const ALLOWED_PAYMENT_FILTERS = {
|
|
412
|
+
ACCOUNT_ID: "filterPaymentAccountId",
|
|
413
|
+
AMOUNT: "filterPaymentAmount",
|
|
414
|
+
CURRENCY: "filterPaymentCurrency",
|
|
415
|
+
DIRECTION: "filterPaymentyDirection",
|
|
416
|
+
FROM: "filterPaymentDateFrom",
|
|
417
|
+
TO: "filterPaymentDateTo",
|
|
418
|
+
STATUS: "filterPaymentStatus"
|
|
419
|
+
};
|
|
420
|
+
const getPaymentsInputSchema = zod.z.object({
|
|
421
|
+
page: zod.z.number().positive(),
|
|
422
|
+
limit: zod.z.number().positive(),
|
|
423
|
+
sort: zod.z.object({
|
|
424
|
+
column: zod.z.enum(["createdAt", "updatedAt", "amount"]),
|
|
425
|
+
direction: zod.z.enum(["asc", "desc"])
|
|
426
|
+
}),
|
|
427
|
+
[ALLOWED_PAYMENT_FILTERS.ACCOUNT_ID]: zod.z.union([zod.z.uuid(), zod.z.uuid().array()]).optional(),
|
|
428
|
+
[ALLOWED_PAYMENT_FILTERS.AMOUNT]: zod.z.union([zod.z.number(), zod.z.number().array()]).optional(),
|
|
429
|
+
[ALLOWED_PAYMENT_FILTERS.CURRENCY]: zod.z.union([zod.z.enum(generalCodes.CURRENCY_CODES), zod.z.enum(generalCodes.CURRENCY_CODES).array()]).optional(),
|
|
430
|
+
[ALLOWED_PAYMENT_FILTERS.DIRECTION]: zod.z.union([zod.z.enum(database_schema.PAYMENT_DIRECTIONS), zod.z.enum(database_schema.PAYMENT_DIRECTIONS).array()]).optional(),
|
|
431
|
+
[ALLOWED_PAYMENT_FILTERS.FROM]: zod.z.date().optional(),
|
|
432
|
+
[ALLOWED_PAYMENT_FILTERS.TO]: zod.z.date().optional(),
|
|
433
|
+
[ALLOWED_PAYMENT_FILTERS.STATUS]: zod.z.union([zod.z.enum(database_schema.PAYMENT_STATUSES), zod.z.enum(database_schema.PAYMENT_STATUSES).array()]).optional()
|
|
434
|
+
});
|
|
435
|
+
|
|
269
436
|
var __defProp = Object.defineProperty;
|
|
270
437
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
271
438
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -277,22 +444,35 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
277
444
|
return result;
|
|
278
445
|
};
|
|
279
446
|
let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.WorkerEntrypoint) {
|
|
280
|
-
constructor(ctx, env,
|
|
447
|
+
constructor(ctx, env, config) {
|
|
281
448
|
super(ctx, env);
|
|
282
|
-
this.
|
|
283
|
-
this.
|
|
449
|
+
this.allowedProviders = [];
|
|
450
|
+
this.allowedProviders = config.allowedProviders;
|
|
451
|
+
this.db = d1.drizzle(this.env.BANK_D1, { schema: database_schema.tables });
|
|
452
|
+
}
|
|
453
|
+
getAllowedProviders() {
|
|
454
|
+
return this.allowedProviders;
|
|
284
455
|
}
|
|
285
|
-
|
|
286
|
-
return
|
|
456
|
+
async getAccounts() {
|
|
457
|
+
return await getAllAccountsQuery(this.db);
|
|
458
|
+
}
|
|
459
|
+
async getPayments(input) {
|
|
460
|
+
return this.handleAction(
|
|
461
|
+
{ data: input, schema: getPaymentsInputSchema },
|
|
462
|
+
{ successMessage: "Payments fetched successfully" },
|
|
463
|
+
async (pagination) => {
|
|
464
|
+
return await getPaymentsWithPaginationQuery(this.db, pagination);
|
|
465
|
+
}
|
|
466
|
+
);
|
|
287
467
|
}
|
|
288
468
|
accountFetchInterval(connectorKey) {
|
|
289
469
|
switch (connectorKey) {
|
|
290
470
|
case "ERSTE":
|
|
291
|
-
return
|
|
471
|
+
return database_schema.ErsteConnector.FETCH_INTERVAL;
|
|
292
472
|
case "FINBRICKS":
|
|
293
|
-
return
|
|
473
|
+
return database_schema.FinbricksConnector.FETCH_INTERVAL;
|
|
294
474
|
case "MOCK":
|
|
295
|
-
return
|
|
475
|
+
return database_schema.MockConnector.FETCH_INTERVAL;
|
|
296
476
|
default:
|
|
297
477
|
return 0;
|
|
298
478
|
}
|
|
@@ -301,16 +481,17 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
301
481
|
return this.handleAction(null, {}, async () => {
|
|
302
482
|
const accountsToSync = [];
|
|
303
483
|
const { getLastSync } = useSync(this.env.BANK_KV);
|
|
304
|
-
|
|
484
|
+
const accounts = await this.getAccounts();
|
|
485
|
+
for (const account of accounts.filter(
|
|
305
486
|
(acc) => !!!acc.connectorKey.includes("MOCK")
|
|
306
487
|
)) {
|
|
307
|
-
let lastSync = await getLastSync({ account });
|
|
488
|
+
let lastSync = await getLastSync({ account: { ...account, token: "" } });
|
|
308
489
|
if (!lastSync) {
|
|
309
490
|
await this.setLastSyncAt({
|
|
310
|
-
iban: account.
|
|
311
|
-
lastSyncedAt: account.
|
|
491
|
+
iban: account.iban,
|
|
492
|
+
lastSyncedAt: account.lastSyncedAt || /* @__PURE__ */ new Date()
|
|
312
493
|
});
|
|
313
|
-
lastSync = await getLastSync({ account });
|
|
494
|
+
lastSync = await getLastSync({ account: { ...account, token: "" } });
|
|
314
495
|
if (!lastSync) continue;
|
|
315
496
|
}
|
|
316
497
|
const accountFetchInterval = this.accountFetchInterval(
|
|
@@ -323,7 +504,8 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
323
504
|
if (!shouldFetch) continue;
|
|
324
505
|
accountsToSync.push({
|
|
325
506
|
...account,
|
|
326
|
-
lastSyncAt: lastSync
|
|
507
|
+
lastSyncAt: lastSync,
|
|
508
|
+
token: ""
|
|
327
509
|
});
|
|
328
510
|
}
|
|
329
511
|
console.log("ACCS TO SYNC", accountsToSync.length);
|
|
@@ -336,16 +518,95 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
336
518
|
console.log("Scheduled CRON payments processing");
|
|
337
519
|
await this.syncAccounts();
|
|
338
520
|
}
|
|
521
|
+
if (controller.cron === this.env.CRON_BATCH_STATUSES) {
|
|
522
|
+
console.log("Scheduled CRON batch statuses");
|
|
523
|
+
await this.updateBatchStatuses();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async updateBatchStatuses() {
|
|
527
|
+
const pendingBatches = await getAllPendingBatchesQuery(this.db);
|
|
528
|
+
const uniqueConnectors = /* @__PURE__ */ new Set();
|
|
529
|
+
const accounts = await this.getAccounts();
|
|
530
|
+
for (const batch of pendingBatches) {
|
|
531
|
+
const connectorKey = accounts.find(
|
|
532
|
+
(acc) => acc.id === batch.accountId
|
|
533
|
+
).connectorKey;
|
|
534
|
+
if (!uniqueConnectors.has(connectorKey)) {
|
|
535
|
+
uniqueConnectors.add(connectorKey);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const finalBatches = [];
|
|
539
|
+
for (const connectorKey of uniqueConnectors) {
|
|
540
|
+
const accs = accounts.filter((acc) => acc.connectorKey === connectorKey);
|
|
541
|
+
const updatedBatches = await Promise.all(
|
|
542
|
+
accs.map(async (account) => {
|
|
543
|
+
const batch = pendingBatches.find((acc) => acc.id === account.id);
|
|
544
|
+
const newStatus = await this.bankConnector.getBatchStatus({
|
|
545
|
+
batchId: batch.id
|
|
546
|
+
});
|
|
547
|
+
return {
|
|
548
|
+
...batch,
|
|
549
|
+
status: newStatus
|
|
550
|
+
};
|
|
551
|
+
})
|
|
552
|
+
);
|
|
553
|
+
finalBatches.push(...updatedBatches);
|
|
554
|
+
}
|
|
555
|
+
const updateBatchesCommands = finalBatches.map((batch) => {
|
|
556
|
+
const { command } = upsertBatchCommand(this.db, {
|
|
557
|
+
batch: {
|
|
558
|
+
...batch
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
return command;
|
|
562
|
+
});
|
|
563
|
+
console.log("Updated batches", finalBatches);
|
|
564
|
+
await this.db.batch([
|
|
565
|
+
updateBatchesCommands[0],
|
|
566
|
+
...updateBatchesCommands.slice(1)
|
|
567
|
+
]);
|
|
568
|
+
console.log("Batch update completed");
|
|
339
569
|
}
|
|
340
570
|
// @action('initiate-bank-connector')
|
|
341
571
|
async initiateBankConnector(input) {
|
|
342
572
|
return this.handleAction(
|
|
343
573
|
{ data: input, schema: initiateConnectorInputSchema },
|
|
344
574
|
{ successMessage: "Bank connector initiated successfully" },
|
|
345
|
-
async ({ connectorKey }) => {
|
|
346
|
-
this.
|
|
347
|
-
|
|
348
|
-
|
|
575
|
+
async ({ connectorKey, withAuth }) => {
|
|
576
|
+
if (!this.allowedProviders.includes(connectorKey)) {
|
|
577
|
+
throw backendSdk.createInternalError(null, {
|
|
578
|
+
message: `Invalid connector key: ${connectorKey}`
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
const accounts = await this.getAccounts();
|
|
582
|
+
const accountsForConnector = accounts.filter(
|
|
583
|
+
(acc) => acc.connectorKey === connectorKey
|
|
584
|
+
);
|
|
585
|
+
const accountsWithCredentials = await Promise.all(
|
|
586
|
+
accountsForConnector.map(async (acc) => {
|
|
587
|
+
const credentials = await getCredentialsByAccountId(this.db, {
|
|
588
|
+
accountId: acc.id
|
|
589
|
+
});
|
|
590
|
+
if (!credentials) {
|
|
591
|
+
throw backendSdk.createInternalError(null, {
|
|
592
|
+
message: `No credentials found for account ${acc.id}`
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
return {
|
|
596
|
+
currency: acc.currency,
|
|
597
|
+
iban: acc.iban,
|
|
598
|
+
token: credentials.value,
|
|
599
|
+
id: acc.id,
|
|
600
|
+
connectorKey: acc.connectorKey
|
|
601
|
+
};
|
|
602
|
+
})
|
|
603
|
+
);
|
|
604
|
+
this.bankConnector = initiateConnector({
|
|
605
|
+
bank: connectorKey,
|
|
606
|
+
connectedAccounts: accountsWithCredentials,
|
|
607
|
+
env: this.env
|
|
608
|
+
});
|
|
609
|
+
if (!withAuth) return;
|
|
349
610
|
await this.bankConnector.authenticate();
|
|
350
611
|
}
|
|
351
612
|
);
|
|
@@ -358,7 +619,9 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
358
619
|
const mappedPayments = paymentsToBatch.map(
|
|
359
620
|
(payment) => ({
|
|
360
621
|
id: backendSdk.uuidv4(),
|
|
622
|
+
accountId: "",
|
|
361
623
|
refId: payment.refId,
|
|
624
|
+
connectorKey: "MOCK",
|
|
362
625
|
amount: payment.amount,
|
|
363
626
|
direction: "OUTGOING",
|
|
364
627
|
paymentType: payment.paymentType,
|
|
@@ -378,7 +641,10 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
378
641
|
debtorIban: payment.debtorIban
|
|
379
642
|
})
|
|
380
643
|
);
|
|
381
|
-
const { supportedPayments, unsupportedPayments } = seperateSupportedPayments(
|
|
644
|
+
const { supportedPayments, unsupportedPayments } = seperateSupportedPayments(
|
|
645
|
+
mappedPayments,
|
|
646
|
+
this.bankConnector.connectedAccounts
|
|
647
|
+
);
|
|
382
648
|
if (unsupportedPayments.length > 0) {
|
|
383
649
|
this.logError({ unsupportedPayments });
|
|
384
650
|
await this.pushToQueue(
|
|
@@ -404,15 +670,19 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
404
670
|
}))
|
|
405
671
|
);
|
|
406
672
|
}
|
|
407
|
-
for (const acc of this.
|
|
673
|
+
for (const acc of this.bankConnector.connectedAccounts) {
|
|
408
674
|
const newPayments = supportedPayments.filter(
|
|
409
|
-
(payment) => payment.debtorIban === acc.
|
|
410
|
-
)
|
|
675
|
+
(payment) => payment.debtorIban === acc.iban && payment.currency === acc.currency
|
|
676
|
+
).map((payment) => ({
|
|
677
|
+
...payment,
|
|
678
|
+
connectorKey: acc.connectorKey,
|
|
679
|
+
accountId: acc.id
|
|
680
|
+
}));
|
|
411
681
|
if (newPayments.length === 0) {
|
|
412
682
|
continue;
|
|
413
683
|
}
|
|
414
684
|
this.log({
|
|
415
|
-
message: `\u{1F4B0} Processing ${newPayments.length} payments for account
|
|
685
|
+
message: `\u{1F4B0} Processing ${newPayments.length} payments for account (${acc.iban}, ${acc.currency})`
|
|
416
686
|
});
|
|
417
687
|
const existingBatch = await getOpenBatchByAccountIdQuery(this.db, {
|
|
418
688
|
accountId: acc.id
|
|
@@ -584,26 +854,19 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
584
854
|
return this.handleAction(
|
|
585
855
|
{ data: input, schema: getAuthUriInputSchema },
|
|
586
856
|
{ successMessage: "Auth URI obtained." },
|
|
587
|
-
async ({
|
|
588
|
-
|
|
589
|
-
if (!account)
|
|
590
|
-
throw backendSdk.createInternalError(null, {
|
|
591
|
-
message: "Account not found",
|
|
592
|
-
code: "ACCOUNT_NOT_FOUND",
|
|
593
|
-
status: 404
|
|
594
|
-
});
|
|
595
|
-
this.bankConnector = initiateConnector(account.connectorKey, this.env);
|
|
857
|
+
async ({ connectorKey }) => {
|
|
858
|
+
await this.initiateBankConnector({ connectorKey, withAuth: false });
|
|
596
859
|
const ott = backendSdk.uuidv4();
|
|
597
|
-
const { command:
|
|
860
|
+
const { command: createOneTimeToken } = createOneTimeTokenCommand(
|
|
598
861
|
this.db,
|
|
599
862
|
{
|
|
600
863
|
ott,
|
|
601
|
-
|
|
864
|
+
refId: connectorKey,
|
|
602
865
|
tokenType: "ACCOUNT_AUTHORIZATION"
|
|
603
866
|
}
|
|
604
867
|
);
|
|
605
|
-
await
|
|
606
|
-
const uri = await this.bankConnector.getAuthUri({
|
|
868
|
+
await createOneTimeToken.execute();
|
|
869
|
+
const uri = await this.bankConnector.getAuthUri({ ott });
|
|
607
870
|
return { uri };
|
|
608
871
|
}
|
|
609
872
|
);
|
|
@@ -630,11 +893,50 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
630
893
|
status: 400
|
|
631
894
|
});
|
|
632
895
|
}
|
|
633
|
-
this.
|
|
634
|
-
|
|
896
|
+
await this.initiateBankConnector({
|
|
897
|
+
connectorKey: ottRow.refId
|
|
898
|
+
});
|
|
899
|
+
const { credentials, accounts } = await this.bankConnector.authorizeAccount({
|
|
635
900
|
urlParams
|
|
636
901
|
});
|
|
637
|
-
|
|
902
|
+
console.log("Bank connector initiated");
|
|
903
|
+
const alreadyExistingAccounts = (await this.getAccounts()).filter(
|
|
904
|
+
(acc) => acc.connectorKey === ottRow.refId && accounts.map((item) => item.iban).includes(acc.iban)
|
|
905
|
+
);
|
|
906
|
+
const upsertAccounts = accounts.map(
|
|
907
|
+
(acc) => upsertAccountCommand(this.db, {
|
|
908
|
+
account: acc
|
|
909
|
+
}).command
|
|
910
|
+
);
|
|
911
|
+
const deleteCredentials = alreadyExistingAccounts.map(
|
|
912
|
+
(acc) => deleteAccountCredentialsCommand(this.db, {
|
|
913
|
+
accountId: acc.id
|
|
914
|
+
}).command
|
|
915
|
+
);
|
|
916
|
+
const createAccountCredentials = credentials.map(
|
|
917
|
+
(cr) => createAccountCredentialsCommand(this.db, {
|
|
918
|
+
credentials: cr
|
|
919
|
+
}).command
|
|
920
|
+
);
|
|
921
|
+
const { command: updateOtt } = expireOneTimeTokenCommand(this.db, {
|
|
922
|
+
ott
|
|
923
|
+
});
|
|
924
|
+
await this.db.batch([
|
|
925
|
+
updateOtt,
|
|
926
|
+
...upsertAccounts,
|
|
927
|
+
...deleteCredentials,
|
|
928
|
+
...createAccountCredentials
|
|
929
|
+
]);
|
|
930
|
+
const fetchedAccounts = await this.getAccounts();
|
|
931
|
+
if (!fetchedAccounts)
|
|
932
|
+
throw backendSdk.createInternalError(null, {
|
|
933
|
+
message: "Account not found",
|
|
934
|
+
code: "NOT_FOUND",
|
|
935
|
+
status: 404
|
|
936
|
+
});
|
|
937
|
+
return {
|
|
938
|
+
accounts: fetchedAccounts
|
|
939
|
+
};
|
|
638
940
|
}
|
|
639
941
|
);
|
|
640
942
|
}
|
|
@@ -660,10 +962,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
660
962
|
if (!payments || payments.length === 0) continue;
|
|
661
963
|
this.log(payments);
|
|
662
964
|
payments.forEach((payment) => {
|
|
663
|
-
payment.direction =
|
|
664
|
-
payment,
|
|
665
|
-
account.identification.iban
|
|
666
|
-
);
|
|
965
|
+
payment.direction = database_schema.getPaymentDirection(payment, account.iban);
|
|
667
966
|
});
|
|
668
967
|
allFetchedPayments.push(...payments);
|
|
669
968
|
}
|
|
@@ -686,7 +985,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
686
985
|
console.log("FETCHEDPAYMANETS TO SYNC", allFetchedPayments.length);
|
|
687
986
|
for (const account of accounts) {
|
|
688
987
|
const paymentsForAccount = allFetchedPayments.filter(
|
|
689
|
-
(payment) => (payment.direction === "OUTGOING" ? payment.debtorIban : payment.creditorIban) === account.
|
|
988
|
+
(payment) => (payment.direction === "OUTGOING" ? payment.debtorIban : payment.creditorIban) === account.iban
|
|
690
989
|
);
|
|
691
990
|
let lastSyncPayment;
|
|
692
991
|
lastSyncPayment = paymentsForAccount.filter(({ status }) => status !== "COMPLETED").sort(
|
|
@@ -733,11 +1032,23 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
733
1032
|
creditorIban,
|
|
734
1033
|
creditorHolderName,
|
|
735
1034
|
debtorIban,
|
|
736
|
-
debtorHolderName
|
|
1035
|
+
debtorHolderName,
|
|
1036
|
+
connectorKey
|
|
737
1037
|
}) => {
|
|
1038
|
+
const account = await getAccountByIbanQuery(this.db, {
|
|
1039
|
+
iban: creditorIban
|
|
1040
|
+
});
|
|
1041
|
+
if (!account)
|
|
1042
|
+
throw backendSdk.createInternalError(null, {
|
|
1043
|
+
message: "Unsupported account",
|
|
1044
|
+
code: "UNSUPPORTED_ACCOUNT",
|
|
1045
|
+
status: 422
|
|
1046
|
+
});
|
|
738
1047
|
const payment = {
|
|
739
1048
|
id: backendSdk.uuidv4(),
|
|
740
1049
|
amount,
|
|
1050
|
+
connectorKey,
|
|
1051
|
+
accountId: account.id,
|
|
741
1052
|
direction: "INCOMING",
|
|
742
1053
|
paymentType: "DOMESTIC",
|
|
743
1054
|
currency,
|
|
@@ -775,10 +1086,10 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
775
1086
|
{ successMessage: "Last sync set." },
|
|
776
1087
|
async ({ iban, lastSyncedAt }) => {
|
|
777
1088
|
const { setLastSync } = useSync(this.env.BANK_KV);
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
);
|
|
781
|
-
if (!
|
|
1089
|
+
const account = await getAccountByIbanQuery(this.db, {
|
|
1090
|
+
iban
|
|
1091
|
+
});
|
|
1092
|
+
if (!account) {
|
|
782
1093
|
throw backendSdk.createInternalError(null, {
|
|
783
1094
|
status: 404,
|
|
784
1095
|
message: "Account for this organization does not exist."
|
|
@@ -788,7 +1099,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
788
1099
|
log: {
|
|
789
1100
|
lastSyncedAt
|
|
790
1101
|
},
|
|
791
|
-
account:
|
|
1102
|
+
account: { ...account, token: "" }
|
|
792
1103
|
});
|
|
793
1104
|
return {};
|
|
794
1105
|
}
|
|
@@ -808,7 +1119,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
808
1119
|
}
|
|
809
1120
|
async getBankAccounts() {
|
|
810
1121
|
return backendSdk.RPCResponse.ok("Bank accounts retrieved successfully", {
|
|
811
|
-
data: this.
|
|
1122
|
+
data: await this.getAccounts()
|
|
812
1123
|
});
|
|
813
1124
|
}
|
|
814
1125
|
async getBatches(input) {
|
|
@@ -817,8 +1128,8 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
817
1128
|
{ successMessage: "Batches retrieved successfully" },
|
|
818
1129
|
async ({ limit = 100, offset = 0 }) => {
|
|
819
1130
|
const [batchesResult, countResult] = await Promise.all([
|
|
820
|
-
this.db.select().from(
|
|
821
|
-
this.db.select({ count: drizzleOrm.sql`count(*)`.as("count") }).from(
|
|
1131
|
+
this.db.select().from(database_schema.tables.batch).limit(limit).offset(offset).orderBy(drizzleOrm.desc(database_schema.tables.batch.createdAt)),
|
|
1132
|
+
this.db.select({ count: drizzleOrm.sql`count(*)`.as("count") }).from(database_schema.tables.batch)
|
|
822
1133
|
]);
|
|
823
1134
|
const totalCount = Number(countResult[0]?.count) || 0;
|
|
824
1135
|
return {
|
|
@@ -829,12 +1140,18 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
829
1140
|
);
|
|
830
1141
|
}
|
|
831
1142
|
};
|
|
1143
|
+
__decorateClass([
|
|
1144
|
+
backendSdk.action("get-payments")
|
|
1145
|
+
], BankServiceBase.prototype, "getPayments", 1);
|
|
832
1146
|
__decorateClass([
|
|
833
1147
|
backendSdk.action("synchronize-accounts")
|
|
834
1148
|
], BankServiceBase.prototype, "syncAccounts", 1);
|
|
835
1149
|
__decorateClass([
|
|
836
1150
|
backendSdk.action("scheduled")
|
|
837
1151
|
], BankServiceBase.prototype, "scheduled", 1);
|
|
1152
|
+
__decorateClass([
|
|
1153
|
+
backendSdk.action("update-batch-statuses")
|
|
1154
|
+
], BankServiceBase.prototype, "updateBatchStatuses", 1);
|
|
838
1155
|
__decorateClass([
|
|
839
1156
|
backendSdk.action("add-payments-to-batch")
|
|
840
1157
|
], BankServiceBase.prototype, "addPaymentsToBatch", 1);
|
|
@@ -872,433 +1189,429 @@ BankServiceBase = __decorateClass([
|
|
|
872
1189
|
backendSdk.service("bank")
|
|
873
1190
|
], BankServiceBase);
|
|
874
1191
|
function defineBankService({
|
|
875
|
-
|
|
1192
|
+
config
|
|
876
1193
|
}) {
|
|
877
1194
|
return class BankService extends BankServiceBase {
|
|
878
1195
|
constructor(ctx, env) {
|
|
879
|
-
super(ctx, env,
|
|
1196
|
+
super(ctx, env, config);
|
|
880
1197
|
}
|
|
881
1198
|
};
|
|
882
1199
|
}
|
|
883
1200
|
|
|
884
|
-
const monthAgo = new Date(
|
|
885
|
-
Date.now() - 30 * 24 * 60 * 60 * 1e3
|
|
886
|
-
// 30 days ago
|
|
887
|
-
);
|
|
888
1201
|
const BankService = defineBankService({
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
],
|
|
956
|
-
productionAccounts: [
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
]
|
|
1202
|
+
config: {
|
|
1203
|
+
allowedProviders: []
|
|
1204
|
+
// {
|
|
1205
|
+
// connectorKey: 'MOCK_COBS',
|
|
1206
|
+
// id: 'staging-czk',
|
|
1207
|
+
// identification: {
|
|
1208
|
+
// number: '1234567890',
|
|
1209
|
+
// bankCode: '5051',
|
|
1210
|
+
// iban: 'CZ0350510000000000000449',
|
|
1211
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1212
|
+
// },
|
|
1213
|
+
// fallbackLastSync: monthAgo,
|
|
1214
|
+
// currency: 'CZK',
|
|
1215
|
+
// production: false,
|
|
1216
|
+
// },
|
|
1217
|
+
// {
|
|
1218
|
+
// connectorKey: 'MOCK_COBS',
|
|
1219
|
+
// id: 'staging-eur',
|
|
1220
|
+
// identification: {
|
|
1221
|
+
// number: '2345678901',
|
|
1222
|
+
// bankCode: '5051',
|
|
1223
|
+
// iban: 'CZ0750510000000000000668',
|
|
1224
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1225
|
+
// },
|
|
1226
|
+
// fallbackLastSync: monthAgo,
|
|
1227
|
+
// currency: 'EUR',
|
|
1228
|
+
// production: false,
|
|
1229
|
+
// },
|
|
1230
|
+
// {
|
|
1231
|
+
// connectorKey: 'FIO',
|
|
1232
|
+
// id: 'kleinpetr-test',
|
|
1233
|
+
// identification: {
|
|
1234
|
+
// number: '2502130437',
|
|
1235
|
+
// bankCode: '2010',
|
|
1236
|
+
// iban: 'CZ8520100000002502130437',
|
|
1237
|
+
// holderName: 'Petr Klein',
|
|
1238
|
+
// },
|
|
1239
|
+
// fallbackLastSync: monthAgo,
|
|
1240
|
+
// currency: 'CZK',
|
|
1241
|
+
// production: true,
|
|
1242
|
+
// },
|
|
1243
|
+
// {
|
|
1244
|
+
// connectorKey: 'MOCK',
|
|
1245
|
+
// id: 'id-test',
|
|
1246
|
+
// identification: {
|
|
1247
|
+
// number: '777777777',
|
|
1248
|
+
// bankCode: '0800',
|
|
1249
|
+
// iban: 'PL0000000000002444430437',
|
|
1250
|
+
// holderName: 'Test Test',
|
|
1251
|
+
// },
|
|
1252
|
+
// fallbackLastSync: monthAgo,
|
|
1253
|
+
// currency: 'PLN',
|
|
1254
|
+
// production: false,
|
|
1255
|
+
// },
|
|
1256
|
+
// {
|
|
1257
|
+
// connectorKey: 'MOCK_COBS',
|
|
1258
|
+
// id: 'staging-usd',
|
|
1259
|
+
// identification: {
|
|
1260
|
+
// iban: 'CZ3456789012345678901234',
|
|
1261
|
+
// accountNumberWithBankCode: '3456789012/3456',
|
|
1262
|
+
// },
|
|
1263
|
+
// currency: 'USD',
|
|
1264
|
+
// bankCode: '0800',
|
|
1265
|
+
// accountNumber: '3456789012',
|
|
1266
|
+
// production: false,
|
|
1267
|
+
// },
|
|
1268
|
+
// ],
|
|
1269
|
+
// productionAccounts: [
|
|
1270
|
+
// // Banka CREDITAS (2250)
|
|
1271
|
+
// {
|
|
1272
|
+
// connectorKey: 'CREDITAS',
|
|
1273
|
+
// id: '2250-CZK',
|
|
1274
|
+
// identification: {
|
|
1275
|
+
// number: '100602391',
|
|
1276
|
+
// bankCode: '2250',
|
|
1277
|
+
// iban: 'CZ5122500000000100602391',
|
|
1278
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1279
|
+
// },
|
|
1280
|
+
// fallbackLastSync: monthAgo,
|
|
1281
|
+
// currency: 'CZK',
|
|
1282
|
+
// production: true,
|
|
1283
|
+
// },
|
|
1284
|
+
// {
|
|
1285
|
+
// connectorKey: 'CREDITAS',
|
|
1286
|
+
// id: '2250-EUR',
|
|
1287
|
+
// identification: {
|
|
1288
|
+
// number: '100602404',
|
|
1289
|
+
// bankCode: '2250',
|
|
1290
|
+
// iban: 'CZ8822500000000100602404',
|
|
1291
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1292
|
+
// },
|
|
1293
|
+
// fallbackLastSync: monthAgo,
|
|
1294
|
+
// currency: 'EUR',
|
|
1295
|
+
// production: true,
|
|
1296
|
+
// },
|
|
1297
|
+
// {
|
|
1298
|
+
// connectorKey: 'CREDITAS',
|
|
1299
|
+
// id: '2250-USD',
|
|
1300
|
+
// identification: {
|
|
1301
|
+
// number: '100602412',
|
|
1302
|
+
// bankCode: '2250',
|
|
1303
|
+
// iban: 'CZ6622500000000100602412',
|
|
1304
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1305
|
+
// },
|
|
1306
|
+
// fallbackLastSync: monthAgo,
|
|
1307
|
+
// currency: 'USD',
|
|
1308
|
+
// production: true,
|
|
1309
|
+
// },
|
|
1310
|
+
// {
|
|
1311
|
+
// connectorKey: 'CREDITAS',
|
|
1312
|
+
// id: '2250-GBP',
|
|
1313
|
+
// identification: {
|
|
1314
|
+
// number: '100602420',
|
|
1315
|
+
// bankCode: '2250',
|
|
1316
|
+
// iban: 'CZ4422500000000100602420',
|
|
1317
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1318
|
+
// },
|
|
1319
|
+
// fallbackLastSync: monthAgo,
|
|
1320
|
+
// currency: 'GBP',
|
|
1321
|
+
// production: true,
|
|
1322
|
+
// },
|
|
1323
|
+
// {
|
|
1324
|
+
// connectorKey: 'CREDITAS',
|
|
1325
|
+
// id: '2250-CHF',
|
|
1326
|
+
// identification: {
|
|
1327
|
+
// number: '100602439',
|
|
1328
|
+
// bankCode: '2250',
|
|
1329
|
+
// iban: 'CZ1622500000000100602439',
|
|
1330
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1331
|
+
// },
|
|
1332
|
+
// fallbackLastSync: monthAgo,
|
|
1333
|
+
// currency: 'CHF',
|
|
1334
|
+
// production: true,
|
|
1335
|
+
// },
|
|
1336
|
+
// {
|
|
1337
|
+
// connectorKey: 'CREDITAS',
|
|
1338
|
+
// id: '2250-PLN',
|
|
1339
|
+
// identification: {
|
|
1340
|
+
// number: '100602447',
|
|
1341
|
+
// bankCode: '2250',
|
|
1342
|
+
// iban: 'CZ9122500000000100602447',
|
|
1343
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1344
|
+
// },
|
|
1345
|
+
// fallbackLastSync: monthAgo,
|
|
1346
|
+
// currency: 'PLN',
|
|
1347
|
+
// production: true,
|
|
1348
|
+
// },
|
|
1349
|
+
// // Fio banka (2010)
|
|
1350
|
+
// {
|
|
1351
|
+
// connectorKey: 'FINBRICKS',
|
|
1352
|
+
// id: '2010-CZK',
|
|
1353
|
+
// identification: {
|
|
1354
|
+
// number: '2500845869',
|
|
1355
|
+
// bankCode: '2010',
|
|
1356
|
+
// iban: 'CZ0420100000002500845869',
|
|
1357
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1358
|
+
// },
|
|
1359
|
+
// fallbackLastSync: monthAgo,
|
|
1360
|
+
// currency: 'CZK',
|
|
1361
|
+
// production: true,
|
|
1362
|
+
// },
|
|
1363
|
+
// {
|
|
1364
|
+
// connectorKey: 'FINBRICKS',
|
|
1365
|
+
// id: '2010-EUR',
|
|
1366
|
+
// identification: {
|
|
1367
|
+
// number: '2600884128',
|
|
1368
|
+
// bankCode: '2010',
|
|
1369
|
+
// iban: 'CZ0820100000002600884128',
|
|
1370
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1371
|
+
// },
|
|
1372
|
+
// fallbackLastSync: monthAgo,
|
|
1373
|
+
// currency: 'EUR',
|
|
1374
|
+
// production: true,
|
|
1375
|
+
// },
|
|
1376
|
+
// {
|
|
1377
|
+
// connectorKey: 'FINBRICKS',
|
|
1378
|
+
// id: '2010-USD',
|
|
1379
|
+
// identification: {
|
|
1380
|
+
// number: '2700884133',
|
|
1381
|
+
// bankCode: '2010',
|
|
1382
|
+
// iban: 'CZ1420100000002700884133',
|
|
1383
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1384
|
+
// },
|
|
1385
|
+
// fallbackLastSync: monthAgo,
|
|
1386
|
+
// currency: 'USD',
|
|
1387
|
+
// production: true,
|
|
1388
|
+
// },
|
|
1389
|
+
// {
|
|
1390
|
+
// connectorKey: 'FINBRICKS',
|
|
1391
|
+
// id: '2010-CHF',
|
|
1392
|
+
// identification: {
|
|
1393
|
+
// number: '2401098351',
|
|
1394
|
+
// bankCode: '2010',
|
|
1395
|
+
// iban: 'CZ0920100000002401098351',
|
|
1396
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1397
|
+
// },
|
|
1398
|
+
// fallbackLastSync: monthAgo,
|
|
1399
|
+
// currency: 'CHF',
|
|
1400
|
+
// production: true,
|
|
1401
|
+
// },
|
|
1402
|
+
// {
|
|
1403
|
+
// connectorKey: 'FINBRICKS',
|
|
1404
|
+
// id: '2010-GBP',
|
|
1405
|
+
// identification: {
|
|
1406
|
+
// number: '2400884131',
|
|
1407
|
+
// bankCode: '2010',
|
|
1408
|
+
// iban: 'CZ3320100000002400884131',
|
|
1409
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1410
|
+
// },
|
|
1411
|
+
// fallbackLastSync: monthAgo,
|
|
1412
|
+
// currency: 'GBP',
|
|
1413
|
+
// production: true,
|
|
1414
|
+
// },
|
|
1415
|
+
// {
|
|
1416
|
+
// connectorKey: 'FINBRICKS',
|
|
1417
|
+
// id: '2010-PLN',
|
|
1418
|
+
// identification: {
|
|
1419
|
+
// number: '2701098353',
|
|
1420
|
+
// bankCode: '2010',
|
|
1421
|
+
// iban: 'CZ8720100000002701098353',
|
|
1422
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1423
|
+
// },
|
|
1424
|
+
// fallbackLastSync: monthAgo,
|
|
1425
|
+
// currency: 'PLN',
|
|
1426
|
+
// production: true,
|
|
1427
|
+
// },
|
|
1428
|
+
// {
|
|
1429
|
+
// connectorKey: 'FINBRICKS',
|
|
1430
|
+
// id: '2010-CAD',
|
|
1431
|
+
// identification: {
|
|
1432
|
+
// number: '2701478102',
|
|
1433
|
+
// bankCode: '2010',
|
|
1434
|
+
// iban: 'CZ5520100000002701478102',
|
|
1435
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1436
|
+
// },
|
|
1437
|
+
// fallbackLastSync: monthAgo,
|
|
1438
|
+
// currency: 'CAD',
|
|
1439
|
+
// production: true,
|
|
1440
|
+
// },
|
|
1441
|
+
// // Komerční banka (0100)
|
|
1442
|
+
// {
|
|
1443
|
+
// connectorKey: 'FINBRICKS',
|
|
1444
|
+
// id: '0100-CZK',
|
|
1445
|
+
// identification: {
|
|
1446
|
+
// number: '115-1483630297',
|
|
1447
|
+
// bankCode: '0100',
|
|
1448
|
+
// iban: 'CZ5901000001151483630297',
|
|
1449
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1450
|
+
// },
|
|
1451
|
+
// fallbackLastSync: monthAgo,
|
|
1452
|
+
// currency: 'CZK',
|
|
1453
|
+
// production: true,
|
|
1454
|
+
// },
|
|
1455
|
+
// {
|
|
1456
|
+
// connectorKey: 'FINBRICKS',
|
|
1457
|
+
// id: '0100-EUR',
|
|
1458
|
+
// identification: {
|
|
1459
|
+
// number: '115-1484940297',
|
|
1460
|
+
// bankCode: '0100',
|
|
1461
|
+
// iban: 'CZ4201000001151484940297',
|
|
1462
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1463
|
+
// },
|
|
1464
|
+
// fallbackLastSync: monthAgo,
|
|
1465
|
+
// currency: 'EUR',
|
|
1466
|
+
// production: true,
|
|
1467
|
+
// },
|
|
1468
|
+
// {
|
|
1469
|
+
// connectorKey: 'FINBRICKS',
|
|
1470
|
+
// id: '0100-USD',
|
|
1471
|
+
// identification: {
|
|
1472
|
+
// number: '115-1483960237',
|
|
1473
|
+
// bankCode: '0100',
|
|
1474
|
+
// iban: 'CZ6201000001151483960237',
|
|
1475
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1476
|
+
// },
|
|
1477
|
+
// fallbackLastSync: monthAgo,
|
|
1478
|
+
// currency: 'USD',
|
|
1479
|
+
// production: true,
|
|
1480
|
+
// },
|
|
1481
|
+
// {
|
|
1482
|
+
// connectorKey: 'FINBRICKS',
|
|
1483
|
+
// id: '0100-PLN',
|
|
1484
|
+
// identification: {
|
|
1485
|
+
// number: '115-6674290267',
|
|
1486
|
+
// bankCode: '0100',
|
|
1487
|
+
// iban: 'CZ3501000001156674290267',
|
|
1488
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1489
|
+
// },
|
|
1490
|
+
// fallbackLastSync: monthAgo,
|
|
1491
|
+
// currency: 'PLN',
|
|
1492
|
+
// production: true,
|
|
1493
|
+
// },
|
|
1494
|
+
// {
|
|
1495
|
+
// connectorKey: 'FINBRICKS',
|
|
1496
|
+
// id: '0100-SEK',
|
|
1497
|
+
// identification: {
|
|
1498
|
+
// number: '115-9578110207',
|
|
1499
|
+
// bankCode: '0100',
|
|
1500
|
+
// iban: 'CZ2401000001159578110207',
|
|
1501
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1502
|
+
// },
|
|
1503
|
+
// fallbackLastSync: monthAgo,
|
|
1504
|
+
// currency: 'SEK',
|
|
1505
|
+
// production: true,
|
|
1506
|
+
// },
|
|
1507
|
+
// // Česká spořitelna (0800)
|
|
1508
|
+
// {
|
|
1509
|
+
// connectorKey: 'ERSTE',
|
|
1510
|
+
// id: '0800-CZK',
|
|
1511
|
+
// identification: {
|
|
1512
|
+
// number: '4413926379',
|
|
1513
|
+
// bankCode: '0800',
|
|
1514
|
+
// iban: 'CZ7908000000004413926379',
|
|
1515
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1516
|
+
// },
|
|
1517
|
+
// fallbackLastSync: monthAgo,
|
|
1518
|
+
// currency: 'CZK',
|
|
1519
|
+
// production: true,
|
|
1520
|
+
// },
|
|
1521
|
+
// {
|
|
1522
|
+
// connectorKey: 'ERSTE',
|
|
1523
|
+
// id: '0800-EUR',
|
|
1524
|
+
// identification: {
|
|
1525
|
+
// number: '1966646293',
|
|
1526
|
+
// bankCode: '0800',
|
|
1527
|
+
// iban: 'CZ2308000000001966646293',
|
|
1528
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1529
|
+
// },
|
|
1530
|
+
// fallbackLastSync: monthAgo,
|
|
1531
|
+
// currency: 'EUR',
|
|
1532
|
+
// production: true,
|
|
1533
|
+
// },
|
|
1534
|
+
// {
|
|
1535
|
+
// connectorKey: 'ERSTE',
|
|
1536
|
+
// id: '0800-USD',
|
|
1537
|
+
// identification: {
|
|
1538
|
+
// number: '1978982243',
|
|
1539
|
+
// bankCode: '0800',
|
|
1540
|
+
// iban: 'CZ1908000000001978982243',
|
|
1541
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1542
|
+
// },
|
|
1543
|
+
// fallbackLastSync: monthAgo,
|
|
1544
|
+
// currency: 'USD',
|
|
1545
|
+
// production: true,
|
|
1546
|
+
// },
|
|
1547
|
+
// {
|
|
1548
|
+
// connectorKey: 'ERSTE',
|
|
1549
|
+
// id: '0800-HUF',
|
|
1550
|
+
// identification: {
|
|
1551
|
+
// number: '13461252',
|
|
1552
|
+
// bankCode: '0800',
|
|
1553
|
+
// iban: 'CZ1908000000000013461252',
|
|
1554
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1555
|
+
// },
|
|
1556
|
+
// fallbackLastSync: monthAgo,
|
|
1557
|
+
// currency: 'HUF',
|
|
1558
|
+
// production: true,
|
|
1559
|
+
// },
|
|
1560
|
+
// // MONETA Money Bank (0600)
|
|
1561
|
+
// {
|
|
1562
|
+
// connectorKey: 'FINBRICKS',
|
|
1563
|
+
// id: '0600-CZK',
|
|
1564
|
+
// identification: {
|
|
1565
|
+
// number: '224252186',
|
|
1566
|
+
// bankCode: '0600',
|
|
1567
|
+
// iban: 'CZ5906000000000224252186',
|
|
1568
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1569
|
+
// },
|
|
1570
|
+
// fallbackLastSync: monthAgo,
|
|
1571
|
+
// currency: 'CZK',
|
|
1572
|
+
// production: true,
|
|
1573
|
+
// },
|
|
1574
|
+
// {
|
|
1575
|
+
// connectorKey: 'FINBRICKS',
|
|
1576
|
+
// id: '0600-EUR',
|
|
1577
|
+
// identification: {
|
|
1578
|
+
// number: '224252231',
|
|
1579
|
+
// bankCode: '0600',
|
|
1580
|
+
// iban: 'CZ0806000000000224252231',
|
|
1581
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1582
|
+
// },
|
|
1583
|
+
// fallbackLastSync: monthAgo,
|
|
1584
|
+
// currency: 'EUR',
|
|
1585
|
+
// production: true,
|
|
1586
|
+
// },
|
|
1587
|
+
// {
|
|
1588
|
+
// connectorKey: 'FINBRICKS',
|
|
1589
|
+
// id: '0600-USD',
|
|
1590
|
+
// identification: {
|
|
1591
|
+
// number: '224252290',
|
|
1592
|
+
// bankCode: '0600',
|
|
1593
|
+
// iban: 'CZ6406000000000224252290',
|
|
1594
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1595
|
+
// },
|
|
1596
|
+
// fallbackLastSync: monthAgo,
|
|
1597
|
+
// currency: 'USD',
|
|
1598
|
+
// production: true,
|
|
1599
|
+
// },
|
|
1600
|
+
// // NEY spořitelní družstvo (2260)
|
|
1601
|
+
// {
|
|
1602
|
+
// connectorKey: 'FINBRICKS',
|
|
1603
|
+
// id: '2260-CZK',
|
|
1604
|
+
// identification: {
|
|
1605
|
+
// number: '1702700014',
|
|
1606
|
+
// bankCode: '2260',
|
|
1607
|
+
// iban: 'CZ7422600000001702700014',
|
|
1608
|
+
// holderName: 'Devizová Burza a.s.',
|
|
1609
|
+
// },
|
|
1610
|
+
// fallbackLastSync: monthAgo,
|
|
1611
|
+
// currency: 'CZK',
|
|
1612
|
+
// production: true,
|
|
1613
|
+
// },
|
|
1614
|
+
// ],
|
|
1302
1615
|
}
|
|
1303
1616
|
});
|
|
1304
1617
|
|