@silexpert/core 1.1.316 → 1.1.318
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/api/resources/Project.d.ts +6 -0
- package/dist/cjs/api/resources/Project.d.ts.map +1 -0
- package/dist/cjs/api/resources/Project.js +16 -0
- package/dist/cjs/api/resources/Project.js.map +1 -0
- package/dist/cjs/api/resources.d.ts +2 -0
- package/dist/cjs/api/resources.d.ts.map +1 -1
- package/dist/cjs/api/resources.js +2 -0
- package/dist/cjs/api/resources.js.map +1 -1
- package/dist/cjs/types/Enum/BalanceSheet.js +14 -14
- package/dist/cjs/types/Enum/BalanceSheet.js.map +1 -1
- package/dist/cjs/types/Enum/BrandClementine.d.ts +5 -0
- package/dist/cjs/types/Enum/BrandClementine.d.ts.map +1 -1
- package/dist/cjs/types/Enum/BrandClementine.js +1 -0
- package/dist/cjs/types/Enum/BrandClementine.js.map +1 -1
- package/dist/cjs/types/Enum/RoleDetail.d.ts +22 -0
- package/dist/cjs/types/Enum/RoleDetail.d.ts.map +1 -1
- package/dist/cjs/types/Enum/RoleDetail.js +22 -0
- package/dist/cjs/types/Enum/RoleDetail.js.map +1 -1
- package/dist/cjs/types/Enum/TaskResponseType.js +1 -1
- package/dist/cjs/types/Enum/TaskResponseType.js.map +1 -1
- package/dist/cjs/types/Interface/api/balanceSheet/ReadBalanceSheet.d.ts +1 -0
- package/dist/cjs/types/Interface/api/balanceSheet/ReadBalanceSheet.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/balanceSheet/ReadBalanceSheet.js.map +1 -1
- package/dist/cjs/types/Interface/api/ldap/NewLDAPUser.d.ts +20 -0
- package/dist/cjs/types/Interface/api/ldap/NewLDAPUser.d.ts.map +1 -0
- package/dist/cjs/types/Interface/api/ldap/NewLDAPUser.js +3 -0
- package/dist/cjs/types/Interface/api/ldap/NewLDAPUser.js.map +1 -0
- package/dist/cjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.d.ts +1 -0
- package/dist/cjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.js +4 -0
- package/dist/cjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.js.map +1 -1
- package/dist/cjs/types/Interface/api/payment/Util.d.ts +1 -0
- package/dist/cjs/types/Interface/api/payment/Util.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/payment/Util.js.map +1 -1
- package/dist/cjs/types/Interface/api/user/CreateCoworker.d.ts +5 -0
- package/dist/cjs/types/Interface/api/user/CreateCoworker.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/user/CreateCoworker.js +35 -2
- package/dist/cjs/types/Interface/api/user/CreateCoworker.js.map +1 -1
- package/dist/cjs/types/Interface/api/user/CreateUser.d.ts +1 -0
- package/dist/cjs/types/Interface/api/user/CreateUser.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/user/CreateUser.js +5 -0
- package/dist/cjs/types/Interface/api/user/CreateUser.js.map +1 -1
- package/dist/cjs/types/Interface/models/IRole.d.ts +1 -0
- package/dist/cjs/types/Interface/models/IRole.d.ts.map +1 -1
- package/dist/cjs/types/Interface/models/IRole.js.map +1 -1
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/payment.d.ts +1 -0
- package/dist/cjs/utils/payment.d.ts.map +1 -1
- package/dist/cjs/utils/payment.js +12 -10
- package/dist/cjs/utils/payment.js.map +1 -1
- package/dist/cjs/utils/tests/payment.spec.js +32 -83
- package/dist/cjs/utils/tests/payment.spec.js.map +1 -1
- package/dist/mjs/api/resources/Project.d.ts +6 -0
- package/dist/mjs/api/resources/Project.d.ts.map +1 -0
- package/dist/mjs/api/resources/Project.js +12 -0
- package/dist/mjs/api/resources/Project.js.map +1 -0
- package/dist/mjs/api/resources.d.ts +2 -0
- package/dist/mjs/api/resources.d.ts.map +1 -1
- package/dist/mjs/api/resources.js +2 -0
- package/dist/mjs/api/resources.js.map +1 -1
- package/dist/mjs/types/Enum/BalanceSheet.js +14 -14
- package/dist/mjs/types/Enum/BalanceSheet.js.map +1 -1
- package/dist/mjs/types/Enum/BrandClementine.d.ts +5 -0
- package/dist/mjs/types/Enum/BrandClementine.d.ts.map +1 -1
- package/dist/mjs/types/Enum/BrandClementine.js +1 -0
- package/dist/mjs/types/Enum/BrandClementine.js.map +1 -1
- package/dist/mjs/types/Enum/RoleDetail.d.ts +22 -0
- package/dist/mjs/types/Enum/RoleDetail.d.ts.map +1 -1
- package/dist/mjs/types/Enum/RoleDetail.js +22 -0
- package/dist/mjs/types/Enum/RoleDetail.js.map +1 -1
- package/dist/mjs/types/Enum/TaskResponseType.js +1 -1
- package/dist/mjs/types/Enum/TaskResponseType.js.map +1 -1
- package/dist/mjs/types/Interface/api/balanceSheet/ReadBalanceSheet.d.ts +1 -0
- package/dist/mjs/types/Interface/api/balanceSheet/ReadBalanceSheet.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/balanceSheet/ReadBalanceSheet.js.map +1 -1
- package/dist/mjs/types/Interface/api/ldap/NewLDAPUser.d.ts +20 -0
- package/dist/mjs/types/Interface/api/ldap/NewLDAPUser.d.ts.map +1 -0
- package/dist/mjs/types/Interface/api/ldap/NewLDAPUser.js +2 -0
- package/dist/mjs/types/Interface/api/ldap/NewLDAPUser.js.map +1 -0
- package/dist/mjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.d.ts +1 -0
- package/dist/mjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.js +5 -0
- package/dist/mjs/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.js.map +1 -1
- package/dist/mjs/types/Interface/api/payment/Util.d.ts +1 -0
- package/dist/mjs/types/Interface/api/payment/Util.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/payment/Util.js.map +1 -1
- package/dist/mjs/types/Interface/api/user/CreateCoworker.d.ts +5 -0
- package/dist/mjs/types/Interface/api/user/CreateCoworker.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/user/CreateCoworker.js +41 -3
- package/dist/mjs/types/Interface/api/user/CreateCoworker.js.map +1 -1
- package/dist/mjs/types/Interface/api/user/CreateUser.d.ts +1 -0
- package/dist/mjs/types/Interface/api/user/CreateUser.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/user/CreateUser.js +6 -0
- package/dist/mjs/types/Interface/api/user/CreateUser.js.map +1 -1
- package/dist/mjs/types/Interface/models/IRole.d.ts +1 -0
- package/dist/mjs/types/Interface/models/IRole.d.ts.map +1 -1
- package/dist/mjs/types/Interface/models/IRole.js.map +1 -1
- package/dist/mjs/types/index.d.ts +1 -0
- package/dist/mjs/types/index.d.ts.map +1 -1
- package/dist/mjs/types/index.js +1 -0
- package/dist/mjs/types/index.js.map +1 -1
- package/dist/mjs/utils/payment.d.ts +1 -0
- package/dist/mjs/utils/payment.d.ts.map +1 -1
- package/dist/mjs/utils/payment.js +12 -10
- package/dist/mjs/utils/payment.js.map +1 -1
- package/dist/mjs/utils/tests/payment.spec.js +21 -71
- package/dist/mjs/utils/tests/payment.spec.js.map +1 -1
- package/package.json +1 -1
- package/ts/api/resources/Project.ts +12 -0
- package/ts/api/resources.ts +2 -0
- package/ts/types/Enum/BalanceSheet.ts +14 -14
- package/ts/types/Enum/BrandClementine.ts +1 -0
- package/ts/types/Enum/RoleDetail.ts +26 -0
- package/ts/types/Enum/TaskResponseType.ts +1 -1
- package/ts/types/Interface/api/balanceSheet/ReadBalanceSheet.ts +1 -0
- package/ts/types/Interface/api/ldap/NewLDAPUser.ts +20 -0
- package/ts/types/Interface/api/machineLearning/CreateMachineLearningAnnotation.ts +3 -0
- package/ts/types/Interface/api/payment/Util.ts +1 -0
- package/ts/types/Interface/api/user/CreateCoworker.ts +32 -3
- package/ts/types/Interface/api/user/CreateUser.ts +4 -0
- package/ts/types/Interface/models/IRole.ts +1 -0
- package/ts/types/index.ts +1 -0
- package/ts/utils/payment.ts +13 -9
- package/ts/utils/tests/payment.spec.ts +22 -68
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dayjs from 'dayjs';
|
|
2
|
-
import { IRegulation, Vat, PaymentMethod, LegalFormTypeEnum } from '../../types';
|
|
2
|
+
import { IRegulation, Vat, PaymentMethod, LegalFormTypeEnum, getTaxesIncludedAmount } from '../../types';
|
|
3
3
|
import MockDate from 'mockdate';
|
|
4
4
|
|
|
5
5
|
import { calculatePaymentsAuto } from '../payment';
|
|
@@ -33,7 +33,6 @@ describe('Payment', () => {
|
|
|
33
33
|
signaturePage: 7,
|
|
34
34
|
};
|
|
35
35
|
const idVat = Vat.TX_10.id;
|
|
36
|
-
const vatRate = Object.values(Vat).find(v => v.id === idVat)?.value ?? 20;
|
|
37
36
|
const listPartialExercicePrestationExpress:PartialExercicePrestationExpress[] = [
|
|
38
37
|
{
|
|
39
38
|
startDate: dayjs().subtract(2, 'year').startOf('month').toDate(),
|
|
@@ -100,50 +99,6 @@ describe('Payment', () => {
|
|
|
100
99
|
expect(error.message).toStrictEqual('Ce type de prestation ne correspond pas aux conditions attendues.');
|
|
101
100
|
}
|
|
102
101
|
});
|
|
103
|
-
test('should return error if listRegulations is empty', () => {
|
|
104
|
-
expect.assertions(2);
|
|
105
|
-
try {
|
|
106
|
-
calculatePaymentsAuto({
|
|
107
|
-
idTypeBrand: 1,
|
|
108
|
-
goToClient: dayjs('2024-06-06').toDate(),
|
|
109
|
-
firstExerciceNonExpresssEndDate,
|
|
110
|
-
idPrestation,
|
|
111
|
-
isWithApplicationFees: true,
|
|
112
|
-
idLegalForm: LegalFormTypeEnum.SARL,
|
|
113
|
-
prestationList,
|
|
114
|
-
idVat,
|
|
115
|
-
listPartialExercicePrestationExpress,
|
|
116
|
-
listRegulations: [],
|
|
117
|
-
yearlyAmountNonExpress,
|
|
118
|
-
nextYearlyAmountNonExpress });
|
|
119
|
-
} catch (error) {
|
|
120
|
-
expect(error).toBeInstanceOf(Error);
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
expect(error.message).toStrictEqual('List of regulations can not be empty');
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
test('should listRegulations contain amount and amountUsed', () => {
|
|
126
|
-
expect.assertions(2);
|
|
127
|
-
try {
|
|
128
|
-
calculatePaymentsAuto({
|
|
129
|
-
idTypeBrand: 1,
|
|
130
|
-
goToClient: dayjs('2024-06-06').toDate(),
|
|
131
|
-
firstExerciceNonExpresssEndDate,
|
|
132
|
-
idPrestation,
|
|
133
|
-
isWithApplicationFees: true,
|
|
134
|
-
idLegalForm: LegalFormTypeEnum.SARL,
|
|
135
|
-
prestationList,
|
|
136
|
-
idVat,
|
|
137
|
-
listPartialExercicePrestationExpress,
|
|
138
|
-
listRegulations: [{ processed: true } as IRegulation],
|
|
139
|
-
yearlyAmountNonExpress,
|
|
140
|
-
nextYearlyAmountNonExpress });
|
|
141
|
-
} catch (error) {
|
|
142
|
-
expect(error).toBeInstanceOf(Error);
|
|
143
|
-
// @ts-ignore
|
|
144
|
-
expect(error.message).toStrictEqual('Amount and amountUsed are missing for regulations');
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
102
|
|
|
148
103
|
// =====================
|
|
149
104
|
// logical
|
|
@@ -214,7 +169,7 @@ describe('Payment', () => {
|
|
|
214
169
|
|
|
215
170
|
// const listNonExpressPayments = payments.filter(p => p.closingDate === newFirstExerciceNonExpresssEndDate);
|
|
216
171
|
const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
|
|
217
|
-
expect(listNonExpressPayments.length).toStrictEqual(nbMonthDelay);
|
|
172
|
+
expect(listNonExpressPayments.length).toStrictEqual(1 + nbMonthDelay); //On ajoute 1 pour les frais de dossier
|
|
218
173
|
|
|
219
174
|
MockDate.reset();
|
|
220
175
|
});
|
|
@@ -240,7 +195,7 @@ describe('Payment', () => {
|
|
|
240
195
|
nextYearlyAmountNonExpress });
|
|
241
196
|
|
|
242
197
|
const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
|
|
243
|
-
expect(listNonExpressPayments.length).toStrictEqual(3);
|
|
198
|
+
expect(listNonExpressPayments.length).toStrictEqual(1 + 3); //On ajoute 1 pour les frais de dossier
|
|
244
199
|
});
|
|
245
200
|
test('should (yearlyAmountNonExpress - sum of listRegulations) / count of monthly payments be equal to monthly payment amount (if not in 3 last month)', async () => {
|
|
246
201
|
const mockedDate = dayjs('2024-05-15').toDate();
|
|
@@ -257,7 +212,7 @@ describe('Payment', () => {
|
|
|
257
212
|
goToClient: dayjs('2024-06-06').toDate(),
|
|
258
213
|
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
259
214
|
idPrestation,
|
|
260
|
-
isWithApplicationFees:
|
|
215
|
+
isWithApplicationFees: false,
|
|
261
216
|
idLegalForm: LegalFormTypeEnum.SARL,
|
|
262
217
|
prestationList,
|
|
263
218
|
idVat,
|
|
@@ -266,10 +221,10 @@ describe('Payment', () => {
|
|
|
266
221
|
yearlyAmountNonExpress,
|
|
267
222
|
nextYearlyAmountNonExpress });
|
|
268
223
|
|
|
269
|
-
const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);
|
|
224
|
+
const diff = getTaxesIncludedAmount(yearlyAmountNonExpress, idVat) - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);
|
|
270
225
|
const amount = Math.round(100 * diff / nbMonthDelay) / 100;
|
|
271
226
|
|
|
272
|
-
expect(payments[
|
|
227
|
+
expect(payments[1].amount).toStrictEqual(amount);
|
|
273
228
|
|
|
274
229
|
MockDate.reset();
|
|
275
230
|
});
|
|
@@ -285,7 +240,7 @@ describe('Payment', () => {
|
|
|
285
240
|
goToClient: dayjs('2024-06-06').toDate(),
|
|
286
241
|
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
287
242
|
idPrestation,
|
|
288
|
-
isWithApplicationFees:
|
|
243
|
+
isWithApplicationFees: false,
|
|
289
244
|
idLegalForm: LegalFormTypeEnum.SARL,
|
|
290
245
|
prestationList,
|
|
291
246
|
idVat,
|
|
@@ -294,10 +249,10 @@ describe('Payment', () => {
|
|
|
294
249
|
yearlyAmountNonExpress,
|
|
295
250
|
nextYearlyAmountNonExpress });
|
|
296
251
|
|
|
297
|
-
const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);
|
|
252
|
+
const diff = getTaxesIncludedAmount(yearlyAmountNonExpress, idVat) - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);
|
|
298
253
|
const amount = Math.round(100 * diff / 3) / 100;
|
|
299
254
|
|
|
300
|
-
expect(payments[
|
|
255
|
+
expect(payments[1].amount).toStrictEqual(amount);
|
|
301
256
|
});
|
|
302
257
|
// annual price increase
|
|
303
258
|
test('should apply annual price increase (2,75%) if signed before last 3 months of civil year', async () => {
|
|
@@ -324,7 +279,8 @@ describe('Payment', () => {
|
|
|
324
279
|
nextYearlyAmountNonExpress });
|
|
325
280
|
|
|
326
281
|
const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
|
|
327
|
-
|
|
282
|
+
const firstPaymentWithTaxRateForced = listNonExpressPayments[1].amount * 1.0275;
|
|
283
|
+
expect(firstPaymentWithTaxRateForced - listNonExpressPayments.splice(-2)[0].amount).toBeLessThanOrEqual(0.01); //Permet de gérer le pb d'arrondi
|
|
328
284
|
|
|
329
285
|
MockDate.reset();
|
|
330
286
|
});
|
|
@@ -368,7 +324,7 @@ describe('Payment', () => {
|
|
|
368
324
|
goToClient: dayjs('2024-06-06').toDate(),
|
|
369
325
|
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
370
326
|
idPrestation,
|
|
371
|
-
isWithApplicationFees:
|
|
327
|
+
isWithApplicationFees: false,
|
|
372
328
|
idLegalForm: LegalFormTypeEnum.SARL,
|
|
373
329
|
prestationList,
|
|
374
330
|
idVat,
|
|
@@ -379,10 +335,10 @@ describe('Payment', () => {
|
|
|
379
335
|
} as IRegulation],
|
|
380
336
|
yearlyAmountNonExpress,
|
|
381
337
|
nextYearlyAmountNonExpress });
|
|
382
|
-
|
|
383
|
-
const paymentsOfFirstExo = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0)
|
|
338
|
+
|
|
339
|
+
const paymentsOfFirstExo = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0)[0].amount ?? 0;
|
|
384
340
|
const paymentsOfSecondExo = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-07-01')) === 0).splice(-1)[0].amount ?? 0;
|
|
385
|
-
expect(paymentsOfFirstExo + appCost *
|
|
341
|
+
expect(Math.round(100 * (paymentsOfFirstExo + getTaxesIncludedAmount(appCost, idVat) * 1.0275)) / 100).toStrictEqual(paymentsOfSecondExo);
|
|
386
342
|
|
|
387
343
|
MockDate.reset();
|
|
388
344
|
});
|
|
@@ -423,7 +379,7 @@ describe('Payment', () => {
|
|
|
423
379
|
goToClient: dayjs('2024-06-06').toDate(),
|
|
424
380
|
firstExerciceNonExpresssEndDate,
|
|
425
381
|
idPrestation,
|
|
426
|
-
isWithApplicationFees:
|
|
382
|
+
isWithApplicationFees: false,
|
|
427
383
|
idLegalForm: LegalFormTypeEnum.SARL,
|
|
428
384
|
prestationList,
|
|
429
385
|
idVat,
|
|
@@ -441,17 +397,15 @@ describe('Payment', () => {
|
|
|
441
397
|
expect(payments.length).toBeGreaterThanOrEqual(2);
|
|
442
398
|
expect(payments[0]).toMatchObject(
|
|
443
399
|
{
|
|
444
|
-
amount:
|
|
445
|
-
datePayment: dayjs(mockedDate).add(1, 'month').startOf('month').toDate(),
|
|
400
|
+
amount: 1320, // 1200 * 1,1
|
|
446
401
|
idPrestation: 1,
|
|
447
|
-
idPaymentMethod:
|
|
402
|
+
idPaymentMethod: PaymentMethod.BANK_CARD.id,
|
|
448
403
|
});
|
|
449
404
|
expect(payments[1]).toMatchObject(
|
|
450
405
|
{
|
|
451
|
-
amount:
|
|
452
|
-
datePayment: dayjs(mockedDate).add(2, 'month').startOf('month').toDate(),
|
|
406
|
+
amount: 680, // 2000 - (1200 * 1,1)
|
|
453
407
|
idPrestation: 1,
|
|
454
|
-
idPaymentMethod:
|
|
408
|
+
idPaymentMethod: PaymentMethod.BANK_CARD.id,
|
|
455
409
|
});
|
|
456
410
|
MockDate.reset();
|
|
457
411
|
});
|
|
@@ -464,7 +418,7 @@ describe('Payment', () => {
|
|
|
464
418
|
goToClient: dayjs('2024-06-06').toDate(),
|
|
465
419
|
firstExerciceNonExpresssEndDate,
|
|
466
420
|
idPrestation,
|
|
467
|
-
isWithApplicationFees:
|
|
421
|
+
isWithApplicationFees: false,
|
|
468
422
|
idLegalForm: LegalFormTypeEnum.SARL,
|
|
469
423
|
prestationList,
|
|
470
424
|
idVat,
|
|
@@ -473,7 +427,7 @@ describe('Payment', () => {
|
|
|
473
427
|
yearlyAmountNonExpress,
|
|
474
428
|
nextYearlyAmountNonExpress });
|
|
475
429
|
expect(payments.length).toBeGreaterThanOrEqual(4);
|
|
476
|
-
expect(payments?.[
|
|
430
|
+
expect(payments?.[1]?.datePayment).toStrictEqual(dayjs().add(2, 'month').startOf('month').toDate());
|
|
477
431
|
MockDate.reset();
|
|
478
432
|
});
|
|
479
433
|
test('last payment returned should be last of a year (12/XX)', async () => {
|