@silexpert/core 1.1.164 → 1.1.166

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 (91) hide show
  1. package/dist/cjs/api/resources/Society.d.ts +2 -1
  2. package/dist/cjs/api/resources/Society.d.ts.map +1 -1
  3. package/dist/cjs/api/resources/Society.js +3 -0
  4. package/dist/cjs/api/resources/Society.js.map +1 -1
  5. package/dist/cjs/api/resources/Subscription.d.ts +2 -0
  6. package/dist/cjs/api/resources/Subscription.d.ts.map +1 -1
  7. package/dist/cjs/api/resources/Subscription.js +3 -0
  8. package/dist/cjs/api/resources/Subscription.js.map +1 -1
  9. package/dist/cjs/types/Enum/BrandPourcentage.d.ts +4 -0
  10. package/dist/cjs/types/Enum/BrandPourcentage.d.ts.map +1 -1
  11. package/dist/cjs/types/Enum/BrandPourcentage.js +92 -1
  12. package/dist/cjs/types/Enum/BrandPourcentage.js.map +1 -1
  13. package/dist/cjs/types/Enum/Contract.d.ts +4 -0
  14. package/dist/cjs/types/Enum/Contract.d.ts.map +1 -1
  15. package/dist/cjs/types/Enum/Contract.js +11 -1
  16. package/dist/cjs/types/Enum/Contract.js.map +1 -1
  17. package/dist/cjs/types/Enum/Log.d.ts +8 -1
  18. package/dist/cjs/types/Enum/Log.d.ts.map +1 -1
  19. package/dist/cjs/types/Enum/Log.js +7 -0
  20. package/dist/cjs/types/Enum/Log.js.map +1 -1
  21. package/dist/cjs/types/Enum/PartnerType.d.ts +4 -0
  22. package/dist/cjs/types/Enum/PartnerType.d.ts.map +1 -1
  23. package/dist/cjs/types/Enum/PartnerType.js +6 -1
  24. package/dist/cjs/types/Enum/PartnerType.js.map +1 -1
  25. package/dist/cjs/types/Interface/api/prestation/Query.d.ts +1 -0
  26. package/dist/cjs/types/Interface/api/prestation/Query.d.ts.map +1 -1
  27. package/dist/cjs/types/Interface/api/prestation/Query.js +8 -0
  28. package/dist/cjs/types/Interface/api/prestation/Query.js.map +1 -1
  29. package/dist/cjs/types/Interface/api/society/Export.d.ts +69 -0
  30. package/dist/cjs/types/Interface/api/society/Export.d.ts.map +1 -0
  31. package/dist/cjs/types/Interface/api/society/Export.js +37 -0
  32. package/dist/cjs/types/Interface/api/society/Export.js.map +1 -0
  33. package/dist/cjs/types/index.d.ts +1 -0
  34. package/dist/cjs/types/index.d.ts.map +1 -1
  35. package/dist/cjs/types/index.js +1 -0
  36. package/dist/cjs/types/index.js.map +1 -1
  37. package/dist/cjs/utils/prestation.d.ts +4 -1
  38. package/dist/cjs/utils/prestation.d.ts.map +1 -1
  39. package/dist/cjs/utils/prestation.js +31 -11
  40. package/dist/cjs/utils/prestation.js.map +1 -1
  41. package/dist/mjs/api/resources/Society.d.ts +2 -1
  42. package/dist/mjs/api/resources/Society.d.ts.map +1 -1
  43. package/dist/mjs/api/resources/Society.js +3 -0
  44. package/dist/mjs/api/resources/Society.js.map +1 -1
  45. package/dist/mjs/api/resources/Subscription.d.ts +2 -0
  46. package/dist/mjs/api/resources/Subscription.d.ts.map +1 -1
  47. package/dist/mjs/api/resources/Subscription.js +3 -0
  48. package/dist/mjs/api/resources/Subscription.js.map +1 -1
  49. package/dist/mjs/types/Enum/BrandPourcentage.d.ts +4 -0
  50. package/dist/mjs/types/Enum/BrandPourcentage.d.ts.map +1 -1
  51. package/dist/mjs/types/Enum/BrandPourcentage.js +92 -1
  52. package/dist/mjs/types/Enum/BrandPourcentage.js.map +1 -1
  53. package/dist/mjs/types/Enum/Contract.d.ts +4 -0
  54. package/dist/mjs/types/Enum/Contract.d.ts.map +1 -1
  55. package/dist/mjs/types/Enum/Contract.js +10 -0
  56. package/dist/mjs/types/Enum/Contract.js.map +1 -1
  57. package/dist/mjs/types/Enum/Log.d.ts +8 -1
  58. package/dist/mjs/types/Enum/Log.d.ts.map +1 -1
  59. package/dist/mjs/types/Enum/Log.js +7 -0
  60. package/dist/mjs/types/Enum/Log.js.map +1 -1
  61. package/dist/mjs/types/Enum/PartnerType.d.ts +4 -0
  62. package/dist/mjs/types/Enum/PartnerType.d.ts.map +1 -1
  63. package/dist/mjs/types/Enum/PartnerType.js +5 -0
  64. package/dist/mjs/types/Enum/PartnerType.js.map +1 -1
  65. package/dist/mjs/types/Interface/api/prestation/Query.d.ts +1 -0
  66. package/dist/mjs/types/Interface/api/prestation/Query.d.ts.map +1 -1
  67. package/dist/mjs/types/Interface/api/prestation/Query.js +10 -1
  68. package/dist/mjs/types/Interface/api/prestation/Query.js.map +1 -1
  69. package/dist/mjs/types/Interface/api/society/Export.d.ts +69 -0
  70. package/dist/mjs/types/Interface/api/society/Export.d.ts.map +1 -0
  71. package/dist/mjs/types/Interface/api/society/Export.js +36 -0
  72. package/dist/mjs/types/Interface/api/society/Export.js.map +1 -0
  73. package/dist/mjs/types/index.d.ts +1 -0
  74. package/dist/mjs/types/index.d.ts.map +1 -1
  75. package/dist/mjs/types/index.js +1 -0
  76. package/dist/mjs/types/index.js.map +1 -1
  77. package/dist/mjs/utils/prestation.d.ts +4 -1
  78. package/dist/mjs/utils/prestation.d.ts.map +1 -1
  79. package/dist/mjs/utils/prestation.js +31 -11
  80. package/dist/mjs/utils/prestation.js.map +1 -1
  81. package/package.json +2 -1
  82. package/ts/api/resources/Society.ts +5 -0
  83. package/ts/api/resources/Subscription.ts +5 -0
  84. package/ts/types/Enum/BrandPourcentage.ts +92 -1
  85. package/ts/types/Enum/Contract.ts +12 -1
  86. package/ts/types/Enum/Log.ts +7 -0
  87. package/ts/types/Enum/PartnerType.ts +7 -1
  88. package/ts/types/Interface/api/prestation/Query.ts +8 -1
  89. package/ts/types/Interface/api/society/Export.ts +91 -0
  90. package/ts/types/index.ts +1 -1
  91. package/ts/utils/prestation.ts +32 -11
