@accounter/server 0.0.9-alpha-20251216144137-dc7316f892e1fcf0e350cfbbaa9ca0746e1c6c50 → 0.0.9-alpha-20251216161545-668306e40cf3aed663f444e0004246489fbec6d4
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 -28
- package/dist/green-invoice-graphql/src/mesh-artifacts/index.d.ts +1 -1
- package/dist/server/src/__generated__/types.d.ts +301 -282
- package/dist/server/src/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/app-providers/green-invoice-client.d.ts +3 -3
- package/dist/server/src/modules/documents/__generated__/types.d.ts +7 -121
- package/dist/server/src/modules/documents/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/documents/helpers/common.helper.d.ts +0 -2
- package/dist/server/src/modules/documents/helpers/common.helper.js +0 -20
- package/dist/server/src/modules/documents/helpers/common.helper.js.map +1 -1
- package/dist/server/src/modules/documents/index.js +2 -9
- package/dist/server/src/modules/documents/index.js.map +1 -1
- package/dist/server/src/modules/green-invoice/__generated__/types.d.ts +135 -6
- package/dist/server/src/modules/green-invoice/__generated__/types.js +2 -0
- package/dist/server/src/modules/green-invoice/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.d.ts +7 -0
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js +53 -0
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js.map +1 -0
- package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.d.ts +27 -21
- package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.js +146 -151
- package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.js.map +1 -1
- package/dist/server/src/modules/green-invoice/helpers/issue-document.helper.d.ts +19 -0
- package/dist/server/src/modules/{documents → green-invoice}/helpers/issue-document.helper.js +11 -59
- package/dist/server/src/modules/green-invoice/helpers/issue-document.helper.js.map +1 -0
- package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js +347 -4
- package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js.map +1 -1
- package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js +512 -4
- package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js.map +1 -1
- package/dist/shaam-uniform-format-generator/src/generator/records/b110.d.ts +35 -35
- package/dist/shaam-uniform-format-generator/src/types/enums.d.ts +71 -71
- package/package.json +1 -1
- package/src/__generated__/types.ts +620 -327
- package/src/modules/documents/__generated__/types.ts +7 -121
- package/src/modules/documents/helpers/common.helper.ts +0 -21
- package/src/modules/documents/index.ts +2 -9
- package/src/modules/green-invoice/__generated__/types.ts +137 -6
- package/src/modules/green-invoice/helpers/contract-to-draft.helper.ts +69 -0
- package/src/modules/green-invoice/helpers/green-invoice.helper.ts +199 -183
- package/src/modules/{documents → green-invoice}/helpers/issue-document.helper.ts +44 -96
- package/src/modules/green-invoice/resolvers/green-invoice.resolvers.ts +520 -5
- package/src/modules/green-invoice/typeDefs/green-invoice.graphql.ts +512 -4
- package/dist/server/src/modules/documents/helpers/issue-document.helper.d.ts +0 -21
- package/dist/server/src/modules/documents/helpers/issue-document.helper.js.map +0 -1
- package/dist/server/src/modules/documents/resolvers/documents-issuing.resolver.d.ts +0 -2
- package/dist/server/src/modules/documents/resolvers/documents-issuing.resolver.js +0 -346
- package/dist/server/src/modules/documents/resolvers/documents-issuing.resolver.js.map +0 -1
- package/dist/server/src/modules/documents/typeDefs/documents-issuing.graphql.d.ts +0 -2
- package/dist/server/src/modules/documents/typeDefs/documents-issuing.graphql.js +0 -228
- package/dist/server/src/modules/documents/typeDefs/documents-issuing.graphql.js.map +0 -1
- package/src/modules/documents/resolvers/documents-issuing.resolver.ts +0 -529
- package/src/modules/documents/typeDefs/documents-issuing.graphql.ts +0 -228
|
@@ -2,28 +2,34 @@ import { GraphQLError } from 'graphql';
|
|
|
2
2
|
import { Injector } from 'graphql-modules';
|
|
3
3
|
import type {
|
|
4
4
|
_DOLLAR_defs_addDocumentRequest_Input,
|
|
5
|
-
_DOLLAR_defs_Country,
|
|
6
|
-
_DOLLAR_defs_Currency,
|
|
7
5
|
_DOLLAR_defs_Document,
|
|
8
6
|
_DOLLAR_defs_DocumentInputNew_Input,
|
|
9
7
|
_DOLLAR_defs_DocumentLang,
|
|
10
8
|
_DOLLAR_defs_DocumentLinkedDocument,
|
|
11
|
-
_DOLLAR_defs_DocumentType,
|
|
12
9
|
_DOLLAR_defs_ExpenseDocumentType,
|
|
13
10
|
_DOLLAR_defs_VatType,
|
|
11
|
+
_DOLLAR_defs_Currency as GreenInvoiceCurrency,
|
|
12
|
+
_DOLLAR_defs_DocumentType as GreenInvoiceDocumentType,
|
|
13
|
+
query_getDocument_payment_items_appType,
|
|
14
14
|
query_getDocument_payment_items_cardType,
|
|
15
|
+
query_getDocument_payment_items_dealType,
|
|
16
|
+
query_getDocument_payment_items_subType,
|
|
15
17
|
query_getDocument_payment_items_type,
|
|
16
18
|
queryInput_previewDocument_input_discount_type,
|
|
17
19
|
queryInput_previewDocument_input_linkType,
|
|
18
20
|
} from '@accounter/green-invoice-graphql';
|
|
19
21
|
import type {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
GreenInvoiceCountry,
|
|
23
|
+
GreenInvoiceDiscountType,
|
|
24
|
+
GreenInvoiceDocumentLang,
|
|
25
|
+
GreenInvoiceLinkType,
|
|
26
|
+
GreenInvoicePaymentAppType,
|
|
27
|
+
GreenInvoicePaymentCardType,
|
|
28
|
+
GreenInvoicePaymentDealType,
|
|
29
|
+
GreenInvoicePaymentSubType,
|
|
30
|
+
GreenInvoicePaymentType,
|
|
31
|
+
GreenInvoiceVatType,
|
|
32
|
+
NewDocumentInput,
|
|
27
33
|
ResolversTypes,
|
|
28
34
|
} from '../../../__generated__/types.js';
|
|
29
35
|
import { CountryCode, Currency, DocumentType } from '../../../shared/enums.js';
|
|
@@ -37,8 +43,8 @@ import type { document_status, IInsertDocumentsParams } from '../../documents/ty
|
|
|
37
43
|
import { validateClientIntegrations } from '../../financial-entities/helpers/clients.helper.js';
|
|
38
44
|
import { ClientsProvider } from '../../financial-entities/providers/clients.provider.js';
|
|
39
45
|
|
|
40
|
-
export function
|
|
41
|
-
rawType?:
|
|
46
|
+
export function normalizeDocumentType(
|
|
47
|
+
rawType?: GreenInvoiceDocumentType | _DOLLAR_defs_ExpenseDocumentType | number | null,
|
|
42
48
|
): DocumentType {
|
|
43
49
|
if (!rawType) {
|
|
44
50
|
return DocumentType.Unprocessed;
|
|
@@ -79,7 +85,7 @@ export function normalizeGreenInvoiceDocumentType(
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
export function getGreenInvoiceDocumentType(documentType: DocumentType):
|
|
88
|
+
export function getGreenInvoiceDocumentType(documentType: DocumentType): GreenInvoiceDocumentType {
|
|
83
89
|
switch (documentType) {
|
|
84
90
|
case DocumentType.Invoice:
|
|
85
91
|
return '_305';
|
|
@@ -97,7 +103,7 @@ export function getGreenInvoiceDocumentType(documentType: DocumentType): _DOLLAR
|
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
export function getTypeFromGreenInvoiceDocument(
|
|
100
|
-
documentType:
|
|
106
|
+
documentType: GreenInvoiceDocumentType,
|
|
101
107
|
): DocumentType {
|
|
102
108
|
switch (documentType) {
|
|
103
109
|
case '_305':
|
|
@@ -115,18 +121,23 @@ export function getTypeFromGreenInvoiceDocument(
|
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
|
|
118
|
-
export function
|
|
119
|
-
documentType:
|
|
124
|
+
export function getGreenInvoiceDocumentNameFromType(
|
|
125
|
+
documentType: DocumentType | GreenInvoiceDocumentType,
|
|
120
126
|
): string {
|
|
121
127
|
switch (documentType) {
|
|
128
|
+
case DocumentType.Invoice:
|
|
122
129
|
case '_305':
|
|
123
130
|
return 'Tax Invoice';
|
|
131
|
+
case DocumentType.Proforma:
|
|
124
132
|
case '_300':
|
|
125
133
|
return 'Proforma Invoice';
|
|
134
|
+
case DocumentType.InvoiceReceipt:
|
|
126
135
|
case '_320':
|
|
127
136
|
return 'Invoice / Receipt';
|
|
137
|
+
case DocumentType.CreditInvoice:
|
|
128
138
|
case '_330':
|
|
129
139
|
return 'Credit Note';
|
|
140
|
+
case DocumentType.Receipt:
|
|
130
141
|
case '_400':
|
|
131
142
|
return 'Receipt';
|
|
132
143
|
default:
|
|
@@ -134,7 +145,9 @@ export function getDocumentNameFromGreenInvoiceType(
|
|
|
134
145
|
}
|
|
135
146
|
}
|
|
136
147
|
|
|
137
|
-
export function getGreenInvoiceDocumentLanguage(
|
|
148
|
+
export function getGreenInvoiceDocumentLanguage(
|
|
149
|
+
lang: GreenInvoiceDocumentLang,
|
|
150
|
+
): _DOLLAR_defs_DocumentLang {
|
|
138
151
|
switch (lang) {
|
|
139
152
|
case 'HEBREW':
|
|
140
153
|
return 'he';
|
|
@@ -147,7 +160,7 @@ export function getGreenInvoiceDocumentLanguage(lang: DocumentLanguage): _DOLLAR
|
|
|
147
160
|
|
|
148
161
|
export function getLanguageFromGreenInvoiceDocument(
|
|
149
162
|
lang: _DOLLAR_defs_DocumentLang,
|
|
150
|
-
):
|
|
163
|
+
): GreenInvoiceDocumentLang {
|
|
151
164
|
switch (lang) {
|
|
152
165
|
case 'he':
|
|
153
166
|
return 'HEBREW';
|
|
@@ -158,7 +171,7 @@ export function getLanguageFromGreenInvoiceDocument(
|
|
|
158
171
|
}
|
|
159
172
|
}
|
|
160
173
|
|
|
161
|
-
export function getGreenInvoiceDocumentVatType(vatType:
|
|
174
|
+
export function getGreenInvoiceDocumentVatType(vatType: GreenInvoiceVatType): _DOLLAR_defs_VatType {
|
|
162
175
|
switch (vatType) {
|
|
163
176
|
case 'DEFAULT':
|
|
164
177
|
return '_0';
|
|
@@ -171,7 +184,9 @@ export function getGreenInvoiceDocumentVatType(vatType: DocumentVatType): _DOLLA
|
|
|
171
184
|
}
|
|
172
185
|
}
|
|
173
186
|
|
|
174
|
-
export function getVatTypeFromGreenInvoiceDocument(
|
|
187
|
+
export function getVatTypeFromGreenInvoiceDocument(
|
|
188
|
+
vatType: _DOLLAR_defs_VatType,
|
|
189
|
+
): GreenInvoiceVatType {
|
|
175
190
|
switch (vatType) {
|
|
176
191
|
case '_0':
|
|
177
192
|
return 'DEFAULT';
|
|
@@ -185,7 +200,7 @@ export function getVatTypeFromGreenInvoiceDocument(vatType: _DOLLAR_defs_VatType
|
|
|
185
200
|
}
|
|
186
201
|
|
|
187
202
|
export function getGreenInvoiceDocumentDiscountType(
|
|
188
|
-
discountType:
|
|
203
|
+
discountType: GreenInvoiceDiscountType,
|
|
189
204
|
): queryInput_previewDocument_input_discount_type {
|
|
190
205
|
switch (discountType) {
|
|
191
206
|
case 'PERCENTAGE':
|
|
@@ -198,7 +213,7 @@ export function getGreenInvoiceDocumentDiscountType(
|
|
|
198
213
|
}
|
|
199
214
|
|
|
200
215
|
export function getGreenInvoiceDocumentPaymentType(
|
|
201
|
-
type:
|
|
216
|
+
type: GreenInvoicePaymentType,
|
|
202
217
|
): query_getDocument_payment_items_type {
|
|
203
218
|
switch (type) {
|
|
204
219
|
case 'TAX_DEDUCTION':
|
|
@@ -226,7 +241,7 @@ export function getGreenInvoiceDocumentPaymentType(
|
|
|
226
241
|
|
|
227
242
|
export function getTypeFromGreenInvoiceDocumentPayment(
|
|
228
243
|
type: query_getDocument_payment_items_type,
|
|
229
|
-
):
|
|
244
|
+
): GreenInvoicePaymentType {
|
|
230
245
|
switch (type) {
|
|
231
246
|
case 'NEGATIVE_1':
|
|
232
247
|
return 'TAX_DEDUCTION';
|
|
@@ -251,100 +266,100 @@ export function getTypeFromGreenInvoiceDocumentPayment(
|
|
|
251
266
|
}
|
|
252
267
|
}
|
|
253
268
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
269
|
+
export function getGreenInvoiceDocumentPaymentSubType(
|
|
270
|
+
subType: GreenInvoicePaymentSubType,
|
|
271
|
+
): query_getDocument_payment_items_subType {
|
|
272
|
+
switch (subType) {
|
|
273
|
+
case 'BITCOIN':
|
|
274
|
+
return '_1';
|
|
275
|
+
case 'BUYME_VOUCHER':
|
|
276
|
+
return '_7';
|
|
277
|
+
case 'ETHEREUM':
|
|
278
|
+
return '_6';
|
|
279
|
+
case 'GIFT_CARD':
|
|
280
|
+
return '_4';
|
|
281
|
+
case 'MONEY_EQUAL':
|
|
282
|
+
return '_2';
|
|
283
|
+
case 'NII_EMPLOYEE_DEDUCTION':
|
|
284
|
+
return '_5';
|
|
285
|
+
case 'PAYONEER':
|
|
286
|
+
return '_8';
|
|
287
|
+
case 'V_CHECK':
|
|
288
|
+
return '_3';
|
|
289
|
+
default:
|
|
290
|
+
throw new Error(`Unsupported payment sub-type: ${subType}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
278
293
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
294
|
+
export function getSubTypeFromGreenInvoiceDocumentPayment(
|
|
295
|
+
subType: query_getDocument_payment_items_subType,
|
|
296
|
+
): GreenInvoicePaymentSubType {
|
|
297
|
+
switch (subType) {
|
|
298
|
+
case '_1':
|
|
299
|
+
return 'BITCOIN';
|
|
300
|
+
case '_7':
|
|
301
|
+
return 'BUYME_VOUCHER';
|
|
302
|
+
case '_6':
|
|
303
|
+
return 'ETHEREUM';
|
|
304
|
+
case '_4':
|
|
305
|
+
return 'GIFT_CARD';
|
|
306
|
+
case '_2':
|
|
307
|
+
return 'MONEY_EQUAL';
|
|
308
|
+
case '_5':
|
|
309
|
+
return 'NII_EMPLOYEE_DEDUCTION';
|
|
310
|
+
case '_8':
|
|
311
|
+
return 'PAYONEER';
|
|
312
|
+
case '_3':
|
|
313
|
+
return 'V_CHECK';
|
|
314
|
+
default:
|
|
315
|
+
throw new Error(`Unsupported payment sub-type: ${subType}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
303
318
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
319
|
+
export function getGreenInvoiceDocumentPaymentAppType(
|
|
320
|
+
appType: GreenInvoicePaymentAppType,
|
|
321
|
+
): query_getDocument_payment_items_appType {
|
|
322
|
+
switch (appType) {
|
|
323
|
+
case 'APPLE_PAY':
|
|
324
|
+
return '_6';
|
|
325
|
+
case 'BIT':
|
|
326
|
+
return '_1';
|
|
327
|
+
case 'CULO':
|
|
328
|
+
return '_4';
|
|
329
|
+
case 'GOOGLE_PAY':
|
|
330
|
+
return '_5';
|
|
331
|
+
case 'PAYBOX':
|
|
332
|
+
return '_3';
|
|
333
|
+
case 'PAY_BY_PEPPER':
|
|
334
|
+
return '_2';
|
|
335
|
+
default:
|
|
336
|
+
throw new Error(`Unsupported payment app type: ${appType}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
324
339
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
340
|
+
export function getPaymentAppTypeFromGreenInvoiceDocument(
|
|
341
|
+
appType: query_getDocument_payment_items_appType,
|
|
342
|
+
): GreenInvoicePaymentAppType {
|
|
343
|
+
switch (appType) {
|
|
344
|
+
case '_6':
|
|
345
|
+
return 'APPLE_PAY';
|
|
346
|
+
case '_1':
|
|
347
|
+
return 'BIT';
|
|
348
|
+
case '_4':
|
|
349
|
+
return 'CULO';
|
|
350
|
+
case '_5':
|
|
351
|
+
return 'GOOGLE_PAY';
|
|
352
|
+
case '_3':
|
|
353
|
+
return 'PAYBOX';
|
|
354
|
+
case '_2':
|
|
355
|
+
return 'PAY_BY_PEPPER';
|
|
356
|
+
default:
|
|
357
|
+
throw new Error(`Unsupported payment app type: ${appType}`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
345
360
|
|
|
346
361
|
export function getGreenInvoiceDocumentPaymentCardType(
|
|
347
|
-
cardType:
|
|
362
|
+
cardType: GreenInvoicePaymentCardType,
|
|
348
363
|
): query_getDocument_payment_items_cardType {
|
|
349
364
|
switch (cardType) {
|
|
350
365
|
case 'AMERICAN_EXPRESS':
|
|
@@ -366,7 +381,7 @@ export function getGreenInvoiceDocumentPaymentCardType(
|
|
|
366
381
|
|
|
367
382
|
export function getCardTypeFromGreenInvoiceDocumentPayment(
|
|
368
383
|
cardType: query_getDocument_payment_items_cardType,
|
|
369
|
-
):
|
|
384
|
+
): GreenInvoicePaymentCardType {
|
|
370
385
|
switch (cardType) {
|
|
371
386
|
case '_4':
|
|
372
387
|
return 'AMERICAN_EXPRESS';
|
|
@@ -385,50 +400,50 @@ export function getCardTypeFromGreenInvoiceDocumentPayment(
|
|
|
385
400
|
}
|
|
386
401
|
}
|
|
387
402
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
403
|
+
export function getGreenInvoiceDocumentPaymentDealType(
|
|
404
|
+
dealType: GreenInvoicePaymentDealType,
|
|
405
|
+
): query_getDocument_payment_items_dealType {
|
|
406
|
+
switch (dealType) {
|
|
407
|
+
case 'CREDIT':
|
|
408
|
+
return '_3';
|
|
409
|
+
case 'DEFERRED':
|
|
410
|
+
return '_4';
|
|
411
|
+
case 'OTHER':
|
|
412
|
+
return '_5';
|
|
413
|
+
case 'PAYMENTS':
|
|
414
|
+
return '_2';
|
|
415
|
+
case 'RECURRING':
|
|
416
|
+
return '_6';
|
|
417
|
+
case 'STANDARD':
|
|
418
|
+
return '_1';
|
|
419
|
+
default:
|
|
420
|
+
throw new Error(`Unsupported payment deal type: ${dealType}`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
408
423
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
424
|
+
export function getDealTypeFromGreenInvoiceDocumentPayment(
|
|
425
|
+
dealType: query_getDocument_payment_items_dealType,
|
|
426
|
+
): GreenInvoicePaymentDealType {
|
|
427
|
+
switch (dealType) {
|
|
428
|
+
case '_3':
|
|
429
|
+
return 'CREDIT';
|
|
430
|
+
case '_4':
|
|
431
|
+
return 'DEFERRED';
|
|
432
|
+
case '_5':
|
|
433
|
+
return 'OTHER';
|
|
434
|
+
case '_2':
|
|
435
|
+
return 'PAYMENTS';
|
|
436
|
+
case '_6':
|
|
437
|
+
return 'RECURRING';
|
|
438
|
+
case '_1':
|
|
439
|
+
return 'STANDARD';
|
|
440
|
+
default:
|
|
441
|
+
throw new Error(`Unsupported payment deal type: ${dealType}`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
429
444
|
|
|
430
445
|
export function getGreenInvoiceDocumentLinkType(
|
|
431
|
-
linkType:
|
|
446
|
+
linkType: GreenInvoiceLinkType,
|
|
432
447
|
): queryInput_previewDocument_input_linkType {
|
|
433
448
|
switch (linkType) {
|
|
434
449
|
case 'CANCEL':
|
|
@@ -440,7 +455,7 @@ export function getGreenInvoiceDocumentLinkType(
|
|
|
440
455
|
}
|
|
441
456
|
}
|
|
442
457
|
|
|
443
|
-
export function convertCurrencyToGreenInvoice(currency: Currency):
|
|
458
|
+
export function convertCurrencyToGreenInvoice(currency: Currency): GreenInvoiceCurrency {
|
|
444
459
|
switch (currency) {
|
|
445
460
|
case Currency.Aud:
|
|
446
461
|
return 'AUD';
|
|
@@ -467,8 +482,8 @@ export function convertCurrencyToGreenInvoice(currency: Currency): _DOLLAR_defs_
|
|
|
467
482
|
}
|
|
468
483
|
}
|
|
469
484
|
|
|
470
|
-
export function greenInvoiceCountryToCountryCode(country:
|
|
471
|
-
const greenInvoiceToCountryCodeMap: Partial<Record<
|
|
485
|
+
export function greenInvoiceCountryToCountryCode(country: GreenInvoiceCountry): CountryCode {
|
|
486
|
+
const greenInvoiceToCountryCodeMap: Partial<Record<GreenInvoiceCountry, CountryCode>> = {
|
|
472
487
|
AD: CountryCode.Andorra,
|
|
473
488
|
AE: CountryCode['United Arab Emirates (the)'],
|
|
474
489
|
AF: CountryCode.Afghanistan,
|
|
@@ -731,8 +746,8 @@ export function greenInvoiceCountryToCountryCode(country: _DOLLAR_defs_Country):
|
|
|
731
746
|
throw new Error(`Unsupported Green Invoice country: ${country}`);
|
|
732
747
|
}
|
|
733
748
|
|
|
734
|
-
export function countryCodeToGreenInvoiceCountry(countryCode: CountryCode):
|
|
735
|
-
const countryCodeToGreenInvoiceMap: Partial<Record<CountryCode,
|
|
749
|
+
export function countryCodeToGreenInvoiceCountry(countryCode: CountryCode): GreenInvoiceCountry {
|
|
750
|
+
const countryCodeToGreenInvoiceMap: Partial<Record<CountryCode, GreenInvoiceCountry>> = {
|
|
736
751
|
[CountryCode.Afghanistan]: 'AF',
|
|
737
752
|
[CountryCode['Åland Islands']]: 'AX',
|
|
738
753
|
[CountryCode.Albania]: 'AL',
|
|
@@ -1052,7 +1067,7 @@ export async function insertNewDocumentFromGreenInvoice(
|
|
|
1052
1067
|
ownerId: string,
|
|
1053
1068
|
preDictatedChargeId?: string | null,
|
|
1054
1069
|
) {
|
|
1055
|
-
const documentType =
|
|
1070
|
+
const documentType = normalizeDocumentType(greenInvoiceDoc.type);
|
|
1056
1071
|
const isOwnerCreditor = greenInvoiceDoc.amount > 0 && documentType !== DocumentType.CreditInvoice;
|
|
1057
1072
|
|
|
1058
1073
|
const links = await injector.get(GreenInvoiceClientProvider).getDocumentLinks(greenInvoiceDoc.id);
|
|
@@ -1225,16 +1240,16 @@ export async function getGreenInvoiceDocuments(injector: Injector, recursive: bo
|
|
|
1225
1240
|
}
|
|
1226
1241
|
|
|
1227
1242
|
export async function convertDocumentInputIntoGreenInvoiceInput(
|
|
1228
|
-
initialInput:
|
|
1243
|
+
initialInput: NewDocumentInput,
|
|
1229
1244
|
injector: Injector,
|
|
1230
1245
|
): Promise<_DOLLAR_defs_DocumentInputNew_Input> {
|
|
1231
1246
|
let client: _DOLLAR_defs_addDocumentRequest_Input['client'] | undefined = undefined;
|
|
1232
1247
|
if (initialInput.client) {
|
|
1233
1248
|
const clientInfo = await injector
|
|
1234
1249
|
.get(ClientsProvider)
|
|
1235
|
-
.getClientByIdLoader.load(initialInput.client.
|
|
1250
|
+
.getClientByIdLoader.load(initialInput.client.businessId);
|
|
1236
1251
|
if (!clientInfo) {
|
|
1237
|
-
throw new GraphQLError(`Client with
|
|
1252
|
+
throw new GraphQLError(`Client with ID ${initialInput.client.greenInvoiceId} not found`);
|
|
1238
1253
|
}
|
|
1239
1254
|
let greenInvoiceId: string | null = null;
|
|
1240
1255
|
try {
|
|
@@ -1243,12 +1258,12 @@ export async function convertDocumentInputIntoGreenInvoiceInput(
|
|
|
1243
1258
|
} catch (error) {
|
|
1244
1259
|
console.error('Failed to validate client integrations', error);
|
|
1245
1260
|
throw new GraphQLError(
|
|
1246
|
-
`Client with
|
|
1261
|
+
`Client with ID ${initialInput.client.greenInvoiceId} has invalid integrations`,
|
|
1247
1262
|
);
|
|
1248
1263
|
}
|
|
1249
1264
|
if (!greenInvoiceId) {
|
|
1250
1265
|
throw new GraphQLError(
|
|
1251
|
-
`Client with
|
|
1266
|
+
`Client with ID ${initialInput.client.greenInvoiceId} not found in Green Invoice`,
|
|
1252
1267
|
);
|
|
1253
1268
|
}
|
|
1254
1269
|
const greenInvoiceClient = await injector
|
|
@@ -1264,7 +1279,6 @@ export async function convertDocumentInputIntoGreenInvoiceInput(
|
|
|
1264
1279
|
} else {
|
|
1265
1280
|
emails.push(...(greenInvoiceClient.emails ?? []));
|
|
1266
1281
|
}
|
|
1267
|
-
// TODO: use local values
|
|
1268
1282
|
client = {
|
|
1269
1283
|
id: greenInvoiceClient.id,
|
|
1270
1284
|
country: greenInvoiceClient.country,
|
|
@@ -1284,7 +1298,7 @@ export async function convertDocumentInputIntoGreenInvoiceInput(
|
|
|
1284
1298
|
...initialInput,
|
|
1285
1299
|
currency: convertCurrencyToGreenInvoice(initialInput.currency),
|
|
1286
1300
|
type: getGreenInvoiceDocumentType(initialInput.type),
|
|
1287
|
-
lang: getGreenInvoiceDocumentLanguage(initialInput.
|
|
1301
|
+
lang: getGreenInvoiceDocumentLanguage(initialInput.lang),
|
|
1288
1302
|
vatType: getGreenInvoiceDocumentVatType(initialInput.vatType ?? 'DEFAULT'),
|
|
1289
1303
|
discount: initialInput.discount
|
|
1290
1304
|
? {
|
|
@@ -1302,12 +1316,14 @@ export async function convertDocumentInputIntoGreenInvoiceInput(
|
|
|
1302
1316
|
payment: initialInput.payment?.map(payment => ({
|
|
1303
1317
|
...payment,
|
|
1304
1318
|
type: getGreenInvoiceDocumentPaymentType(payment.type),
|
|
1305
|
-
subType: undefined,
|
|
1306
|
-
appType: undefined,
|
|
1319
|
+
subType: payment.subType ? getGreenInvoiceDocumentPaymentSubType(payment.subType) : undefined,
|
|
1320
|
+
appType: payment.appType ? getGreenInvoiceDocumentPaymentAppType(payment.appType) : undefined,
|
|
1307
1321
|
cardType: payment.cardType
|
|
1308
1322
|
? getGreenInvoiceDocumentPaymentCardType(payment.cardType)
|
|
1309
1323
|
: undefined,
|
|
1310
|
-
dealType:
|
|
1324
|
+
dealType: payment.dealType
|
|
1325
|
+
? getGreenInvoiceDocumentPaymentDealType(payment.dealType)
|
|
1326
|
+
: undefined,
|
|
1311
1327
|
currency: convertCurrencyToGreenInvoice(payment.currency),
|
|
1312
1328
|
})),
|
|
1313
1329
|
linkedDocumentIds: initialInput.linkedDocumentIds?.length
|
|
@@ -1319,34 +1335,34 @@ export async function convertDocumentInputIntoGreenInvoiceInput(
|
|
|
1319
1335
|
};
|
|
1320
1336
|
}
|
|
1321
1337
|
|
|
1322
|
-
export
|
|
1338
|
+
export function convertGreenInvoiceDocumentToLocalDocumentInfo(
|
|
1323
1339
|
greenInvoiceDocument: _DOLLAR_defs_Document,
|
|
1324
|
-
|
|
1325
|
-
): Promise<ResolversTypes['DocumentDraft']> {
|
|
1326
|
-
const client = await (greenInvoiceDocument.client?.id
|
|
1327
|
-
? injector
|
|
1328
|
-
.get(ClientsProvider)
|
|
1329
|
-
.getClientByGreenInvoiceIdLoader.load(greenInvoiceDocument.client?.id)
|
|
1330
|
-
: Promise.resolve(undefined));
|
|
1340
|
+
): ResolversTypes['NewDocumentInfo'] {
|
|
1331
1341
|
return {
|
|
1332
1342
|
...greenInvoiceDocument,
|
|
1333
|
-
client,
|
|
1343
|
+
client: greenInvoiceDocument.client?.id,
|
|
1334
1344
|
currency: greenInvoiceDocument.currency as Currency,
|
|
1335
1345
|
income: greenInvoiceDocument.income?.filter(Boolean).map(income => ({
|
|
1336
1346
|
...income!,
|
|
1337
1347
|
currency: income!.currency as Currency,
|
|
1338
1348
|
vatType: getVatTypeFromGreenInvoiceDocument(income!.vatType),
|
|
1339
1349
|
})),
|
|
1340
|
-
|
|
1350
|
+
lang: getLanguageFromGreenInvoiceDocument(greenInvoiceDocument.lang),
|
|
1341
1351
|
payment: greenInvoiceDocument.payment?.filter(Boolean).map(payment => ({
|
|
1342
1352
|
...payment!,
|
|
1343
|
-
appType:
|
|
1353
|
+
appType: payment?.appType
|
|
1354
|
+
? getPaymentAppTypeFromGreenInvoiceDocument(payment.appType)
|
|
1355
|
+
: undefined,
|
|
1344
1356
|
cardType: payment?.cardType
|
|
1345
1357
|
? getCardTypeFromGreenInvoiceDocumentPayment(payment.cardType)
|
|
1346
1358
|
: undefined,
|
|
1347
1359
|
currency: payment!.currency as Currency,
|
|
1348
|
-
dealType:
|
|
1349
|
-
|
|
1360
|
+
dealType: payment?.dealType
|
|
1361
|
+
? getDealTypeFromGreenInvoiceDocumentPayment(payment.dealType)
|
|
1362
|
+
: undefined,
|
|
1363
|
+
subType: payment?.subType
|
|
1364
|
+
? getSubTypeFromGreenInvoiceDocumentPayment(payment.subType)
|
|
1365
|
+
: undefined,
|
|
1350
1366
|
type: getTypeFromGreenInvoiceDocumentPayment(payment!.type),
|
|
1351
1367
|
})),
|
|
1352
1368
|
type: getTypeFromGreenInvoiceDocument(greenInvoiceDocument.type),
|