@develit-services/bank 0.0.42 → 0.0.44

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.
@@ -1,15 +1,15 @@
1
1
  import { uuidv4, bankAccountMetadataSchema, develitWorker, createInternalError, first, action, service } from '@develit-io/backend-sdk';
2
2
  import { WorkerEntrypoint } from 'cloudflare:workers';
3
3
  import { drizzle } from 'drizzle-orm/d1';
4
- import { t as tables, F as FinbricksConnector, M as MockConnector, E as ErsteConnector, c as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, P as PAYMENT_TYPES, g as CONNECTOR_KEYS, B as BATCH_STATUSES, d as PAYMENT_STATUSES, e as PAYMENT_DIRECTIONS, i as accountInsertSchema, v as getPaymentDirection } from '../shared/bank.C4RJkRzZ.mjs';
4
+ import { t as tables, F as FinbricksConnector, M as MockConnector, E as ErsteConnector, c as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, P as PAYMENT_TYPES, g as CONNECTOR_KEYS, B as BATCH_STATUSES, d as PAYMENT_STATUSES, e as PAYMENT_DIRECTIONS, i as accountInsertSchema, v as getPaymentDirection } from '../shared/bank.BWcFhTu1.mjs';
5
5
  import 'jose';
6
6
  import { CURRENCY_CODES } from '@develit-io/general-codes';
7
7
  import { z } from 'zod';
8
8
  import { eq, inArray, and, sql, asc, desc, gte, lte } from 'drizzle-orm';
9
- import { M as MockCobsConnector } from '../shared/bank.WJE512Ly.mjs';
9
+ import { M as MockCobsConnector } from '../shared/bank.6WoCPIFy.mjs';
10
10
  import 'drizzle-orm/sqlite-core';
11
- import 'drizzle-zod';
12
11
  import 'date-fns';
12
+ import 'drizzle-zod';
13
13
  import 'drizzle-orm/relations';
14
14
 
