@silexpert/core 2.0.68-4 → 2.0.69

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 (108) hide show
  1. package/dist/api/resources/Account.d.ts +0 -1
  2. package/dist/api/resources/Account.d.ts.map +1 -1
  3. package/dist/api/resources/Account.js +0 -3
  4. package/dist/api/resources/Account.js.map +1 -1
  5. package/dist/api/resources/Acd.d.ts +1 -2
  6. package/dist/api/resources/Acd.d.ts.map +1 -1
  7. package/dist/api/resources/Acd.js +0 -3
  8. package/dist/api/resources/Acd.js.map +1 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +0 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/types/Enum/MailAuto.d.ts +11 -11
  14. package/dist/types/Enum/MailAuto.d.ts.map +1 -1
  15. package/dist/types/Enum/MailAuto.js +48 -0
  16. package/dist/types/Enum/MailAuto.js.map +1 -1
  17. package/dist/types/Interface/api/account/Create.d.ts +1 -5
  18. package/dist/types/Interface/api/account/Create.d.ts.map +1 -1
  19. package/dist/types/Interface/api/account/Create.js +4 -38
  20. package/dist/types/Interface/api/account/Create.js.map +1 -1
  21. package/dist/types/Interface/api/accountingTransaction/QueryTransaction.js +1 -1
  22. package/dist/types/Interface/api/accountingTransaction/QueryTransaction.js.map +1 -1
  23. package/dist/types/Interface/api/commercialManagement/Create.d.ts +2 -1
  24. package/dist/types/Interface/api/commercialManagement/Create.d.ts.map +1 -1
  25. package/dist/types/Interface/api/commercialManagement/Create.js +5 -0
  26. package/dist/types/Interface/api/commercialManagement/Create.js.map +1 -1
  27. package/dist/types/Interface/api/docoon/Create.d.ts +1 -0
  28. package/dist/types/Interface/api/docoon/Create.d.ts.map +1 -1
  29. package/dist/types/Interface/api/docoon/Create.js +8 -1
  30. package/dist/types/Interface/api/docoon/Create.js.map +1 -1
  31. package/dist/types/Interface/api/product/CreateProduct.d.ts +0 -1
  32. package/dist/types/Interface/api/product/CreateProduct.d.ts.map +1 -1
  33. package/dist/types/Interface/api/product/CreateProduct.js +1 -8
  34. package/dist/types/Interface/api/product/CreateProduct.js.map +1 -1
  35. package/dist/types/Interface/api/registration/DeclareRegistration.d.ts +0 -1
  36. package/dist/types/Interface/api/registration/DeclareRegistration.d.ts.map +1 -1
  37. package/dist/types/Interface/api/registration/DeclareRegistration.js +0 -8
  38. package/dist/types/Interface/api/registration/DeclareRegistration.js.map +1 -1
  39. package/dist/types/Interface/api/user/RegisterProspect.d.ts +1 -0
  40. package/dist/types/Interface/api/user/RegisterProspect.d.ts.map +1 -1
  41. package/dist/types/Interface/api/user/RegisterProspect.js.map +1 -1
  42. package/dist/types/Interface/models/IAccount.d.ts +0 -1
  43. package/dist/types/Interface/models/IAccount.d.ts.map +1 -1
  44. package/dist/types/Interface/models/IAccount.js +0 -1
  45. package/dist/types/Interface/models/IAccount.js.map +1 -1
  46. package/dist/types/Interface/models/IAccountingFile.d.ts +1 -0
  47. package/dist/types/Interface/models/IAccountingFile.d.ts.map +1 -1
  48. package/dist/types/Interface/models/IAccountingFile.js +1 -0
  49. package/dist/types/Interface/models/IAccountingFile.js.map +1 -1
  50. package/dist/types/Interface/models/IProduct.d.ts +0 -3
  51. package/dist/types/Interface/models/IProduct.d.ts.map +1 -1
  52. package/dist/types/Interface/models/IProduct.js +0 -2
  53. package/dist/types/Interface/models/IProduct.js.map +1 -1
  54. package/dist/types/Interface/models/IProductInvoice.d.ts +0 -3
  55. package/dist/types/Interface/models/IProductInvoice.d.ts.map +1 -1
  56. package/dist/types/Interface/models/IProductInvoice.js +0 -2
  57. package/dist/types/Interface/models/IProductInvoice.js.map +1 -1
  58. package/dist/types/Interface/models/ISocietyGescom.d.ts +0 -1
  59. package/dist/types/Interface/models/ISocietyGescom.d.ts.map +1 -1
  60. package/dist/types/Interface/models/ISocietyGescom.js +0 -2
  61. package/dist/types/Interface/models/ISocietyGescom.js.map +1 -1
  62. package/dist/types/index.d.ts +0 -1
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/dist/types/index.js +0 -1
  65. package/dist/types/index.js.map +1 -1
  66. package/dist/utils/commercialManagement/document.d.ts +7 -0
  67. package/dist/utils/commercialManagement/document.d.ts.map +1 -1
  68. package/dist/utils/commercialManagement/document.js +129 -2
  69. package/dist/utils/commercialManagement/document.js.map +1 -1
  70. package/dist/utils/index.d.ts +0 -1
  71. package/dist/utils/index.d.ts.map +1 -1
  72. package/dist/utils/index.js +0 -1
  73. package/dist/utils/index.js.map +1 -1
  74. package/package.json +1 -1
  75. package/ts/api/resources/Account.ts +0 -4
  76. package/ts/api/resources/Acd.ts +1 -5
  77. package/ts/index.ts +0 -1
  78. package/ts/types/Enum/MailAuto.ts +66 -1
  79. package/ts/types/Interface/api/account/Create.ts +3 -29
  80. package/ts/types/Interface/api/accountingTransaction/QueryTransaction.ts +1 -1
  81. package/ts/types/Interface/api/commercialManagement/Create.ts +4 -1
  82. package/ts/types/Interface/api/docoon/Create.ts +6 -1
  83. package/ts/types/Interface/api/product/CreateProduct.ts +1 -6
  84. package/ts/types/Interface/api/registration/DeclareRegistration.ts +0 -6
  85. package/ts/types/Interface/api/user/RegisterProspect.ts +1 -0
  86. package/ts/types/Interface/models/IAccount.ts +0 -1
  87. package/ts/types/Interface/models/IAccountingFile.ts +1 -0
  88. package/ts/types/Interface/models/IProduct.ts +0 -3
  89. package/ts/types/Interface/models/IProductInvoice.ts +0 -3
  90. package/ts/types/Interface/models/ISocietyGescom.ts +0 -2
  91. package/ts/types/index.ts +0 -1
  92. package/ts/utils/commercialManagement/document.ts +147 -2
  93. package/ts/utils/index.ts +0 -1
  94. package/dist/types/Interface/api/acd/Vat.d.ts +0 -52
  95. package/dist/types/Interface/api/acd/Vat.d.ts.map +0 -1
  96. package/dist/types/Interface/api/acd/Vat.js +0 -14
  97. package/dist/types/Interface/api/acd/Vat.js.map +0 -1
  98. package/dist/utils/acdVat.d.ts +0 -4
  99. package/dist/utils/acdVat.d.ts.map +0 -1
  100. package/dist/utils/acdVat.js +0 -57
  101. package/dist/utils/acdVat.js.map +0 -1
  102. package/dist/utils/tests/acdVat.spec.d.ts +0 -2
  103. package/dist/utils/tests/acdVat.spec.d.ts.map +0 -1
  104. package/dist/utils/tests/acdVat.spec.js +0 -25
  105. package/dist/utils/tests/acdVat.spec.js.map +0 -1
  106. package/ts/types/Interface/api/acd/Vat.ts +0 -52
  107. package/ts/utils/acdVat.ts +0 -63
  108. package/ts/utils/tests/acdVat.spec.ts +0 -26
