@silexpert/core 1.0.123 → 1.0.126

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 (127) hide show
  1. package/es/api/resources/Employee.d.ts.map +1 -1
  2. package/es/api/resources/Employee.js +3 -2
  3. package/es/api/resources/Employee.js.map +1 -1
  4. package/es/api/resources/Mail.d.ts +2 -1
  5. package/es/api/resources/Mail.d.ts.map +1 -1
  6. package/es/api/resources/Mail.js +3 -0
  7. package/es/api/resources/Mail.js.map +1 -1
  8. package/es/api/resources/SocietyConfigBalanceSheet.d.ts +1 -1
  9. package/es/api/resources/SocietyConfigBalanceSheet.d.ts.map +1 -1
  10. package/es/api/resources/SocietyConfigBalanceSheet.js +2 -2
  11. package/es/api/resources/SocietyConfigBalanceSheet.js.map +1 -1
  12. package/es/types/Enum/BalanceSheet.d.ts +1 -1
  13. package/es/types/Enum/BalanceSheet.js +1 -1
  14. package/es/types/Enum/BalanceSheet.js.map +1 -1
  15. package/es/types/Enum/BrandComptalib.js +1 -1
  16. package/es/types/Enum/BrandComptalib.js.map +1 -1
  17. package/es/types/Enum/DepositDocumentType.d.ts +10 -0
  18. package/es/types/Enum/DepositDocumentType.d.ts.map +1 -1
  19. package/es/types/Enum/DepositDocumentType.js +12 -0
  20. package/es/types/Enum/DepositDocumentType.js.map +1 -1
  21. package/es/types/Enum/Ged.d.ts +4 -0
  22. package/es/types/Enum/Ged.d.ts.map +1 -1
  23. package/es/types/Enum/Ged.js +26 -0
  24. package/es/types/Enum/Ged.js.map +1 -1
  25. package/es/types/Enum/MailAuto.d.ts +17 -7
  26. package/es/types/Enum/MailAuto.d.ts.map +1 -1
  27. package/es/types/Enum/MailAuto.js +28 -6
  28. package/es/types/Enum/MailAuto.js.map +1 -1
  29. package/es/types/Enum/RevisionGuide.d.ts +3 -3
  30. package/es/types/Enum/RevisionGuide.d.ts.map +1 -1
  31. package/es/types/Enum/RevisionGuide.js +3 -3
  32. package/es/types/Enum/RevisionGuide.js.map +1 -1
  33. package/es/types/Interface/api/mail/QueryGetSignature.d.ts +6 -0
  34. package/es/types/Interface/api/mail/QueryGetSignature.d.ts.map +1 -0
  35. package/es/types/Interface/api/mail/QueryGetSignature.js +32 -0
  36. package/es/types/Interface/api/mail/QueryGetSignature.js.map +1 -0
  37. package/es/types/Interface/api/societyConfigBalanceSheet/QueryGetAllSocietyConfigBalanceSheet.js +1 -1
  38. package/es/types/Interface/api/societyConfigBalanceSheet/QueryGetAllSocietyConfigBalanceSheet.js.map +1 -1
  39. package/es/types/Interface/models/IGedFile.d.ts +2 -0
  40. package/es/types/Interface/models/IGedFile.d.ts.map +1 -1
  41. package/es/types/Interface/models/IGedFile.js.map +1 -1
  42. package/es/types/Interface/models/IPaymentExpectation.d.ts +1 -0
  43. package/es/types/Interface/models/IPaymentExpectation.d.ts.map +1 -1
  44. package/es/types/Interface/models/IPaymentExpectation.js.map +1 -1
  45. package/es/types/Interface/models/ISociety.d.ts +2 -1
  46. package/es/types/Interface/models/ISociety.d.ts.map +1 -1
  47. package/es/types/Interface/models/ISociety.js.map +1 -1
  48. package/es/types/Interface/models/ISocietyConfigBalanceSheet.d.ts +6 -2
  49. package/es/types/Interface/models/ISocietyConfigBalanceSheet.d.ts.map +1 -1
  50. package/es/types/Interface/models/ISocietyConfigBalanceSheet.js.map +1 -1
  51. package/es/types/index.d.ts +1 -0
  52. package/es/types/index.d.ts.map +1 -1
  53. package/es/types/index.js +1 -0
  54. package/es/types/index.js.map +1 -1
  55. package/es/utils/commercialManagement/templates/body.d.ts.map +1 -1
  56. package/es/utils/commercialManagement/templates/body.js +2 -1
  57. package/es/utils/commercialManagement/templates/body.js.map +1 -1
  58. package/es/utils/commercialManagement/templates/common.js +1 -1
  59. package/es/utils/commercialManagement/templates/common.js.map +1 -1
  60. package/es/utils/email/templates/signature.d.ts +2 -0
  61. package/es/utils/email/templates/signature.d.ts.map +1 -0
  62. package/es/utils/email/templates/signature.js +196 -0
  63. package/es/utils/email/templates/signature.js.map +1 -0
  64. package/es/utils/email.d.ts +2 -0
  65. package/es/utils/email.d.ts.map +1 -0
  66. package/es/utils/email.js +223 -0
  67. package/es/utils/email.js.map +1 -0
  68. package/es/utils/index.d.ts +1 -0
  69. package/es/utils/index.d.ts.map +1 -1
  70. package/es/utils/index.js +1 -0
  71. package/es/utils/index.js.map +1 -1
  72. package/js/api/resources/Employee.js +4 -2
  73. package/js/api/resources/Employee.js.map +1 -1
  74. package/js/api/resources/Mail.js +6 -0
  75. package/js/api/resources/Mail.js.map +1 -1
  76. package/js/api/resources/SocietyConfigBalanceSheet.js +2 -2
  77. package/js/api/resources/SocietyConfigBalanceSheet.js.map +1 -1
  78. package/js/types/Enum/BalanceSheet.js +1 -1
  79. package/js/types/Enum/BalanceSheet.js.map +1 -1
  80. package/js/types/Enum/BrandComptalib.js +1 -1
  81. package/js/types/Enum/BrandComptalib.js.map +1 -1
  82. package/js/types/Enum/DepositDocumentType.js +17 -1
  83. package/js/types/Enum/DepositDocumentType.js.map +1 -1
  84. package/js/types/Enum/Ged.js +19 -0
  85. package/js/types/Enum/Ged.js.map +1 -1
  86. package/js/types/Enum/MailAuto.js +34 -6
  87. package/js/types/Enum/MailAuto.js.map +1 -1
  88. package/js/types/Enum/RevisionGuide.js +3 -3
  89. package/js/types/Enum/RevisionGuide.js.map +1 -1
  90. package/js/types/Interface/api/mail/QueryGetSignature.js +33 -0
  91. package/js/types/Interface/api/mail/QueryGetSignature.js.map +1 -0
  92. package/js/types/Interface/api/societyConfigBalanceSheet/QueryGetAllSocietyConfigBalanceSheet.js +1 -1
  93. package/js/types/Interface/api/societyConfigBalanceSheet/QueryGetAllSocietyConfigBalanceSheet.js.map +1 -1
  94. package/js/types/index.js +12 -0
  95. package/js/types/index.js.map +1 -1
  96. package/js/utils/commercialManagement/templates/body.js +2 -1
  97. package/js/utils/commercialManagement/templates/body.js.map +1 -1
  98. package/js/utils/commercialManagement/templates/common.js +1 -1
  99. package/js/utils/commercialManagement/templates/common.js.map +1 -1
  100. package/js/utils/email/templates/signature.js +201 -0
  101. package/js/utils/email/templates/signature.js.map +1 -0
  102. package/js/utils/email.js +317 -0
  103. package/js/utils/email.js.map +1 -0
  104. package/js/utils/index.js +12 -0
  105. package/js/utils/index.js.map +1 -1
  106. package/package.json +1 -1
  107. package/ts/api/resources/Employee.ts +3 -2
  108. package/ts/api/resources/Mail.ts +5 -0
  109. package/ts/api/resources/SocietyConfigBalanceSheet.ts +2 -2
  110. package/ts/types/Enum/BalanceSheet.ts +1 -1
  111. package/ts/types/Enum/BrandComptalib.ts +1 -1
  112. package/ts/types/Enum/DepositDocumentType.ts +12 -0
  113. package/ts/types/Enum/Ged.ts +27 -0
  114. package/ts/types/Enum/MailAuto.ts +30 -7
  115. package/ts/types/Enum/RevisionGuide.ts +3 -3
  116. package/ts/types/Interface/api/mail/QueryGetSignature.ts +21 -0
  117. package/ts/types/Interface/api/societyConfigBalanceSheet/QueryGetAllSocietyConfigBalanceSheet.ts +1 -1
  118. package/ts/types/Interface/models/IGedFile.ts +2 -0
  119. package/ts/types/Interface/models/IPaymentExpectation.ts +1 -0
  120. package/ts/types/Interface/models/ISociety.ts +2 -0
  121. package/ts/types/Interface/models/ISocietyConfigBalanceSheet.ts +6 -2
  122. package/ts/types/index.ts +1 -0
  123. package/ts/utils/commercialManagement/templates/body.ts +2 -1
  124. package/ts/utils/commercialManagement/templates/common.ts +1 -1
  125. package/ts/utils/email/templates/signature.ts +198 -0
  126. package/ts/utils/email.ts +230 -0
  127. package/ts/utils/index.ts +1 -0
