@accounter/server 0.0.8-alpha-20251109135308-a84f8e3eb2a8a6f57c2ecf91b0965dfafbc40bf8 → 0.0.8-alpha-20251109140515-1fd3ef8170a6718d943f932cd779f9d9207c78f7
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/CHANGELOG.md +5 -5
- package/dist/server/src/modules/financial-accounts/__generated__/financial-accounts.types.d.ts +0 -72
- package/dist/server/src/modules/financial-accounts/__generated__/financial-bank-accounts.types.d.ts +155 -0
- package/dist/server/src/modules/financial-accounts/__generated__/financial-bank-accounts.types.js +3 -0
- package/dist/server/src/modules/financial-accounts/__generated__/financial-bank-accounts.types.js.map +1 -0
- package/dist/server/src/modules/financial-accounts/__generated__/types.d.ts +13 -13
- package/dist/server/src/modules/financial-accounts/index.js +6 -3
- package/dist/server/src/modules/financial-accounts/index.js.map +1 -1
- package/dist/server/src/modules/financial-accounts/providers/financial-accounts.provider.js +4 -4
- package/dist/server/src/modules/financial-accounts/providers/financial-bank-accounts.provider.d.ts +24 -0
- package/dist/server/src/modules/financial-accounts/providers/financial-bank-accounts.provider.js +218 -0
- package/dist/server/src/modules/financial-accounts/providers/financial-bank-accounts.provider.js.map +1 -0
- package/dist/server/src/modules/financial-accounts/resolvers/financial-accounts.resolver.js +0 -8
- package/dist/server/src/modules/financial-accounts/resolvers/financial-accounts.resolver.js.map +1 -1
- package/dist/server/src/modules/financial-accounts/resolvers/financial-bank-accounts.resolver.d.ts +2 -0
- package/dist/server/src/modules/financial-accounts/resolvers/financial-bank-accounts.resolver.js +28 -0
- package/dist/server/src/modules/financial-accounts/resolvers/financial-bank-accounts.resolver.js.map +1 -0
- package/dist/server/src/modules/financial-accounts/typeDefs/financial-accounts.graphql.js +0 -11
- package/dist/server/src/modules/financial-accounts/typeDefs/financial-accounts.graphql.js.map +1 -1
- package/dist/server/src/modules/financial-accounts/typeDefs/financial-bank-accounts.graphql.d.ts +2 -0
- package/dist/server/src/modules/financial-accounts/typeDefs/financial-bank-accounts.graphql.js +14 -0
- package/dist/server/src/modules/financial-accounts/typeDefs/financial-bank-accounts.graphql.js.map +1 -0
- package/dist/server/src/modules/financial-accounts/types.d.ts +1 -0
- package/dist/server/src/modules/financial-accounts/types.js +1 -0
- package/dist/server/src/modules/financial-accounts/types.js.map +1 -1
- package/dist/server/src/modules/green-invoice/helpers/issue-document.helper.js +12 -2
- package/dist/server/src/modules/green-invoice/helpers/issue-document.helper.js.map +1 -1
- package/package.json +3 -3
- package/src/modules/financial-accounts/__generated__/financial-accounts.types.ts +0 -72
- package/src/modules/financial-accounts/__generated__/financial-bank-accounts.types.ts +171 -0
- package/src/modules/financial-accounts/__generated__/types.ts +13 -13
- package/src/modules/financial-accounts/index.ts +6 -3
- package/src/modules/financial-accounts/providers/financial-accounts.provider.ts +4 -4
- package/src/modules/financial-accounts/providers/financial-bank-accounts.provider.ts +241 -0
- package/src/modules/financial-accounts/resolvers/financial-accounts.resolver.ts +0 -8
- package/src/modules/financial-accounts/resolvers/financial-bank-accounts.resolver.ts +47 -0
- package/src/modules/financial-accounts/typeDefs/financial-accounts.graphql.ts +0 -11
- package/src/modules/financial-accounts/typeDefs/financial-bank-accounts.graphql.ts +14 -0
- package/src/modules/financial-accounts/types.ts +1 -0
- package/src/modules/green-invoice/helpers/issue-document.helper.ts +16 -2
|
@@ -12,22 +12,22 @@ import type {
|
|
|
12
12
|
} from '../types.js';
|
|
13
13
|
|
|
14
14
|
const getFinancialAccountsByOwnerIds = sql<IGetFinancialAccountsByOwnerIdsQuery>`
|
|
15
|
-
SELECT
|
|
15
|
+
SELECT id, account_number, private_business, owner, type
|
|
16
16
|
FROM accounter_schema.financial_accounts
|
|
17
17
|
WHERE owner IN $$ownerIds;`;
|
|
18
18
|
|
|
19
19
|
const getFinancialAccountsByAccountNumbers = sql<IGetFinancialAccountsByAccountNumbersQuery>`
|
|
20
|
-
SELECT
|
|
20
|
+
SELECT id, account_number, private_business, owner, type
|
|
21
21
|
FROM accounter_schema.financial_accounts
|
|
22
22
|
WHERE account_number IN $$accountNumbers;`;
|
|
23
23
|
|
|
24
24
|
const getFinancialAccountsByAccountIDs = sql<IGetFinancialAccountsByAccountIDsQuery>`
|
|
25
|
-
SELECT
|
|
25
|
+
SELECT id, account_number, private_business, owner, type
|
|
26
26
|
FROM accounter_schema.financial_accounts
|
|
27
27
|
WHERE id IN $$accountIDs;`;
|
|
28
28
|
|
|
29
29
|
const getAllFinancialAccounts = sql<IGetAllFinancialAccountsQuery>`
|
|
30
|
-
SELECT
|
|
30
|
+
SELECT id, account_number, private_business, owner, type
|
|
31
31
|
FROM accounter_schema.financial_accounts;`;
|
|
32
32
|
|
|
33
33
|
@Injectable({
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
import { Injectable, Scope } from 'graphql-modules';
|
|
3
|
+
import { DBProvider } from '@modules/app-providers/db.provider.js';
|
|
4
|
+
import { sql } from '@pgtyped/runtime';
|
|
5
|
+
import { getCacheInstance } from '@shared/helpers';
|
|
6
|
+
import type {
|
|
7
|
+
IDeleteBankAccountParams,
|
|
8
|
+
IDeleteBankAccountQuery,
|
|
9
|
+
IGetAllFinancialBankAccountsQuery,
|
|
10
|
+
IGetAllFinancialBankAccountsResult,
|
|
11
|
+
IGetFinancialBankAccountsByIdsQuery,
|
|
12
|
+
IInsertBankAccountsParams,
|
|
13
|
+
IInsertBankAccountsQuery,
|
|
14
|
+
IUpdateBankAccountParams,
|
|
15
|
+
IUpdateBankAccountQuery,
|
|
16
|
+
} from '../types.js';
|
|
17
|
+
|
|
18
|
+
const getFinancialBankAccountsByIds = sql<IGetFinancialBankAccountsByIdsQuery>`
|
|
19
|
+
SELECT id,
|
|
20
|
+
bank_number,
|
|
21
|
+
branch_number,
|
|
22
|
+
extended_bank_number,
|
|
23
|
+
party_preferred_indication,
|
|
24
|
+
party_account_involvement_code,
|
|
25
|
+
account_deal_date,
|
|
26
|
+
account_update_date,
|
|
27
|
+
meteg_doar_net,
|
|
28
|
+
kod_harshaat_peilut,
|
|
29
|
+
account_closing_reason_code,
|
|
30
|
+
account_agreement_opening_date,
|
|
31
|
+
service_authorization_desc,
|
|
32
|
+
branch_type_code,
|
|
33
|
+
mymail_entitlement_switch,
|
|
34
|
+
product_label
|
|
35
|
+
FROM accounter_schema.financial_bank_accounts
|
|
36
|
+
WHERE id IN $$bankAccountIds;`;
|
|
37
|
+
|
|
38
|
+
const getAllFinancialBankAccounts = sql<IGetAllFinancialBankAccountsQuery>`
|
|
39
|
+
SELECT id,
|
|
40
|
+
bank_number,
|
|
41
|
+
branch_number,
|
|
42
|
+
extended_bank_number,
|
|
43
|
+
party_preferred_indication,
|
|
44
|
+
party_account_involvement_code,
|
|
45
|
+
account_deal_date,
|
|
46
|
+
account_update_date,
|
|
47
|
+
meteg_doar_net,
|
|
48
|
+
kod_harshaat_peilut,
|
|
49
|
+
account_closing_reason_code,
|
|
50
|
+
account_agreement_opening_date,
|
|
51
|
+
service_authorization_desc,
|
|
52
|
+
branch_type_code,
|
|
53
|
+
mymail_entitlement_switch,
|
|
54
|
+
product_label
|
|
55
|
+
FROM accounter_schema.financial_bank_accounts;`;
|
|
56
|
+
|
|
57
|
+
const updateBankAccount = sql<IUpdateBankAccountQuery>`
|
|
58
|
+
UPDATE accounter_schema.financial_bank_accounts
|
|
59
|
+
SET
|
|
60
|
+
bank_number =COALESCE(
|
|
61
|
+
$bankNumber,
|
|
62
|
+
bank_number
|
|
63
|
+
),
|
|
64
|
+
branch_number =COALESCE(
|
|
65
|
+
$branchNumber,
|
|
66
|
+
branch_number
|
|
67
|
+
),
|
|
68
|
+
extended_bank_number =COALESCE(
|
|
69
|
+
$extendedBankNumber,
|
|
70
|
+
extended_bank_number
|
|
71
|
+
),
|
|
72
|
+
party_preferred_indication =COALESCE(
|
|
73
|
+
$partyPreferredIndication,
|
|
74
|
+
party_preferred_indication
|
|
75
|
+
),
|
|
76
|
+
party_account_involvement_code =COALESCE(
|
|
77
|
+
$partyAccountInvolvementCode,
|
|
78
|
+
party_account_involvement_code
|
|
79
|
+
),
|
|
80
|
+
account_deal_date =COALESCE(
|
|
81
|
+
$accountDealDate,
|
|
82
|
+
account_deal_date
|
|
83
|
+
),
|
|
84
|
+
account_update_date =COALESCE(
|
|
85
|
+
$accountUpdateDate,
|
|
86
|
+
account_update_date
|
|
87
|
+
),
|
|
88
|
+
meteg_doar_net =COALESCE(
|
|
89
|
+
$metegDoarNet,
|
|
90
|
+
meteg_doar_net
|
|
91
|
+
),
|
|
92
|
+
kod_harshaat_peilut =COALESCE(
|
|
93
|
+
$kodHarshaatPeilut,
|
|
94
|
+
kod_harshaat_peilut
|
|
95
|
+
),
|
|
96
|
+
account_closing_reason_code =COALESCE(
|
|
97
|
+
$accountClosingReasonCode,
|
|
98
|
+
account_closing_reason_code
|
|
99
|
+
),
|
|
100
|
+
account_agreement_opening_date =COALESCE(
|
|
101
|
+
$accountAgreementOpeningDate,
|
|
102
|
+
account_agreement_opening_date
|
|
103
|
+
),
|
|
104
|
+
service_authorization_desc =COALESCE(
|
|
105
|
+
$serviceAuthorizationDesc,
|
|
106
|
+
service_authorization_desc
|
|
107
|
+
),
|
|
108
|
+
branch_type_code =COALESCE(
|
|
109
|
+
$branchTypeCode,
|
|
110
|
+
branch_type_code
|
|
111
|
+
),
|
|
112
|
+
mymail_entitlement_switch =COALESCE(
|
|
113
|
+
$mymailEntitlementSwitch,
|
|
114
|
+
mymail_entitlement_switch
|
|
115
|
+
),
|
|
116
|
+
product_label =COALESCE(
|
|
117
|
+
$productLabel,
|
|
118
|
+
product_label
|
|
119
|
+
)
|
|
120
|
+
WHERE
|
|
121
|
+
id = $bankAccountId
|
|
122
|
+
RETURNING *;
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
const insertBankAccounts = sql<IInsertBankAccountsQuery>`
|
|
126
|
+
INSERT INTO accounter_schema.financial_bank_accounts (
|
|
127
|
+
bank_number,
|
|
128
|
+
branch_number,
|
|
129
|
+
extended_bank_number,
|
|
130
|
+
party_preferred_indication,
|
|
131
|
+
party_account_involvement_code,
|
|
132
|
+
account_deal_date,
|
|
133
|
+
account_update_date,
|
|
134
|
+
meteg_doar_net,
|
|
135
|
+
kod_harshaat_peilut,
|
|
136
|
+
account_closing_reason_code,
|
|
137
|
+
account_agreement_opening_date,
|
|
138
|
+
service_authorization_desc,
|
|
139
|
+
branch_type_code,
|
|
140
|
+
mymail_entitlement_switch,
|
|
141
|
+
product_label
|
|
142
|
+
)
|
|
143
|
+
VALUES $$bankAccounts(
|
|
144
|
+
bankNumber,
|
|
145
|
+
branchNumber,
|
|
146
|
+
extendedBankNumber,
|
|
147
|
+
partyPreferredIndication,
|
|
148
|
+
partyAccountInvolvementCode,
|
|
149
|
+
accountDealDate,
|
|
150
|
+
accountUpdateDate,
|
|
151
|
+
metegDoarNet,
|
|
152
|
+
kodHarshaatPeilut,
|
|
153
|
+
accountClosingReasonCode,
|
|
154
|
+
accountAgreementOpeningDate,
|
|
155
|
+
serviceAuthorizationDesc,
|
|
156
|
+
branchTypeCode,
|
|
157
|
+
mymailEntitlementSwitch,
|
|
158
|
+
productLabel
|
|
159
|
+
)
|
|
160
|
+
RETURNING *;`;
|
|
161
|
+
|
|
162
|
+
const deleteBankAccount = sql<IDeleteBankAccountQuery>`
|
|
163
|
+
DELETE FROM accounter_schema.financial_bank_accounts
|
|
164
|
+
WHERE id = $bankAccountId
|
|
165
|
+
RETURNING id;
|
|
166
|
+
`;
|
|
167
|
+
|
|
168
|
+
@Injectable({
|
|
169
|
+
scope: Scope.Singleton,
|
|
170
|
+
global: true,
|
|
171
|
+
})
|
|
172
|
+
export class FinancialBankAccountsProvider {
|
|
173
|
+
cache = getCacheInstance({
|
|
174
|
+
stdTTL: 60 * 5,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
constructor(private dbProvider: DBProvider) {}
|
|
178
|
+
|
|
179
|
+
private async batchFinancialBankAccountsByIds(bankAccountIds: readonly string[]) {
|
|
180
|
+
const accounts = await getFinancialBankAccountsByIds.run(
|
|
181
|
+
{
|
|
182
|
+
bankAccountIds,
|
|
183
|
+
},
|
|
184
|
+
this.dbProvider,
|
|
185
|
+
);
|
|
186
|
+
return bankAccountIds.map(id => accounts.find(account => account.id === id));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public getFinancialBankAccountByIdLoader = new DataLoader(
|
|
190
|
+
(bankAccountIds: readonly string[]) => this.batchFinancialBankAccountsByIds(bankAccountIds),
|
|
191
|
+
{
|
|
192
|
+
cacheKeyFn: key => `bank-account-id-${key}`,
|
|
193
|
+
cacheMap: this.cache,
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
public getAllFinancialBankAccounts() {
|
|
198
|
+
const cached = this.cache.get<IGetAllFinancialBankAccountsResult[]>('all-bank-accounts');
|
|
199
|
+
if (cached) {
|
|
200
|
+
return Promise.resolve(cached);
|
|
201
|
+
}
|
|
202
|
+
return getAllFinancialBankAccounts.run(undefined, this.dbProvider).then(res => {
|
|
203
|
+
this.cache.set('all-bank-accounts', res);
|
|
204
|
+
res.map(account => {
|
|
205
|
+
this.getFinancialBankAccountByIdLoader.prime(account.id, account);
|
|
206
|
+
});
|
|
207
|
+
return res;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public async updateBankAccount(params: IUpdateBankAccountParams) {
|
|
212
|
+
const updatedAccounts = await updateBankAccount.run(params, this.dbProvider);
|
|
213
|
+
const updatedAccount = updatedAccounts[0];
|
|
214
|
+
if (updatedAccount) {
|
|
215
|
+
this.invalidateById(updatedAccount.id);
|
|
216
|
+
this.getFinancialBankAccountByIdLoader.prime(updatedAccount.id, updatedAccount);
|
|
217
|
+
}
|
|
218
|
+
return updatedAccount;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public async deleteBankAccount(params: IDeleteBankAccountParams) {
|
|
222
|
+
if (params.bankAccountId) {
|
|
223
|
+
this.invalidateById(params.bankAccountId);
|
|
224
|
+
}
|
|
225
|
+
return deleteBankAccount.run(params, this.dbProvider);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public async insertBankAccounts(params: IInsertBankAccountsParams) {
|
|
229
|
+
this.cache.delete('all-bank-accounts');
|
|
230
|
+
return insertBankAccounts.run(params, this.dbProvider);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
public invalidateById(bankAccountId: string) {
|
|
234
|
+
this.cache.delete(`bank-account-id-${bankAccountId}`);
|
|
235
|
+
this.cache.delete('all-bank-accounts');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
public clearCache() {
|
|
239
|
+
this.cache.clear();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -12,14 +12,6 @@ export const financialAccountsResolvers: FinancialAccountsModule.Resolvers = {
|
|
|
12
12
|
return injector.get(FinancialAccountsProvider).getAllFinancialAccounts();
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
|
-
BankFinancialAccount: {
|
|
16
|
-
__isTypeOf: DbAccount => DbAccount.type === 'BANK_ACCOUNT',
|
|
17
|
-
...commonFinancialAccountFields,
|
|
18
|
-
accountNumber: DbAccount => DbAccount.account_number,
|
|
19
|
-
bankNumber: DbAccount => DbAccount.bank_number!.toString(),
|
|
20
|
-
branchNumber: DbAccount => DbAccount.branch_number!.toString(),
|
|
21
|
-
name: DbAccount => `${DbAccount.bank_number}-${DbAccount.account_number}`,
|
|
22
|
-
},
|
|
23
15
|
CardFinancialAccount: {
|
|
24
16
|
__isTypeOf: DbAccount => DbAccount.type === 'CREDIT_CARD',
|
|
25
17
|
...commonFinancialAccountFields,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
import { Injector } from 'graphql-modules';
|
|
3
|
+
import { FinancialBankAccountsProvider } from '../providers/financial-bank-accounts.provider.js';
|
|
4
|
+
import type {
|
|
5
|
+
FinancialAccountsModule,
|
|
6
|
+
IGetFinancialAccountsByOwnerIdsResult,
|
|
7
|
+
IGetFinancialBankAccountsByIdsResult,
|
|
8
|
+
} from '../types.js';
|
|
9
|
+
import { commonFinancialAccountFields } from './common.js';
|
|
10
|
+
|
|
11
|
+
async function getBankAccountByFinancialAccount(
|
|
12
|
+
financialAccount: IGetFinancialAccountsByOwnerIdsResult,
|
|
13
|
+
injector: Injector,
|
|
14
|
+
): Promise<IGetFinancialBankAccountsByIdsResult> {
|
|
15
|
+
const bankAccount = await injector
|
|
16
|
+
.get(FinancialBankAccountsProvider)
|
|
17
|
+
.getFinancialBankAccountByIdLoader.load(financialAccount.id);
|
|
18
|
+
if (!bankAccount) {
|
|
19
|
+
throw new GraphQLError('Bank account not found');
|
|
20
|
+
}
|
|
21
|
+
return bankAccount;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const financialBankAccountsResolvers: FinancialAccountsModule.Resolvers = {
|
|
25
|
+
Query: {
|
|
26
|
+
// allFinancialAccounts: async (_, __, { injector }) => {
|
|
27
|
+
// return injector.get(FinancialAccountsProvider).getAllFinancialAccounts();
|
|
28
|
+
// },
|
|
29
|
+
},
|
|
30
|
+
BankFinancialAccount: {
|
|
31
|
+
__isTypeOf: DbAccount => DbAccount.type === 'BANK_ACCOUNT',
|
|
32
|
+
...commonFinancialAccountFields,
|
|
33
|
+
accountNumber: DbAccount => DbAccount.account_number,
|
|
34
|
+
bankNumber: async (DbAccount, _, { injector }) =>
|
|
35
|
+
getBankAccountByFinancialAccount(DbAccount, injector).then(bankAccount =>
|
|
36
|
+
bankAccount.bank_number.toString(),
|
|
37
|
+
),
|
|
38
|
+
branchNumber: async (DbAccount, _, { injector }) =>
|
|
39
|
+
getBankAccountByFinancialAccount(DbAccount, injector).then(bankAccount =>
|
|
40
|
+
bankAccount.branch_number.toString(),
|
|
41
|
+
),
|
|
42
|
+
name: async (DbAccount, _, { injector }) =>
|
|
43
|
+
getBankAccountByFinancialAccount(DbAccount, injector).then(
|
|
44
|
+
bankAccount => `${bankAccount.bank_number}-${DbAccount.account_number}`,
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -14,17 +14,6 @@ export default gql`
|
|
|
14
14
|
type: String!
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
" represent a single bank account"
|
|
18
|
-
type BankFinancialAccount implements FinancialAccount {
|
|
19
|
-
id: UUID!
|
|
20
|
-
name: String!
|
|
21
|
-
type: String!
|
|
22
|
-
" the external identifier of the bank account "
|
|
23
|
-
accountNumber: String!
|
|
24
|
-
bankNumber: String!
|
|
25
|
-
branchNumber: String!
|
|
26
|
-
}
|
|
27
|
-
|
|
28
17
|
" represent a single credit card "
|
|
29
18
|
type CardFinancialAccount implements FinancialAccount {
|
|
30
19
|
id: UUID!
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { gql } from 'graphql-modules';
|
|
2
|
+
|
|
3
|
+
export default gql`
|
|
4
|
+
" represent a single bank account"
|
|
5
|
+
type BankFinancialAccount implements FinancialAccount {
|
|
6
|
+
id: UUID!
|
|
7
|
+
name: String!
|
|
8
|
+
type: String!
|
|
9
|
+
" the external identifier of the bank account "
|
|
10
|
+
accountNumber: String!
|
|
11
|
+
bankNumber: String!
|
|
12
|
+
branchNumber: String!
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
IGetIssuedDocumentsByIdsResult,
|
|
10
10
|
} from '@modules/documents/types';
|
|
11
11
|
import { FinancialAccountsProvider } from '@modules/financial-accounts/providers/financial-accounts.provider.js';
|
|
12
|
+
import { FinancialBankAccountsProvider } from '@modules/financial-accounts/providers/financial-bank-accounts.provider.js';
|
|
13
|
+
import { IGetFinancialBankAccountsByIdsResult } from '@modules/financial-accounts/types.js';
|
|
12
14
|
import { BusinessesProvider } from '@modules/financial-entities/providers/businesses.provider.js';
|
|
13
15
|
import { IGetTransactionsByChargeIdsResult } from '@modules/transactions/types';
|
|
14
16
|
import { DocumentType } from '@shared/enums';
|
|
@@ -57,6 +59,18 @@ export async function getPaymentsFromTransactions(
|
|
|
57
59
|
break;
|
|
58
60
|
}
|
|
59
61
|
|
|
62
|
+
let bankAccount: IGetFinancialBankAccountsByIdsResult | undefined = undefined;
|
|
63
|
+
if (account.type === 'BANK_ACCOUNT') {
|
|
64
|
+
bankAccount = await injector
|
|
65
|
+
.get(FinancialBankAccountsProvider)
|
|
66
|
+
.getFinancialBankAccountByIdLoader.load(account.id);
|
|
67
|
+
if (!bankAccount) {
|
|
68
|
+
throw new GraphQLError(
|
|
69
|
+
`Bank account details not found for financial account ID "${account.id}"`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
60
74
|
// get further fields
|
|
61
75
|
let paymentTypeSpecificAttributes: Partial<GreenInvoicePayment> = {};
|
|
62
76
|
switch (type as string) {
|
|
@@ -76,8 +90,8 @@ export async function getPaymentsFromTransactions(
|
|
|
76
90
|
break;
|
|
77
91
|
case 'WIRE_TRANSFER':
|
|
78
92
|
paymentTypeSpecificAttributes = {
|
|
79
|
-
bankName:
|
|
80
|
-
bankBranch:
|
|
93
|
+
bankName: bankAccount?.bank_number?.toString(),
|
|
94
|
+
bankBranch: bankAccount?.branch_number?.toString(),
|
|
81
95
|
bankAccount: account.account_number?.toString(),
|
|
82
96
|
};
|
|
83
97
|
break;
|