@@ -4,4 +4,11 @@ import { CreateInvoiceDocument, CreateMailHeader, CreatePreSaleDocument, ReadCom
4
4
  import 'dayjs/locale/fr.js';
5
5
  export declare function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoiceType, payload: CreateInvoiceDocument | CreatePreSaleDocument, shouldHideBrandName?: boolean, nodeEnv?: string | undefined): ReadCommercialDocumentTemplate;
6
6
  export declare function generateMailHeader(params: CreateMailHeader, shouldHideBrandName?: boolean, nodeEnv?: string | undefined): ReadCommercialMailTemplate;
7
+ /**
8
+ * @description Si cette fonction est modifiée, penser à check si la fonction `checkErrors` de `emission.service.ts` du core doit être modifiée aussi
9
+ */
10
+ export declare function checkCommercialDocumentInformation(payload: CreateInvoiceDocument | CreatePreSaleDocument): {
11
+ valid: boolean;
12
+ errors?: string[];
13
+ };
7
14
  //# sourceMappingURL=document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAG/B,MAAM,wDAAwD,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAO1E,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAK9B,OAAO,oBAAoB,CAAC;AAa5B,wBAAgB,0BAA0B,CACxC,qBAAqB,EAAE,mBAAmB,EAC1C,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,EACtD,mBAAmB,UAAQ,EAC3B,OAAO,GAAE,MAAM,GAAG,SAAqB,GACtC,8BAA8B,CAuIhC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,gBAAgB,EACxB,mBAAmB,UAAQ,EAC3B,OAAO,GAAE,MAAM,GAAG,SAAqB,GACtC,0BAA0B,CA4B5B"}
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAG/B,MAAM,wDAAwD,CAAC;AAQhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAO1E,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAK9B,OAAO,oBAAoB,CAAC;AAa5B,wBAAgB,0BAA0B,CACxC,qBAAqB,EAAE,mBAAmB,EAC1C,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,EACtD,mBAAmB,UAAQ,EAC3B,OAAO,GAAE,MAAM,GAAG,SAAqB,GACtC,8BAA8B,CAuIhC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,gBAAgB,EACxB,mBAAmB,UAAQ,EAC3B,OAAO,GAAE,MAAM,GAAG,SAAqB,GACtC,0BAA0B,CA4B5B;AASD;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,GAAG;IAC1G,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CA4HA"}
@@ -1,12 +1,12 @@
1
1
  import dayjs from 'dayjs';
