@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
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
import { Injector } from 'graphql-modules';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { _DOLLAR_defs_Document, _DOLLAR_defs_DocumentInputNew_Input, _DOLLAR_defs_DocumentLang, _DOLLAR_defs_ExpenseDocumentType, _DOLLAR_defs_VatType, _DOLLAR_defs_Currency as GreenInvoiceCurrency, _DOLLAR_defs_DocumentType as GreenInvoiceDocumentType, query_getDocument_payment_items_appType, query_getDocument_payment_items_cardType, query_getDocument_payment_items_dealType, query_getDocument_payment_items_subType, query_getDocument_payment_items_type, queryInput_previewDocument_input_discount_type, queryInput_previewDocument_input_linkType } from '../../../../../green-invoice-graphql/src/index.js';
|
|
3
|
+
import type { GreenInvoiceCountry, GreenInvoiceDiscountType, GreenInvoiceDocumentLang, GreenInvoiceLinkType, GreenInvoicePaymentAppType, GreenInvoicePaymentCardType, GreenInvoicePaymentDealType, GreenInvoicePaymentSubType, GreenInvoicePaymentType, GreenInvoiceVatType, NewDocumentInput, ResolversTypes } from '../../../__generated__/types.js';
|
|
4
4
|
import { CountryCode, Currency, DocumentType } from '../../../shared/enums.js';
|
|
5
5
|
import type { document_status } from '../../documents/types.js';
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function getGreenInvoiceDocumentType(documentType: DocumentType):
|
|
8
|
-
export declare function getTypeFromGreenInvoiceDocument(documentType:
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function getGreenInvoiceDocumentLanguage(lang:
|
|
11
|
-
export declare function getLanguageFromGreenInvoiceDocument(lang: _DOLLAR_defs_DocumentLang):
|
|
12
|
-
export declare function getGreenInvoiceDocumentVatType(vatType:
|
|
13
|
-
export declare function getVatTypeFromGreenInvoiceDocument(vatType: _DOLLAR_defs_VatType):
|
|
14
|
-
export declare function getGreenInvoiceDocumentDiscountType(discountType:
|
|
15
|
-
export declare function getGreenInvoiceDocumentPaymentType(type:
|
|
16
|
-
export declare function getTypeFromGreenInvoiceDocumentPayment(type: query_getDocument_payment_items_type):
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
6
|
+
export declare function normalizeDocumentType(rawType?: GreenInvoiceDocumentType | _DOLLAR_defs_ExpenseDocumentType | number | null): DocumentType;
|
|
7
|
+
export declare function getGreenInvoiceDocumentType(documentType: DocumentType): GreenInvoiceDocumentType;
|
|
8
|
+
export declare function getTypeFromGreenInvoiceDocument(documentType: GreenInvoiceDocumentType): DocumentType;
|
|
9
|
+
export declare function getGreenInvoiceDocumentNameFromType(documentType: DocumentType | GreenInvoiceDocumentType): string;
|
|
10
|
+
export declare function getGreenInvoiceDocumentLanguage(lang: GreenInvoiceDocumentLang): _DOLLAR_defs_DocumentLang;
|
|
11
|
+
export declare function getLanguageFromGreenInvoiceDocument(lang: _DOLLAR_defs_DocumentLang): GreenInvoiceDocumentLang;
|
|
12
|
+
export declare function getGreenInvoiceDocumentVatType(vatType: GreenInvoiceVatType): _DOLLAR_defs_VatType;
|
|
13
|
+
export declare function getVatTypeFromGreenInvoiceDocument(vatType: _DOLLAR_defs_VatType): GreenInvoiceVatType;
|
|
14
|
+
export declare function getGreenInvoiceDocumentDiscountType(discountType: GreenInvoiceDiscountType): queryInput_previewDocument_input_discount_type;
|
|
15
|
+
export declare function getGreenInvoiceDocumentPaymentType(type: GreenInvoicePaymentType): query_getDocument_payment_items_type;
|
|
16
|
+
export declare function getTypeFromGreenInvoiceDocumentPayment(type: query_getDocument_payment_items_type): GreenInvoicePaymentType;
|
|
17
|
+
export declare function getGreenInvoiceDocumentPaymentSubType(subType: GreenInvoicePaymentSubType): query_getDocument_payment_items_subType;
|
|
18
|
+
export declare function getSubTypeFromGreenInvoiceDocumentPayment(subType: query_getDocument_payment_items_subType): GreenInvoicePaymentSubType;
|
|
19
|
+
export declare function getGreenInvoiceDocumentPaymentAppType(appType: GreenInvoicePaymentAppType): query_getDocument_payment_items_appType;
|
|
20
|
+
export declare function getPaymentAppTypeFromGreenInvoiceDocument(appType: query_getDocument_payment_items_appType): GreenInvoicePaymentAppType;
|
|
21
|
+
export declare function getGreenInvoiceDocumentPaymentCardType(cardType: GreenInvoicePaymentCardType): query_getDocument_payment_items_cardType;
|
|
22
|
+
export declare function getCardTypeFromGreenInvoiceDocumentPayment(cardType: query_getDocument_payment_items_cardType): GreenInvoicePaymentCardType;
|
|
23
|
+
export declare function getGreenInvoiceDocumentPaymentDealType(dealType: GreenInvoicePaymentDealType): query_getDocument_payment_items_dealType;
|
|
24
|
+
export declare function getDealTypeFromGreenInvoiceDocumentPayment(dealType: query_getDocument_payment_items_dealType): GreenInvoicePaymentDealType;
|
|
25
|
+
export declare function getGreenInvoiceDocumentLinkType(linkType: GreenInvoiceLinkType): queryInput_previewDocument_input_linkType;
|
|
26
|
+
export declare function convertCurrencyToGreenInvoice(currency: Currency): GreenInvoiceCurrency;
|
|
27
|
+
export declare function greenInvoiceCountryToCountryCode(country: GreenInvoiceCountry): CountryCode;
|
|
28
|
+
export declare function countryCodeToGreenInvoiceCountry(countryCode: CountryCode): GreenInvoiceCountry;
|
|
23
29
|
export declare function greenInvoiceToDocumentStatus(greenInvoiceStatus: number): document_status;
|
|
24
30
|
export declare function getLinkedDocuments(injector: Injector, externalDocumentId: string): Promise<string[] | null>;
|
|
25
31
|
export declare function insertNewDocumentFromGreenInvoice(injector: Injector, greenInvoiceDoc: _DOLLAR_defs_Document, ownerId: string, preDictatedChargeId?: string | null): Promise<import("../../documents/types.js").IInsertDocumentsResult>;
|
|
26
32
|
export declare function getGreenInvoiceDocuments(injector: Injector, recursive?: boolean): Promise<_DOLLAR_defs_Document[]>;
|
|
27
|
-
export declare function convertDocumentInputIntoGreenInvoiceInput(initialInput:
|
|
28
|
-
export declare function
|
|
33
|
+
export declare function convertDocumentInputIntoGreenInvoiceInput(initialInput: NewDocumentInput, injector: Injector): Promise<_DOLLAR_defs_DocumentInputNew_Input>;
|
|
34
|
+
export declare function convertGreenInvoiceDocumentToLocalDocumentInfo(greenInvoiceDocument: _DOLLAR_defs_Document): ResolversTypes['NewDocumentInfo'];
|
|
@@ -8,7 +8,7 @@ import { DocumentsProvider } from '../../documents/providers/documents.provider.
|
|
|
8
8
|
import { IssuedDocumentsProvider } from '../../documents/providers/issued-documents.provider.js';
|
|
9
9
|
import { validateClientIntegrations } from '../../financial-entities/helpers/clients.helper.js';
|
|
10
10
|
import { ClientsProvider } from '../../financial-entities/providers/clients.provider.js';
|
|
11
|
-
export function
|
|
11
|
+
export function normalizeDocumentType(rawType) {
|
|
12
12
|
if (!rawType) {
|
|
13
13
|
return DocumentType.Unprocessed;
|
|
14
14
|
}
|
|
@@ -77,16 +77,21 @@ export function getTypeFromGreenInvoiceDocument(documentType) {
|
|
|
77
77
|
throw new Error(`Unsupported document type: ${documentType}`);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
export function
|
|
80
|
+
export function getGreenInvoiceDocumentNameFromType(documentType) {
|
|
81
81
|
switch (documentType) {
|
|
82
|
+
case DocumentType.Invoice:
|
|
82
83
|
case '_305':
|
|
83
84
|
return 'Tax Invoice';
|
|
85
|
+
case DocumentType.Proforma:
|
|
84
86
|
case '_300':
|
|
85
87
|
return 'Proforma Invoice';
|
|
88
|
+
case DocumentType.InvoiceReceipt:
|
|
86
89
|
case '_320':
|
|
87
90
|
return 'Invoice / Receipt';
|
|
91
|
+
case DocumentType.CreditInvoice:
|
|
88
92
|
case '_330':
|
|
89
93
|
return 'Credit Note';
|
|
94
|
+
case DocumentType.Receipt:
|
|
90
95
|
case '_400':
|
|
91
96
|
return 'Receipt';
|
|
92
97
|
default:
|
|
@@ -195,94 +200,86 @@ export function getTypeFromGreenInvoiceDocumentPayment(type) {
|
|
|
195
200
|
throw new Error(`Unsupported payment type: ${type}`);
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// case '_3':
|
|
279
|
-
// return 'PAYBOX';
|
|
280
|
-
// case '_2':
|
|
281
|
-
// return 'PAY_BY_PEPPER';
|
|
282
|
-
// default:
|
|
283
|
-
// throw new Error(`Unsupported payment app type: ${appType}`);
|
|
284
|
-
// }
|
|
285
|
-
// }
|
|
203
|
+
export function getGreenInvoiceDocumentPaymentSubType(subType) {
|
|
204
|
+
switch (subType) {
|
|
205
|
+
case 'BITCOIN':
|
|
206
|
+
return '_1';
|
|
207
|
+
case 'BUYME_VOUCHER':
|
|
208
|
+
return '_7';
|
|
209
|
+
case 'ETHEREUM':
|
|
210
|
+
return '_6';
|
|
211
|
+
case 'GIFT_CARD':
|
|
212
|
+
return '_4';
|
|
213
|
+
case 'MONEY_EQUAL':
|
|
214
|
+
return '_2';
|
|
215
|
+
case 'NII_EMPLOYEE_DEDUCTION':
|
|
216
|
+
return '_5';
|
|
217
|
+
case 'PAYONEER':
|
|
218
|
+
return '_8';
|
|
219
|
+
case 'V_CHECK':
|
|
220
|
+
return '_3';
|
|
221
|
+
default:
|
|
222
|
+
throw new Error(`Unsupported payment sub-type: ${subType}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
export function getSubTypeFromGreenInvoiceDocumentPayment(subType) {
|
|
226
|
+
switch (subType) {
|
|
227
|
+
case '_1':
|
|
228
|
+
return 'BITCOIN';
|
|
229
|
+
case '_7':
|
|
230
|
+
return 'BUYME_VOUCHER';
|
|
231
|
+
case '_6':
|
|
232
|
+
return 'ETHEREUM';
|
|
233
|
+
case '_4':
|
|
234
|
+
return 'GIFT_CARD';
|
|
235
|
+
case '_2':
|
|
236
|
+
return 'MONEY_EQUAL';
|
|
237
|
+
case '_5':
|
|
238
|
+
return 'NII_EMPLOYEE_DEDUCTION';
|
|
239
|
+
case '_8':
|
|
240
|
+
return 'PAYONEER';
|
|
241
|
+
case '_3':
|
|
242
|
+
return 'V_CHECK';
|
|
243
|
+
default:
|
|
244
|
+
throw new Error(`Unsupported payment sub-type: ${subType}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
export function getGreenInvoiceDocumentPaymentAppType(appType) {
|
|
248
|
+
switch (appType) {
|
|
249
|
+
case 'APPLE_PAY':
|
|
250
|
+
return '_6';
|
|
251
|
+
case 'BIT':
|
|
252
|
+
return '_1';
|
|
253
|
+
case 'CULO':
|
|
254
|
+
return '_4';
|
|
255
|
+
case 'GOOGLE_PAY':
|
|
256
|
+
return '_5';
|
|
257
|
+
case 'PAYBOX':
|
|
258
|
+
return '_3';
|
|
259
|
+
case 'PAY_BY_PEPPER':
|
|
260
|
+
return '_2';
|
|
261
|
+
default:
|
|
262
|
+
throw new Error(`Unsupported payment app type: ${appType}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
export function getPaymentAppTypeFromGreenInvoiceDocument(appType) {
|
|
266
|
+
switch (appType) {
|
|
267
|
+
case '_6':
|
|
268
|
+
return 'APPLE_PAY';
|
|
269
|
+
case '_1':
|
|
270
|
+
return 'BIT';
|
|
271
|
+
case '_4':
|
|
272
|
+
return 'CULO';
|
|
273
|
+
case '_5':
|
|
274
|
+
return 'GOOGLE_PAY';
|
|
275
|
+
case '_3':
|
|
276
|
+
return 'PAYBOX';
|
|
277
|
+
case '_2':
|
|
278
|
+
return 'PAY_BY_PEPPER';
|
|
279
|
+
default:
|
|
280
|
+
throw new Error(`Unsupported payment app type: ${appType}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
286
283
|
export function getGreenInvoiceDocumentPaymentCardType(cardType) {
|
|
287
284
|
switch (cardType) {
|
|
288
285
|
case 'AMERICAN_EXPRESS':
|
|
@@ -319,46 +316,42 @@ export function getCardTypeFromGreenInvoiceDocumentPayment(cardType) {
|
|
|
319
316
|
throw new Error(`Unsupported payment card type: ${cardType}`);
|
|
320
317
|
}
|
|
321
318
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
// default:
|
|
359
|
-
// throw new Error(`Unsupported payment deal type: ${dealType}`);
|
|
360
|
-
// }
|
|
361
|
-
// }
|
|
319
|
+
export function getGreenInvoiceDocumentPaymentDealType(dealType) {
|
|
320
|
+
switch (dealType) {
|
|
321
|
+
case 'CREDIT':
|
|
322
|
+
return '_3';
|
|
323
|
+
case 'DEFERRED':
|
|
324
|
+
return '_4';
|
|
325
|
+
case 'OTHER':
|
|
326
|
+
return '_5';
|
|
327
|
+
case 'PAYMENTS':
|
|
328
|
+
return '_2';
|
|
329
|
+
case 'RECURRING':
|
|
330
|
+
return '_6';
|
|
331
|
+
case 'STANDARD':
|
|
332
|
+
return '_1';
|
|
333
|
+
default:
|
|
334
|
+
throw new Error(`Unsupported payment deal type: ${dealType}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
export function getDealTypeFromGreenInvoiceDocumentPayment(dealType) {
|
|
338
|
+
switch (dealType) {
|
|
339
|
+
case '_3':
|
|
340
|
+
return 'CREDIT';
|
|
341
|
+
case '_4':
|
|
342
|
+
return 'DEFERRED';
|
|
343
|
+
case '_5':
|
|
344
|
+
return 'OTHER';
|
|
345
|
+
case '_2':
|
|
346
|
+
return 'PAYMENTS';
|
|
347
|
+
case '_6':
|
|
348
|
+
return 'RECURRING';
|
|
349
|
+
case '_1':
|
|
350
|
+
return 'STANDARD';
|
|
351
|
+
default:
|
|
352
|
+
throw new Error(`Unsupported payment deal type: ${dealType}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
362
355
|
export function getGreenInvoiceDocumentLinkType(linkType) {
|
|
363
356
|
switch (linkType) {
|
|
364
357
|
case 'CANCEL':
|
|
@@ -955,7 +948,7 @@ export async function getLinkedDocuments(injector, externalDocumentId) {
|
|
|
955
948
|
return linkedDocumentsIds;
|
|
956
949
|
}
|
|
957
950
|
export async function insertNewDocumentFromGreenInvoice(injector, greenInvoiceDoc, ownerId, preDictatedChargeId) {
|
|
958
|
-
const documentType =
|
|
951
|
+
const documentType = normalizeDocumentType(greenInvoiceDoc.type);
|
|
959
952
|
const isOwnerCreditor = greenInvoiceDoc.amount > 0 && documentType !== DocumentType.CreditInvoice;
|
|
960
953
|
const links = await injector.get(GreenInvoiceClientProvider).getDocumentLinks(greenInvoiceDoc.id);
|
|
961
954
|
if (!links) {
|
|
@@ -1106,9 +1099,9 @@ export async function convertDocumentInputIntoGreenInvoiceInput(initialInput, in
|
|
|
1106
1099
|
if (initialInput.client) {
|
|
1107
1100
|
const clientInfo = await injector
|
|
1108
1101
|
.get(ClientsProvider)
|
|
1109
|
-
.getClientByIdLoader.load(initialInput.client.
|
|
1102
|
+
.getClientByIdLoader.load(initialInput.client.businessId);
|
|
1110
1103
|
if (!clientInfo) {
|
|
1111
|
-
throw new GraphQLError(`Client with
|
|
1104
|
+
throw new GraphQLError(`Client with ID ${initialInput.client.greenInvoiceId} not found`);
|
|
1112
1105
|
}
|
|
1113
1106
|
let greenInvoiceId = null;
|
|
1114
1107
|
try {
|
|
@@ -1117,10 +1110,10 @@ export async function convertDocumentInputIntoGreenInvoiceInput(initialInput, in
|
|
|
1117
1110
|
}
|
|
1118
1111
|
catch (error) {
|
|
1119
1112
|
console.error('Failed to validate client integrations', error);
|
|
1120
|
-
throw new GraphQLError(`Client with
|
|
1113
|
+
throw new GraphQLError(`Client with ID ${initialInput.client.greenInvoiceId} has invalid integrations`);
|
|
1121
1114
|
}
|
|
1122
1115
|
if (!greenInvoiceId) {
|
|
1123
|
-
throw new GraphQLError(`Client with
|
|
1116
|
+
throw new GraphQLError(`Client with ID ${initialInput.client.greenInvoiceId} not found in Green Invoice`);
|
|
1124
1117
|
}
|
|
1125
1118
|
const greenInvoiceClient = await injector
|
|
1126
1119
|
.get(GreenInvoiceClientProvider)
|
|
@@ -1136,7 +1129,6 @@ export async function convertDocumentInputIntoGreenInvoiceInput(initialInput, in
|
|
|
1136
1129
|
else {
|
|
1137
1130
|
emails.push(...(greenInvoiceClient.emails ?? []));
|
|
1138
1131
|
}
|
|
1139
|
-
// TODO: use local values
|
|
1140
1132
|
client = {
|
|
1141
1133
|
id: greenInvoiceClient.id,
|
|
1142
1134
|
country: greenInvoiceClient.country,
|
|
@@ -1156,7 +1148,7 @@ export async function convertDocumentInputIntoGreenInvoiceInput(initialInput, in
|
|
|
1156
1148
|
...initialInput,
|
|
1157
1149
|
currency: convertCurrencyToGreenInvoice(initialInput.currency),
|
|
1158
1150
|
type: getGreenInvoiceDocumentType(initialInput.type),
|
|
1159
|
-
lang: getGreenInvoiceDocumentLanguage(initialInput.
|
|
1151
|
+
lang: getGreenInvoiceDocumentLanguage(initialInput.lang),
|
|
1160
1152
|
vatType: getGreenInvoiceDocumentVatType(initialInput.vatType ?? 'DEFAULT'),
|
|
1161
1153
|
discount: initialInput.discount
|
|
1162
1154
|
? {
|
|
@@ -1173,12 +1165,14 @@ export async function convertDocumentInputIntoGreenInvoiceInput(initialInput, in
|
|
|
1173
1165
|
payment: initialInput.payment?.map(payment => ({
|
|
1174
1166
|
...payment,
|
|
1175
1167
|
type: getGreenInvoiceDocumentPaymentType(payment.type),
|
|
1176
|
-
subType: undefined,
|
|
1177
|
-
appType: undefined,
|
|
1168
|
+
subType: payment.subType ? getGreenInvoiceDocumentPaymentSubType(payment.subType) : undefined,
|
|
1169
|
+
appType: payment.appType ? getGreenInvoiceDocumentPaymentAppType(payment.appType) : undefined,
|
|
1178
1170
|
cardType: payment.cardType
|
|
1179
1171
|
? getGreenInvoiceDocumentPaymentCardType(payment.cardType)
|
|
1180
1172
|
: undefined,
|
|
1181
|
-
dealType:
|
|
1173
|
+
dealType: payment.dealType
|
|
1174
|
+
? getGreenInvoiceDocumentPaymentDealType(payment.dealType)
|
|
1175
|
+
: undefined,
|
|
1182
1176
|
currency: convertCurrencyToGreenInvoice(payment.currency),
|
|
1183
1177
|
})),
|
|
1184
1178
|
linkedDocumentIds: initialInput.linkedDocumentIds?.length
|
|
@@ -1189,31 +1183,32 @@ export async function convertDocumentInputIntoGreenInvoiceInput(initialInput, in
|
|
|
1189
1183
|
: undefined,
|
|
1190
1184
|
};
|
|
1191
1185
|
}
|
|
1192
|
-
export
|
|
1193
|
-
const client = await (greenInvoiceDocument.client?.id
|
|
1194
|
-
? injector
|
|
1195
|
-
.get(ClientsProvider)
|
|
1196
|
-
.getClientByGreenInvoiceIdLoader.load(greenInvoiceDocument.client?.id)
|
|
1197
|
-
: Promise.resolve(undefined));
|
|
1186
|
+
export function convertGreenInvoiceDocumentToLocalDocumentInfo(greenInvoiceDocument) {
|
|
1198
1187
|
return {
|
|
1199
1188
|
...greenInvoiceDocument,
|
|
1200
|
-
client,
|
|
1189
|
+
client: greenInvoiceDocument.client?.id,
|
|
1201
1190
|
currency: greenInvoiceDocument.currency,
|
|
1202
1191
|
income: greenInvoiceDocument.income?.filter(Boolean).map(income => ({
|
|
1203
1192
|
...income,
|
|
1204
1193
|
currency: income.currency,
|
|
1205
1194
|
vatType: getVatTypeFromGreenInvoiceDocument(income.vatType),
|
|
1206
1195
|
})),
|
|
1207
|
-
|
|
1196
|
+
lang: getLanguageFromGreenInvoiceDocument(greenInvoiceDocument.lang),
|
|
1208
1197
|
payment: greenInvoiceDocument.payment?.filter(Boolean).map(payment => ({
|
|
1209
1198
|
...payment,
|
|
1210
|
-
appType:
|
|
1199
|
+
appType: payment?.appType
|
|
1200
|
+
? getPaymentAppTypeFromGreenInvoiceDocument(payment.appType)
|
|
1201
|
+
: undefined,
|
|
1211
1202
|
cardType: payment?.cardType
|
|
1212
1203
|
? getCardTypeFromGreenInvoiceDocumentPayment(payment.cardType)
|
|
1213
1204
|
: undefined,
|
|
1214
1205
|
currency: payment.currency,
|
|
1215
|
-
dealType:
|
|
1216
|
-
|
|
1206
|
+
dealType: payment?.dealType
|
|
1207
|
+
? getDealTypeFromGreenInvoiceDocumentPayment(payment.dealType)
|
|
1208
|
+
: undefined,
|
|
1209
|
+
subType: payment?.subType
|
|
1210
|
+
? getSubTypeFromGreenInvoiceDocumentPayment(payment.subType)
|
|
1211
|
+
: undefined,
|
|
1217
1212
|
type: getTypeFromGreenInvoiceDocumentPayment(payment.type),
|
|
1218
1213
|
})),
|
|
1219
1214
|
type: getTypeFromGreenInvoiceDocument(greenInvoiceDocument.type),
|