@silexpert/core 1.0.163 → 1.0.164

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 (76) hide show
  1. package/es/api/resources/Quotation.d.ts +17 -0
  2. package/es/api/resources/Quotation.d.ts.map +1 -0
  3. package/es/api/resources/Quotation.js +20 -0
  4. package/es/api/resources/Quotation.js.map +1 -0
  5. package/es/api/resources/Rating.d.ts +18 -0
  6. package/es/api/resources/Rating.d.ts.map +1 -0
  7. package/es/api/resources/Rating.js +20 -0
  8. package/es/api/resources/Rating.js.map +1 -0
  9. package/es/api/resources.d.ts +4 -0
  10. package/es/api/resources.d.ts.map +1 -1
  11. package/es/api/resources.js +4 -0
  12. package/es/api/resources.js.map +1 -1
  13. package/es/types/Enum/AbsenceType.d.ts +4 -3
  14. package/es/types/Enum/AbsenceType.d.ts.map +1 -1
  15. package/es/types/Enum/AbsenceType.js +5 -0
  16. package/es/types/Enum/AbsenceType.js.map +1 -1
  17. package/es/types/Enum/Channel.d.ts +3 -1
  18. package/es/types/Enum/Channel.d.ts.map +1 -1
  19. package/es/types/Enum/Channel.js +2 -0
  20. package/es/types/Enum/Channel.js.map +1 -1
  21. package/es/types/Interface/api/quotation/ReadClientQuotation.d.ts +20 -0
  22. package/es/types/Interface/api/quotation/ReadClientQuotation.d.ts.map +1 -0
  23. package/es/types/Interface/api/quotation/ReadClientQuotation.js +2 -0
  24. package/es/types/Interface/api/quotation/ReadClientQuotation.js.map +1 -0
  25. package/es/types/Interface/api/rating/QueryRatingPaginated.d.ts +6 -0
  26. package/es/types/Interface/api/rating/QueryRatingPaginated.d.ts.map +1 -0
  27. package/es/types/Interface/api/rating/QueryRatingPaginated.js +42 -0
  28. package/es/types/Interface/api/rating/QueryRatingPaginated.js.map +1 -0
  29. package/es/types/Interface/api/task/QueryPaginatedTask.d.ts +1 -1
  30. package/es/types/Interface/api/task/QueryPaginatedTask.d.ts.map +1 -1
  31. package/es/types/Interface/api/task/QueryPaginatedTask.js +3 -3
  32. package/es/types/Interface/api/task/QueryPaginatedTask.js.map +1 -1
  33. package/es/types/Interface/models/IRating.d.ts +9 -5
  34. package/es/types/Interface/models/IRating.d.ts.map +1 -1
  35. package/es/types/Interface/models/IRating.js.map +1 -1
  36. package/es/types/index.d.ts +2 -0
  37. package/es/types/index.d.ts.map +1 -1
  38. package/es/types/index.js +2 -0
  39. package/es/types/index.js.map +1 -1
  40. package/es/utils/quotation.d.ts +5 -0
  41. package/es/utils/quotation.d.ts.map +1 -1
  42. package/es/utils/quotation.js +160 -0
  43. package/es/utils/quotation.js.map +1 -1
  44. package/js/api/resources/Quotation.js +27 -0
  45. package/js/api/resources/Quotation.js.map +1 -0
  46. package/js/api/resources/Rating.js +29 -0
  47. package/js/api/resources/Rating.js.map +1 -0
  48. package/js/api/resources.js +5 -1
  49. package/js/api/resources.js.map +1 -1
  50. package/js/types/Enum/AbsenceType.js +4 -0
  51. package/js/types/Enum/AbsenceType.js.map +1 -1
  52. package/js/types/Enum/Channel.js +2 -0
  53. package/js/types/Enum/Channel.js.map +1 -1
  54. package/js/types/Interface/api/quotation/ReadClientQuotation.js +6 -0
  55. package/js/types/Interface/api/quotation/ReadClientQuotation.js.map +1 -0
  56. package/js/types/Interface/api/rating/QueryRatingPaginated.js +40 -0
  57. package/js/types/Interface/api/rating/QueryRatingPaginated.js.map +1 -0
  58. package/js/types/Interface/api/task/QueryPaginatedTask.js +1 -1
  59. package/js/types/Interface/api/task/QueryPaginatedTask.js.map +1 -1
  60. package/js/types/Interface/models/IRating.js.map +1 -1
  61. package/js/types/index.js +20 -0
  62. package/js/types/index.js.map +1 -1
  63. package/js/utils/quotation.js +158 -0
  64. package/js/utils/quotation.js.map +1 -1
  65. package/package.json +1 -1
  66. package/ts/api/resources/Quotation.ts +22 -0
  67. package/ts/api/resources/Rating.ts +23 -0
  68. package/ts/api/resources.ts +4 -0
  69. package/ts/types/Enum/AbsenceType.ts +6 -1
  70. package/ts/types/Enum/Channel.ts +2 -0
  71. package/ts/types/Interface/api/quotation/ReadClientQuotation.ts +19 -0
  72. package/ts/types/Interface/api/rating/QueryRatingPaginated.ts +29 -0
  73. package/ts/types/Interface/api/task/QueryPaginatedTask.ts +3 -3
  74. package/ts/types/Interface/models/IRating.ts +9 -5
  75. package/ts/types/index.ts +2 -0
  76. package/ts/utils/quotation.ts +178 -0
@@ -4,8 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getLeadQuotation = getLeadQuotation;
7
+ exports.getClientQuotation = getClientQuotation;
8
+ exports.compareTwoCotation = compareTwoCotation;
9
+ var _dayjs = require("dayjs");
10
+ var dayjs = _interopRequireWildcard(_dayjs);
7
11
  var _MailDomainType = require("../types/Enum/MailDomainType");
8
12
  var _Activity = require("../types/Enum/Activity");