2
- import { AccountingCategoryList, FontIds, fontList, InvoiceLanguage } from '../../types/Enum/CommercialManagement.js';
2
+ import { AccountingCategoryList, CommercialVatMentionList, FontIds, fontList, InvoiceLanguage, } from '../../types/Enum/CommercialManagement.js';
3
3
  import { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice.js';
4
4
  import { Vat } from '../../types/Enum/Vat.js';
5
5
  import { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount.js';
6
6
  import { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common.js';
7
7
  import { bodyTemplate } from './templates/body.js';
8
8
  import { productToReadProductEditing } from './product.js';
9
- import { vatToReadVatEditing } from './vat.js';
9
+ import { getById, vatToReadVatEditing } from './vat.js';
10
10
  import { thirdPartyToReadThirdPartyEditing } from './thirdParty.js';
11
11
  import { getBrandConfig } from '../brands.js';
12
12
  import { internationalizationChoices, internationalizationConsistency } from './internationalization/choices.js';
@@ -158,4 +158,131 @@ export function generateMailHeader(params, shouldHideBrandName = false, nodeEnv
158
158
  header: ejs.render(mailTemplate.header, data),
159
159
  };
160
160
  }
161
+ function isMissing(value) {
162
+ if (value === null || value === undefined)
163
+ return true;
164
+ if (typeof value === 'string')
165
+ return value.trim().length === 0;
166
+ if (Array.isArray(value))
167
+ return value.length === 0;
168
+ return false;
169
+ }
170
+ /**
171
+ * @description Si cette fonction est modifiée, penser à check si la fonction `checkErrors` de `emission.service.ts` du core doit être modifiée aussi
172
+ */
173
+ export function checkCommercialDocumentInformation(payload) {
174
+ const errors = [];
175
+ const products = orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));
176
+ const vats = orderBy(Object.values(groupBy(products, 'vatFormatted')).map((v) => vatToReadVatEditing(v), 'value')).filter((v) => v.id !== Vat.MARGE.id);
177
+ const totalVats = sumBy(vats, (v) => round(v.amount));
178
+ const totalTaxExcluded = sumBy(products, (p) => round(p.totalTaxExcluded));
179
+ const totalTaxIncluded = round(totalTaxExcluded + totalVats);
180
+ const requiredData = [
181
+ // Invoice
182
+ { value: payload.reference, error: 'Le numéro de facture est obligatoire.' },
183
+ { value: payload.idEstimateInvoiceType, error: 'Le type de document est obligatoire.' },
184
+ { value: payload.emissionDate, error: 'La date d’émission est obligatoire.' },
185
+ // Items
186
+ ...products.flatMap((product, index) => {
187
+ const productLabel = product.itemSaleName?.trim() ? `"${product.itemSaleName}"` : `à la ligne ${index + 1}`;
188
+ return [
189
+ {
190
+ value: product.itemSaleName,
191
+ error: `Le nom de l'article ${productLabel} est obligatoire.`,
192
+ },
193
+ {
194
+ value: product.priceTaxExcluded,
195
+ error: `Le prix net de l'article ${productLabel} est obligatoire.`,
196
+ },
197
+ {
198
+ value: product.quantity,
199
+ error: `La quantité de l'article ${productLabel} est obligatoire.`,
200
+ },
201
+ {
202
+ value: product.unit,
203
+ error: `Le code EN 16931 de l'article ${productLabel} est obligatoire.`,
204
+ },
205
+ {
206
+ value: product.idVat,
207
+ error: `Le type de TVA de l'article ${productLabel} est obligatoire.`,
208
+ },
209
+ {
210
+ value: product.totalTaxExcluded,
211
+ error: `Le montant net de l'article ${productLabel} est obligatoire.`,
212
+ },
213
+ ];
214
+ }),
215
+ // Seller
216
+ { value: payload.name, error: 'Le nom du vendeur est obligatoire.' },
217
+ { value: payload.siren, error: 'Le SIREN du vendeur est obligatoire.' },
218
+ {
219
+ value: payload.zipCode,
220
+ error: 'Le code postal du vendeur est obligatoire.',
221
+ },
222
+ {
223
+ value: payload.street,
224
+ error: 'L’adresse du vendeur est obligatoire.',
225
+ },
226
+ {
227
+ value: payload.city,
228
+ error: 'La ville du vendeur est obligatoire.',
229
+ },
230
+ {
231
+ value: payload.idCountry,
232
+ error: 'Le pays du vendeur est obligatoire.',
233
+ },
234
+ {
235
+ value: payload.settings?.mailContact,
236
+ error: 'L’email du vendeur est obligatoire.',
237
+ },
238
+ // Customer
239
+ {
240
+ value: payload.thirdParty.company ?? payload.thirdParty.fullname ?? 'NA',
241
+ error: 'Le nom de l’acheteur est obligatoire.',
242
+ },
243
+ {
244
+ value: payload.thirdParty?.idCountry,
245
+ error: 'Le pays de l’acheteur est obligatoire.',
246
+ },
247
+ // Vats
248
+ ...vats.flatMap((vat, index) => [
249
+ {
250
+ value: vat.amount,
251
+ error: `Le montant de TVA à la ligne ${index + 1} est obligatoire.`,
252
+ },
253
+ {
254
+ value: vat.base,
255
+ error: `La base d’imposition de la TVA à la ligne ${index + 1} est obligatoire.`,
256
+ },
257
+ {
258
+ value: vat.value,
259
+ error: `Le type de TVA à la ligne ${index + 1} est obligatoire.`,
260
+ },
261
+ ]),
262
+ // Totals
263
+ { value: totalTaxExcluded, error: 'Le montant total hors taxe est obligatoire.' },
264
+ {
265
+ value: totalTaxExcluded,
266
+ error: 'La somme du montant net des lignes est obligatoire.',
267
+ },
268
+ { value: totalVats, error: 'Le montant total de TVA est obligatoire.' },
269
+ {
270
+ value: totalTaxIncluded,
271
+ error: 'Le montant total TTC est obligatoire.',
272
+ },
273
+ ];
274
+ // Check des mentions de tva
275
+ const vatType = CommercialVatMentionList.find((v) => v.value === payload.vatMention)?.taxType ?? 'standard';
276
+ // Si le type de tva est margin, autoliquidation, export ou exempt,
277
+ // aucun produit ne doit avoir de tva > 0
278
+ if (['margin', 'autoliquidation', 'export', 'exempt'].includes(vatType)) {
279
+ for (const product of products) {
280
+ if (getById(product.idVat)?.value !== 0) {
281
+ errors.push(`L'article ${product.itemSaleName} a une TVA non nulle alors que le type de TVA est ${vatType}.`);
282
+ }
283
+ }
284
+ }
285
+ errors.push(...requiredData.filter((data) => isMissing(data.value)).map((data) => data.error));
286
+ return { valid: errors.length === 0, errors: errors.length > 0 ? errors : undefined };
287
+ }
161
288
  //# sourceMappingURL=document.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC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';\nimport {\n ReadCommercialDocumentTemplate,\n ReadDocumentEditing,\n ReadVatEditing,\n} from '../../types/Interface/api/commercialManagement/Read.js';\nimport { AccountingCategoryList, FontIds, fontList, InvoiceLanguage } from '../../types/Enum/CommercialManagement.js';\nimport { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice.js';\nimport { Vat } from '../../types/Enum/Vat.js';\nimport { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount.js';\nimport { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common.js';\nimport { bodyTemplate } from './templates/body.js';\nimport { productToReadProductEditing } from './product.js';\nimport { vatToReadVatEditing } from './vat.js';\nimport {\n CreateInvoiceDocument,\n CreateMailHeader,\n CreatePreSaleDocument,\n ReadCommercialMailTemplate,\n} from '../../types/index.js';\nimport { thirdPartyToReadThirdPartyEditing } from './thirdParty.js';\nimport { getBrandConfig } from '../brands.js';\nimport { internationalizationChoices, internationalizationConsistency } from './internationalization/choices.js';\nimport ejs from 'ejs';\nimport 'dayjs/locale/fr.js';\nimport { orderBy, groupBy, sumBy, round, uniq } from 'lodash-es';\nimport sanitize from 'sanitize-html';\n\ntype brandColorType = {\n primary: string;\n primary50: string;\n primary100: string;\n primary300: string;\n primary500: string;\n primary700: string;\n};\n\nexport function generateCommercialDocument(\n idEstimateInvoiceType: EstimateInvoiceType,\n payload: CreateInvoiceDocument | CreatePreSaleDocument,\n shouldHideBrandName = false,\n nodeEnv: string | undefined = undefined,\n): ReadCommercialDocumentTemplate {\n const products = orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));\n const vats = orderBy(\n Object.values(groupBy(products, 'vatFormatted')).map((v) => vatToReadVatEditing(v), 'value'),\n ).filter((v) => v.id !== Vat.MARGE.id);\n\n const thirdParty = thirdPartyToReadThirdPartyEditing(payload.thirdParty);\n\n let forcedVats: ReadVatEditing[] | undefined = undefined;\n\n if (payload.advanceProducts?.length) {\n const advanceVats = Object.values(groupBy(payload.advanceProducts, 'vatFormatted'))\n .map((v) => vatToReadVatEditing(v), 'value')\n .filter((v) => v.id !== Vat.MARGE.id);\n\n forcedVats = vats.map((v) => {\n const base = v.base - (advanceVats.find((a) => a.id === v.id)?.base ?? 0);\n const toPay = v.toPay - (advanceVats.find((a) => a.id === v.id)?.toPay ?? 0);\n return {\n ...v,\n baseFormatted: integerToFormattedAmountString(base),\n amountFormatted: integerToFormattedAmountString(toPay),\n };\n });\n }\n\n const totalVats = sumBy(vats, (v) => round(v.amount));\n const totalTaxExcluded = sumBy(products, (p) => round(p.totalTaxExcluded));\n\n const totalTaxIncluded = totalTaxExcluded + totalVats;\n\n const locale = payload.language ?? InvoiceLanguage.FR;\n const languageOption = internationalizationChoices[locale];\n\n const accountingCategory = AccountingCategoryList.find((a) => a.id === payload.accountingCategory)?.label ?? null;\n\n const recoveryCost = payload.recoveryCost;\n const data: ReadDocumentEditing & { brandColors: brandColorType; brandName: string; shouldHideBrandName: boolean } = {\n ...payload,\n thirdParty,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType,\n title: payload.title ?? null,\n penalties: payload.penalties\n ? (internationalizationConsistency(locale, payload.penalties, 'penalties') ?? payload.penalties)\n : null,\n termsOfPayment: payload.termsOfPayment\n ? (internationalizationConsistency(locale, payload.termsOfPayment, 'termsOfPayment') ?? payload.termsOfPayment)\n : null,\n recoveryCost: recoveryCost\n ? (internationalizationConsistency(locale, recoveryCost, 'recoveryCost') ?? recoveryCost)\n : null,\n discount: payload.discount\n ? (internationalizationConsistency(locale, payload.discount, 'discount') ?? payload.discount)\n : null,\n vatMention: payload.vatMention\n ? (internationalizationConsistency(locale, payload.vatMention, 'vatMention') ?? payload.vatMention)\n : null,\n phoneContact: payload.settings?.phoneContact ?? null,\n products,\n vats,\n totalTaxExcluded: totalTaxExcluded,\n totalTaxIncluded: round(totalTaxIncluded),\n totalTaxAndDiscountIncluded: round(totalTaxIncluded),\n generalDiscountFormatted: payload.generalDiscount2\n ? integerToFormattedAmountString(payload.generalDiscount2)\n : null,\n depositFormatted: payload.deposit ? integerToFormattedAmountString(payload.deposit) : null,\n totalTaxExcludedFormatted: integerToFormattedAmountString(totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountString(totalTaxIncluded),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(\n totalTaxIncluded - (payload.generalDiscount2 ?? 0) - (payload.deposit ?? 0),\n ),\n totalVatAmountFormatted: integerToFormattedAmountString(totalVats),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name: fontList.find((f) => f.id === payload.settings?.idFont)?.name ?? fontList[0].name,\n url: fontList.find((f) => f.id === payload.settings?.idFont)?.link ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`\n .split('')\n .reduceRight((acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`, '')\n .trim()\n : null,\n dueDateFormatted: payload.dueDate ? dayjs(payload.dueDate).format('DD/MM/YYYY') : null,\n expirationDateFormatted: payload.expirationDate ? dayjs(payload.expirationDate).format('DD/MM/YYYY') : null,\n emissionDateFormatted: payload.emissionDate ? dayjs(payload.emissionDate).format('DD/MM/YYYY') : null,\n shouldDisplayDiscountColumn: !!products.find((p) => p.discount2 && p.discount2 > 0),\n // @ts-ignore\n marginVats: uniq(products.filter((p) => p.marginVatFormatted !== null).map((p) => p.marginVatFormatted)),\n accountingCategoryFormatted: accountingCategory\n ? (internationalizationConsistency(locale, accountingCategory, 'accountingCategory') ?? null)\n : null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv }) as unknown as string}`,\n shouldHideBrandName,\n addressComplement: payload.addressComplement ?? null,\n paymentType: payload.paymentType\n ? (internationalizationConsistency(locale, payload.paymentType, 'paymentType') ?? payload.paymentType)\n : null,\n languageTemplate: languageOption,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n const documentFreeText = [EstimateInvoiceType.DEVIS, EstimateInvoiceType.BON].includes(idEstimateInvoiceType)\n ? payload?.settings?.freeEstimateText\n : payload?.settings?.freeInvoiceText;\n\n return {\n header: ejs.render(commonTemplate.header, data),\n body: ejs.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? sanitize(data.comment?.replace(/\\n/g, '<br/>'), { allowedTags: ['b', 'i', 'em', 'br', 'strong'] })\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? sanitize(p.comment?.replace(/\\n/g, '<br/>'), { allowedTags: ['b', 'i', 'em', 'br', 'strong'] })\n : null,\n // @ts-expect-error\n unitFormatted: internationalizationConsistency(locale, p.unitFormatted, 'unit'),\n })),\n vats: forcedVats ?? vats,\n }),\n footer: ejs.render(commonTemplate.footer, {\n ...data,\n freeText: documentFreeText ?? null,\n }),\n data,\n };\n}\n\nexport function generateMailHeader(\n params: CreateMailHeader,\n shouldHideBrandName = false,\n nodeEnv: string | undefined = undefined,\n): ReadCommercialMailTemplate {\n const locale = params.payload.language ?? InvoiceLanguage.FR;\n const languageOption = internationalizationChoices[locale];\n dayjs.locale('fr');\n const data = {\n ...params.payload,\n totalTaxExcludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded),\n totalVatFormatted: integerToFormattedAmountObject(\n params.payload.totalTaxIncluded - params.payload.totalTaxExcluded,\n ),\n dueDateFormatted: params.payload.dueDate ? dayjs(params.payload.dueDate).format('DD MMMM YYYY') : null,\n hasVat: params.hasVat,\n hostS3: params.hostS3,\n logoUrl: params.logoUrl,\n companyName: params.companyName,\n fileUrl: params.fileUrl,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n shouldHideBrandName,\n languageMail: languageOption,\n };\n\n const mailTemplate = new CommercialDocumentMailHTML();\n\n return {\n header: ejs.render(mailTemplate.header, data),\n };\n}\n"]}
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,OAAO,EACP,QAAQ,EACR,eAAe,GAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAOxD,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACjH,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,QAAQ,MAAM,eAAe,CAAC;AAWrC,MAAM,UAAU,0BAA0B,CACxC,qBAA0C,EAC1C,OAAsD,EACtD,mBAAmB,GAAG,KAAK,EAC3B,UAA8B,SAAS;IAEvC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,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,CAAC,CAAC,CAAC;IAE/F,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACxF,CAAC","sourcesContent":["import dayjs from 'dayjs';\nimport {\n ReadCommercialDocumentTemplate,\n ReadDocumentEditing,\n ReadVatEditing,\n} from '../../types/Interface/api/commercialManagement/Read.js';\nimport {\n AccountingCategoryList,\n CommercialVatMentionList,\n FontIds,\n fontList,\n InvoiceLanguage,\n} from '../../types/Enum/CommercialManagement.js';\nimport { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice.js';\nimport { Vat } from '../../types/Enum/Vat.js';\nimport { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount.js';\nimport { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common.js';\nimport { bodyTemplate } from './templates/body.js';\nimport { productToReadProductEditing } from './product.js';\nimport { getById, vatToReadVatEditing } from './vat.js';\nimport {\n CreateInvoiceDocument,\n CreateMailHeader,\n CreatePreSaleDocument,\n ReadCommercialMailTemplate,\n} from '../../types/index.js';\nimport { thirdPartyToReadThirdPartyEditing } from './thirdParty.js';\nimport { getBrandConfig } from '../brands.js';\nimport { internationalizationChoices, internationalizationConsistency } from './internationalization/choices.js';\nimport ejs from 'ejs';\nimport 'dayjs/locale/fr.js';\nimport { orderBy, groupBy, sumBy, round, uniq } from 'lodash-es';\nimport sanitize from 'sanitize-html';\n\ntype brandColorType = {\n primary: string;\n primary50: string;\n primary100: string;\n primary300: string;\n primary500: string;\n primary700: string;\n};\n\nexport function generateCommercialDocument(\n idEstimateInvoiceType: EstimateInvoiceType,\n payload: CreateInvoiceDocument | CreatePreSaleDocument,\n shouldHideBrandName = false,\n nodeEnv: string | undefined = undefined,\n): ReadCommercialDocumentTemplate {\n const products = orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));\n const vats = orderBy(\n Object.values(groupBy(products, 'vatFormatted')).map((v) => vatToReadVatEditing(v), 'value'),\n ).filter((v) => v.id !== Vat.MARGE.id);\n\n const thirdParty = thirdPartyToReadThirdPartyEditing(payload.thirdParty);\n\n let forcedVats: ReadVatEditing[] | undefined = undefined;\n\n if (payload.advanceProducts?.length) {\n const advanceVats = Object.values(groupBy(payload.advanceProducts, 'vatFormatted'))\n .map((v) => vatToReadVatEditing(v), 'value')\n .filter((v) => v.id !== Vat.MARGE.id);\n\n forcedVats = vats.map((v) => {\n const base = v.base - (advanceVats.find((a) => a.id === v.id)?.base ?? 0);\n const toPay = v.toPay - (advanceVats.find((a) => a.id === v.id)?.toPay ?? 0);\n return {\n ...v,\n baseFormatted: integerToFormattedAmountString(base),\n amountFormatted: integerToFormattedAmountString(toPay),\n };\n });\n }\n\n const totalVats = sumBy(vats, (v) => round(v.amount));\n const totalTaxExcluded = sumBy(products, (p) => round(p.totalTaxExcluded));\n\n const totalTaxIncluded = totalTaxExcluded + totalVats;\n\n const locale = payload.language ?? InvoiceLanguage.FR;\n const languageOption = internationalizationChoices[locale];\n\n const accountingCategory = AccountingCategoryList.find((a) => a.id === payload.accountingCategory)?.label ?? null;\n\n const recoveryCost = payload.recoveryCost;\n const data: ReadDocumentEditing & { brandColors: brandColorType; brandName: string; shouldHideBrandName: boolean } = {\n ...payload,\n thirdParty,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType,\n title: payload.title ?? null,\n penalties: payload.penalties\n ? (internationalizationConsistency(locale, payload.penalties, 'penalties') ?? payload.penalties)\n : null,\n termsOfPayment: payload.termsOfPayment\n ? (internationalizationConsistency(locale, payload.termsOfPayment, 'termsOfPayment') ?? payload.termsOfPayment)\n : null,\n recoveryCost: recoveryCost\n ? (internationalizationConsistency(locale, recoveryCost, 'recoveryCost') ?? recoveryCost)\n : null,\n discount: payload.discount\n ? (internationalizationConsistency(locale, payload.discount, 'discount') ?? payload.discount)\n : null,\n vatMention: payload.vatMention\n ? (internationalizationConsistency(locale, payload.vatMention, 'vatMention') ?? payload.vatMention)\n : null,\n phoneContact: payload.settings?.phoneContact ?? null,\n products,\n vats,\n totalTaxExcluded: totalTaxExcluded,\n totalTaxIncluded: round(totalTaxIncluded),\n totalTaxAndDiscountIncluded: round(totalTaxIncluded),\n generalDiscountFormatted: payload.generalDiscount2\n ? integerToFormattedAmountString(payload.generalDiscount2)\n : null,\n depositFormatted: payload.deposit ? integerToFormattedAmountString(payload.deposit) : null,\n totalTaxExcludedFormatted: integerToFormattedAmountString(totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountString(totalTaxIncluded),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(\n totalTaxIncluded - (payload.generalDiscount2 ?? 0) - (payload.deposit ?? 0),\n ),\n totalVatAmountFormatted: integerToFormattedAmountString(totalVats),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name: fontList.find((f) => f.id === payload.settings?.idFont)?.name ?? fontList[0].name,\n url: fontList.find((f) => f.id === payload.settings?.idFont)?.link ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`\n .split('')\n .reduceRight((acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`, '')\n .trim()\n : null,\n dueDateFormatted: payload.dueDate ? dayjs(payload.dueDate).format('DD/MM/YYYY') : null,\n expirationDateFormatted: payload.expirationDate ? dayjs(payload.expirationDate).format('DD/MM/YYYY') : null,\n emissionDateFormatted: payload.emissionDate ? dayjs(payload.emissionDate).format('DD/MM/YYYY') : null,\n shouldDisplayDiscountColumn: !!products.find((p) => p.discount2 && p.discount2 > 0),\n // @ts-ignore\n marginVats: uniq(products.filter((p) => p.marginVatFormatted !== null).map((p) => p.marginVatFormatted)),\n accountingCategoryFormatted: accountingCategory\n ? (internationalizationConsistency(locale, accountingCategory, 'accountingCategory') ?? null)\n : null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv }) as unknown as string}`,\n shouldHideBrandName,\n addressComplement: payload.addressComplement ?? null,\n paymentType: payload.paymentType\n ? (internationalizationConsistency(locale, payload.paymentType, 'paymentType') ?? payload.paymentType)\n : null,\n languageTemplate: languageOption,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n const documentFreeText = [EstimateInvoiceType.DEVIS, EstimateInvoiceType.BON].includes(idEstimateInvoiceType)\n ? payload?.settings?.freeEstimateText\n : payload?.settings?.freeInvoiceText;\n\n return {\n header: ejs.render(commonTemplate.header, data),\n body: ejs.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? sanitize(data.comment?.replace(/\\n/g, '<br/>'), { allowedTags: ['b', 'i', 'em', 'br', 'strong'] })\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? sanitize(p.comment?.replace(/\\n/g, '<br/>'), { allowedTags: ['b', 'i', 'em', 'br', 'strong'] })\n : null,\n // @ts-expect-error\n unitFormatted: internationalizationConsistency(locale, p.unitFormatted, 'unit'),\n })),\n vats: forcedVats ?? vats,\n }),\n footer: ejs.render(commonTemplate.footer, {\n ...data,\n freeText: documentFreeText ?? null,\n }),\n data,\n };\n}\n\nexport function generateMailHeader(\n params: CreateMailHeader,\n shouldHideBrandName = false,\n nodeEnv: string | undefined = undefined,\n): ReadCommercialMailTemplate {\n const locale = params.payload.language ?? InvoiceLanguage.FR;\n const languageOption = internationalizationChoices[locale];\n dayjs.locale('fr');\n const data = {\n ...params.payload,\n totalTaxExcludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded),\n totalVatFormatted: integerToFormattedAmountObject(\n params.payload.totalTaxIncluded - params.payload.totalTaxExcluded,\n ),\n dueDateFormatted: params.payload.dueDate ? dayjs(params.payload.dueDate).format('DD MMMM YYYY') : null,\n hasVat: params.hasVat,\n hostS3: params.hostS3,\n logoUrl: params.logoUrl,\n companyName: params.companyName,\n fileUrl: params.fileUrl,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n shouldHideBrandName,\n languageMail: languageOption,\n };\n\n const mailTemplate = new CommercialDocumentMailHTML();\n\n return {\n header: ejs.render(mailTemplate.header, data),\n };\n}\n\nfunction isMissing(value: unknown): boolean {\n if (value === null || value === undefined) return true;\n if (typeof value === 'string') return value.trim().length === 0;\n if (Array.isArray(value)) return value.length === 0;\n return false;\n}\n\n/**\n * @description Si cette fonction est modifiée, penser à check si la fonction `checkErrors` de `emission.service.ts` du core doit être modifiée aussi\n */\nexport function checkCommercialDocumentInformation(payload: CreateInvoiceDocument | CreatePreSaleDocument): {\n valid: boolean;\n errors?: string[];\n} {\n const errors: string[] = [];\n\n const products = orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));\n const vats = orderBy(\n Object.values(groupBy(products, 'vatFormatted')).map((v) => vatToReadVatEditing(v), 'value'),\n ).filter((v) => v.id !== Vat.MARGE.id);\n\n const totalVats = sumBy(vats, (v) => round(v.amount));\n const totalTaxExcluded = sumBy(products, (p) => round(p.totalTaxExcluded));\n const totalTaxIncluded = round(totalTaxExcluded + totalVats);\n\n const requiredData: Array<{ value: unknown; error: string }> = [\n // Invoice\n { value: payload.reference, error: 'Le numéro de facture est obligatoire.' },\n { value: payload.idEstimateInvoiceType, error: 'Le type de document est obligatoire.' },\n { value: payload.emissionDate, error: 'La date d’émission est obligatoire.' },\n // Items\n ...products.flatMap((product, index) => {\n const productLabel = product.itemSaleName?.trim() ? `\"${product.itemSaleName}\"` : `à la ligne ${index + 1}`;\n\n return [\n {\n value: product.itemSaleName,\n error: `Le nom de l'article ${productLabel} est obligatoire.`,\n },\n {\n value: product.priceTaxExcluded,\n error: `Le prix net de l'article ${productLabel} est obligatoire.`,\n },\n {\n value: product.quantity,\n error: `La quantité de l'article ${productLabel} est obligatoire.`,\n },\n {\n value: product.unit,\n error: `Le code EN 16931 de l'article ${productLabel} est obligatoire.`,\n },\n {\n value: product.idVat,\n error: `Le type de TVA de l'article ${productLabel} est obligatoire.`,\n },\n {\n value: product.totalTaxExcluded,\n error: `Le montant net de l'article ${productLabel} est obligatoire.`,\n },\n ];\n }),\n // Seller\n { value: payload.name, error: 'Le nom du vendeur est obligatoire.' },\n { value: payload.siren, error: 'Le SIREN du vendeur est obligatoire.' },\n {\n value: payload.zipCode,\n error: 'Le code postal du vendeur est obligatoire.',\n },\n {\n value: payload.street,\n error: 'L’adresse du vendeur est obligatoire.',\n },\n {\n value: payload.city,\n error: 'La ville du vendeur est obligatoire.',\n },\n {\n value: payload.idCountry,\n error: 'Le pays du vendeur est obligatoire.',\n },\n {\n value: payload.settings?.mailContact,\n error: 'L’email du vendeur est obligatoire.',\n },\n // Customer\n {\n value: payload.thirdParty.company ?? payload.thirdParty.fullname ?? 'NA',\n error: 'Le nom de l’acheteur est obligatoire.',\n },\n {\n value: payload.thirdParty?.idCountry,\n error: 'Le pays de l’acheteur est obligatoire.',\n },\n // Vats\n ...vats.flatMap((vat, index) => [\n {\n value: vat.amount,\n error: `Le montant de TVA à la ligne ${index + 1} est obligatoire.`,\n },\n {\n value: vat.base,\n error: `La base d’imposition de la TVA à la ligne ${index + 1} est obligatoire.`,\n },\n {\n value: vat.value,\n error: `Le type de TVA à la ligne ${index + 1} est obligatoire.`,\n },\n ]),\n // Totals\n { value: totalTaxExcluded, error: 'Le montant total hors taxe est obligatoire.' },\n {\n value: totalTaxExcluded,\n error: 'La somme du montant net des lignes est obligatoire.',\n },\n { value: totalVats, error: 'Le montant total de TVA est obligatoire.' },\n {\n value: totalTaxIncluded,\n error: 'Le montant total TTC est obligatoire.',\n },\n ];\n\n // Check des mentions de tva\n const vatType = CommercialVatMentionList.find((v) => v.value === payload.vatMention)?.taxType ?? 'standard';\n\n // Si le type de tva est margin, autoliquidation, export ou exempt,\n // aucun produit ne doit avoir de tva > 0\n if (['margin', 'autoliquidation', 'export', 'exempt'].includes(vatType)) {\n for (const product of products) {\n if (getById(product.idVat)?.value !== 0) {\n errors.push(`L'article ${product.itemSaleName} a une TVA non nulle alors que le type de TVA est ${vatType}.`);\n }\n }\n }\n\n errors.push(...requiredData.filter((data) => isMissing(data.value)).map((data) => data.error));\n\n return { valid: errors.length === 0, errors: errors.length > 0 ? errors : undefined };\n}\n"]}
@@ -20,7 +20,6 @@ export * from './bankAccount.js';
20
20
  export * from './commercialOffer.js';
21
21
  export * from './societyApproval.js';
22
22
  export * from './commercialManagement/saleEmail.js';
23
- export * from './acdVat.js';
24
23
  export * from './transforms/boolean.transform.js';
25
24
  export * from './transforms/number.transform.js';
26
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC"}
@@ -20,7 +20,6 @@ export * from './bankAccount.js';
20
20
  export * from './commercialOffer.js';
21
21
  export * from './societyApproval.js';
22
22
  export * from './commercialManagement/saleEmail.js';
23
- export * from './acdVat.js';
24
23
  export * from './transforms/boolean.transform.js';
25
24
  export * from './transforms/number.transform.js';
26
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC","sourcesContent":["export * from './objectUtils/index.js';\nexport * from './stringUtils/index.js';\nexport * from './brands.js';\nexport * from './webmail.js';\nexport * from './decorators/isE164PhoneNumber.decorator.js';\nexport * from './documents.js';\nexport * from './balanceSheetModule.js';\nexport * from './siretValidation.js';\nexport * from './statutsGeneration.js';\nexport * from './exercice.js';\nexport * from './prestation.js';\nexport * from './task.js';\nexport * from './social.js';\nexport * from './commercialManagement/recurrence.js';\nexport * from './amount.js';\nexport * from './quotation.js';\nexport * from './isHtml.js';\nexport * from './isUrl.js';\nexport * from './bankAccount.js';\nexport * from './commercialOffer.js';\nexport * from './societyApproval.js';\nexport * from './commercialManagement/saleEmail.js';\nexport * from './acdVat.js';\nexport * from './transforms/boolean.transform.js';\nexport * from './transforms/number.transform.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC","sourcesContent":["export * from './objectUtils/index.js';\nexport * from './stringUtils/index.js';\nexport * from './brands.js';\nexport * from './webmail.js';\nexport * from './decorators/isE164PhoneNumber.decorator.js';\nexport * from './documents.js';\nexport * from './balanceSheetModule.js';\nexport * from './siretValidation.js';\nexport * from './statutsGeneration.js';\nexport * from './exercice.js';\nexport * from './prestation.js';\nexport * from './task.js';\nexport * from './social.js';\nexport * from './commercialManagement/recurrence.js';\nexport * from './amount.js';\nexport * from './quotation.js';\nexport * from './isHtml.js';\nexport * from './isUrl.js';\nexport * from './bankAccount.js';\nexport * from './commercialOffer.js';\nexport * from './societyApproval.js';\nexport * from './commercialManagement/saleEmail.js';\nexport * from './transforms/boolean.transform.js';\nexport * from './transforms/number.transform.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "2.0.68-4",
3
+ "version": "2.0.69",
4
4
  "description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
5
5
  "keywords": [
6
6
  "accounting",
@@ -37,10 +37,6 @@ export class Account extends Resource {
37
37
  return this.axios.$post(`/society/${idSociety}/accountsSociety`, params);
38
38
  }
39
39
 
40
- getOrCreateAccountsSociety(idSociety: number, params: CreateAccountSociety): Promise<IAccount> {
41
- return this.axios.$post(`/society/${idSociety}/accountsSociety/get-or-create`, params);
42
- }
43
-
44
40
  getGenericAccounts(): Promise<BasePaginate<IAccount>> {
45
41
  return this.axios.$get('/society/genericAccounts');
46
42
  }
@@ -1,12 +1,8 @@
1
- import type { CreateAcdAuthentication, IAccount } from '../../index.js';
1
+ import { CreateAcdAuthentication } from '../../index.js';
2
2
  import { Resource } from '../Resource.js';
3
3
 
4
4
  export class Acd extends Resource {
5
5
  authenticate(body: CreateAcdAuthentication): Promise<{ token: string }> {
6
6
  return this.axios.$post('/connectors/acd/authenticate', body);
7
7
  }
8
-
9
- getAccounts(): Promise<IAccount[]> {
10
- return this.axios.$get('/connectors/acd/accounts');
11
- }
12
8
  }
package/ts/index.ts CHANGED
@@ -2,6 +2,5 @@ export * from './utils/index.js';
2
2
  export * from './utils/commercialManagement/product.js';
3
3
  export * from './utils/commercialManagement/vat.js';
4
4
  export * from './utils/commercialManagement/recovery.js';
5
- export * from './utils/acdVat.js';
6
5
  export * from './types/index.js';
7
6
  export * from './api/index.js';
@@ -228,7 +228,21 @@ export const MailAutoTypeDetail = [
228
228
  },
229
229
  ];
230
230
 
231
- export const MailAutoList = [
231
+ export interface MailAutoListField {
232
+ name: string;
233
+ lg?: string;
234
+ }
235
+
236
+ interface MailAutoListItem {
237
+ id: MailAuto;
238
+ onlyforRoles: string[] | null;
239
+ alias: string;
240
+ title: string;
241
+ subject: string | ((sendRefusedTemplate: boolean) => string);
242
+ fields: MailAutoListField[];
243
+ }
244
+
245
+ export const MailAutoList: MailAutoListItem[] = [
232
246
  {
233
247
  id: MailAuto.ASK_DOCUMENTS_FOR_BALANCE_SHEET,
234
248
  onlyforRoles: null,
@@ -253,4 +267,55 @@ export const MailAutoList = [
253
267
  subject: 'Rejet de prélèvement',
254
268
  fields: [{ name: 'to', lg: 'xs12 sm5' }, { name: 'subject', lg: 'xs12 sm7' }, { name: 'contentHtml' }],
255
269
  },
270
+ {
271
+ id: MailAuto.ASK_DOCUMENTS_CHECKLIST,
272
+ onlyforRoles: null,
273
+ alias: 'checklist-ask-documents',
274
+ title: 'Demande de documents',
275
+ subject: 'Demande de documents',
276
+ fields: [],
277
+ },
278
+ {
279
+ id: MailAuto.RELAUNCH_DOCUMENTS_CHECKLIST,
280
+ onlyforRoles: null,
281
+ alias: 'checklist-relaunch-documents',
282
+ title: 'Relance demande de documents',
283
+ subject: (sendRefusedTemplate: boolean) =>
284
+ sendRefusedTemplate ? "Refus d'un document" : 'Relance demande de documents',
285
+ fields: [],
286
+ },
287
+ {
288
+ id: MailAuto.ASK_DOCUMENTS_CUT_OFF,
289
+ onlyforRoles: null,
290
+ alias: 'cut-off-ask-documents',
291
+ title: "Demande d'informations et documents complémentaires",
292
+ subject: "Demande d'informations et documents complémentaires",
293
+ fields: [],
294
+ },
295
+ {
296
+ id: MailAuto.RELAUNCH_DOCUMENTS_CUT_OFF,
297
+ onlyforRoles: null,
298
+ alias: 'cut-off-relaunch-documents',
299
+ title: 'Relance demande de documents',
300
+ subject: (sendRefusedTemplate: boolean) =>
301
+ sendRefusedTemplate ? "Refus d'un document" : 'Relance demande de documents',
302
+ fields: [],
303
+ },
304
+ {
305
+ id: MailAuto.ASK_DOCUMENTS_BANK_STATEMENT,
306
+ onlyforRoles: null,
307
+ alias: 'ask-documents-bank-statement',
308
+ title: 'Demande de documents',
309
+ subject: 'Demande de documents',
310
+ fields: [],
311
+ },
312
+ {
313
+ id: MailAuto.RELAUNCH_DOCUMENTS_BANK_STATEMENT,
314
+ onlyforRoles: null,
315
+ alias: 'relaunch-documents-bank-statement',
316
+ title: 'Relance demande de documents',
317
+ subject: (sendRefusedTemplate: boolean) =>
318
+ sendRefusedTemplate ? "Refus d'un document" : 'Relance demande de documents',
319
+ fields: [],
320
+ },
256
321
  ];
@@ -1,45 +1,19 @@
1
- import { IsArray, IsDateString, IsNumber, IsOptional, IsString, IsBoolean, IsObject, IsInt } from 'class-validator';
1
+ import { IsArray, IsDateString, IsNumber, IsOptional, IsString } from 'class-validator';
2
2
  import { IAccount } from '../../../index.js';
3
3
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
4
4
 
5
5
  export class CreateAccountSociety {
6
6
  @ApiProperty()
7
- @IsInt()
8
7
  number: number;
9
8
 
10
9
  @ApiProperty()
11
- @IsString()
12
10
  name: string;
13
11
 
14
- @ApiPropertyOptional()
15
- @IsInt()
16
- @IsOptional()
17
- idNature?: number;
18
-
19
- @ApiPropertyOptional()
20
- @IsInt()
21
- @IsOptional()
22
- idAccountType?: number;
12
+ @ApiProperty()
13
+ idParentAccount: number;
23
14
 
24
15
  @ApiPropertyOptional()
25
- @IsInt()
26
- @IsOptional()
27
16
  idVat?: number;
28
-
29
- @ApiPropertyOptional()
30
- @IsInt()
31
- @IsOptional()
32
- idParentAccount?: number;
33
-
34
- @ApiPropertyOptional()
35
- @IsBoolean()
36
- @IsOptional()
37
- isGeneric?: boolean;
38
-
39
- @ApiPropertyOptional()
40
- @IsObject()
41
- @IsOptional()
42
- metadata?: Record<string, any>;
43
17
  }
44
18
 
45
19
  export class CreateAccount {
@@ -2,7 +2,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
2
  import { TypeCustomerProviderOperation } from '../../../Enum/TypeCustomerProviderOperation.js';
3
3
  import { AccountingJournal } from '../../../Enum/AccountingJournal.js';
4
4
  import { IsBoolean, IsDateString, IsInt, IsOptional } from 'class-validator';
5
- import { ToBoolean } from '#utils/transforms/boolean.transform.js';
5
+ import { ToBoolean } from '../../../../utils/transforms/boolean.transform.js';
6
6
 
7
7
  export class QueryTransaction {
8
8
  id: number;
@@ -12,7 +12,7 @@ import {
12
12
  Length,
13
13
  Min,
14
14
  } from 'class-validator';
15
- import { BorderLineType, IFile, ReadProductEditing } from '../../../index.js';
15
+ import { BorderLineType, CountryId, IFile, ReadProductEditing } from '../../../index.js';
16
16
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
17
17
  import {
18
18
  AccountingCategoryId,
@@ -473,6 +473,9 @@ export class CommercialDocumentInputs {
473
473
  @ApiProperty({ description: 'Commercial city address of seller' })
474
474
  city: string | null;
475
475
 
476
+ @ApiProperty({ description: 'Commercial country address of seller' })
477
+ idCountry: CountryId | null;
478
+
476
479
  @ApiProperty()
477
480
  settings: ISocietyGescom;
478
481
 
@@ -1,5 +1,5 @@
1
1
  import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
2
- import { IsString, IsOptional, IsArray, IsEnum, IsDateString } from 'class-validator';
2
+ import { IsString, IsOptional, IsArray, IsEnum, IsDateString, IsNumber } from 'class-validator';
3
3
  import { DocoonFlowType } from './DocoonInvoice.js';
4
4
  import { EInvoicingStatusCode } from '#types/Enum/EInvoicingStatusCode.js';
5
5
  import { EInvoicingReasonType } from '#types/Enum/EInvoicingReasonType.js';
@@ -85,4 +85,9 @@ export class AcceptEInvoice {
85
85
  @IsString()
86
86
  @IsOptional()
87
87
  internalComment?: string;
88
+
89
+ @ApiPropertyOptional()
90
+ @IsNumber()
91
+ @IsOptional()
92
+ idThirdParty?: number;
88
93
  }
@@ -1,4 +1,4 @@
1
- import { IsBoolean, IsInt, IsNumber, IsOptional, IsString, Min } from 'class-validator';
1
+ import { IsBoolean, IsNumber, IsOptional, IsString, Min } from 'class-validator';
2
2
  import { ProductType, Unit } from '../../../index.js';
3
3
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
4
4
  import { ToBoolean } from '../../../../utils/transforms/boolean.transform.js';
@@ -54,9 +54,4 @@ export class CreateProduct {
54
54
  @IsString()
55
55
  @IsOptional()
56
56
  codeProduct?: string;
57
-
58
- @ApiPropertyOptional()
59
- @IsInt()
60
- @IsOptional()
61
- idAccount?: number;
62
57
  }
@@ -37,12 +37,6 @@ export class ProcessVatRegistration {
37
37
  @ToBoolean()
38
38
  isTestMode?: boolean;
39
39
 
40
- @ApiPropertyOptional()
41
- @IsOptional()
42
- @IsBoolean()
43
- @ToBoolean()
44
- debug?: boolean;
45
-
46
40
  @ApiProperty()
47
41
  @IsNumber()
48
42
  state: CustomerVatState;
@@ -27,6 +27,7 @@ export interface RegisterProspectResponse {
27
27
  token?: string;
28
28
  idUser?: number;
29
29
  idSociety?: number;
30
+ resetPasswordLink?: string;
30
31
  }
31
32
 
32
33
  /**
@@ -40,7 +40,6 @@ export class IAccount {
40
40
  idRegisterCategorie?: number | null;
41
41
  idSector?: number | null;
42
42
  idParentAccount?: number | null;
43
- metadata?: Record<string, any> | null;
44
43
  createdAt?: Date | null;
45
44
  updatedAt?: Date | null;
46
45
  deletedAt?: Date | null;
@@ -19,6 +19,7 @@ export class IAccountingFile {
19
19
  totalTaxExcluded?: number | null;
20
20
  isMobile: boolean;
21
21
  internComment?: string | null;
22
+ invoiceNumber?: string | null;
22
23
  idAccountingTransaction?: number | null;
23
24
  idEstimateInvoice?: number | null;
24
25
  idAccountingFileType: number;
@@ -1,6 +1,5 @@
1
1
  import { IVat } from './IVat.js';
2
2
  import { ISociety } from './ISociety.js';
3
- import { IAccount } from './IAccount.js';
4
3
 
5
4
  // products
6
5
  export class IProduct {
@@ -16,7 +15,6 @@ export class IProduct {
16
15
  amountOfPurchase: number | null;
17
16
  marginVatType?: number;
18
17
  idSociety: number;
19
- idAccount?: number | null;
20
18
  createdAt?: Date | null;
21
19
  updatedAt?: Date | null;
22
20
  deletedAt?: Date | null;
@@ -24,5 +22,4 @@ export class IProduct {
24
22
  // Associations
25
23
  vat?: IVat;
26
24
  society?: ISociety;
27
- account?: IAccount;
28
25
  }
@@ -1,6 +1,5 @@
1
1
  import { IVat } from './IVat.js';
2
2
  import { IProduct } from './IProduct.js';
3
- import type { IAccount } from './IAccount.js';
4
3
  import { DiscountType } from '../../Enum/CommercialManagement.js';
5
4
 
6
5
  // itemsEstimates
@@ -8,7 +7,6 @@ export class IProductInvoice {
8
7
  id?: number;
9
8
  idEstimateInvoice: number;
10
9
  idProduct: number | null;
11
- idAccount?: number | null;
12
10
  idVat: number;
13
11
  marginVatType?: number;
14
12
  amountOfPurchase: number | null;
@@ -28,5 +26,4 @@ export class IProductInvoice {
28
26
  // Associations
29
27
  vat?: IVat;
30
28
  product?: IProduct;
31
- account?: IAccount;
32
29
  }
@@ -47,8 +47,6 @@ export class ISocietyGescom {
47
47
  idSociety?: number | null;
48
48
  shouldHideBrandName?: boolean;
49
49
  shouldHideEmailHeader?: boolean;
50
- // Regroupe les ecritures comptables par compte pour l export des ecritures comptables.
51
- areEntriesGroupedByAccount?: boolean;
52
50
  customerBlockBorderThickness?: number | null;
53
51
  customerBlockBorderColor?: string | null;
54
52
  lineSeparationThickness?: number | null;