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