15
15
  const upsertAccountCommand = (db, { account }) => {
@@ -378,10 +378,8 @@ const simulateDepositInputSchema = z.object({
378
378
  bankingSs: z.string().max(10).optional(),
379
379
  bankingKs: z.string().max(10).optional(),
380
380
  message: z.string(),
381
- creditorIban: z.string().max(34),
382
- creditorHolderName: z.string(),
383
- debtorIban: z.string().max(34),
384
- debtorHolderName: z.string(),
381
+ creditor: bankAccountMetadataSchema,
382
+ debtor: bankAccountMetadataSchema,
385
383
  connectorKey: z.enum(CONNECTOR_KEYS)
386
384
  });
387
385
 
@@ -528,9 +526,11 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
528
526
  this.env.QUEUE_BUS_QUEUE,
529
527
  allFetchedPayments.map((payment) => ({
530
528
  eventType: "BANK_PAYMENT",
529
+ eventSignal: "created",
531
530
  bankPayment: payment,
532
531
  metadata: {
533
532
  correlationId: uuidv4(),
533
+ entityId: payment.id,
534
534
  timestamp: (/* @__PURE__ */ new Date()).toDateString()
535
535
  }
536
536
  }))
@@ -737,6 +737,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
737
737
  this.env.QUEUE_BUS_QUEUE,
738
738
  unsupportedPayments.map((unsupported) => ({
739
739
  eventType: "BANK_PAYMENT",
740
+ eventSignal: "failed",
740
741
  bankPayment: {
741
742
  ...unsupported,
742
743
  status: "FAILED",
@@ -744,6 +745,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
744
745
  },
745
746
  metadata: {
746
747
  correlationId: unsupported.correlationId,
748
+ entityId: unsupported.id,
747
749
  timestamp: (/* @__PURE__ */ new Date()).toDateString()
748
750
  }
749
751
  }))
@@ -1028,14 +1030,12 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1028
1030
  bankingSs,
1029
1031
  bankingKs,
1030
1032
  message,
1031
- creditorIban,
1032
- creditorHolderName,
1033
- debtorIban,
1034
- debtorHolderName,
1033
+ creditor,
1034
+ debtor,
1035
1035
  connectorKey
1036
1036
  }) => {
1037
1037
  const account = await getAccountByIbanQuery(this.db, {
1038
- iban: creditorIban
1038
+ iban: debtor.iban
1039
1039
  });
1040
1040
  if (!account)
1041
1041
  throw createInternalError(null, {
@@ -1045,6 +1045,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1045
1045
  });
1046
1046
  const payment = {
1047
1047
  id: uuidv4(),
1048
+ correlationId: uuidv4(),
1048
1049
  amount,
1049
1050
  connectorKey,
1050
1051
  accountId: account.id,
@@ -1059,19 +1060,21 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1059
1060
  ss: bankingSs,
1060
1061
  ks: bankingKs,
1061
1062
  message,
1062
- creditorIban,
1063
- creditorHolderName,
1064
- debtorIban,
1065
- debtorHolderName
1063
+ creditor,
1064
+ creditorIban: creditor.iban,
1065
+ debtor,
1066
+ debtorIban: debtor.iban
1066
1067
  };
1067
1068
  const { command } = createPaymentCommand(this.db, { payment });
1068
1069
  const createdPayment = await command.execute().then(first);
1069
1070
  this.logQueuePush({ payment, isPaymentExecuted: true });
1070
1071
  await this.pushToQueue(this.env.QUEUE_BUS_QUEUE, {
1071
1072
  eventType: "BANK_PAYMENT",
1073
+ eventSignal: "completed",
1072
1074
  bankPayment: createdPayment,
1073
1075
  metadata: {
1074
- correlationId: createdPayment.id,
1076
+ correlationId: createdPayment.correlationId,
1077
+ entityId: createdPayment.id,
1075
1078
  timestamp: (/* @__PURE__ */ new Date()).toDateString()
1076
1079
  }
1077
1080
  });
@@ -1,6 +1,6 @@
1
1
  import { Environment } from '@develit-io/backend-sdk';
2
2
  import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
3
- import { a as PaymentInsertType, t as tables } from './bank.PvYf5Bqd.js';
3
+ import { a as PaymentInsertType, t as tables } from './bank.CCilUVCi.js';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  import { z } from 'zod';
6
6
  import * as drizzle_zod from 'drizzle-zod';
@@ -1,4 +1,4 @@
1
- import { F as FinbricksConnector } from './bank.C4RJkRzZ.mjs';
1
+ import { F as FinbricksConnector } from './bank.BWcFhTu1.mjs';
2
2
 
3
3
  class MockCobsConnector extends FinbricksConnector {
4
4
  constructor(config) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const database_schema = require('./bank.Cw5xzUgM.cjs');
3
+ const database_schema = require('./bank.BVzOzXdX.cjs');
4
4
 
5
5
  class MockCobsConnector extends database_schema.FinbricksConnector {
6
6
  constructor(config) {
@@ -2,17 +2,40 @@
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
4
  const sqliteCore = require('drizzle-orm/sqlite-core');
5
+ const dateFns = require('date-fns');
5
6
  const drizzleOrm = require('drizzle-orm');
6
7
  const generalCodes = require('@develit-io/general-codes');
7
8
  const zod = require('zod');
8
9
  const jose = require('jose');
9
10
  const drizzleZod = require('drizzle-zod');
10
- const dateFns = require('date-fns');
11
11
  const relations = require('drizzle-orm/relations');
12
12
 
13
13
  class IBankConnector {
14
14
  }
15
15
 
16
+ const mapReferencesToPayment = (reference) => {
17
+ const symbols = {
18
+ vs: void 0,
19
+ ss: void 0,
20
+ ks: void 0
21
+ };
22
+ if (!reference) return symbols;
23
+ if (Array.isArray(reference) && reference.length > 0) {
24
+ symbols.vs = reference.find((ref) => ref.includes("VS")) || void 0;
25
+ symbols.ss = reference.find((ref) => ref.includes("SS")) || void 0;
26
+ symbols.ks = reference.find((ref) => ref.includes("KS")) || void 0;
27
+ }
28
+ if (typeof reference === "string") {
29
+ const vsMatch = reference.match(/VS[:\s]*(\d+)/i);
30
+ const ssMatch = reference.match(/SS[:\s]*(\d+)/i);
31
+ const ksMatch = reference.match(/KS[:\s]*(\d+)/i);
32
+ if (vsMatch) symbols.vs = vsMatch[1];
33
+ if (ssMatch) symbols.ss = ssMatch[1];
34
+ if (ksMatch) symbols.ks = ksMatch[1];
35
+ }
36
+ return symbols;
37
+ };
38
+
16
39
  async function signFinbricksJws({
17
40
  privateKeyPem,
18
41
  merchantId,
@@ -113,29 +136,6 @@ const FINBRICKS_ENDPOINTS = {
113
136
  BATCH_STATUS: "/transaction/platform/batchPayment/status"
114
137
  };
115
138
 
116
- const mapReferencesToPayment = (reference) => {
117
- const symbols = {
118
- vs: void 0,
119
- ss: void 0,
120
- ks: void 0
121
- };
122
- if (!reference) return symbols;
123
- if (Array.isArray(reference) && reference.length > 0) {
124
- symbols.vs = reference.find((ref) => ref.includes("VS")) || void 0;
125
- symbols.ss = reference.find((ref) => ref.includes("SS")) || void 0;
126
- symbols.ks = reference.find((ref) => ref.includes("KS")) || void 0;
127
- }
128
- if (typeof reference === "string") {
129
- const vsMatch = reference.match(/VS[:\s]*(\d+)/i);
130
- const ssMatch = reference.match(/SS[:\s]*(\d+)/i);
131
- const ksMatch = reference.match(/KS[:\s]*(\d+)/i);
132
- if (vsMatch) symbols.vs = vsMatch[1];
133
- if (ssMatch) symbols.ss = ssMatch[1];
134
- if (ksMatch) symbols.ks = ksMatch[1];
135
- }
136
- return symbols;
137
- };
138
-
139
139
  const mapFinbricksStatus = (status) => {
140
140
  switch (status) {
141
141
  case "BOOK":
@@ -182,6 +182,7 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
182
182
  const related = tx.entryDetails?.transactionDetails?.relatedParties;
183
183
  const base = {
184
184
  id: backendSdk.uuidv4(),
185
+ correlationId: backendSdk.uuidv4(),
185
186
  connectorKey: account.connectorKey,
186
187
  accountId: account.id,
187
188
  bankRefId: tx.entryReference || tx.fbxReference,
@@ -194,14 +195,30 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
194
195
  ...mapReferencesToPayment(
195
196
  tx.entryDetails.transactionDetails?.remittanceInformation?.structured?.creditorReferenceInformation?.reference || tx.entryDetails.transactionDetails?.references?.endToEndIdentification
196
197
  ),
197
- debtorHolderName: isIncoming ? related?.debtor?.name || "Unknown" : "Unknown",
198
- creditorHolderName: isIncoming ? "Unknown" : related?.creditor?.name || "Unknown",
199
- debtorIban: isIncoming ? related.debtorAccount?.identification?.iban || account.iban : account.iban,
200
- creditorIban: isIncoming ? account.iban : related.creditorAccount?.identification?.iban || account.iban,
198
+ creditor: {
199
+ holderName: isIncoming ? "Unknown" : related?.creditor?.name || "Unknown",
200
+ iban: isIncoming ? account.iban || void 0 : related.creditorAccount?.identification?.iban || account.iban || void 0,
201
+ number: isIncoming ? account.number || void 0 : related.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
202
+ "/"
203
+ )[0] : account.number || void 0,
204
+ bankCode: isIncoming ? account.bankCode || void 0 : related.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
205
+ "/"
206
+ )[1] : account.bankCode || void 0
207
+ },
208
+ debtor: {
209
+ holderName: isIncoming ? related?.debtor?.name || "Unknown" : "Unknown",
210
+ iban: isIncoming ? related.debtorAccount?.identification?.iban || account.iban || void 0 : account.iban ?? void 0,
211
+ number: isIncoming ? related.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
212
+ "/"
213
+ )[0] : account.number || void 0 : account.number || void 0,
214
+ bankCode: isIncoming ? related.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
215
+ "/"
216
+ )[1] : account.bankCode || void 0 : account.bankCode || void 0
217
+ },
201
218
  direction: "INCOMING"
202
219
  // přepíšeme správným směrem níže
203
220
  };
204
- base.direction = getPaymentDirection(base, account.iban);
221
+ base.direction = isIncoming ? "INCOMING" : "OUTGOING";
205
222
  return base;
206
223
  };
207
224
 
@@ -486,13 +503,13 @@ class FinbricksConnector extends IBankConnector {
486
503
  },
487
504
  amount: payment.amount,
488
505
  debtor: {
489
- debtorAccountIban: payment.debtorIban,
490
- debtorName: payment.debtorHolderName || "Devizov\xE1 burza",
506
+ debtorAccountIban: payment.debtor.iban,
507
+ debtorName: payment.debtor.holderName,
491
508
  paymentProvider: this.PROVIDER
492
509
  },
493
510
  creditor: {
494
- creditorAccountIban: payment.creditorIban,
495
- creditorName: payment.creditorHolderName
511
+ creditorAccountIban: payment.creditor.iban,
512
+ creditorName: payment.creditor.holderName
496
513
  },
497
514
  callbackUrl: "https://www.example.com"
498
515
  }
@@ -526,9 +543,9 @@ class FinbricksConnector extends IBankConnector {
526
543
  merchantId: this.finbricks.MERCHANT_ID,
527
544
  merchantTransactionId: payment.bankRefId,
528
545
  totalPrice: payment.amount,
529
- debtorAccountIban: payment.debtorIban,
530
- creditorAccountIban: payment.creditorIban,
531
- creditorName: payment.creditorHolderName,
546
+ debtorAccountIban: payment.debtor.iban,
547
+ creditorAccountIban: payment.creditor.iban,
548
+ creditorName: payment.creditor.holderName,
532
549
  description: payment.message,
533
550
  variableSymbol: payment.vs,
534
551
  callbackUrl: "https://example.com/callback",
@@ -744,7 +761,7 @@ class ErsteConnector extends IBankConnector {
744
761
  debtorAccount: { identification: { iban: payment.debtorIban } },
745
762
  creditorAccount: { identification: { iban: payment.creditorIban } },
746
763
  creditor: {
747
- name: payment.creditorHolderName
764
+ name: payment.creditor.holderName
748
765
  }
749
766
  };
750
767
  const [data, error] = await backendSdk.useResult(
@@ -886,17 +903,32 @@ class ErsteConnector extends IBankConnector {
886
903
  const symbols = mapReferencesToPayment(reference);
887
904
  const paymentInsert = {
888
905
  id: backendSdk.uuidv4(),
906
+ correlationId: backendSdk.uuidv4(),
889
907
  connectorKey: "ERSTE",
890
908
  accountId: account.id,
891
909
  bankRefId: payment.entryReference,
892
910
  amount: payment.amount.value,
893
911
  currency: payment.amount.currency.code,
894
- debtorHolderName: payment.entryDetails.transactionDetails.relatedParties.debtor?.name,
895
- debtorIban: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.iban,
896
- debtorAccountNumberWithBankCode: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification,
897
- creditorHolderName: payment.entryDetails.transactionDetails.relatedParties.creditor?.name || "",
898
- creditorIban: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.iban,
899
- creditorAccountNumberWithBankCode: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification,
912
+ debtor: {
913
+ holderName: payment.entryDetails.transactionDetails.relatedParties.debtor?.name,
914
+ iban: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.iban,
915
+ number: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.debtorAccount.identification.other.identification.split(
916
+ "/"
917
+ )[0] : void 0,
918
+ bankCode: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.debtorAccount.identification.other.identification.split(
919
+ "/"
920
+ )[1] : void 0
921
+ },
922
+ creditor: {
923
+ holderName: payment.entryDetails.transactionDetails.relatedParties.creditor?.name,
924
+ iban: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.iban,
925
+ number: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.creditorAccount.identification.other.identification.split(
926
+ "/"
927
+ )[0] : void 0,
928
+ bankCode: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.creditorAccount.identification.other.identification.split(
929
+ "/"
930
+ )[1] : void 0
931
+ },
900
932
  paymentType: "DOMESTIC",
901
933
  direction: "INCOMING",
902
934
  message: payment.entryDetails.transactionDetails.remittanceInformation?.unstructured,
@@ -908,7 +940,7 @@ class ErsteConnector extends IBankConnector {
908
940
  };
909
941
  return {
910
942
  ...paymentInsert,
911
- direction: getPaymentDirection(paymentInsert, account.iban)
943
+ direction: account.iban ? getPaymentDirection(paymentInsert, account.iban) : "INCOMING"
912
944
  };
913
945
  });
914
946
  return payments;
@@ -1,16 +1,39 @@
1
1
  import { uuidv4, useResult, createInternalError, bankAccount, base } from '@develit-io/backend-sdk';
2
2
  import { sqliteTable, integer, text, unique, real } from 'drizzle-orm/sqlite-core';
3
+ import { format, parseISO } from 'date-fns';
3
4
  import { and, eq } from 'drizzle-orm';
4
5
  import { COUNTRY_CODES_2, CURRENCY_CODES } from '@develit-io/general-codes';
5
6
  import { z } from 'zod';
6
7
  import { importPKCS8, SignJWT } from 'jose';
7
8
  import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-zod';
8
- import { format, parseISO } from 'date-fns';
9
9
  import { relations } from 'drizzle-orm/relations';
10
10
 
11
11
  class IBankConnector {
12
12
  }
13
13
 
14
+ const mapReferencesToPayment = (reference) => {
15
+ const symbols = {
16
+ vs: void 0,
17
+ ss: void 0,
18
+ ks: void 0
19
+ };
20
+ if (!reference) return symbols;
21
+ if (Array.isArray(reference) && reference.length > 0) {
22
+ symbols.vs = reference.find((ref) => ref.includes("VS")) || void 0;
23
+ symbols.ss = reference.find((ref) => ref.includes("SS")) || void 0;
24
+ symbols.ks = reference.find((ref) => ref.includes("KS")) || void 0;
25
+ }
26
+ if (typeof reference === "string") {
27
+ const vsMatch = reference.match(/VS[:\s]*(\d+)/i);
28
+ const ssMatch = reference.match(/SS[:\s]*(\d+)/i);
29
+ const ksMatch = reference.match(/KS[:\s]*(\d+)/i);
30
+ if (vsMatch) symbols.vs = vsMatch[1];
31
+ if (ssMatch) symbols.ss = ssMatch[1];
32
+ if (ksMatch) symbols.ks = ksMatch[1];
33
+ }
34
+ return symbols;
35
+ };
36
+
14
37
  async function signFinbricksJws({
15
38
  privateKeyPem,
16
39
  merchantId,
@@ -111,29 +134,6 @@ const FINBRICKS_ENDPOINTS = {
111
134
  BATCH_STATUS: "/transaction/platform/batchPayment/status"
112
135
  };
113
136
 
114
- const mapReferencesToPayment = (reference) => {
115
- const symbols = {
116
- vs: void 0,
117
- ss: void 0,
118
- ks: void 0
119
- };
120
- if (!reference) return symbols;
121
- if (Array.isArray(reference) && reference.length > 0) {
122
- symbols.vs = reference.find((ref) => ref.includes("VS")) || void 0;
123
- symbols.ss = reference.find((ref) => ref.includes("SS")) || void 0;
124
- symbols.ks = reference.find((ref) => ref.includes("KS")) || void 0;
125
- }
126
- if (typeof reference === "string") {
127
- const vsMatch = reference.match(/VS[:\s]*(\d+)/i);
128
- const ssMatch = reference.match(/SS[:\s]*(\d+)/i);
129
- const ksMatch = reference.match(/KS[:\s]*(\d+)/i);
130
- if (vsMatch) symbols.vs = vsMatch[1];
131
- if (ssMatch) symbols.ss = ssMatch[1];
132
- if (ksMatch) symbols.ks = ksMatch[1];
133
- }
134
- return symbols;
135
- };
136
-
137
137
  const mapFinbricksStatus = (status) => {
138
138
  switch (status) {
139
139
  case "BOOK":
@@ -180,6 +180,7 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
180
180
  const related = tx.entryDetails?.transactionDetails?.relatedParties;
181
181
  const base = {
182
182
  id: uuidv4(),
183
+ correlationId: uuidv4(),
183
184
  connectorKey: account.connectorKey,
184
185
  accountId: account.id,
185
186
  bankRefId: tx.entryReference || tx.fbxReference,
@@ -192,14 +193,30 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
192
193
  ...mapReferencesToPayment(
193
194
  tx.entryDetails.transactionDetails?.remittanceInformation?.structured?.creditorReferenceInformation?.reference || tx.entryDetails.transactionDetails?.references?.endToEndIdentification
194
195
  ),
195
- debtorHolderName: isIncoming ? related?.debtor?.name || "Unknown" : "Unknown",
196
- creditorHolderName: isIncoming ? "Unknown" : related?.creditor?.name || "Unknown",
197
- debtorIban: isIncoming ? related.debtorAccount?.identification?.iban || account.iban : account.iban,
198
- creditorIban: isIncoming ? account.iban : related.creditorAccount?.identification?.iban || account.iban,
196
+ creditor: {
197
+ holderName: isIncoming ? "Unknown" : related?.creditor?.name || "Unknown",
198
+ iban: isIncoming ? account.iban || void 0 : related.creditorAccount?.identification?.iban || account.iban || void 0,
199
+ number: isIncoming ? account.number || void 0 : related.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
200
+ "/"
201
+ )[0] : account.number || void 0,
202
+ bankCode: isIncoming ? account.bankCode || void 0 : related.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
203
+ "/"
204
+ )[1] : account.bankCode || void 0
205
+ },
206
+ debtor: {
207
+ holderName: isIncoming ? related?.debtor?.name || "Unknown" : "Unknown",
208
+ iban: isIncoming ? related.debtorAccount?.identification?.iban || account.iban || void 0 : account.iban ?? void 0,
209
+ number: isIncoming ? related.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
210
+ "/"
211
+ )[0] : account.number || void 0 : account.number || void 0,
212
+ bankCode: isIncoming ? related.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
213
+ "/"
214
+ )[1] : account.bankCode || void 0 : account.bankCode || void 0
215
+ },
199
216
  direction: "INCOMING"
200
217
  // přepíšeme správným směrem níže
201
218
  };
202
- base.direction = getPaymentDirection(base, account.iban);
219
+ base.direction = isIncoming ? "INCOMING" : "OUTGOING";
203
220
  return base;
204
221
  };
205
222
 
@@ -484,13 +501,13 @@ class FinbricksConnector extends IBankConnector {
484
501
  },
485
502
  amount: payment.amount,
486
503
  debtor: {
487
- debtorAccountIban: payment.debtorIban,
488
- debtorName: payment.debtorHolderName || "Devizov\xE1 burza",
504
+ debtorAccountIban: payment.debtor.iban,
505
+ debtorName: payment.debtor.holderName,
489
506
  paymentProvider: this.PROVIDER
490
507
  },
491
508
  creditor: {
492
- creditorAccountIban: payment.creditorIban,
493
- creditorName: payment.creditorHolderName
509
+ creditorAccountIban: payment.creditor.iban,
510
+ creditorName: payment.creditor.holderName
494
511
  },
495
512
  callbackUrl: "https://www.example.com"
496
513
  }
@@ -524,9 +541,9 @@ class FinbricksConnector extends IBankConnector {
524
541
  merchantId: this.finbricks.MERCHANT_ID,
525
542
  merchantTransactionId: payment.bankRefId,
526
543
  totalPrice: payment.amount,
527
- debtorAccountIban: payment.debtorIban,
528
- creditorAccountIban: payment.creditorIban,
529
- creditorName: payment.creditorHolderName,
544
+ debtorAccountIban: payment.debtor.iban,
545
+ creditorAccountIban: payment.creditor.iban,
546
+ creditorName: payment.creditor.holderName,
530
547
  description: payment.message,
531
548
  variableSymbol: payment.vs,
532
549
  callbackUrl: "https://example.com/callback",
@@ -742,7 +759,7 @@ class ErsteConnector extends IBankConnector {
742
759
  debtorAccount: { identification: { iban: payment.debtorIban } },
743
760
  creditorAccount: { identification: { iban: payment.creditorIban } },
744
761
  creditor: {
745
- name: payment.creditorHolderName
762
+ name: payment.creditor.holderName
746
763
  }
747
764
  };
748
765
  const [data, error] = await useResult(
@@ -884,17 +901,32 @@ class ErsteConnector extends IBankConnector {
884
901
  const symbols = mapReferencesToPayment(reference);
885
902
  const paymentInsert = {
886
903
  id: uuidv4(),
904
+ correlationId: uuidv4(),
887
905
  connectorKey: "ERSTE",
888
906
  accountId: account.id,
889
907
  bankRefId: payment.entryReference,
890
908
  amount: payment.amount.value,
891
909
  currency: payment.amount.currency.code,
892
- debtorHolderName: payment.entryDetails.transactionDetails.relatedParties.debtor?.name,
893
- debtorIban: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.iban,
894
- debtorAccountNumberWithBankCode: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification,
895
- creditorHolderName: payment.entryDetails.transactionDetails.relatedParties.creditor?.name || "",
896
- creditorIban: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.iban,
897
- creditorAccountNumberWithBankCode: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification,
910
+ debtor: {
911
+ holderName: payment.entryDetails.transactionDetails.relatedParties.debtor?.name,
912
+ iban: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.iban,
913
+ number: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.debtorAccount.identification.other.identification.split(
914
+ "/"
915
+ )[0] : void 0,
916
+ bankCode: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.debtorAccount.identification.other.identification.split(
917
+ "/"
918
+ )[1] : void 0
919
+ },
920
+ creditor: {
921
+ holderName: payment.entryDetails.transactionDetails.relatedParties.creditor?.name,
922
+ iban: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.iban,
923
+ number: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.creditorAccount.identification.other.identification.split(
924
+ "/"
925
+ )[0] : void 0,
926
+ bankCode: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.creditorAccount.identification.other.identification.split(
927
+ "/"
928
+ )[1] : void 0
929
+ },
898
930
  paymentType: "DOMESTIC",
899
931
  direction: "INCOMING",
900
932
  message: payment.entryDetails.transactionDetails.remittanceInformation?.unstructured,
@@ -906,7 +938,7 @@ class ErsteConnector extends IBankConnector {
906
938
  };
907
939
  return {
908
940
  ...paymentInsert,
909
- direction: getPaymentDirection(paymentInsert, account.iban)
941
+ direction: account.iban ? getPaymentDirection(paymentInsert, account.iban) : "INCOMING"
910
942
  };
911
943
  });
912
944
  return payments;
@@ -83,10 +83,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
83
83
  }>;
84
84
  status: z.ZodEnum<{
85
85
  PREPARED: "PREPARED";
86
- INITIALIZED: "INITIALIZED";
86
+ COMPLETED: "COMPLETED";
87
87
  FAILED: "FAILED";
88
+ INITIALIZED: "INITIALIZED";
88
89
  PENDING: "PENDING";
89
- COMPLETED: "COMPLETED";
90
90
  CREATED: "CREATED";
91
91
  }>;
92
92
  batchId: z.ZodString;
@@ -166,7 +166,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
166
166
  tableName: "batch";
167
167
  dataType: "string";
168
168
  columnType: "SQLiteText";
169
- data: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
169
+ data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
170
170
  driverParam: string;
171
171
  notNull: false;
172
172
  hasDefault: false;
@@ -179,7 +179,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
179
179
  generated: undefined;
180
180
  }, {}, {
181
181
  length: number | undefined;
182
- $type: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
182
+ $type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
183
183
  }>;
184
184
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
185
185
  name: "payments";
@@ -475,7 +475,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
475
475
  tableName: "payment";
476
476
  dataType: "string";
477
477
  columnType: "SQLiteText";
478
- data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
478
+ data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
479
479
  driverParam: string;
480
480
  notNull: true;
481
481
  hasDefault: false;
@@ -488,7 +488,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
488
488
  generated: undefined;
489
489
  }, {}, {
490
490
  length: number | undefined;
491
- $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
491
+ $type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
492
492
  }>;
493
493
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
494
494
  name: "status_reason";
@@ -83,10 +83,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
83
83
  }>;
