@silexpert/core 1.1.165 → 1.1.167
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.
- package/dist/cjs/types/Enum/BrandPourcentage.d.ts +4 -0
- package/dist/cjs/types/Enum/BrandPourcentage.d.ts.map +1 -1
- package/dist/cjs/types/Enum/BrandPourcentage.js +2 -1
- package/dist/cjs/types/Enum/BrandPourcentage.js.map +1 -1
- package/dist/cjs/types/Enum/Constitution.d.ts +3 -0
- package/dist/cjs/types/Enum/Constitution.d.ts.map +1 -1
- package/dist/cjs/types/Enum/Constitution.js +3 -0
- package/dist/cjs/types/Enum/Constitution.js.map +1 -1
- package/dist/cjs/types/Enum/PrestationType.js +6 -6
- package/dist/cjs/types/Enum/PrestationType.js.map +1 -1
- package/dist/cjs/types/Enum/PriceGridClementine.d.ts +9 -0
- package/dist/cjs/types/Enum/PriceGridClementine.d.ts.map +1 -1
- package/dist/cjs/types/Enum/PriceGridClementine.js +15 -0
- package/dist/cjs/types/Enum/PriceGridClementine.js.map +1 -1
- package/dist/cjs/types/Interface/api/prestation/Query.d.ts +1 -0
- package/dist/cjs/types/Interface/api/prestation/Query.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/prestation/Query.js +8 -0
- package/dist/cjs/types/Interface/api/prestation/Query.js.map +1 -1
- package/dist/cjs/utils/prestation.d.ts +4 -1
- package/dist/cjs/utils/prestation.d.ts.map +1 -1
- package/dist/cjs/utils/prestation.js +47 -23
- package/dist/cjs/utils/prestation.js.map +1 -1
- package/dist/mjs/types/Enum/BrandPourcentage.d.ts +4 -0
- package/dist/mjs/types/Enum/BrandPourcentage.d.ts.map +1 -1
- package/dist/mjs/types/Enum/BrandPourcentage.js +2 -1
- package/dist/mjs/types/Enum/BrandPourcentage.js.map +1 -1
- package/dist/mjs/types/Enum/Constitution.d.ts +3 -0
- package/dist/mjs/types/Enum/Constitution.d.ts.map +1 -1
- package/dist/mjs/types/Enum/Constitution.js +3 -0
- package/dist/mjs/types/Enum/Constitution.js.map +1 -1
- package/dist/mjs/types/Enum/PrestationType.js +6 -6
- package/dist/mjs/types/Enum/PrestationType.js.map +1 -1
- package/dist/mjs/types/Enum/PriceGridClementine.d.ts +9 -0
- package/dist/mjs/types/Enum/PriceGridClementine.d.ts.map +1 -1
- package/dist/mjs/types/Enum/PriceGridClementine.js +15 -0
- package/dist/mjs/types/Enum/PriceGridClementine.js.map +1 -1
- package/dist/mjs/types/Interface/api/prestation/Query.d.ts +1 -0
- package/dist/mjs/types/Interface/api/prestation/Query.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/prestation/Query.js +10 -1
- package/dist/mjs/types/Interface/api/prestation/Query.js.map +1 -1
- package/dist/mjs/utils/prestation.d.ts +4 -1
- package/dist/mjs/utils/prestation.d.ts.map +1 -1
- package/dist/mjs/utils/prestation.js +37 -13
- package/dist/mjs/utils/prestation.js.map +1 -1
- package/package.json +1 -1
- package/ts/types/Enum/BrandPourcentage.ts +2 -1
- package/ts/types/Enum/Constitution.ts +3 -0
- package/ts/types/Enum/PrestationType.ts +6 -6
- package/ts/types/Enum/PriceGridClementine.ts +15 -0
- package/ts/types/Interface/api/prestation/Query.ts +8 -1
- package/ts/utils/prestation.ts +43 -12
package/ts/utils/prestation.ts
CHANGED
|
@@ -26,6 +26,7 @@ type priceGrid = {
|
|
|
26
26
|
properties?: propertie[],
|
|
27
27
|
vatRegimeMonthly?: vatRegime[],
|
|
28
28
|
vatRegimeYearly?: vatRegime[],
|
|
29
|
+
taxSystem?: taxSystem[],
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
type monthlyPayment = {
|
|
@@ -54,6 +55,11 @@ type vatRegime = {
|
|
|
54
55
|
price: number,
|
|
55
56
|
};
|
|
56
57
|
|
|
58
|
+
type taxSystem = {
|
|
59
|
+
id: number,
|
|
60
|
+
price: number,
|
|
61
|
+
};
|
|
62
|
+
|
|
57
63
|
const isOtherAccountingMissions = (idPrestationList: number): boolean => [
|
|
58
64
|
PrestationType.PREVISIONNEL,
|
|
59
65
|
PrestationType.BILAN_INTERMEDIAIRE,
|
|
@@ -119,22 +125,30 @@ const getPriceGrid = (idTypeBrand: number, idPrestationList: number): priceGrid
|
|
|
119
125
|
return currentPriceGrid;
|
|
120
126
|
};
|
|
121
127
|
|
|
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 } => {
|
|
128
|
+
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, idTaxSystem: number): { totalPrestation: number, reduceMonth: number, canBeCreated: boolean, monthNbr: number, price: number } => {
|
|
123
129
|
let totalPrestation: number = 0;
|
|
124
130
|
let reduceMonth: number = 0;
|
|
131
|
+
let monthNbr: number = NbrMonth;
|
|
132
|
+
let yearlyPrice: number | undefined;
|
|
133
|
+
let finalMonthlyPrice: number | undefined;
|
|
134
|
+
let canBeCreated: boolean = true;
|
|
135
|
+
let recalculateMonthly: boolean = false;
|
|
125
136
|
|
|
126
137
|
/* Récupération de la grille tarifaire */
|
|
127
138
|
const currentPriceGrid: priceGrid | undefined = getPriceGrid(idTypeBrand, idPrestationList);
|
|
128
139
|
|
|
129
140
|
if (currentPriceGrid) {
|
|
130
141
|
let monthlyPrice: number | undefined;
|
|
131
|
-
let yearlyPrice: number | undefined;
|
|
132
142
|
let vatRegimePrice: number | undefined;
|
|
143
|
+
let taxSystemPrice: number | undefined;
|
|
133
144
|
|
|
134
145
|
/* Gestion du régime de TVA */
|
|
135
146
|
if (currentPriceGrid.vatRegimeMonthly && !isYearly) vatRegimePrice = currentPriceGrid.vatRegimeMonthly?.find(regime => regime.type === idVatRegime)?.price;
|
|
136
147
|
else if (currentPriceGrid.vatRegimeYearly && isYearly) vatRegimePrice = currentPriceGrid.vatRegimeYearly?.find(regime => regime.type === idVatRegime)?.price;
|
|
137
148
|
|
|
149
|
+
/* Gestion du Régime d'imposition */
|
|
150
|
+
if (currentPriceGrid.taxSystem && idTaxSystem) taxSystemPrice = currentPriceGrid.taxSystem?.find(tax => tax.id === idTaxSystem)?.price;
|
|
151
|
+
|
|
138
152
|
/* Gestion des montants */
|
|
139
153
|
if (currentPriceGrid.turnoverMonthly && !isYearly) monthlyPrice = currentPriceGrid.turnoverMonthly?.find(turn => turnover < turn.turnoverValue)?.price;
|
|
140
154
|
else if (currentPriceGrid.properties) monthlyPrice = currentPriceGrid.properties?.find(property => property.amount === rentsNumber)?.price;
|
|
@@ -143,24 +157,31 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList: number, endDate
|
|
|
143
157
|
else if (!pastBalanceSheet && currentPriceGrid.turnoverCreatedYear) yearlyPrice = currentPriceGrid.turnoverCreatedYear?.find(turn => turnover < turn.turnoverValue)?.price;
|
|
144
158
|
else if (pastBalanceSheet && currentPriceGrid.turnoverPastYear) yearlyPrice = currentPriceGrid.turnoverPastYear?.find(turn => turnover < turn.turnoverValue)?.price;
|
|
145
159
|
else if (currentPriceGrid.partner) yearlyPrice = currentPriceGrid.partner?.find(part => part.amountMinimum <= associatesNumber && part.amountMaximum >= associatesNumber)?.price;
|
|
146
|
-
|
|
160
|
+
finalMonthlyPrice = (monthlyPrice ? monthlyPrice : 0) + (vatRegimePrice ? vatRegimePrice : 0) + (taxSystemPrice ? taxSystemPrice : 0);
|
|
147
161
|
|
|
148
162
|
/* Gestion des mois */
|
|
149
163
|
let cloturedPast: boolean = false;
|
|
150
164
|
if (dayjs(endDate, 'YYYY-MM-DD').subtract(15, 'day').isBefore(dayjs())) cloturedPast = true;
|
|
151
165
|
const minimumMonth: number | undefined = currentPriceGrid.minimumMonthlyPayment?.find(monthlyPayment => monthlyPayment.id === (cloturedPast ? ClosingType.OUTDATED : ClosingType.IN_PROGRESS))?.month;
|
|
152
166
|
const maximumMonth: number | undefined = currentPriceGrid.maximumMonthlyPayment?.find(monthlyPayment => monthlyPayment.id === (cloturedPast ? ClosingType.OUTDATED : ClosingType.IN_PROGRESS))?.month;
|
|
153
|
-
let monthNbr: number = NbrMonth;
|
|
154
167
|
if (totalMonth > 0) monthNbr = monthNbr - totalMonth;
|
|
155
|
-
if (minimumMonth && monthNbr < minimumMonth)
|
|
156
|
-
|
|
168
|
+
if (minimumMonth && monthNbr < minimumMonth) {
|
|
169
|
+
monthNbr = minimumMonth;
|
|
170
|
+
recalculateMonthly = true;
|
|
171
|
+
if (totalMonth > 0) canBeCreated = false;
|
|
172
|
+
}
|
|
173
|
+
if (maximumMonth && monthNbr > maximumMonth) {
|
|
174
|
+
monthNbr = maximumMonth;
|
|
175
|
+
recalculateMonthly = true;
|
|
176
|
+
if (totalMonth > 0) canBeCreated = false;
|
|
177
|
+
}
|
|
157
178
|
|
|
158
179
|
reduceMonth = (monthNbr === NbrMonth - totalMonth ? totalMonth : 0);
|
|
159
180
|
|
|
160
181
|
/* Prix Final */
|
|
161
182
|
totalPrestation = (yearlyPrice ? yearlyPrice : finalMonthlyPrice * monthNbr);
|
|
162
183
|
}
|
|
163
|
-
return { totalPrestation, reduceMonth };
|
|
184
|
+
return { totalPrestation, reduceMonth, canBeCreated, monthNbr: yearlyPrice ? 0 : recalculateMonthly ? NbrMonth : monthNbr, price: yearlyPrice ? yearlyPrice : recalculateMonthly ? (totalPrestation / NbrMonth) : (finalMonthlyPrice ? finalMonthlyPrice : 0) };
|
|
164
185
|
};
|
|
165
186
|
|
|
166
187
|
const calculatePrestationPriceWithPrestationList = (prestationList: IPrestationList): number => {
|
|
@@ -171,10 +192,13 @@ const calculatePrestationPriceWithPrestationList = (prestationList: IPrestationL
|
|
|
171
192
|
return totalPrestation;
|
|
172
193
|
};
|
|
173
194
|
|
|
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 } => {
|
|
195
|
+
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, idTaxSystem: number, isYearly: boolean = false): { totalPrestation: number, reduceMonth: number, canBeCreated: boolean, calculDetail: string, price: number } => {
|
|
175
196
|
let totalPrestation: number = 0;
|
|
176
197
|
let reduceMonth: number = 0;
|
|
177
|
-
let
|
|
198
|
+
let canBeCreated: boolean = true;
|
|
199
|
+
let monthNbr: number = 0;
|
|
200
|
+
let price: number = 0;
|
|
201
|
+
let totalWithReduce: { totalPrestation: number, reduceMonth: number, canBeCreated: boolean, monthNbr: number, price: number } = { totalPrestation: 0, reduceMonth: 0, canBeCreated: true, monthNbr: 0, price: 0 };
|
|
178
202
|
|
|
179
203
|
/* Gestion du prix en fonction de la prestation */
|
|
180
204
|
if (
|
|
@@ -197,14 +221,17 @@ const calculatePrestationPrice = (idPrestationList: number, prestationList: IPre
|
|
|
197
221
|
PrestationType.COMPTA_PRO_COMPTASTART_EXPRESS,
|
|
198
222
|
].includes(idPrestationList)
|
|
199
223
|
) {
|
|
200
|
-
totalWithReduce = calculatePrestationPriceWithPriceGrid(idPrestationList, endDate, NbrMonth, turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, isYearly, totalMonth);
|
|
224
|
+
totalWithReduce = calculatePrestationPriceWithPriceGrid(idPrestationList, endDate, NbrMonth, turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, isYearly, totalMonth, idTaxSystem);
|
|
201
225
|
totalPrestation = totalWithReduce.totalPrestation;
|
|
202
226
|
reduceMonth = totalWithReduce.reduceMonth;
|
|
227
|
+
canBeCreated = totalWithReduce.canBeCreated;
|
|
228
|
+
monthNbr = totalWithReduce.monthNbr;
|
|
229
|
+
price = totalWithReduce.price;
|
|
203
230
|
} else {
|
|
204
231
|
totalPrestation = calculatePrestationPriceWithPrestationList(prestationList);
|
|
205
232
|
}
|
|
206
|
-
if (totalPercentage > 0) totalPrestation = totalPrestation - (totalPrestation * (totalPercentage / 100));
|
|
207
233
|
if (totalAmount > 0) totalPrestation = totalPrestation - totalAmount;
|
|
234
|
+
if (totalPercentage > 0) totalPrestation = totalPrestation - (totalPrestation * (totalPercentage / 100));
|
|
208
235
|
if (prestationList.minimumPrice && totalPrestation < prestationList.minimumPrice) totalPrestation = prestationList.minimumPrice;
|
|
209
236
|
/* Gestion des options */
|
|
210
237
|
let OptionTotalPrice: number = 0;
|
|
@@ -216,7 +243,11 @@ const calculatePrestationPrice = (idPrestationList: number, prestationList: IPre
|
|
|
216
243
|
}
|
|
217
244
|
totalPrestation += (OptionTotalPrice ? OptionTotalPrice : 0);
|
|
218
245
|
|
|
219
|
-
|
|
246
|
+
if (isWithApplicationFees) totalPrestation += 50;
|
|
247
|
+
|
|
248
|
+
const calculDetail = `${monthNbr > 0 ? monthNbr + ' mois x ' + price + '€' : price + '€'} ${totalAmount > 0 ? '- ' + totalAmount + '€' : ''} ${totalPercentage > 0 ? '- ' + totalPercentage + '%' : ''} ${isWithApplicationFees ? '+ 50€' : ''}`;
|
|
249
|
+
|
|
250
|
+
return { totalPrestation, reduceMonth, canBeCreated, calculDetail, price };
|
|
220
251
|
};
|
|
221
252
|
|
|
222
253
|
const getPrestationOptions = (idPrestationList: number): PrestationOptionType[] => {
|