@accounter/server 0.0.9-alpha-20251216161545-668306e40cf3aed663f444e0004246489fbec6d4 → 0.0.9-alpha-20251216205426-5f8c6ec241db9449687000a5cc5dbb8cbb861623

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +28 -5
  2. package/dist/green-invoice-graphql/src/mesh-artifacts/index.d.ts +1 -1
  3. package/dist/green-invoice-graphql/src/mesh-artifacts/index.js +2 -2
  4. package/dist/green-invoice-graphql/src/mesh-artifacts/index.js.map +1 -1
  5. package/dist/server/src/__generated__/types.d.ts +282 -301
  6. package/dist/server/src/__generated__/types.js.map +1 -1
  7. package/dist/server/src/modules/app-providers/green-invoice-client.d.ts +3 -3
  8. package/dist/server/src/modules/contracts/helpers/contracts.helper.d.ts +2 -0
  9. package/dist/server/src/modules/contracts/helpers/contracts.helper.js +20 -0
  10. package/dist/server/src/modules/contracts/helpers/contracts.helper.js.map +1 -1
  11. package/dist/server/src/modules/documents/__generated__/types.d.ts +121 -7
  12. package/dist/server/src/modules/documents/__generated__/types.js.map +1 -1
  13. package/dist/server/src/modules/documents/helpers/common.helper.d.ts +2 -0
  14. package/dist/server/src/modules/documents/helpers/common.helper.js +20 -0
  15. package/dist/server/src/modules/documents/helpers/common.helper.js.map +1 -1
  16. package/dist/server/src/modules/documents/helpers/issue-document.helper.d.ts +21 -0
  17. package/dist/server/src/modules/{green-invoice → documents}/helpers/issue-document.helper.js +61 -11
  18. package/dist/server/src/modules/documents/helpers/issue-document.helper.js.map +1 -0
  19. package/dist/server/src/modules/documents/index.js +9 -2
  20. package/dist/server/src/modules/documents/index.js.map +1 -1
  21. package/dist/server/src/modules/documents/resolvers/documents-issuing.resolver.d.ts +2 -0
  22. package/dist/server/src/modules/documents/resolvers/documents-issuing.resolver.js +357 -0
  23. package/dist/server/src/modules/documents/resolvers/documents-issuing.resolver.js.map +1 -0
  24. package/dist/server/src/modules/documents/typeDefs/documents-issuing.graphql.d.ts +2 -0
  25. package/dist/server/src/modules/documents/typeDefs/documents-issuing.graphql.js +228 -0
  26. package/dist/server/src/modules/documents/typeDefs/documents-issuing.graphql.js.map +1 -0
  27. package/dist/server/src/modules/green-invoice/__generated__/types.d.ts +6 -135
  28. package/dist/server/src/modules/green-invoice/__generated__/types.js +0 -2
  29. package/dist/server/src/modules/green-invoice/__generated__/types.js.map +1 -1
  30. package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.d.ts +21 -27
  31. package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.js +160 -151
  32. package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.js.map +1 -1
  33. package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js +4 -347
  34. package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js.map +1 -1
  35. package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js +4 -512
  36. package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js.map +1 -1
  37. package/dist/shaam-uniform-format-generator/src/generator/records/b110.d.ts +35 -35
  38. package/dist/shaam-uniform-format-generator/src/types/enums.d.ts +71 -71
  39. package/package.json +2 -2
  40. package/src/__generated__/types.ts +327 -620
  41. package/src/modules/contracts/helpers/contracts.helper.ts +22 -0
  42. package/src/modules/documents/__generated__/types.ts +121 -7
  43. package/src/modules/documents/helpers/common.helper.ts +21 -0
  44. package/src/modules/{green-invoice → documents}/helpers/issue-document.helper.ts +104 -44
  45. package/src/modules/documents/index.ts +9 -2
  46. package/src/modules/documents/resolvers/documents-issuing.resolver.ts +554 -0
  47. package/src/modules/documents/typeDefs/documents-issuing.graphql.ts +228 -0
  48. package/src/modules/green-invoice/__generated__/types.ts +6 -137
  49. package/src/modules/green-invoice/helpers/green-invoice.helper.ts +195 -201
  50. package/src/modules/green-invoice/resolvers/green-invoice.resolvers.ts +5 -520
  51. package/src/modules/green-invoice/typeDefs/green-invoice.graphql.ts +4 -512
  52. package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.d.ts +0 -7
  53. package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js +0 -53
  54. package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js.map +0 -1
  55. package/dist/server/src/modules/green-invoice/helpers/issue-document.helper.d.ts +0 -19
  56. package/dist/server/src/modules/green-invoice/helpers/issue-document.helper.js.map +0 -1
  57. package/src/modules/green-invoice/helpers/contract-to-draft.helper.ts +0 -69