84
84
  status: z.ZodEnum<{
85
85
  PREPARED: "PREPARED";
86
- INITIALIZED: "INITIALIZED";
86
+ COMPLETED: "COMPLETED";
87
87
  FAILED: "FAILED";
88
+ INITIALIZED: "INITIALIZED";
88
89
  PENDING: "PENDING";
89
- COMPLETED: "COMPLETED";
90
90
  CREATED: "CREATED";
91
91
  }>;
92
92
  batchId: z.ZodString;
@@ -166,7 +166,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
166
166
  tableName: "batch";
167
167
  dataType: "string";
168
168
  columnType: "SQLiteText";
169
- data: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
169
+ data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
170
170
  driverParam: string;
171
171
  notNull: false;
172
172
  hasDefault: false;
@@ -179,7 +179,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
179
179
  generated: undefined;
180
180
  }, {}, {
181
181
  length: number | undefined;
182
- $type: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
182
+ $type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
183
183
  }>;
184
184
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
185
185
  name: "payments";
@@ -475,7 +475,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
475
475
  tableName: "payment";
476
476
  dataType: "string";
477
477
  columnType: "SQLiteText";
478
- data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
478
+ data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
479
479
  driverParam: string;
480
480
  notNull: true;
481
481
  hasDefault: false;
@@ -488,7 +488,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
488
488
  generated: undefined;
489
489
  }, {}, {
490
490
  length: number | undefined;
491
- $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
491
+ $type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
492
492
  }>;
493
493
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
494
494
  name: "status_reason";