13
+ var _ComptaType = require("../types/Enum/ComptaType");
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9
16
  function getLeadQuotation(params) {
10
17
  const {
11
18
  firstname,
@@ -104,4 +111,155 @@ function getLeadQuotation(params) {
104
111
  }
105
112
  return quotation;
106
113
  }
114
+ /* besoin en entré de la société concerné avec les différents imports (society), ainsi que la liste des autres sociétés ou l'owner est owner (otherSocieties) */
115
+ function getClientQuotation(society, otherSocieties, lastNotice, unpaidDetails, reports, societyProcedings, tabBankAccount) {
116
+ var _a, _b, _c, _d, _e, _f;
117
+ let quotationPositive = 0;
118
+ let quotationNegative = 0;
119
+ let quotation = 0;
120
+ const detailQuotation = {
121
+ signature: 0,
122
+ seniority: 0,
123
+ additionalBenefits: 0,
124
+ additionalCompanies: 0,
125
+ unpayed: 0,
126
+ updatedAnnotations: 0,
127
+ bankSynchronization: 0,
128
+ rating: 0,
129
+ labRefused: 0,
130
+ ongoingProceedings: 0,
131
+ report: 0,
132
+ termination: 0,
133
+ created: 0
134
+ };
135
+ // calcul de l'ancienneté de la société
136
+ const anciennete = dayjs().diff(dayjs(society.dateIsClient, 'YYYY-MM-DD'), 'years');
137
+ const ponderation = anciennete * 0.1 + 1;
138
+ /* Type de comptabilité du client (Tresorerie (+10) / Engagement (+15)) */
139
+ if (society.idComptaType) {
140
+ if ([_ComptaType.ComptaType.CASH_BASED, _ComptaType.ComptaType.CASH_BASED_ASSISTANCE, _ComptaType.ComptaType.CASH_BASED_SEIZURE].includes(society.idComptaType)) {
141
+ quotationPositive += 10;
142
+ detailQuotation.signature += 10;
143
+ } else if ([_ComptaType.ComptaType.ACCRUALS, _ComptaType.ComptaType.ACCRUALS_ASSISTANCE, _ComptaType.ComptaType.ACCRUALS_SEIZURE].includes(society.idComptaType)) {
144
+ quotationPositive += 15;
145
+ detailQuotation.signature += 15;
146
+ }
147
+ }
148
+ /* Ancienneté (1 ans < dateIsClient < 2 ans (+10) / 2 ans < dateIsClient (+15 / année)) */
149
+ if (society.dateIsClient) {
150
+ const yearAsClient = Number(new Date().getFullYear()) - Number(new Date(society.dateIsClient).getFullYear());
151
+ if (yearAsClient > 0) {
152
+ quotationPositive += 10;
153
+ detailQuotation.seniority += 10;
154
+ if (yearAsClient > 1) {
155
+ quotationPositive += 15 * (yearAsClient - 1);
156
+ detailQuotation.seniority += 15 * (yearAsClient - 1);
157
+ }
158
+ }
159
+ }
160
+ /* Prestations Complémentaires (+5 / prestation) */
161
+ if ((_a = society.prestationsSocieties) === null || _a === void 0 ? void 0 : _a.length) {
162
+ const prestationsCompl = society.prestationsSocieties.filter(prestation => prestation.idPrestationComplementary);
163
+ prestationsCompl.forEach(() => {
164
+ quotationPositive += Math.ceil(5 * ponderation);
165
+ detailQuotation.additionalBenefits += Math.ceil(5 * ponderation);
166
+ });
167
+ }
168
+ /* Sociétés supplémentaires (+8 / société) */
169
+ if (otherSocieties.length) {
170
+ quotationPositive += Math.ceil(8 * otherSocieties.length * ponderation);
171
+ detailQuotation.additionalCompanies += Math.ceil(8 * otherSocieties.length * ponderation);
172
+ }
173
+ /* Impayés (-15 / mois) */
174
+ if (unpaidDetails.length) {
175
+ quotationNegative -= Math.ceil(15 * unpaidDetails.length * ponderation);
176
+ detailQuotation.unpayed -= Math.ceil(15 * unpaidDetails.length * ponderation);
177
+ }
178
+ /* annotations à jour */
179
+ if ((_b = tabBankAccount.societyAccountingTransactions) === null || _b === void 0 ? void 0 : _b.length) {
180
+ // on check s'il y a 80% des lignes annotées (dateLocked)
181
+ let countNotAnnoted = 0;
182
+ let percentageAnnotations = 100;
183
+ tabBankAccount.societyAccountingTransactions.map(na => {
184
+ if (na.dateLocked === null) {
185
+ countNotAnnoted += 1;
186
+ }
187
+ return countNotAnnoted;
188
+ });
189
+ if (countNotAnnoted !== 0) percentageAnnotations = countNotAnnoted / ((_c = tabBankAccount.societyAccountingTransactions) === null || _c === void 0 ? void 0 : _c.length) * 100;
190
+ if (percentageAnnotations >= 80) {
191
+ quotationPositive += Math.ceil(12 * ponderation);
192
+ detailQuotation.updatedAnnotations += Math.ceil(12 * ponderation);
193
+ } else {
194
+ quotationNegative -= Math.ceil(12 * ponderation);
195
+ detailQuotation.updatedAnnotations -= Math.ceil(12 * ponderation);
196
+ }
197
+ }
198
+ /* synchronisation bancaire */
199
+ if ((_d = tabBankAccount.societyActivatedBankAccounts) === null || _d === void 0 ? void 0 : _d.length) {
200
+ // comptes synchro
201
+ const synchro = tabBankAccount.societyActivatedBankAccounts.length - tabBankAccount.desactivatedBankAccount.length;
202
+ quotationPositive += Math.ceil(12 * synchro * ponderation);
203
+ detailQuotation.bankSynchronization += Math.ceil(12 * synchro * ponderation);
204
+ // comptes desynchro
205
+ quotationNegative -= Math.ceil(12 * tabBankAccount.desactivatedBankAccount.length * ponderation);
206
+ detailQuotation.bankSynchronization -= Math.ceil(12 * tabBankAccount.desactivatedBankAccount.length * ponderation);
207
+ }
208
+ /* avis */
209
+ if (lastNotice && lastNotice.data.length === 1) {
210
+ if (lastNotice.data[0].average === 5) {
211
+ quotationPositive += Math.ceil(10 * ponderation);
212
+ detailQuotation.rating += Math.ceil(10 * ponderation);
213
+ } else {
214
+ quotationNegative -= 10;
215
+ detailQuotation.rating -= 10;
216
+ }
217
+ }
218
+ /* LAB refusée */
219
+ if (!((_e = society.societyDetail) === null || _e === void 0 ? void 0 : _e.acceptation)) {
220
+ quotationNegative -= 10;
221
+ detailQuotation.labRefused -= 10;
222
+ }
223
+ /* Cessation de paiement - redressement judiciaire - procédure en cours / signalements / résiliation */
224
+ if (societyProcedings === null || societyProcedings === void 0 ? void 0 : societyProcedings.length) {
225
+ quotationNegative -= 5 * societyProcedings.length;
226
+ detailQuotation.ongoingProceedings -= 5 * societyProcedings.length;
227
+ }
228
+ if (reports === null || reports === void 0 ? void 0 : reports.length) {
229
+ quotationNegative -= 10;
230
+ detailQuotation.report -= 10;
231
+ }
232
+ if (society.isWaitingEnd) {
233
+ quotationNegative -= 50;
234
+ detailQuotation.termination -= 50;
235
+ }
236
+ /* Création chez nous */
237
+ if ((_f = society.prestationsSocieties) === null || _f === void 0 ? void 0 : _f.length) {
238
+ const prestationsCreation = society.prestationsSocieties.filter(prestation => prestation.idPrestationList === 15); // creation pas d'enum
239
+ prestationsCreation.forEach(() => {
240
+ quotationPositive += 10;
241
+ detailQuotation.created += 10;
242
+ });
243
+ }
244
+ if (quotationPositive > 100) quotationPositive = 100;
245
+ if (quotationNegative > 100) quotationNegative = 100;
246
+ quotation = quotationPositive + quotationNegative;
247
+ if (quotation < 0) quotation = 0;
248
+ return {
249
+ cotation: quotation,
250
+ data: detailQuotation,
251
+ idSociety: society.id
252
+ };
253
+ }
254
+ function compareTwoCotation(cotations) {
255
+ // on recupere les 2 dernieres cotations de la societe
256
+ const higher = false;
257
+ if (cotations[0].cotation === cotations[1].cotation) {
258
+ return null;
259
+ }
260
+ if (cotations[0].cotation > cotations[1].cotation) {
261
+ return true;
262
+ }
263
+ return higher;
264
+ }
107
265
  //# sourceMappingURL=quotation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"quotation.js","names":["getLeadQuotation","_MailDomainType","require","_Activity","params","firstname","lastname","phone","mail","annualTurnover","source","alreadyExist","activitySector","includes","quotation","substr","BasicDomain","find","domain","ForbidenDomain","Date","getDay","dateTime","year","getFullYear","month","getMonth","day","getDate","startTime","endTime","getTime","fieldNumber","filter","data","length","Activity","INFORMATIQUE","CONSEIL","TRANSPORT","BTP","RESTAURATION","COMMERCANT","MEDICAL","PROF_LIB"],"sources":["../../ts/utils/quotation.ts"],"sourcesContent":["import { ForbidenDomain, BasicDomain } from '../types/Enum/MailDomainType';\nimport { Activity } from '../types/Enum/Activity';\n\ntype getLeadQuotationParams = {\n firstname: string,\n lastname: string,\n phone: string,\n mail: string,\n annualTurnover: number,\n source: number,\n alreadyExist: boolean,\n activitySector: number,\n};\n\nexport function getLeadQuotation(params: getLeadQuotationParams):number {\n const {\n firstname, lastname, phone, mail, annualTurnover, source, alreadyExist, activitySector,\n } = params;\n if (\n firstname === 'test'\n || lastname === 'test'\n || mail?.includes('test')\n || ['606060606', '707070707', '612345678', '712345678', '687654321', '787654321'].includes(phone)\n ) {\n return 0;\n }\n let quotation = 0;\n\n /* cotation du prénom */\n if (firstname) quotation += 5;\n\n /* cotation du nom */\n if (lastname) quotation += 5;\n\n /* cotation du numéro de téléphone */\n if (['6', '7'].includes(phone.substr(0, 1))) {\n quotation += 15;\n } else {\n quotation += 5;\n }\n\n /* cotation de l'adresse email */\n if (BasicDomain.find((domain) => mail?.includes(domain))) {\n quotation += 5;\n } else\n if (!ForbidenDomain.find((domain) => mail?.includes(domain))) {\n quotation += 15;\n }\n\n /* cotation du CA annuel */\n if ([0, 150000, 400000, 783000, 783001].includes(annualTurnover)) {\n quotation += 10;\n } else if ([50000, 234000].includes(annualTurnover)) {\n quotation += 5;\n }\n\n /* cotation de la date d'ajout */\n if ([1, 2, 3, 4, 5].includes(new Date().getDay())) {\n const dateTime = new Date();\n const year = dateTime.getFullYear();\n const month = dateTime.getMonth();\n const day = dateTime.getDate();\n const startTime = new Date(`${year}-${month + 1}-${day} 08:45:00`);\n const endTime = new Date(`${year}-${month + 1}-${day} 18:45:00`);\n if ((startTime.getTime() <= dateTime.getTime()) && (endTime.getTime() >= dateTime.getTime())) {\n quotation += 15;\n } else {\n quotation += 5;\n }\n } else {\n quotation += 5;\n }\n\n /* cotation de la source */\n /* Parrainage */\n if (source === 49) {\n quotation += 10;\n\n /* calendly, appel entrant */\n } else if (source === 2) {\n quotation += 8;\n\n /* adWords, Bing, Formulaire */\n } else if (source === 4) {\n quotation += 6;\n\n /* Chat, Whatsapp */\n } else if ([29, 92].includes(source)) {\n quotation += 2;\n }\n\n /* cotation de la qualité (nombre de champs remplis) */\n const fieldNumber = [firstname, lastname, phone, mail, annualTurnover, activitySector].filter((data) => !!data).length;\n switch (fieldNumber) {\n case 6:\n quotation += 10;\n break;\n case 5:\n quotation += 8;\n break;\n case 4:\n quotation += 6;\n break;\n case 3:\n quotation += 4;\n break;\n case 2:\n quotation += 2;\n break;\n default:\n break;\n }\n\n /* cotation de l'existence du lead (déjà existant ou non) */\n if (alreadyExist) quotation += 8;\n\n /* cotation du secteur d'activité */\n if ([Activity.INFORMATIQUE, Activity.CONSEIL].includes(activitySector)) {\n quotation += 10;\n } else if ([Activity.TRANSPORT, Activity.BTP, Activity.RESTAURATION, Activity.COMMERCANT, Activity.MEDICAL, Activity.PROF_LIB].includes(activitySector)) {\n quotation += 5;\n }\n\n return quotation;\n}"],"mappings":";;;;;QAcgBA,gBAAgB,GAAhBA,gBAAgB;AAdhC,IAAAC,eAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAaM,SAAUF,gBAAgBA,CAACI,MAA8B;EAC7D,MAAM;IACJC,SAAS;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,IAAI;IAAEC,cAAc;IAAEC,MAAM;IAAEC,YAAY;IAAEC;EAAc,CACvF,GAAGR,MAAM;EACV,IACEC,SAAS,KAAK,MAAM,IACjBC,QAAQ,KAAK,MAAM,KACnBE,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEK,QAAQ,CAAC,MAAM,CAAC,KACtB,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,CAACA,QAAQ,CAACN,KAAK,CAAC,EACjG;IACA,OAAO,CAAC;;EAEV,IAAIO,SAAS,GAAG,CAAC;EAEjB;EACA,IAAIT,SAAS,EAAES,SAAS,IAAI,CAAC;EAE7B;EACA,IAAIR,QAAQ,EAAEQ,SAAS,IAAI,CAAC;EAE5B;EACA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACD,QAAQ,CAACN,KAAK,CAACQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;IAC3CD,SAAS,IAAI,EAAE;GAChB,MAAM;IACLA,SAAS,IAAI,CAAC;;EAGhB;EACA,IAAIE,2BAAW,CAACC,IAAI,CAAEC,MAAM,IAAKV,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEK,QAAQ,CAACK,MAAM,CAAC,CAAC,EAAE;IACxDJ,SAAS,IAAI,CAAC;GACf,MACD,IAAI,CAACK,8BAAc,CAACF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B,OAAOA,SAAS;AAClB"}
1
+ {"version":3,"file":"quotation.js","names":["getLeadQuotation","exports","getClientQuotation","compareTwoCotation","_dayjs","require","dayjs","_interopRequireWildcard","_MailDomainType","_Activity","_ComptaType","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","params","firstname","lastname","phone","mail","annualTurnover","source","alreadyExist","activitySector","includes","quotation","substr","BasicDomain","find","domain","ForbidenDomain","Date","getDay","dateTime","year","getFullYear","month","getMonth","day","getDate","startTime","endTime","getTime","fieldNumber","filter","data","length","Activity","INFORMATIQUE","CONSEIL","TRANSPORT","BTP","RESTAURATION","COMMERCANT","MEDICAL","PROF_LIB","society","otherSocieties","lastNotice","unpaidDetails","reports","societyProcedings","tabBankAccount","quotationPositive","quotationNegative","detailQuotation","signature","seniority","additionalBenefits","additionalCompanies","unpayed","updatedAnnotations","bankSynchronization","rating","labRefused","ongoingProceedings","report","termination","created","anciennete","diff","dateIsClient","ponderation","idComptaType","ComptaType","CASH_BASED","CASH_BASED_ASSISTANCE","CASH_BASED_SEIZURE","ACCRUALS","ACCRUALS_ASSISTANCE","ACCRUALS_SEIZURE","yearAsClient","Number","_a","prestationsSocieties","prestationsCompl","prestation","idPrestationComplementary","forEach","Math","ceil","_b","societyAccountingTransactions","countNotAnnoted","percentageAnnotations","map","na","dateLocked","_c","_d","societyActivatedBankAccounts","synchro","desactivatedBankAccount","average","_e","societyDetail","acceptation","isWaitingEnd","_f","prestationsCreation","idPrestationList","cotation","idSociety","id","cotations","higher"],"sources":["../../ts/utils/quotation.ts"],"sourcesContent":["import * as dayjs from 'dayjs';\nimport { ForbidenDomain, BasicDomain } from '../types/Enum/MailDomainType';\nimport { Activity } from '../types/Enum/Activity';\nimport { ComptaType } from '../types/Enum/ComptaType';\nimport { ISociety } from '../types/Interface/models/ISociety';\nimport { ICotation } from '../types/Interface/models/ICotation';\nimport {\n BasePaginate,\n IRating, IReport, ISocietyProceding, ReadClientQuotation,\n} from '../types';\n\ntype getLeadQuotationParams = {\n firstname: string,\n lastname: string,\n phone: string,\n mail: string,\n annualTurnover: number,\n source: number,\n alreadyExist: boolean,\n activitySector: number,\n};\n\nexport function getLeadQuotation(params: getLeadQuotationParams):number {\n const {\n firstname, lastname, phone, mail, annualTurnover, source, alreadyExist, activitySector,\n } = params;\n if (\n firstname === 'test'\n || lastname === 'test'\n || mail?.includes('test')\n || ['606060606', '707070707', '612345678', '712345678', '687654321', '787654321'].includes(phone)\n ) {\n return 0;\n }\n let quotation = 0;\n\n /* cotation du prénom */\n if (firstname) quotation += 5;\n\n /* cotation du nom */\n if (lastname) quotation += 5;\n\n /* cotation du numéro de téléphone */\n if (['6', '7'].includes(phone.substr(0, 1))) {\n quotation += 15;\n } else {\n quotation += 5;\n }\n\n /* cotation de l'adresse email */\n if (BasicDomain.find((domain) => mail?.includes(domain))) {\n quotation += 5;\n } else\n if (!ForbidenDomain.find((domain) => mail?.includes(domain))) {\n quotation += 15;\n }\n\n /* cotation du CA annuel */\n if ([0, 150000, 400000, 783000, 783001].includes(annualTurnover)) {\n quotation += 10;\n } else if ([50000, 234000].includes(annualTurnover)) {\n quotation += 5;\n }\n\n /* cotation de la date d'ajout */\n if ([1, 2, 3, 4, 5].includes(new Date().getDay())) {\n const dateTime = new Date();\n const year = dateTime.getFullYear();\n const month = dateTime.getMonth();\n const day = dateTime.getDate();\n const startTime = new Date(`${year}-${month + 1}-${day} 08:45:00`);\n const endTime = new Date(`${year}-${month + 1}-${day} 18:45:00`);\n if ((startTime.getTime() <= dateTime.getTime()) && (endTime.getTime() >= dateTime.getTime())) {\n quotation += 15;\n } else {\n quotation += 5;\n }\n } else {\n quotation += 5;\n }\n\n /* cotation de la source */\n /* Parrainage */\n if (source === 49) {\n quotation += 10;\n\n /* calendly, appel entrant */\n } else if (source === 2) {\n quotation += 8;\n\n /* adWords, Bing, Formulaire */\n } else if (source === 4) {\n quotation += 6;\n\n /* Chat, Whatsapp */\n } else if ([29, 92].includes(source)) {\n quotation += 2;\n }\n\n /* cotation de la qualité (nombre de champs remplis) */\n const fieldNumber = [firstname, lastname, phone, mail, annualTurnover, activitySector].filter((data) => !!data).length;\n switch (fieldNumber) {\n case 6:\n quotation += 10;\n break;\n case 5:\n quotation += 8;\n break;\n case 4:\n quotation += 6;\n break;\n case 3:\n quotation += 4;\n break;\n case 2:\n quotation += 2;\n break;\n default:\n break;\n }\n\n /* cotation de l'existence du lead (déjà existant ou non) */\n if (alreadyExist) quotation += 8;\n\n /* cotation du secteur d'activité */\n if ([Activity.INFORMATIQUE, Activity.CONSEIL].includes(activitySector)) {\n quotation += 10;\n } else if ([Activity.TRANSPORT, Activity.BTP, Activity.RESTAURATION, Activity.COMMERCANT, Activity.MEDICAL, Activity.PROF_LIB].includes(activitySector)) {\n quotation += 5;\n }\n\n return quotation;\n}\n\n/* besoin en entré de la société concerné avec les différents imports (society), ainsi que la liste des autres sociétés ou l'owner est owner (otherSocieties) */\nexport function getClientQuotation(society: ISociety, otherSocieties: ISociety[], lastNotice: BasePaginate<IRating>, unpaidDetails: [], reports: IReport[], societyProcedings: ISocietyProceding[], tabBankAccount: any): ReadClientQuotation {\n let quotationPositive = 0;\n let quotationNegative = 0;\n let quotation = 0;\n const detailQuotation = {\n signature: 0,\n seniority: 0,\n additionalBenefits: 0,\n additionalCompanies: 0,\n unpayed: 0,\n updatedAnnotations: 0,\n bankSynchronization: 0,\n rating: 0,\n labRefused: 0,\n ongoingProceedings: 0,\n report: 0,\n termination: 0,\n created: 0,\n };\n\n // calcul de l'ancienneté de la société\n const anciennete = dayjs().diff(dayjs(society.dateIsClient, 'YYYY-MM-DD'), 'years');\n const ponderation = (anciennete * 0.1) + 1;\n\n /* Type de comptabilité du client (Tresorerie (+10) / Engagement (+15)) */\n if (society.idComptaType) {\n if ([ComptaType.CASH_BASED, ComptaType.CASH_BASED_ASSISTANCE, ComptaType.CASH_BASED_SEIZURE].includes(society.idComptaType)) {\n quotationPositive += 10;\n detailQuotation.signature += 10;\n } else if ([ComptaType.ACCRUALS, ComptaType.ACCRUALS_ASSISTANCE, ComptaType.ACCRUALS_SEIZURE].includes(society.idComptaType)) {\n quotationPositive += 15;\n detailQuotation.signature += 15;\n }\n }\n\n /* Ancienneté (1 ans < dateIsClient < 2 ans (+10) / 2 ans < dateIsClient (+15 / année)) */\n if (society.dateIsClient) {\n const yearAsClient = Number(new Date().getFullYear()) - Number(new Date(society.dateIsClient).getFullYear());\n if (yearAsClient > 0) {\n quotationPositive += 10;\n detailQuotation.seniority += 10;\n if (yearAsClient > 1) {\n quotationPositive += 15 * (yearAsClient - 1);\n detailQuotation.seniority += 15 * (yearAsClient - 1);\n }\n }\n }\n\n /* Prestations Complémentaires (+5 / prestation) */\n if (society.prestationsSocieties?.length) {\n const prestationsCompl = society.prestationsSocieties.filter((prestation) => prestation.idPrestationComplementary);\n prestationsCompl.forEach(() => {\n quotationPositive += Math.ceil(5 * ponderation);\n detailQuotation.additionalBenefits += Math.ceil(5 * ponderation);\n });\n }\n\n /* Sociétés supplémentaires (+8 / société) */\n if (otherSocieties.length) {\n quotationPositive += Math.ceil(8 * otherSocieties.length * ponderation);\n detailQuotation.additionalCompanies += Math.ceil(8 * otherSocieties.length * ponderation);\n }\n\n /* Impayés (-15 / mois) */\n if (unpaidDetails.length) {\n quotationNegative -= Math.ceil(15 * unpaidDetails.length * ponderation);\n detailQuotation.unpayed -= Math.ceil(15 * unpaidDetails.length * ponderation);\n }\n\n /* annotations à jour */\n if (tabBankAccount.societyAccountingTransactions?.length) {\n // on check s'il y a 80% des lignes annotées (dateLocked)\n let countNotAnnoted = 0;\n let percentageAnnotations = 100;\n tabBankAccount.societyAccountingTransactions.map((na:any) => {\n if (na.dateLocked === null) {\n countNotAnnoted += 1;\n }\n return countNotAnnoted;\n });\n if (countNotAnnoted !== 0) percentageAnnotations = (countNotAnnoted / tabBankAccount.societyAccountingTransactions?.length) * 100;\n if (percentageAnnotations >= 80) {\n quotationPositive += Math.ceil(12 * ponderation);\n detailQuotation.updatedAnnotations += Math.ceil(12 * ponderation);\n } else {\n quotationNegative -= Math.ceil(12 * ponderation);\n detailQuotation.updatedAnnotations -= Math.ceil(12 * ponderation);\n }\n }\n\n /* synchronisation bancaire */\n if (tabBankAccount.societyActivatedBankAccounts?.length) {\n // comptes synchro\n const synchro = tabBankAccount.societyActivatedBankAccounts.length - tabBankAccount.desactivatedBankAccount.length;\n quotationPositive += Math.ceil(12 * synchro * ponderation);\n detailQuotation.bankSynchronization += Math.ceil(12 * synchro * ponderation);\n\n // comptes desynchro\n quotationNegative -= Math.ceil(12 * tabBankAccount.desactivatedBankAccount.length * ponderation);\n detailQuotation.bankSynchronization -= Math.ceil(12 * tabBankAccount.desactivatedBankAccount.length * ponderation);\n }\n\n /* avis */\n if (lastNotice && lastNotice.data.length === 1) {\n if (lastNotice.data[0].average === 5) {\n quotationPositive += Math.ceil(10 * ponderation);\n detailQuotation.rating += Math.ceil(10 * ponderation);\n } else {\n quotationNegative -= 10;\n detailQuotation.rating -= 10;\n }\n }\n\n /* LAB refusée */\n if (!society.societyDetail?.acceptation) {\n quotationNegative -= 10;\n detailQuotation.labRefused -= 10;\n }\n\n /* Cessation de paiement - redressement judiciaire - procédure en cours / signalements / résiliation */\n if (societyProcedings?.length) {\n quotationNegative -= 5 * societyProcedings.length;\n detailQuotation.ongoingProceedings -= 5 * societyProcedings.length;\n }\n\n if (reports?.length) {\n quotationNegative -= 10;\n detailQuotation.report -= 10;\n }\n\n if (society.isWaitingEnd) {\n quotationNegative -= 50;\n detailQuotation.termination -= 50;\n }\n\n /* Création chez nous */\n if (society.prestationsSocieties?.length) {\n const prestationsCreation = society.prestationsSocieties.filter((prestation) => prestation.idPrestationList === 15); // creation pas d'enum\n prestationsCreation.forEach(() => {\n quotationPositive += 10;\n detailQuotation.created += 10;\n });\n }\n\n if (quotationPositive > 100) quotationPositive = 100;\n if (quotationNegative > 100) quotationNegative = 100;\n\n quotation = quotationPositive + quotationNegative;\n\n if (quotation < 0) quotation = 0;\n\n return {\n cotation: quotation,\n data: detailQuotation,\n idSociety: society.id as number,\n };\n}\n\nexport function compareTwoCotation(cotations: ICotation[]):boolean | null {\n // on recupere les 2 dernieres cotations de la societe\n const higher = false;\n if (cotations[0].cotation === cotations[1].cotation) {\n return null;\n } if (cotations[0].cotation > cotations[1].cotation) {\n return true;\n }\n return higher;\n}"],"mappings":";;;;;QAsBgBA,gBAAgB,GAAhBA,gBAAgB;AAAAC,OAAA,CAiHhBC,kBAAkB,GAAlBA,kBAAkB;AAAAD,OAAA,CA8JlBE,kBAAkB,GAAlBA,kBAAkB;AArSlC,IAAAC,MAAA,GAAAC,OAAA;AAA+B,IAAnBC,KAAK,GAAAC,uBAAA,CAAAH,MAAA;AACjB,IAAAI,eAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAAsD,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IA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,GAAGC,iBAAiB;EAEjD,IAAIvC,SAAS,GAAG,CAAC,EAAEA,SAAS,GAAG,CAAC;EAEhC,OAAO;IACLgG,QAAQ,EAAEhG,SAAS;IACnBoB,IAAI,EAAEoB,eAAe;IACrByD,SAAS,EAAElE,OAAO,CAACmE;GACpB;AACH;AAEM,SAAU1I,kBAAkBA,CAAC2I,SAAsB;EACvD;EACA,MAAMC,MAAM,GAAG,KAAK;EACpB,IAAID,SAAS,CAAC,CAAC,CAAC,CAACH,QAAQ,KAAKG,SAAS,CAAC,CAAC,CAAC,CAACH,QAAQ,EAAE;IACnD,OAAO,IAAI;;EACX,IAAIG,SAAS,CAAC,CAAC,CAAC,CAACH,QAAQ,GAAGG,SAAS,CAAC,CAAC,CAAC,CAACH,QAAQ,EAAE;IACnD,OAAO,IAAI;;EAEb,OAAOI,MAAM;AACf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "1.0.163",
3
+ "version": "1.0.164",
4
4
  "description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
5
5
  "homepage": "https://gitlab.compta-clementine.fr/dev/silex-api",
6
6
  "main": "js/index.js",
@@ -0,0 +1,22 @@
1
+ import { ICotation } from '../../types/Interface/models/ICotation';
2
+ import { Resource } from '../Resource';
3
+
4
+ export class Quotation extends Resource {
5
+ /**
6
+ * Compare l'évolution entre les 2 derniere cotation
7
+ * @param { number } idSociety
8
+ * @returns { boolean }
9
+ */
10
+ public compareQuotation(idSociety: number): Promise<boolean | null> {
11
+ return this.axios.$get(`/quotation/compare/${idSociety}`);
12
+ }
13
+
14
+ /**
15
+ * Retourne la derniere cotation enregistrée
16
+ * @param { number } idSociety
17
+ * @returns { Cotation }
18
+ */
19
+ getLast(idSociety: number): Promise<ICotation> {
20
+ return this.axios.$get(`/quotation/${idSociety}`);
21
+ }
22
+ }
@@ -0,0 +1,23 @@
1
+ import { CancelToken } from 'axios';
2
+ import { Resource } from '../Resource';
3
+ import { BasePaginate, IRating, QueryRatingPaginated } from '../../types';
4
+
5
+ export class Rating extends Resource {
6
+ /**
7
+ * Creation d'un avis sur le clementinier qu'un client a deposé
8
+ * @param { IRating } payload
9
+ * @returns { IRating }
10
+ */
11
+ createRating(payload: IRating, cancelToken?: CancelToken): Promise<IRating> {
12
+ return this.axios.$post('/ratings', payload);
13
+ }
14
+
15
+ /**
16
+ * Retourne les enregistrement de la table rating sous format paginé
17
+ * @param { QueryRatingPaginated } params
18
+ * @returns { BasePaginate<IRating> }
19
+ */
20
+ public getPaginate(params: QueryRatingPaginated): Promise<BasePaginate<IRating>> {
21
+ return this.axios.$get('/ratings/paginate', { params });
22
+ }
23
+ }
@@ -117,6 +117,8 @@ import { SignFile } from './resources/SignFile';
117
117
  import { Rule } from './resources/Rule';
118
118
  import { VatRegimeHistory } from './resources/VatRegimeHistory';
119
119
  import { Acceptance } from './resources/Acceptance';
120
+ import { Rating } from './resources/Rating';
121
+ import { Quotation } from './resources/Quotation';
120
122
 
121
123
  export const resources = {
122
124
  simulation: Simulation,
@@ -237,5 +239,7 @@ export const resources = {
237
239
  societyConfigBalanceSheet: SocietyConfigBalanceSheet,
238
240
  signFile: SignFile,
239
241
  rule: Rule,
242
+ rating: Rating,
240
243
  acceptance: Acceptance,
244
+ quotation: Quotation,
241
245
  };
@@ -7,9 +7,10 @@ export enum AbsenceType {
7
7
  REMOTE = 6,
8
8
  SCHOOL = 7,
9
9
  UNJUSTIFIED = 8,
10
+ UNPAID_LEAVE = 9,
10
11
  }
11
12
 
12
- export const AbsenceTypeList = [
13
+ export const AbsenceTypeList: Array<{ id: AbsenceType, label: string }> = [
13
14
  {
14
15
  id: AbsenceType.DAY_OFF,
15
16
  label: 'Jours de congé',
@@ -42,4 +43,8 @@ export const AbsenceTypeList = [
42
43
  id: AbsenceType.UNJUSTIFIED,
43
44
  label: 'Absence non justifiée',
44
45
  },
46
+ {
47
+ id: AbsenceType.UNPAID_LEAVE,
48
+ label: 'Congés sans solde',
49
+ },
45
50
  ];
@@ -1,4 +1,6 @@
1
1
  export enum Channel {
2
2
  COMMENT = 1,
3
3
  PHONE = 2,
4
+ TASK = 4,
5
+ SMS = 5,
4
6
  }
@@ -0,0 +1,19 @@
1
+ export type ReadClientQuotation = {
2
+ cotation: number,
3
+ data: {
4
+ signature: number,
5
+ seniority: number,
6
+ additionalBenefits: number,
7
+ additionalCompanies: number,
8
+ unpayed: number,
9
+ updatedAnnotations: number,
10
+ bankSynchronization: number,
11
+ rating: number,
12
+ labRefused: number,
13
+ ongoingProceedings: number,
14
+ report: number,
15
+ termination: number,
16
+ created: number,
17
+ },
18
+ idSociety: number
19
+ };
@@ -0,0 +1,29 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '../../../../utils';
2
+
3
+ export class QueryRatingPaginated {
4
+ @ApiProperty({
5
+ description: 'limit of element',
6
+ required: true,
7
+ type: Number,
8
+ default: 50,
9
+ example: 50,
10
+ })
11
+ limit: number;
12
+
13
+ @ApiProperty({
14
+ description: 'limit of element',
15
+ required: true,
16
+ type: Number,
17
+ default: 1,
18
+ example: 5,
19
+ })
20
+ page: number;
21
+
22
+ @ApiPropertyOptional({
23
+ description: 'idSociety',
24
+ required: false,
25
+ type: Number,
26
+ example: 1,
27
+ })
28
+ idSociety: number;
29
+ }
@@ -1,5 +1,5 @@
1
1
  import {
2
- IsBoolean, IsNumber, IsOptional, IsString, IsInt, IsDate, IsIn,
2
+ IsBoolean, IsNumber, IsOptional, IsString, IsInt, IsDate, IsIn, IsArray,
3
3
  } from 'class-validator';
4
4
  import { ApiPropertyOptional } from '../../../../utils';
5
5
  import { ToBoolean } from '../../../../utils/transforms/boolean.transform';
@@ -52,8 +52,8 @@ export class QueryPaginatedTask {
52
52
 
53
53
  @ApiPropertyOptional({ description: 'user who create the task' })
54
54
  @IsOptional()
55
- @IsInt()
56
- idUserWhoCreated?: number;
55
+ @IsArray()
56
+ idUserWhoCreated?: number[];
57
57
 
58
58
  @ApiPropertyOptional()
59
59
  @IsOptional()
@@ -3,14 +3,18 @@ import { ISociety } from './ISociety';
3
3
  // ratings
4
4
  export interface IRating {
5
5
  id?: number;
6
- notes: string;
7
- comment: string;
8
- average: number;
9
- dateNotShowPopUp: Date | null;
6
+ notes?: string;
7
+ comment?: string;
8
+ average?: number;
9
+ dateNotShowPopUp?: Date | null;
10
+ link?: string | null;
11
+ idUserWhoInsert: number | null;
12
+ noticeDate?: Date | null;
13
+ isMugSent?: boolean | null;
10
14
  idSociety: number;
11
15
  createdAt?: Date | null;
12
16
  updatedAt?: Date | null;
13
17
 
14
18
  // Associations
15
- society: ISociety;
19
+ society?: ISociety;
16
20
  }
package/ts/types/index.ts CHANGED
@@ -638,6 +638,7 @@ export * from './Interface/api/timeRecorder/ReadUsersNotConnected';
638
638
  export * from './Interface/api/timeRecorder/UpdateRecorder';
639
639
  export * from './Interface/api/inpiBalance/QueryInpiBalanceStatistic';
640
640
  export * from './Interface/api/inpiBalance/QueryInpiBalancePaginated';
641
+ export * from './Interface/api/rating/QueryRatingPaginated';
641
642
  export * from './Interface/api/inpiBalance/inpiBalanceStatistic';
642
643
  export * from './Interface/api/inpiPayment/QueryInpiPaymentStatistic';
643
644
  export * from './Interface/api/inpiPayment/QueryInpiPaymentPaginated';
@@ -882,6 +883,7 @@ export * from './Interface/api/rule/Update';
882
883
  export * from './Interface/api/rule/Read';
883
884
  export * from './Interface/api/revive/PostRevive';
884
885
  export * from './Interface/api/acceptance/CreateAcceptance';
886
+ export * from './Interface/api/quotation/ReadClientQuotation';
885
887
 
886
888
  // Enums types
887
889
  export * from './Interface/enum/Util';
@@ -1,5 +1,13 @@
1
+ import * as dayjs from 'dayjs';
1
2
  import { ForbidenDomain, BasicDomain } from '../types/Enum/MailDomainType';
2
3
  import { Activity } from '../types/Enum/Activity';
4
+ import { ComptaType } from '../types/Enum/ComptaType';
5
+ import { ISociety } from '../types/Interface/models/ISociety';
6
+ import { ICotation } from '../types/Interface/models/ICotation';
7
+ import {
8
+ BasePaginate,
9
+ IRating, IReport, ISocietyProceding, ReadClientQuotation,
10
+ } from '../types';
3
11
 
4
12
  type getLeadQuotationParams = {
5
13
  firstname: string,
@@ -122,4 +130,174 @@ export function getLeadQuotation(params: getLeadQuotationParams):number {
122
130
  }
123
131
 
124
132
  return quotation;
133
+ }
134
+
135
+ /* besoin en entré de la société concerné avec les différents imports (society), ainsi que la liste des autres sociétés ou l'owner est owner (otherSocieties) */
136
+ export function getClientQuotation(society: ISociety, otherSocieties: ISociety[], lastNotice: BasePaginate<IRating>, unpaidDetails: [], reports: IReport[], societyProcedings: ISocietyProceding[], tabBankAccount: any): ReadClientQuotation {
137
+ let quotationPositive = 0;
138
+ let quotationNegative = 0;
139
+ let quotation = 0;
140
+ const detailQuotation = {
141
+ signature: 0,
142
+ seniority: 0,
143
+ additionalBenefits: 0,
144
+ additionalCompanies: 0,
145
+ unpayed: 0,
146
+ updatedAnnotations: 0,
147
+ bankSynchronization: 0,
148
+ rating: 0,
149
+ labRefused: 0,
150
+ ongoingProceedings: 0,
151
+ report: 0,
152
+ termination: 0,
153
+ created: 0,
154
+ };
155
+
156
+ // calcul de l'ancienneté de la société
157
+ const anciennete = dayjs().diff(dayjs(society.dateIsClient, 'YYYY-MM-DD'), 'years');
158
+ const ponderation = (anciennete * 0.1) + 1;
159
+
160
+ /* Type de comptabilité du client (Tresorerie (+10) / Engagement (+15)) */
161
+ if (society.idComptaType) {
162
+ if ([ComptaType.CASH_BASED, ComptaType.CASH_BASED_ASSISTANCE, ComptaType.CASH_BASED_SEIZURE].includes(society.idComptaType)) {
163
+ quotationPositive += 10;
164
+ detailQuotation.signature += 10;
165
+ } else if ([ComptaType.ACCRUALS, ComptaType.ACCRUALS_ASSISTANCE, ComptaType.ACCRUALS_SEIZURE].includes(society.idComptaType)) {
166
+ quotationPositive += 15;
167
+ detailQuotation.signature += 15;
168
+ }
169
+ }
170
+
171
+ /* Ancienneté (1 ans < dateIsClient < 2 ans (+10) / 2 ans < dateIsClient (+15 / année)) */
172
+ if (society.dateIsClient) {
173
+ const yearAsClient = Number(new Date().getFullYear()) - Number(new Date(society.dateIsClient).getFullYear());
174
+ if (yearAsClient > 0) {
175
+ quotationPositive += 10;
176
+ detailQuotation.seniority += 10;
177
+ if (yearAsClient > 1) {
178
+ quotationPositive += 15 * (yearAsClient - 1);
179
+ detailQuotation.seniority += 15 * (yearAsClient - 1);
180
+ }
181
+ }
182
+ }
183
+
184
+ /* Prestations Complémentaires (+5 / prestation) */
185
+ if (society.prestationsSocieties?.length) {
186
+ const prestationsCompl = society.prestationsSocieties.filter((prestation) => prestation.idPrestationComplementary);
187
+ prestationsCompl.forEach(() => {
188
+ quotationPositive += Math.ceil(5 * ponderation);
189
+ detailQuotation.additionalBenefits += Math.ceil(5 * ponderation);
190
+ });
191
+ }
192
+
193
+ /* Sociétés supplémentaires (+8 / société) */
194
+ if (otherSocieties.length) {
195
+ quotationPositive += Math.ceil(8 * otherSocieties.length * ponderation);
196
+ detailQuotation.additionalCompanies += Math.ceil(8 * otherSocieties.length * ponderation);
197
+ }
198
+
199
+ /* Impayés (-15 / mois) */
200
+ if (unpaidDetails.length) {
201
+ quotationNegative -= Math.ceil(15 * unpaidDetails.length * ponderation);
202
+ detailQuotation.unpayed -= Math.ceil(15 * unpaidDetails.length * ponderation);
203
+ }
204
+
205
+ /* annotations à jour */
206
+ if (tabBankAccount.societyAccountingTransactions?.length) {
207
+ // on check s'il y a 80% des lignes annotées (dateLocked)
208
+ let countNotAnnoted = 0;
209
+ let percentageAnnotations = 100;
210
+ tabBankAccount.societyAccountingTransactions.map((na:any) => {
211
+ if (na.dateLocked === null) {
212
+ countNotAnnoted += 1;
213
+ }
214
+ return countNotAnnoted;
215
+ });
216
+ if (countNotAnnoted !== 0) percentageAnnotations = (countNotAnnoted / tabBankAccount.societyAccountingTransactions?.length) * 100;
217
+ if (percentageAnnotations >= 80) {
218
+ quotationPositive += Math.ceil(12 * ponderation);
219
+ detailQuotation.updatedAnnotations += Math.ceil(12 * ponderation);
220
+ } else {
221
+ quotationNegative -= Math.ceil(12 * ponderation);
222
+ detailQuotation.updatedAnnotations -= Math.ceil(12 * ponderation);
223
+ }
224
+ }
225
+
226
+ /* synchronisation bancaire */
227
+ if (tabBankAccount.societyActivatedBankAccounts?.length) {
228
+ // comptes synchro
229
+ const synchro = tabBankAccount.societyActivatedBankAccounts.length - tabBankAccount.desactivatedBankAccount.length;
230
+ quotationPositive += Math.ceil(12 * synchro * ponderation);
231
+ detailQuotation.bankSynchronization += Math.ceil(12 * synchro * ponderation);
232
+
233
+ // comptes desynchro
234
+ quotationNegative -= Math.ceil(12 * tabBankAccount.desactivatedBankAccount.length * ponderation);
235
+ detailQuotation.bankSynchronization -= Math.ceil(12 * tabBankAccount.desactivatedBankAccount.length * ponderation);
236
+ }
237
+
238
+ /* avis */
239
+ if (lastNotice && lastNotice.data.length === 1) {
240
+ if (lastNotice.data[0].average === 5) {
241
+ quotationPositive += Math.ceil(10 * ponderation);
242
+ detailQuotation.rating += Math.ceil(10 * ponderation);
243
+ } else {
244
+ quotationNegative -= 10;
245
+ detailQuotation.rating -= 10;
246
+ }
247
+ }
248
+
249
+ /* LAB refusée */
250
+ if (!society.societyDetail?.acceptation) {
251
+ quotationNegative -= 10;
252
+ detailQuotation.labRefused -= 10;
253
+ }
254
+
255
+ /* Cessation de paiement - redressement judiciaire - procédure en cours / signalements / résiliation */
256
+ if (societyProcedings?.length) {
257
+ quotationNegative -= 5 * societyProcedings.length;
258
+ detailQuotation.ongoingProceedings -= 5 * societyProcedings.length;
259
+ }
260
+
261
+ if (reports?.length) {
262
+ quotationNegative -= 10;
263
+ detailQuotation.report -= 10;
264
+ }
265
+
266
+ if (society.isWaitingEnd) {
267
+ quotationNegative -= 50;
268
+ detailQuotation.termination -= 50;
269
+ }
270
+
271
+ /* Création chez nous */
272
+ if (society.prestationsSocieties?.length) {
273
+ const prestationsCreation = society.prestationsSocieties.filter((prestation) => prestation.idPrestationList === 15); // creation pas d'enum
274
+ prestationsCreation.forEach(() => {
275
+ quotationPositive += 10;
276
+ detailQuotation.created += 10;
277
+ });
278
+ }
279
+
280
+ if (quotationPositive > 100) quotationPositive = 100;
281
+ if (quotationNegative > 100) quotationNegative = 100;
282
+
283
+ quotation = quotationPositive + quotationNegative;
284
+
285
+ if (quotation < 0) quotation = 0;
286
+
287
+ return {
288
+ cotation: quotation,
289
+ data: detailQuotation,
290
+ idSociety: society.id as number,
291
+ };
292
+ }
293
+
294
+ export function compareTwoCotation(cotations: ICotation[]):boolean | null {
295
+ // on recupere les 2 dernieres cotations de la societe
296
+ const higher = false;
297
+ if (cotations[0].cotation === cotations[1].cotation) {
298
+ return null;
299
+ } if (cotations[0].cotation > cotations[1].cotation) {
300
+ return true;
301
+ }
302
+ return higher;
125
303
  }