@@ -119,16 +119,20 @@ const getPriceGrid = (idTypeBrand: number, idPrestationList: number): priceGrid
119
119
  return currentPriceGrid;
120
120
  };
121
121
 
122
- const calculatePrestationPriceWithPriceGrid = (idPrestationList: number, endDate: string, NbrMonth: number, turnover: number, rentsNumber: number, employeesNumber: number, associatesNumber: number, idTypeBrand: number, idVatRegime: number, pastBalanceSheet: boolean, isYearly: boolean, totalMonth: number): { totalPrestation: number, reduceMonth: number } => {
122
+ const calculatePrestationPriceWithPriceGrid = (idPrestationList: number, endDate: string, NbrMonth: number, turnover: number, rentsNumber: number, employeesNumber: number, associatesNumber: number, idTypeBrand: number, idVatRegime: number, pastBalanceSheet: boolean, isYearly: boolean, totalMonth: number): { totalPrestation: number, reduceMonth: number, canBeCreated: boolean, monthNbr: number, price: number } => {
123
123
  let totalPrestation: number = 0;
124
124
  let reduceMonth: number = 0;
125
+ let monthNbr: number = NbrMonth;
126
+ let yearlyPrice: number | undefined;
127
+ let finalMonthlyPrice: number | undefined;
128
+ let canBeCreated: boolean = true;
129
+ let recalculateMonthly: boolean = false;
125
130
 
126
131
  /* Récupération de la grille tarifaire */
127
132
  const currentPriceGrid: priceGrid | undefined = getPriceGrid(idTypeBrand, idPrestationList);
128
133
 
129
134
  if (currentPriceGrid) {
130
135
  let monthlyPrice: number | undefined;
131
- let yearlyPrice: number | undefined;
132
136
  let vatRegimePrice: number | undefined;
133
137
 
134
138
  /* Gestion du régime de TVA */
@@ -143,24 +147,31 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList: number, endDate
143
147
  else if (!pastBalanceSheet && currentPriceGrid.turnoverCreatedYear) yearlyPrice = currentPriceGrid.turnoverCreatedYear?.find(turn => turnover < turn.turnoverValue)?.price;
144
148
  else if (pastBalanceSheet && currentPriceGrid.turnoverPastYear) yearlyPrice = currentPriceGrid.turnoverPastYear?.find(turn => turnover < turn.turnoverValue)?.price;
145
149
  else if (currentPriceGrid.partner) yearlyPrice = currentPriceGrid.partner?.find(part => part.amountMinimum <= associatesNumber && part.amountMaximum >= associatesNumber)?.price;
146
- const finalMonthlyPrice: number | undefined = (monthlyPrice ? monthlyPrice : 0) + (vatRegimePrice ? vatRegimePrice : 0);
150
+ finalMonthlyPrice = (monthlyPrice ? monthlyPrice : 0) + (vatRegimePrice ? vatRegimePrice : 0);
147
151
 
148
152
  /* Gestion des mois */
149
153
  let cloturedPast: boolean = false;
150
154
  if (dayjs(endDate, 'YYYY-MM-DD').subtract(15, 'day').isBefore(dayjs())) cloturedPast = true;
151
155
  const minimumMonth: number | undefined = currentPriceGrid.minimumMonthlyPayment?.find(monthlyPayment => monthlyPayment.id === (cloturedPast ? ClosingType.OUTDATED : ClosingType.IN_PROGRESS))?.month;
152
156
  const maximumMonth: number | undefined = currentPriceGrid.maximumMonthlyPayment?.find(monthlyPayment => monthlyPayment.id === (cloturedPast ? ClosingType.OUTDATED : ClosingType.IN_PROGRESS))?.month;
153
- let monthNbr: number = NbrMonth;
154
157
  if (totalMonth > 0) monthNbr = monthNbr - totalMonth;
155
- if (minimumMonth && monthNbr < minimumMonth) monthNbr = minimumMonth;
156
- if (maximumMonth && monthNbr > maximumMonth) monthNbr = maximumMonth;
158
+ if (minimumMonth && monthNbr < minimumMonth) {
159
+ monthNbr = minimumMonth;
160
+ recalculateMonthly = true;
161
+ if (totalMonth > 0) canBeCreated = false;
162
+ }
163
+ if (maximumMonth && monthNbr > maximumMonth) {
164
+ monthNbr = maximumMonth;
165
+ recalculateMonthly = true;
166
+ if (totalMonth > 0) canBeCreated = false;
167
+ }
157
168
 
158
169
  reduceMonth = (monthNbr === NbrMonth - totalMonth ? totalMonth : 0);
159
170
 
160
171
  /* Prix Final */
161
172
  totalPrestation = (yearlyPrice ? yearlyPrice : finalMonthlyPrice * monthNbr);
162
173
  }
163
- return { totalPrestation, reduceMonth };
174
+ return { totalPrestation, reduceMonth, canBeCreated, monthNbr: yearlyPrice ? 0 : recalculateMonthly ? NbrMonth : monthNbr, price: yearlyPrice ? yearlyPrice : recalculateMonthly ? (totalPrestation / NbrMonth) : (finalMonthlyPrice ? finalMonthlyPrice : 0) };
164
175
  };
165
176
 
166
177
  const calculatePrestationPriceWithPrestationList = (prestationList: IPrestationList): number => {
@@ -171,10 +182,13 @@ const calculatePrestationPriceWithPrestationList = (prestationList: IPrestationL
171
182
  return totalPrestation;
172
183
  };
173
184
 
174
- const calculatePrestationPrice = (idPrestationList: number, prestationList: IPrestationList, endDate: string, NbrMonth: number, turnover: number, rentsNumber: number, employeesNumber: number, associatesNumber: number, idTypeBrand: number, idVatRegime: number, pastBalanceSheet: boolean, optionsList: number[], totalPercentage: number, totalAmount: number, totalMonth: number, isYearly: boolean = false): { totalPrestation: number, reduceMonth: number } => {
185
+ const calculatePrestationPrice = (idPrestationList: number, prestationList: IPrestationList, endDate: string, NbrMonth: number, turnover: number, rentsNumber: number, employeesNumber: number, associatesNumber: number, idTypeBrand: number, idVatRegime: number, pastBalanceSheet: boolean, optionsList: number[], totalPercentage: number, totalAmount: number, totalMonth: number, isWithApplicationFees: boolean, isYearly: boolean = false): { totalPrestation: number, reduceMonth: number, canBeCreated: boolean, calculDetail: string, price: number } => {
175
186
  let totalPrestation: number = 0;
176
187
  let reduceMonth: number = 0;
177
- let totalWithReduce: { totalPrestation: number, reduceMonth: number } = { totalPrestation: 0, reduceMonth: 0 };
188
+ let canBeCreated: boolean = true;
189
+ let monthNbr: number = 0;
190
+ let price: number = 0;
191
+ let totalWithReduce: { totalPrestation: number, reduceMonth: number, canBeCreated: boolean, monthNbr: number, price: number } = { totalPrestation: 0, reduceMonth: 0, canBeCreated: true, monthNbr: 0, price: 0 };
178
192
 
179
193
  /* Gestion du prix en fonction de la prestation */
180
194
  if (
@@ -200,11 +214,14 @@ const calculatePrestationPrice = (idPrestationList: number, prestationList: IPre
200
214
  totalWithReduce = calculatePrestationPriceWithPriceGrid(idPrestationList, endDate, NbrMonth, turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, isYearly, totalMonth);
201
215
  totalPrestation = totalWithReduce.totalPrestation;
202
216
  reduceMonth = totalWithReduce.reduceMonth;
217
+ canBeCreated = totalWithReduce.canBeCreated;
218
+ monthNbr = totalWithReduce.monthNbr;
219
+ price = totalWithReduce.price;
203
220
  } else {
204
221
  totalPrestation = calculatePrestationPriceWithPrestationList(prestationList);
205
222
  }
206
- if (totalPercentage > 0) totalPrestation = totalPrestation - (totalPrestation * (totalPercentage / 100));
207
223
  if (totalAmount > 0) totalPrestation = totalPrestation - totalAmount;
224
+ if (totalPercentage > 0) totalPrestation = totalPrestation - (totalPrestation * (totalPercentage / 100));
208
225
  if (prestationList.minimumPrice && totalPrestation < prestationList.minimumPrice) totalPrestation = prestationList.minimumPrice;
209
226
  /* Gestion des options */
210
227
  let OptionTotalPrice: number = 0;
@@ -216,7 +233,11 @@ const calculatePrestationPrice = (idPrestationList: number, prestationList: IPre
216
233
  }
217
234
  totalPrestation += (OptionTotalPrice ? OptionTotalPrice : 0);
218
235
 
219
- return { totalPrestation, reduceMonth };
236
+ if (isWithApplicationFees) totalPrestation += 50;
237
+
238
+ const calculDetail = `${monthNbr > 0 ? monthNbr + ' mois x ' + price + '€' : price + '€'} ${totalAmount > 0 ? '- ' + totalAmount + '€' : ''} ${totalPercentage > 0 ? '- ' + totalPercentage + '%' : ''} ${isWithApplicationFees ? '+ 50€' : ''}`;
239
+
240
+ return { totalPrestation, reduceMonth, canBeCreated, calculDetail, price };
220
241
  };
221
242
 
222
243
  const getPrestationOptions = (idPrestationList: number): PrestationOptionType[] => {