@@ -0,0 +1,230 @@
1
+ import * as dayjs from 'dayjs';
2
+ import { orderBy as orderByLodash } from 'lodash';
3
+ import { Role } from '../types/Enum/Role';
4
+ import { getBrandConfig } from './brands';
5
+ import { signatureTemplate } from './email/templates/signature';
6
+
7
+ const ejs = require('ejs');
8
+
9
+ function intersection<T>(arr: [T[], T[]]) { return arr.reduce((a: T[], b: T[]) => a.filter((c) => b.includes(c)), []); }
10
+
11
+ function getRoleSignature(user:any) {
12
+ if (user.positionLabel) return user.positionLabel;
13
+
14
+ const isStagiaireOrAlternant = user.roles.map((r: any) => r.id).includes(Role.INTERN) || user.roles.map((r: any) => r.id).includes(Role.ALTERNATE);
15
+ const isManager = user.roles.map((r: any) => r.id).includes(Role.MANAGER);
16
+
17
+ const isSocial = user.roles.map((r: any) => r.id).includes(Role.SOCIAL);
18
+ const isJuridic = user.roles.map((r: any) => r.id).includes(Role.JURIDIC);
19
+ const isFacturation = user.roles.map((r: any) => r.id).includes(Role.FACTURATION);
20
+ const isExpert = user.roles.map((r: any) => r.id).includes(Role.EXPERT_ACCOUNTANT);
21
+ const isCS = user.roles.map((r: any) => r.id).includes(Role.CUSTOMER_SUCCESS);
22
+ const isSales = user.roles.map((r: any) => r.id).includes(Role.COMMERCIAL);
23
+ const isAdmin = user.roles.map((r: any) => r.id).includes(Role.ADMIN);
24
+ const isFront = !!intersection([user.roles.map((r: any) => r.id), [Role.FRONT_OFFICE, Role.FRONT_OFFICE_EXPRESS]]).length;
25
+
26
+ if (isSales && isManager) { return 'Responsable commercial'; }
27
+ if (isSales) { return `Chargé${user.idCivility === 2 ? 'e' : ''} de clientèle`; }
28
+
29
+ if (isCS && isManager) { return 'Responsable de clientèle'; }
30
+ if (isCS) { return `Chargé${user.idCivility === 2 ? 'e' : ''} de clientèle`; }
31
+
32
+ if (isFacturation && isStagiaireOrAlternant) { return 'Assistant facturation'; }
33
+ if (isFacturation && isManager) { return 'Responsable facturation'; }
34
+ if (isFacturation) { return `Chargé${user.idCivility === 2 ? 'e' : ''} de facturation`; }
35
+
36
+ if (isJuridic && isStagiaireOrAlternant) { return 'Assistant juridique'; }
37
+ if (isJuridic && isManager) { return 'Responsable juridique'; }
38
+ if (isJuridic) { return 'Juriste'; }
39
+
40
+ if (isSocial && isStagiaireOrAlternant) { return 'Assistant paie'; }
41
+ if (isSocial && isManager) { return 'Responsable paie'; }
42
+ if (isSocial) { return 'Gestionnaire de paie'; }
43
+
44
+ if (isExpert) { return `Expert${user.idCivility === 2 ? 'e' : ''}-comptable`; }
45
+
46
+ if (isAdmin) { return 'Développeur web'; }
47
+
48
+ if (isFront && isManager) return 'Responsable comptable';
49
+ if (isFront && isStagiaireOrAlternant) return 'Assistant comptable';
50
+ if (isFront) return `Comptable dédié${user.idCivility === 2 ? 'e' : ''}`;
51
+ return `Comptable dédié${user.idCivility === 2 ? 'e' : ''}`;
52
+ }
53
+
54
+ function getHoraires(user:any) { // On affiche les horaires uniquement pour les front, et pas pour les TVA
55
+ if (!intersection([user.roles.map((r: any) => r.id), [Role.FRONT_OFFICE, Role.FRONT_OFFICE_EXPRESS, Role.COMMERCIAL]]).length) return 'Du lundi au vendredi de 9h à 19h';
56
+
57
+ if (!user.workingSchedules.length) return 'Du lundi au vendredi de 9h à 19h';
58
+
59
+ let reducedSchedules = user.workingSchedules.reduce((acc: any, e:any, index: number) => {
60
+ const name = `${dayjs(e.morningStart, 'HH:mm:ss').format('HH:mm')}-${dayjs(e.afternoonEnd || e.morningEnd, 'HH:mm:ss').format('HH:mm')}`;
61
+ if (!acc[name]) acc[name] = [index];
62
+ else acc[name].push(index);
63
+ return acc;
64
+ }, {});
65
+
66
+ reducedSchedules = orderByLodash(reducedSchedules, (elem) => elem.length, ['desc']);
67
+
68
+ let resultHoraire = '';
69
+ let startH;
70
+ let startM;
71
+ let endH;
72
+ let endM;
73
+ let firstDayOfWeek;
74
+ let lastDayOfWeek;
75
+
76
+ reducedSchedules.forEach((schedule: any, index: number) => {
77
+ startH = dayjs(user.workingSchedules[schedule[0]].morningStart ? user.workingSchedules[schedule[0]].morningStart : user.workingSchedules[schedule[0]].afternoonStart, 'HH:mm:ss').get('hour');
78
+ startM = dayjs(user.workingSchedules[schedule[0]].morningStart ? user.workingSchedules[schedule[0]].morningStart : user.workingSchedules[schedule[0]].afternoonStart, 'HH:mm:ss').get('minute');
79
+ endH = dayjs(user.workingSchedules[schedule[0]].afternoonEnd || user.workingSchedules[schedule[0]].morningEnd, 'HH:mm:ss').get('hour');
80
+ endM = dayjs(user.workingSchedules[schedule[0]].afternoonEnd || user.workingSchedules[schedule[0]].morningEnd, 'HH:mm:ss').get('minute');
81
+ firstDayOfWeek = dayjs().locale('fr').day(user.workingSchedules[schedule[0]].idDay).format('dddd');
82
+ if (!index) {
83
+ // pour le premier index, on affiche l'amplitude horaire la plus commune, du XX au XX de Xh à Xh
84
+ lastDayOfWeek = dayjs().locale('fr').day(user.workingSchedules[user.workingSchedules.length - 1].idDay).format('dddd');
85
+ resultHoraire += `Du ${firstDayOfWeek} au ${lastDayOfWeek} de ${startH}h${startM > 0 ? startM : ''} à ${endH}h${endM > 0 ? endM : ''}`;
86
+ } else { // Fonctionnel si uniquement un jour par semaine avec des horaires différents
87
+ resultHoraire += `<br/>Le ${firstDayOfWeek} de ${startH}h${startM > 0 ? startM : ''} à ${endH}h${endM > 0 ? endM : ''}`;
88
+ }
89
+ });
90
+ return resultHoraire;
91
+ }
92
+
93
+ function getMailSignature(user:any, idTypeBrand:number) {
94
+ const informatiqueMail = getBrandConfig({
95
+ ...(idTypeBrand ? { idTypeBrand } : {}),
96
+ objectWaited: 'listMails.informatique',
97
+ }) as unknown as string;
98
+ const bonjourMail = getBrandConfig({
99
+ ...(idTypeBrand ? { idTypeBrand } : {}),
100
+ objectWaited: 'listMails.bonjour',
101
+ }) as unknown as string;
102
+
103
+ if (user.roles.map((r: any) => r.id).includes(Role.ADMIN)) { return informatiqueMail; }
104
+ if (user && !!intersection([user.roles.map((r: any) => r.id), [Role.FRONT_OFFICE, Role.FRONT_OFFICE_EXPRESS, Role.COMMERCIAL]]).length) return user.email;
105
+ return bonjourMail;
106
+ }
107
+
108
+ function getPhoneSignature(user:any) {
109
+ if (user.phone !== '0383931414') { return user.phone.replace(/\B(?=(\d{2})+(?!\d))/g, '&nbsp;'); }
110
+ return false;
111
+ }
112
+
113
+ export function generateSignature(params: any): string {
114
+ const {
115
+ forceRole = null, idTypeBrand = 1, ...otherParams
116
+ } = params;
117
+ let {
118
+ user,
119
+ } = otherParams;
120
+
121
+ const hostS3 = getBrandConfig({
122
+ idTypeBrand,
123
+ objectWaited: 'urlS3',
124
+ });
125
+
126
+ const brandName = getBrandConfig({
127
+ ...(idTypeBrand ? { idTypeBrand } : {}),
128
+ objectWaited: 'name',
129
+ }) as unknown as string;
130
+ const bonjourMail = getBrandConfig({
131
+ ...(idTypeBrand ? { idTypeBrand } : {}),
132
+ objectWaited: 'listMails.bonjour',
133
+ }) as unknown as string;
134
+ const socialMail = getBrandConfig({
135
+ ...(idTypeBrand ? { idTypeBrand } : {}),
136
+ objectWaited: 'listMails.social',
137
+ }) as unknown as string;
138
+ const supportMail = getBrandConfig({
139
+ ...(idTypeBrand ? { idTypeBrand } : {}),
140
+ objectWaited: 'listMails.support',
141
+ }) as unknown as string;
142
+ const juridiqueMail = getBrandConfig({
143
+ ...(idTypeBrand ? { idTypeBrand } : {}),
144
+ objectWaited: 'listMails.juridique',
145
+ }) as unknown as string;
146
+ const facturationMail = getBrandConfig({
147
+ ...(idTypeBrand ? { idTypeBrand } : {}),
148
+ objectWaited: 'listMails.facturation',
149
+ }) as unknown as string;
150
+ const primaryColor = getBrandConfig({
151
+ ...(idTypeBrand ? { idTypeBrand } : {}),
152
+ objectWaited: 'colors.primary',
153
+ }) as unknown as string;
154
+ const standardPhoneSignature = getBrandConfig({
155
+ ...(idTypeBrand ? { idTypeBrand } : {}),
156
+ objectWaited: 'listPhones.contact',
157
+ }) as unknown as string;
158
+ const juridiquePhoneSignature = getBrandConfig({
159
+ ...(idTypeBrand ? { idTypeBrand } : {}),
160
+ objectWaited: 'listPhones.juridique',
161
+ }) as unknown as string;
162
+ const socialPhoneSignature = getBrandConfig({
163
+ ...(idTypeBrand ? { idTypeBrand } : {}),
164
+ objectWaited: 'listPhones.social',
165
+ }) as unknown as string;
166
+
167
+ let roleSignature: string | null;
168
+ let mailSignature: string | null;
169
+ let phoneSignature: string | boolean;
170
+ let horaires: string | null;
171
+ [roleSignature, mailSignature, phoneSignature, horaires] = ['Expert-Comptable', bonjourMail, false, 'Du lundi au vendredi de 9h à 19h'];
172
+
173
+ if (!user) { // Signature Clementine
174
+ user = {
175
+ firstname: `L'équipe ${brandName}`,
176
+ isAll: true,
177
+ };
178
+ roleSignature = '';
179
+ } else if (forceRole === 'social') { // Signature social
180
+ user = {
181
+ firstname: 'Service social',
182
+ isAll: true,
183
+ };
184
+ mailSignature = socialMail;
185
+ roleSignature = '';
186
+ phoneSignature = socialPhoneSignature;
187
+ } else if (forceRole === 'support') { // Signature support
188
+ user = {
189
+ firstname: 'Service Support',
190
+ isAll: true,
191
+ };
192
+ mailSignature = supportMail;
193
+ roleSignature = null;
194
+ } else if (forceRole === 'juridique') { // Signature juridique
195
+ user = {
196
+ firstname: 'Service juridique',
197
+ isAll: true,
198
+ };
199
+ mailSignature = juridiqueMail;
200
+ roleSignature = null;
201
+ phoneSignature = juridiquePhoneSignature;
202
+ } else if (forceRole === 'facturation') { // Signature facturation
203
+ user = {
204
+ firstname: 'Service facturation',
205
+ isAll: true,
206
+ };
207
+ mailSignature = facturationMail;
208
+ roleSignature = null;
209
+ phoneSignature = standardPhoneSignature;
210
+ } else if (user !== 0) { // Signature par défaut
211
+ roleSignature = getRoleSignature(user);
212
+ mailSignature = getMailSignature(user, idTypeBrand);
213
+ horaires = getHoraires(user);
214
+ phoneSignature = getPhoneSignature(user);
215
+ }
216
+
217
+ return ejs.render(signatureTemplate, {
218
+ forceRole,
219
+ brandName,
220
+ hostS3,
221
+ user,
222
+ roleSignature,
223
+ mailSignature,
224
+ phoneSignature,
225
+ standardPhoneSignature,
226
+ horaires,
227
+ primaryColor,
228
+ supportMail,
229
+ });
230
+ }
package/ts/utils/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from './decorators';
6
6
  export * from './documents';
7
7
  export * from './balanceSheetModule';
8
8
  export * from './siretValidation';
9
+ export * from './email';
9
10
  export * from './prestation';
10
11
  export * from './task';
11
12
  export * from './social';