@@ -0,0 +1,357 @@
1
+ import { addMonths, endOfMonth, format, startOfMonth, subMonths } from 'date-fns';
2
+ import { GraphQLError } from 'graphql';
3
+ import { DocumentType } from '../../../shared/enums.js';
4
+ import { dateToTimelessDateString } from '../../../shared/helpers/index.js';
5
+ import { GreenInvoiceClientProvider } from '../../app-providers/green-invoice-client.js';
6
+ import { getChargeBusinesses, getChargeDocumentsMeta, } from '../../charges/helpers/common.helper.js';
7
+ import { ChargesProvider } from '../../charges/providers/charges.provider.js';
8
+ import { getProductName, getSubscriptionPlanName, normalizeProduct, normalizeSubscriptionPlan, } from '../../contracts/helpers/contracts.helper.js';
9
+ import { ContractsProvider } from '../../contracts/providers/contracts.provider.js';
10
+ import { validateClientIntegrations } from '../../financial-entities/helpers/clients.helper.js';
11
+ import { BusinessesProvider } from '../../financial-entities/providers/businesses.provider.js';
12
+ import { ClientsProvider } from '../../financial-entities/providers/clients.provider.js';
13
+ import { convertDocumentInputIntoGreenInvoiceInput, getDocumentNameFromGreenInvoiceType, normalizeGreenInvoiceDocumentType, } from '../../green-invoice/helpers/green-invoice.helper.js';
14
+ import { TransactionsProvider } from '../../transactions/providers/transactions.provider.js';
15
+ import { getDocumentNameFromType } from '../helpers/common.helper.js';
16
+ import { convertContractToDraft, deduceVatTypeFromBusiness, executeDocumentIssue, filterAndHandleSwiftTransactions, getDocumentDateOutOfTransactions, getIncomeRecordsFromDocuments, getLinkedDocumentsAttributes, getPaymentsFromTransactions, getTypeFromDocumentsAndTransactions, } from '../helpers/issue-document.helper.js';
17
+ import { DocumentsProvider } from '../providers/documents.provider.js';
18
+ import { IssuedDocumentsProvider } from '../providers/issued-documents.provider.js';
19
+ import { normalizeDocumentType } from './common.js';
20
+ export const documentsIssuingResolvers = {
21
+ Query: {
22
+ newDocumentDraftByCharge: async (_, { chargeId }, { injector, adminContext: { defaultCryptoConversionFiatCurrency, financialAccounts: { swiftBusinessId }, locality, }, }) => {
23
+ if (!chargeId) {
24
+ throw new GraphQLError('Charge ID is required to fetch document draft');
25
+ }
26
+ const chargePromise = injector.get(ChargesProvider).getChargeByIdLoader.load(chargeId);
27
+ const documentsPromise = injector
28
+ .get(DocumentsProvider)
29
+ .getDocumentsByChargeIdLoader.load(chargeId);
30
+ const transactionsPromise = injector
31
+ .get(TransactionsProvider)
32
+ .transactionsByChargeIDLoader.load(chargeId)
33
+ .then(res => filterAndHandleSwiftTransactions(res, swiftBusinessId));
34
+ const [charge, documents, transactions, { documentsCurrency }, { mainBusinessId }] = await Promise.all([
35
+ chargePromise,
36
+ documentsPromise,
37
+ transactionsPromise,
38
+ getChargeDocumentsMeta(chargeId, injector),
39
+ getChargeBusinesses(chargeId, injector),
40
+ ]);
41
+ if (!charge) {
42
+ throw new GraphQLError(`Charge with ID "${chargeId}" not found`);
43
+ }
44
+ const clientPromise = mainBusinessId
45
+ ? injector.get(ClientsProvider).getClientByIdLoader.load(mainBusinessId)
46
+ : Promise.resolve(undefined);
47
+ const openIssuedDocumentsPromise = injector
48
+ .get(IssuedDocumentsProvider)
49
+ .getIssuedDocumentsByIdLoader.loadMany(documents.map(d => d.id))
50
+ .then(res => res.filter(r => {
51
+ if (!r)
52
+ return false;
53
+ if (r instanceof Error) {
54
+ console.error('Failed to fetch issued document', r);
55
+ return false;
56
+ }
57
+ if (r.status !== 'OPEN') {
58
+ return false;
59
+ }
60
+ return true;
61
+ }));
62
+ const paymentPromise = getPaymentsFromTransactions(injector, transactions);
63
+ const vatTypePromise = deduceVatTypeFromBusiness(injector, locality, mainBusinessId);
64
+ const [client, openIssuedDocuments, payment, vatType] = await Promise.all([
65
+ clientPromise,
66
+ openIssuedDocumentsPromise,
67
+ paymentPromise,
68
+ vatTypePromise,
69
+ ]);
70
+ const greenInvoiceDocuments = await Promise.all(openIssuedDocuments.map(doc => injector
71
+ .get(GreenInvoiceClientProvider)
72
+ .documentLoader.load(doc.external_id)
73
+ .then(res => {
74
+ if (!res) {
75
+ console.error('Failed to fetch document from Green Invoice', doc.external_id);
76
+ return null;
77
+ }
78
+ return res;
79
+ }))).then(res => res.filter(Boolean));
80
+ const greenInvoiceClientId = validateClientIntegrations(client?.integrations ?? {}).greenInvoiceId;
81
+ if (!greenInvoiceClientId) {
82
+ throw new GraphQLError(`Green invoice integration missing for business ID="${mainBusinessId}"`);
83
+ }
84
+ const income = getIncomeRecordsFromDocuments(openIssuedDocuments.map(doc => greenInvoiceDocuments.find(gd => gd.id === doc.external_id)));
85
+ if (income.length === 0 && transactions.length > 0) {
86
+ income.push(...transactions.map(transaction => ({
87
+ description: transaction.source_description ?? '',
88
+ quantity: 1,
89
+ price: Number(transaction.amount),
90
+ currency: transaction.currency,
91
+ currencyRate: undefined,
92
+ vatType,
93
+ })));
94
+ }
95
+ const type = getTypeFromDocumentsAndTransactions(greenInvoiceDocuments.map(doc => ({ type: normalizeGreenInvoiceDocumentType(doc.type) })), transactions);
96
+ const linkedDocsAttributes = getLinkedDocumentsAttributes(openIssuedDocuments, type === DocumentType.CreditInvoice);
97
+ let remarks = charge.user_description;
98
+ if (greenInvoiceDocuments.length) {
99
+ remarks = greenInvoiceDocuments.map(doc => doc.remarks).join(', ');
100
+ switch (type) {
101
+ case DocumentType.Receipt:
102
+ case DocumentType.InvoiceReceipt:
103
+ remarks = `${getDocumentNameFromType(type)} for ${greenInvoiceDocuments.map(doc => `${getDocumentNameFromGreenInvoiceType(doc.type)} ${doc.number}`).join(', ')}`;
104
+ break;
105
+ }
106
+ }
107
+ else if (client?.remark) {
108
+ remarks = client.remark;
109
+ }
110
+ const documentDate = getDocumentDateOutOfTransactions(transactions);
111
+ const transactionsCurrencies = Array.from(new Set(transactions.map(t => t.currency)));
112
+ const transactionsCurrency = transactionsCurrencies.length === 1 ? transactionsCurrencies[0] : undefined;
113
+ const draft = {
114
+ remarks,
115
+ // description: ____,
116
+ // footer: ____,
117
+ type,
118
+ date: documentDate,
119
+ dueDate: dateToTimelessDateString(endOfMonth(new Date())),
120
+ language: 'ENGLISH',
121
+ currency: (transactionsCurrency ||
122
+ documentsCurrency ||
123
+ defaultCryptoConversionFiatCurrency),
124
+ vatType,
125
+ rounding: false,
126
+ signed: true,
127
+ client,
128
+ income,
129
+ payment,
130
+ // linkedPaymentId: ____,
131
+ // maxPayments: _____,
132
+ // discount: _____,
133
+ ...linkedDocsAttributes,
134
+ };
135
+ return draft;
136
+ },
137
+ newDocumentDraftByDocument: async (_, { documentId }, { injector, adminContext: { defaultCryptoConversionFiatCurrency, financialAccounts: { swiftBusinessId }, locality, }, }) => {
138
+ if (!documentId) {
139
+ throw new GraphQLError('Document ID is required to fetch document draft');
140
+ }
141
+ const document = await injector
142
+ .get(DocumentsProvider)
143
+ .getDocumentsByIdLoader.load(documentId);
144
+ if (!document) {
145
+ throw new GraphQLError(`Document with ID "${documentId}" not found`);
146
+ }
147
+ const chargePromise = document.charge_id
148
+ ? injector.get(ChargesProvider).getChargeByIdLoader.load(document.charge_id)
149
+ : Promise.resolve(undefined);
150
+ const transactionsPromise = document.charge_id
151
+ ? injector
152
+ .get(TransactionsProvider)
153
+ .transactionsByChargeIDLoader.load(document.charge_id)
154
+ .then(res => filterAndHandleSwiftTransactions(res, swiftBusinessId))
155
+ : Promise.resolve(undefined);
156
+ const mainBusinessIdPromise = document.charge_id
157
+ ? getChargeBusinesses(document.charge_id, injector).then(res => res.mainBusinessId)
158
+ : Promise.resolve(undefined);
159
+ const [charge, transactions, mainBusinessId] = await Promise.all([
160
+ chargePromise,
161
+ transactionsPromise,
162
+ mainBusinessIdPromise,
163
+ ]);
164
+ if (!charge) {
165
+ throw new GraphQLError(`Charge with ID "${document.charge_id}" not found`);
166
+ }
167
+ const clientPromise = mainBusinessId
168
+ ? injector.get(ClientsProvider).getClientByIdLoader.load(mainBusinessId)
169
+ : Promise.resolve(undefined);
170
+ const openIssuedDocumentPromise = injector
171
+ .get(IssuedDocumentsProvider)
172
+ .getIssuedDocumentsByIdLoader.load(document.id);
173
+ const vatTypePromise = deduceVatTypeFromBusiness(injector, locality, mainBusinessId);
174
+ const [client, openIssuedDocument, vatType] = await Promise.all([
175
+ clientPromise,
176
+ openIssuedDocumentPromise,
177
+ vatTypePromise,
178
+ ]);
179
+ if (!openIssuedDocument) {
180
+ throw new GraphQLError(`Document with ID "${document.id}" doesn't seem like a document we issued`);
181
+ }
182
+ if (openIssuedDocument.status !== 'OPEN') {
183
+ throw new GraphQLError(`Document with ID "${document.id}" is closed`);
184
+ }
185
+ const greenInvoiceDocumentPromise = injector
186
+ .get(GreenInvoiceClientProvider)
187
+ .documentLoader.load(openIssuedDocument.external_id)
188
+ .then(res => {
189
+ if (!res) {
190
+ console.error('Failed to fetch document from Green Invoice', openIssuedDocument.external_id);
191
+ return null;
192
+ }
193
+ return res;
194
+ });
195
+ const paymentPromise = getPaymentsFromTransactions(injector, transactions ?? []);
196
+ const greenInvoiceClientId = validateClientIntegrations(client?.integrations ?? {}).greenInvoiceId;
197
+ if (!greenInvoiceClientId) {
198
+ throw new GraphQLError(`Green invoice integration missing for business ID="${mainBusinessId}"`);
199
+ }
200
+ const [greenInvoiceDocument, payment, { documentsCurrency }] = await Promise.all([
201
+ greenInvoiceDocumentPromise,
202
+ paymentPromise,
203
+ getChargeDocumentsMeta(charge.id, injector),
204
+ ]);
205
+ if (!greenInvoiceDocument) {
206
+ throw new GraphQLError(`Document with ID "${document.id}" doesn't have a Green Invoice matching document`);
207
+ }
208
+ const income = getIncomeRecordsFromDocuments([greenInvoiceDocument]);
209
+ const type = getTypeFromDocumentsAndTransactions([{ type: normalizeDocumentType(document.type) }], transactions ?? []);
210
+ const linkedDocsAttributes = getLinkedDocumentsAttributes([openIssuedDocument], type === DocumentType.CreditInvoice);
211
+ let remarks = greenInvoiceDocument.remarks;
212
+ switch (type) {
213
+ case DocumentType.Receipt:
214
+ case DocumentType.InvoiceReceipt:
215
+ remarks = `${getDocumentNameFromType(type)} for ${getDocumentNameFromGreenInvoiceType(greenInvoiceDocument.type)} ${greenInvoiceDocument.number}`;
216
+ break;
217
+ }
218
+ if (!remarks && client?.remark) {
219
+ remarks = client.remark;
220
+ }
221
+ const documentDate = getDocumentDateOutOfTransactions(transactions ?? []);
222
+ const draft = {
223
+ remarks,
224
+ // description: ____,
225
+ // footer: ____,
226
+ type,
227
+ date: documentDate,
228
+ dueDate: dateToTimelessDateString(endOfMonth(new Date())),
229
+ language: 'ENGLISH',
230
+ currency: (documentsCurrency || defaultCryptoConversionFiatCurrency),
231
+ vatType,
232
+ rounding: false,
233
+ signed: true,
234
+ client,
235
+ income,
236
+ payment,
237
+ // linkedPaymentId: ____,
238
+ // maxPayments: _____,
239
+ // discount: _____,
240
+ ...linkedDocsAttributes,
241
+ };
242
+ return draft;
243
+ },
244
+ periodicalDocumentDrafts: async (_, { issueMonth }, { injector }) => {
245
+ const openContracts = await injector.get(ContractsProvider).getAllOpenContracts();
246
+ const monthlyBillingCycle = 'MONTHLY';
247
+ const monthlyContracts = openContracts.filter(contract => contract.billing_cycle.toLocaleUpperCase() === monthlyBillingCycle);
248
+ const drafts = await Promise.all(monthlyContracts.map(async (contract) => convertContractToDraft(contract, injector, issueMonth)));
249
+ return drafts;
250
+ },
251
+ periodicalDocumentDraftsByContracts: async (_, { issueMonth, contractIds }, { injector }) => {
252
+ const contracts = await injector
253
+ .get(ContractsProvider)
254
+ .getContractsByIdLoader.loadMany(contractIds)
255
+ .then(res => res.filter(c => !!c && !(c instanceof Error)));
256
+ const drafts = await Promise.all(contracts.map(async (contract) => convertContractToDraft(contract, injector, issueMonth)));
257
+ return drafts;
258
+ },
259
+ clientMonthlyChargeDraft: async (_, { clientId, issueMonth }, { injector }) => {
260
+ const clientContracts = await injector
261
+ .get(ContractsProvider)
262
+ .getContractsByClientIdLoader.load(clientId);
263
+ const contracts = clientContracts.filter(clientContract => clientContract.is_active);
264
+ if (contracts.length === 0) {
265
+ throw new GraphQLError(`No active contracts found for client ID="${clientId}"`);
266
+ }
267
+ if (contracts.length > 1) {
268
+ throw new GraphQLError(`Multiple active contracts found for client ID="${clientId}", cannot deduce which one to use`);
269
+ }
270
+ const contract = contracts[0];
271
+ if (!contract) {
272
+ throw new GraphQLError(`Contract not found for client ID="${clientId}"`);
273
+ }
274
+ const businessPromise = injector
275
+ .get(BusinessesProvider)
276
+ .getBusinessByIdLoader.load(contract.client_id);
277
+ const clientPromise = injector
278
+ .get(ClientsProvider)
279
+ .getClientByIdLoader.load(contract.client_id);
280
+ const [business, client] = await Promise.all([businessPromise, clientPromise]);
281
+ if (!business) {
282
+ throw new GraphQLError(`Business ID="${contract.client_id}" not found`);
283
+ }
284
+ if (!client) {
285
+ throw new GraphQLError(`Client not found for business ID="${contract.client_id}"`);
286
+ }
287
+ const greenInvoiceId = validateClientIntegrations(client.integrations)?.greenInvoiceId;
288
+ if (!greenInvoiceId) {
289
+ throw new GraphQLError(`Green invoice match not found for business ID="${contract.client_id}"`);
290
+ }
291
+ const today = issueMonth ? addMonths(new Date(issueMonth), 1) : new Date();
292
+ const monthStart = dateToTimelessDateString(startOfMonth(today));
293
+ const monthEnd = dateToTimelessDateString(endOfMonth(today));
294
+ const year = today.getFullYear() + (today.getMonth() === 0 ? -1 : 0);
295
+ const month = format(subMonths(today, 1), 'MMMM');
296
+ const vatType = await deduceVatTypeFromBusiness(injector, business.country, contract.client_id);
297
+ const draft = {
298
+ remarks: `${contract.purchase_orders[0] ? `PO: ${contract.purchase_orders[0]}${contract.remarks ? ', ' : ''}` : ''}${contract.remarks ?? ''}`,
299
+ description: `${getProductName(normalizeProduct(contract.product ?? ''))} ${getSubscriptionPlanName(normalizeSubscriptionPlan(contract.plan ?? ''))} - ${month} ${year}`,
300
+ type: normalizeDocumentType(contract.document_type),
301
+ date: monthStart,
302
+ dueDate: monthEnd,
303
+ language: 'ENGLISH',
304
+ currency: contract.currency,
305
+ vatType,
306
+ rounding: false,
307
+ signed: true,
308
+ client,
309
+ income: [
310
+ {
311
+ description: `${getProductName(normalizeProduct(contract.product ?? ''))} ${getSubscriptionPlanName(normalizeSubscriptionPlan(contract.plan ?? ''))} - ${month} ${year}`,
312
+ quantity: 1,
313
+ price: contract.amount,
314
+ currency: contract.currency,
315
+ vatType,
316
+ },
317
+ ],
318
+ };
319
+ return draft;
320
+ },
321
+ },
322
+ Mutation: {
323
+ issueGreenInvoiceDocuments: async (_, { generateDocumentsInfo }, { injector, adminContext: { defaultAdminBusinessId } }) => {
324
+ const errors = [];
325
+ await Promise.all(generateDocumentsInfo.map(document => {
326
+ executeDocumentIssue(injector, defaultAdminBusinessId, document, undefined, true, undefined, true).catch(e => {
327
+ console.error(e);
328
+ errors.push(`${document.client?.name ?? document.client?.id}: ${e.message}`);
329
+ });
330
+ }));
331
+ return {
332
+ success: true,
333
+ errors,
334
+ };
335
+ },
336
+ issueGreenInvoiceDocument: async (_, { input: initialInput, emailContent, attachment, chargeId, sendEmail = false }, { injector, adminContext: { defaultAdminBusinessId } }) => {
337
+ return executeDocumentIssue(injector, defaultAdminBusinessId, initialInput, emailContent ?? undefined, attachment ?? undefined, chargeId ?? undefined, sendEmail ?? false);
338
+ },
339
+ previewDocument: async (_, { input: initialInput }, { injector }) => {
340
+ const input = await convertDocumentInputIntoGreenInvoiceInput(initialInput, injector);
341
+ const document = await injector.get(GreenInvoiceClientProvider).previewDocuments({ input });
342
+ if (!document) {
343
+ throw new GraphQLError('Failed to generate document preview');
344
+ }
345
+ if ('errorMessage' in document) {
346
+ console.error('Failed to generate document preview', document);
347
+ throw new GraphQLError(`Failed to generate document preview, Green Invoice returned: ${document.errorMessage}`);
348
+ }
349
+ if ('file' in document && document.file) {
350
+ return document.file;
351
+ }
352
+ console.error('Document preview does not contain a file', document);
353
+ throw new GraphQLError('Document preview does not contain a file');
354
+ },
355
+ },
356
+ };
357
+ //# sourceMappingURL=documents-issuing.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents-issuing.resolver.js","sourceRoot":"","sources":["../../../../../../src/modules/documents/resolvers/documents-issuing.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAY,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAEpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,2DAA2D,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,OAAO,EACL,yCAAyC,EACzC,mCAAmC,EACnC,iCAAiC,GAClC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACp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@
1
+ declare const _default: import("graphql").DocumentNode;
2
+ export default _default;
@@ -0,0 +1,228 @@
1
+ import { gql } from 'graphql-modules';
2
+ export default gql `
3
+ extend type Query {
4
+ newDocumentDraftByCharge(chargeId: UUID!): DocumentDraft! @auth(role: ACCOUNTANT)
5
+ newDocumentDraftByDocument(documentId: UUID!): DocumentDraft! @auth(role: ACCOUNTANT)
6
+ periodicalDocumentDrafts(issueMonth: TimelessDate!): [DocumentDraft!]! @auth(role: ACCOUNTANT)
7
+ periodicalDocumentDraftsByContracts(
8
+ issueMonth: TimelessDate!
9
+ contractIds: [UUID!]!
10
+ ): [DocumentDraft!]! @auth(role: ACCOUNTANT)
11
+
12
+ clientMonthlyChargeDraft(clientId: UUID!, issueMonth: TimelessDate!): DocumentDraft!
13
+ @auth(role: ACCOUNTANT)
14
+ }
15
+
16
+ extend type Mutation {
17
+ issueGreenInvoiceDocuments(
18
+ generateDocumentsInfo: [DocumentIssueInput!]!
19
+ ): GenerateDocumentsResult! @auth(role: ACCOUNTANT)
20
+ issueGreenInvoiceDocument(
21
+ input: DocumentIssueInput!
22
+ emailContent: String
23
+ attachment: Boolean
24
+ chargeId: UUID
25
+ sendEmail: Boolean
26
+ ): Charge! @auth(role: ACCOUNTANT)
27
+ previewDocument(input: DocumentIssueInput!): FileScalar! @auth(role: ACCOUNTANT)
28
+ }
29
+
30
+ " result type for generateDocuments" # eslint-disable-next-line @graphql-eslint/strict-id-in-types -- no current solution for this
31
+ type GenerateDocumentsResult {
32
+ success: Boolean!
33
+ errors: [String!]
34
+ }
35
+
36
+ " for previewing/issuing document "
37
+ type DocumentDraft {
38
+ description: String
39
+ remarks: String
40
+ footer: String
41
+ type: DocumentType!
42
+ date: String
43
+ dueDate: String
44
+ language: DocumentLanguage!
45
+ currency: Currency!
46
+ vatType: DocumentVatType!
47
+ discount: DocumentDiscount
48
+ rounding: Boolean
49
+ signed: Boolean
50
+ maxPayments: Int
51
+ client: Client
52
+ income: [DocumentIncomeRecord!]
53
+ payment: [DocumentPaymentRecord!]
54
+ linkedDocumentIds: [String!]
55
+ linkedPaymentId: String
56
+ linkType: DocumentLinkType
57
+ }
58
+
59
+ " income info "
60
+ type DocumentIncomeRecord {
61
+ currency: Currency!
62
+ currencyRate: Float
63
+ description: String!
64
+ itemId: String
65
+ price: Float!
66
+ quantity: Float!
67
+ vatRate: Float
68
+ vatType: DocumentVatType!
69
+ }
70
+
71
+ " payment info "
72
+ type DocumentPaymentRecord {
73
+ currency: Currency!
74
+ currencyRate: Float
75
+ date: String
76
+ price: Float!
77
+ type: PaymentType!
78
+ " subType: GreenInvoicePaymentSubType "
79
+ bankName: String
80
+ bankBranch: String
81
+ bankAccount: String
82
+ chequeNum: String
83
+ accountId: String
84
+ transactionId: String
85
+ " appType: GreenInvoicePaymentAppType "
86
+ cardType: DocumentPaymentRecordCardType
87
+ cardNum: String
88
+ " dealType: GreenInvoicePaymentDealType "
89
+ numPayments: Int
90
+ firstPayment: Float
91
+ }
92
+
93
+ " document discount info "
94
+ type DocumentDiscount {
95
+ amount: Float!
96
+ type: DocumentDiscountType!
97
+ }
98
+
99
+ " document language enum "
100
+ enum DocumentLanguage {
101
+ ENGLISH
102
+ HEBREW
103
+ }
104
+
105
+ " VAT type enum "
106
+ enum DocumentVatType {
107
+ DEFAULT
108
+ EXEMPT
109
+ MIXED
110
+ }
111
+
112
+ " discount type enum "
113
+ enum DocumentDiscountType {
114
+ SUM
115
+ PERCENTAGE
116
+ }
117
+
118
+ " payment type enum "
119
+ enum PaymentType {
120
+ TAX_DEDUCTION
121
+ CASH
122
+ CHEQUE
123
+ CREDIT_CARD
124
+ WIRE_TRANSFER
125
+ PAYPAL
126
+ OTHER_DEDUCTION
127
+ PAYMENT_APP
128
+ OTHER
129
+ }
130
+
131
+ " link type enum "
132
+ enum DocumentLinkType {
133
+ LINK
134
+ CANCEL
135
+ }
136
+
137
+ " card type enum "
138
+ enum DocumentPaymentRecordCardType {
139
+ UNKNOWN
140
+ ISRACARD
141
+ VISA
142
+ MASTERCARD
143
+ AMERICAN_EXPRESS
144
+ DINERS
145
+ }
146
+
147
+ " input for issuing or previewing document "
148
+ input DocumentIssueInput {
149
+ description: String
150
+ remarks: String
151
+ footer: String
152
+ type: DocumentType!
153
+ date: String
154
+ dueDate: String
155
+ language: DocumentLanguage!
156
+ currency: Currency!
157
+ vatType: DocumentVatType!
158
+ discount: DocumentDiscountInput
159
+ rounding: Boolean
160
+ signed: Boolean
161
+ maxPayments: Int
162
+ client: DocumentClientInput
163
+ income: [DocumentIncomeRecordInput!]
164
+ payment: [DocumentPaymentRecordInput!]
165
+ linkedDocumentIds: [String!]
166
+ linkedPaymentId: String
167
+ linkType: DocumentLinkType
168
+ }
169
+
170
+ " discount input "
171
+ input DocumentDiscountInput {
172
+ amount: Float!
173
+ type: DocumentDiscountType!
174
+ }
175
+
176
+ " client input "
177
+ input DocumentClientInput {
178
+ country: CountryCode
179
+ emails: [String!]
180
+ id: UUID!
181
+ name: String
182
+ phone: String
183
+ taxId: String
184
+ self: Boolean
185
+ address: String
186
+ city: String
187
+ zip: String
188
+ fax: String
189
+ mobile: String
190
+ add: Boolean
191
+ }
192
+
193
+ " income input "
194
+ input DocumentIncomeRecordInput {
195
+ amount: Float
196
+ amountTotal: Float
197
+ catalogNum: String
198
+ currency: Currency!
199
+ currencyRate: Float
200
+ description: String!
201
+ itemId: String
202
+ price: Float!
203
+ quantity: Float!
204
+ vat: Float
205
+ vatRate: Float
206
+ vatType: DocumentVatType!
207
+ }
208
+
209
+ " payment input "
210
+ input DocumentPaymentRecordInput {
211
+ currency: Currency!
212
+ currencyRate: Float
213
+ date: String
214
+ price: Float!
215
+ type: PaymentType!
216
+ bankName: String
217
+ bankBranch: String
218
+ bankAccount: String
219
+ chequeNum: String
220
+ accountId: String
221
+ transactionId: String
222
+ cardType: DocumentPaymentRecordCardType
223
+ cardNum: String
224
+ numPayments: Int
225
+ firstPayment: Float
226
+ }
227
+ `;
228
+ //# sourceMappingURL=documents-issuing.graphql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents-issuing.graphql.js","sourceRoot":"","sources":["../../../../../../src/modules/documents/typeDefs/documents-issuing.graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiOjB,CAAC"}