@silexpert/core 1.3.273 → 1.3.274
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/PrestationType.js +3 -3
- package/dist/cjs/types/Enum/PrestationType.js.map +1 -1
- package/dist/cjs/types/Interface/api/commercial/QueryGetStats.d.ts +7 -1
- package/dist/cjs/types/Interface/api/commercial/QueryGetStats.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/commercial/QueryGetStats.js +45 -10
- package/dist/cjs/types/Interface/api/commercial/QueryGetStats.js.map +1 -1
- package/dist/cjs/utils/prestation.d.ts +26 -13
- package/dist/cjs/utils/prestation.d.ts.map +1 -1
- package/dist/cjs/utils/prestation.js +136 -135
- package/dist/cjs/utils/prestation.js.map +1 -1
- package/dist/mjs/types/Enum/PrestationType.js +3 -3
- package/dist/mjs/types/Enum/PrestationType.js.map +1 -1
- package/dist/mjs/types/Interface/api/commercial/QueryGetStats.d.ts +7 -1
- package/dist/mjs/types/Interface/api/commercial/QueryGetStats.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/commercial/QueryGetStats.js +43 -3
- package/dist/mjs/types/Interface/api/commercial/QueryGetStats.js.map +1 -1
- package/dist/mjs/utils/prestation.d.ts +26 -13
- package/dist/mjs/utils/prestation.d.ts.map +1 -1
- package/dist/mjs/utils/prestation.js +50 -51
- package/dist/mjs/utils/prestation.js.map +1 -1
- package/package.json +1 -1
- package/ts/types/Enum/PrestationType.ts +3 -3
- package/ts/types/Interface/api/commercial/QueryGetStats.ts +33 -3
- package/ts/utils/prestation.ts +64 -53
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { IsInt, IsOptional, IsString } from 'class-validator';
|
|
2
|
-
import { ApiPropertyOptional } from '
|
|
1
|
+
import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';
|
|
2
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
3
|
+
import { ToBoolean } from '../../../../utils/transforms/boolean.transform.js';
|
|
4
|
+
import { ToNumber } from '../../../../utils/transforms/number.transform.js';
|
|
5
|
+
import { OptionalQueryPaginate } from '../BasePaginate.js';
|
|
3
6
|
|
|
4
|
-
export class QueryGetStats {
|
|
7
|
+
export class QueryGetStats extends OptionalQueryPaginate {
|
|
5
8
|
@ApiPropertyOptional()
|
|
6
9
|
@IsOptional()
|
|
7
10
|
@IsString()
|
|
8
11
|
search?: string;
|
|
9
12
|
|
|
13
|
+
@ApiPropertyOptional()
|
|
14
|
+
@IsOptional()
|
|
15
|
+
@IsBoolean()
|
|
16
|
+
@ToBoolean()
|
|
17
|
+
isInCA?: boolean;
|
|
18
|
+
|
|
19
|
+
@ApiPropertyOptional()
|
|
20
|
+
@IsOptional()
|
|
21
|
+
@IsInt()
|
|
22
|
+
@ToNumber()
|
|
23
|
+
isAdditionalSales?: number;
|
|
24
|
+
|
|
10
25
|
@ApiPropertyOptional()
|
|
11
26
|
@IsOptional()
|
|
12
27
|
@IsInt()
|
|
@@ -37,8 +52,23 @@ export class QueryGetStats {
|
|
|
37
52
|
@IsInt({ each: true })
|
|
38
53
|
idPrestationList?: number[];
|
|
39
54
|
|
|
55
|
+
@ApiPropertyOptional()
|
|
56
|
+
@IsOptional()
|
|
57
|
+
@IsInt({ each: true })
|
|
58
|
+
idOfferList?: number[];
|
|
59
|
+
|
|
60
|
+
@ApiPropertyOptional()
|
|
61
|
+
@IsOptional()
|
|
62
|
+
@IsInt({ each: true })
|
|
63
|
+
idState?: number[];
|
|
64
|
+
|
|
40
65
|
@ApiPropertyOptional()
|
|
41
66
|
@IsOptional()
|
|
42
67
|
@IsInt({ each: true })
|
|
43
68
|
idConstitutionState?: number[];
|
|
69
|
+
|
|
70
|
+
@ApiPropertyOptional()
|
|
71
|
+
@IsOptional()
|
|
72
|
+
@IsInt()
|
|
73
|
+
idTypeBrand?: number;
|
|
44
74
|
}
|
package/ts/utils/prestation.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { IExercice, IPrestation, IPrestationList } from '../types';
|
|
2
|
-
import { Vat } from '../types/Enum/Vat';
|
|
3
|
-
import { ReasonTerminationType } from '../types/Enum/ReasonTerminationType';
|
|
4
|
-
import {
|
|
5
|
-
import { intersection } from './noLodash';
|
|
1
|
+
import { IExercice, IPrestation, IPrestationList } from '../types/index.js';
|
|
2
|
+
import { Vat } from '../types/Enum/Vat.js';
|
|
3
|
+
import { ReasonTerminationType } from '../types/Enum/ReasonTerminationType.js';
|
|
4
|
+
import { intersection } from './noLodash.js';
|
|
6
5
|
import {
|
|
7
6
|
ClementineSubscriptionAccountancySoftwarePrestations,
|
|
8
7
|
PrestationDetail,
|
|
9
8
|
PrestationType,
|
|
10
|
-
} from '../types/Enum/PrestationType';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { exerciceNumber } from './exercice';
|
|
9
|
+
} from '../types/Enum/PrestationType.js';
|
|
10
|
+
import { PrestationOptionType, PrestationOption } from '../types/Enum/PrestationOption.js';
|
|
11
|
+
import { PriceGridClementine } from '../types/Enum/PriceGridClementine.js';
|
|
12
|
+
import { PriceGridPourcentage } from '../types/Enum/PriceGridPourcentage.js';
|
|
13
|
+
import { PriceGridLegalstart } from '../types/Enum/PriceGridLegalstart.js';
|
|
14
|
+
import { PriceGridStatutsExpress } from '../types/Enum/PriceGridStatutsExpress.js';
|
|
15
|
+
import { ClosingType } from '../types/Enum/ClosingType.js';
|
|
16
|
+
import { getBrandNameByNodeEnv } from './brands.js';
|
|
17
|
+
import dayjs from 'dayjs';
|
|
18
|
+
import { exerciceNumber } from './exercice.js';
|
|
21
19
|
|
|
22
20
|
type priceGridBrand = {
|
|
23
21
|
idTypeBrand: number;
|
|
@@ -154,10 +152,45 @@ const isConsultingHour = (idPrestationList: number[]): boolean =>
|
|
|
154
152
|
!!intersection(idPrestationList, [PrestationType.CONSULTING_HOUR]).length;
|
|
155
153
|
|
|
156
154
|
const isSoftwarePrestation = (idPrestationList: number[]): boolean =>
|
|
157
|
-
!!intersection(idPrestationList, [
|
|
158
|
-
.
|
|
155
|
+
!!intersection(idPrestationList, [
|
|
156
|
+
PrestationType.STEERING,
|
|
157
|
+
PrestationType.VAT,
|
|
158
|
+
PrestationType.BALANCESHEET,
|
|
159
|
+
PrestationType.BILLING,
|
|
160
|
+
]).length; /* &&
|
|
159
161
|
idPrestationList.length === 1 */ // Commenté car si un client résilie un software pour un utre software, condition non prise en charge
|
|
160
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Retourne la première prestation comptable non catalogue trouvée dans une liste.
|
|
165
|
+
*
|
|
166
|
+
* @param prestationsList Liste de prestations de référence.
|
|
167
|
+
* @returns La prestation comptable non catalogue, ou undefined si aucune n'est trouvée.
|
|
168
|
+
*/
|
|
169
|
+
const getComptableNotCatalogPrestation = (
|
|
170
|
+
prestationsList: Array<Partial<IPrestationList>>,
|
|
171
|
+
): Partial<IPrestationList> | undefined =>
|
|
172
|
+
prestationsList.find((prestation) => !!prestation.isComptable && !prestation.isCatalog);
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Retourne true si une prestation comptable (isPlannable & isComptable & !isCatalog) est trouvée dans la liste.
|
|
176
|
+
*
|
|
177
|
+
* @param prestationsList Liste de prestations de référence.
|
|
178
|
+
* @returns true si une prestation comptable est trouvée, sinon false.
|
|
179
|
+
*/
|
|
180
|
+
const hasAccountingPrestation = (prestationsList: Array<Partial<IPrestationList>>): boolean =>
|
|
181
|
+
!!prestationsList.find((prestation) => !!prestation.isPlannable && !!prestation.isComptable && !prestation.isCatalog);
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Retourne la première prestation comptable (isPlannable & isComptable & !isCatalog) trouvée dans la liste.
|
|
185
|
+
*
|
|
186
|
+
* @param prestationsList Liste de prestations de référence.
|
|
187
|
+
* @returns La prestation comptable, ou undefined si aucune n'est trouvée.
|
|
188
|
+
*/
|
|
189
|
+
const getAccountingPrestation = (
|
|
190
|
+
prestationsList: Array<Partial<IPrestationList>>,
|
|
191
|
+
): Partial<IPrestationList> | undefined =>
|
|
192
|
+
prestationsList.find((prestation) => !!prestation.isPlannable && !!prestation.isComptable && !prestation.isCatalog);
|
|
193
|
+
|
|
161
194
|
const calculateScoringOfPrestation = (
|
|
162
195
|
idPrestationType: PrestationType,
|
|
163
196
|
prestations: IPrestation[],
|
|
@@ -196,7 +229,9 @@ const calculateScoringOfPrestation = (
|
|
|
196
229
|
p.isComptable &&
|
|
197
230
|
!p.isCatalog &&
|
|
198
231
|
p.id &&
|
|
199
|
-
![PrestationType.BALANCESHEET, PrestationType.VAT, PrestationType.STEERING].includes(
|
|
232
|
+
![PrestationType.BALANCESHEET, PrestationType.VAT, PrestationType.STEERING, PrestationType.BILLING].includes(
|
|
233
|
+
p.id,
|
|
234
|
+
),
|
|
200
235
|
);
|
|
201
236
|
const prestationHalfPriceIds = prestationHalfPriceList.map((t) => t.id);
|
|
202
237
|
|
|
@@ -227,9 +262,8 @@ const calculateScoringOfPrestation = (
|
|
|
227
262
|
const prestationsExistIds = prestationsSignedPaid.map((prestation) => prestation.idPrestationList);
|
|
228
263
|
const prestationHalfPriceAlreadyDoneIds = prestationsExistIds.filter((id) => prestationHalfPriceIds.includes(id));
|
|
229
264
|
|
|
230
|
-
// If one of the prestations already done is in the list of prestations that are half price and if the idPrestationType is in prestationHalfPriceIds, return
|
|
231
|
-
if (prestationHalfPriceAlreadyDoneIds.length && prestationHalfPriceIds.includes(idPrestationType))
|
|
232
|
-
return Math.floor(numberPoint * 0.3);
|
|
265
|
+
// If one of the prestations already done is in the list of prestations that are half price and if the idPrestationType is in prestationHalfPriceIds, return upsell points (250)
|
|
266
|
+
if (prestationHalfPriceAlreadyDoneIds.length && prestationHalfPriceIds.includes(idPrestationType)) return 250;
|
|
233
267
|
|
|
234
268
|
return numberPoint;
|
|
235
269
|
};
|
|
@@ -427,24 +461,6 @@ const calculatePrestationPriceWithPrestationList = (prestationList: IPrestationL
|
|
|
427
461
|
return totalPrestation;
|
|
428
462
|
};
|
|
429
463
|
|
|
430
|
-
/**
|
|
431
|
-
* From idLegalForm, get application fees amount (without taxes included if no idVat passed, or with taxes included calculated by given idVat)
|
|
432
|
-
* @param idLegalForm
|
|
433
|
-
* @param idVat
|
|
434
|
-
* @returns amount of application fees, without taxes included
|
|
435
|
-
* @deprecated Application fees are not charged anymore
|
|
436
|
-
*/
|
|
437
|
-
const getApplicationFeesAmount = (idLegalForm: number, idVat?: number) => {
|
|
438
|
-
let applicationFeesAmount = 50;
|
|
439
|
-
if (idLegalForm === LegalFormTypeEnum.SCI) applicationFeesAmount = 150;
|
|
440
|
-
|
|
441
|
-
//Sans tva, on envoie le montant HT
|
|
442
|
-
if (!idVat) return applicationFeesAmount;
|
|
443
|
-
|
|
444
|
-
//Avec tva, on envoie le montant TTC
|
|
445
|
-
return getTaxesIncludedAmount(applicationFeesAmount, idVat);
|
|
446
|
-
};
|
|
447
|
-
|
|
448
464
|
const calculatePrestationPrice = (
|
|
449
465
|
idPrestationList: number,
|
|
450
466
|
prestationList: IPrestationList,
|
|
@@ -461,7 +477,6 @@ const calculatePrestationPrice = (
|
|
|
461
477
|
totalPercentage: number /* total pourcentage offer (%) */,
|
|
462
478
|
totalAmount: number /* total montant offer (€) */,
|
|
463
479
|
totalMonth: number /* total mois offer (mois) */,
|
|
464
|
-
isWithApplicationFees: boolean /* frais de dossier */,
|
|
465
480
|
idTaxSystem: number,
|
|
466
481
|
idLegalForm: number,
|
|
467
482
|
isYearly: boolean = false /* prestation annuel ou mensuel */,
|
|
@@ -552,11 +567,10 @@ const calculatePrestationPrice = (
|
|
|
552
567
|
} else {
|
|
553
568
|
totalPrestation = calculatePrestationPriceWithPrestationList(prestationList);
|
|
554
569
|
if ([PrestationType.CREATION_SOCIETE].includes(idPrestationList) && !isSubPrestation) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
570
|
+
// totalPrestation += 50;
|
|
571
|
+
// La création est offerte désormais
|
|
572
|
+
// inutile d'ajouter les frais de greffe et d'annonce légale,
|
|
573
|
+
// car ne compte pas dans le calcul pour les sales
|
|
560
574
|
}
|
|
561
575
|
}
|
|
562
576
|
/* Gestion des offres */
|
|
@@ -578,13 +592,8 @@ const calculatePrestationPrice = (
|
|
|
578
592
|
});
|
|
579
593
|
}
|
|
580
594
|
totalPrestation += OptionTotalPrice ? OptionTotalPrice : 0;
|
|
581
|
-
/* Gestion des frais de dossier */
|
|
582
|
-
// if (isWithApplicationFees) {
|
|
583
|
-
// const applicationFeesAmount = getApplicationFeesAmount(idLegalForm);
|
|
584
|
-
// totalPrestation += applicationFeesAmount;
|
|
585
|
-
// }
|
|
586
595
|
|
|
587
|
-
const calculDetail = `${monthNbr > 0 ? monthNbr + ' mois x ' + Math.round(price * 100) / 100 + '€' : Math.round(price * 100) / 100 + '€'} ${totalAmount > 0 ? '- ' + totalAmount + '€' : ''} ${totalPercentage > 0 ? '- ' + totalPercentage + '%' : ''}
|
|
596
|
+
const calculDetail = `${monthNbr > 0 ? monthNbr + ' mois x ' + Math.round(price * 100) / 100 + '€' : Math.round(price * 100) / 100 + '€'} ${totalAmount > 0 ? '- ' + totalAmount + '€' : ''} ${totalPercentage > 0 ? '- ' + totalPercentage + '%' : ''}`;
|
|
588
597
|
|
|
589
598
|
return {
|
|
590
599
|
totalPrestation,
|
|
@@ -665,11 +674,13 @@ export {
|
|
|
665
674
|
isExpress,
|
|
666
675
|
isConsultingHour,
|
|
667
676
|
isSoftwarePrestation,
|
|
677
|
+
getComptableNotCatalogPrestation,
|
|
678
|
+
hasAccountingPrestation,
|
|
679
|
+
getAccountingPrestation,
|
|
668
680
|
calculateScoringOfPrestation,
|
|
669
681
|
calculatePrestationPrice,
|
|
670
682
|
getPrestationOptions,
|
|
671
683
|
isAbleToUpdatePrice,
|
|
672
684
|
calculatePrestationPriceWithPriceGrid,
|
|
673
|
-
getApplicationFeesAmount,
|
|
674
685
|
idPrestationListToOfferType,
|
|
675
686
|
};
|