@silexpert/core 1.1.315 → 1.1.317

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.
@@ -15,7 +15,6 @@ const mockdate_1 = require("mockdate");
15
15
  const payment_1 = require("../payment");
16
16
  describe('Payment', () => {
17
17
  describe('calculatePayments', () => {
18
- var _a, _b;
19
18
  const idPrestation = 1;
20
19
  const idSociety = 1;
21
20
  const yearlyAmountNonExpress = 1800;
@@ -41,7 +40,6 @@ describe('Payment', () => {
41
40
  signaturePage: 7,
42
41
  };
43
42
  const idVat = types_1.Vat.TX_10.id;
44
- const vatRate = (_b = (_a = Object.values(types_1.Vat).find(v => v.id === idVat)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 20;
45
43
  const listPartialExercicePrestationExpress = [
46
44
  {
47
45
  startDate: dayjs().subtract(2, 'year').startOf('month').toDate(),
@@ -106,54 +104,6 @@ describe('Payment', () => {
106
104
  expect(error.message).toStrictEqual('Ce type de prestation ne correspond pas aux conditions attendues.');
107
105
  }
108
106
  });
109
- test('should return error if listRegulations is empty', () => {
110
- expect.assertions(2);
111
- try {
112
- (0, payment_1.calculatePaymentsAuto)({
113
- idTypeBrand: 1,
114
- goToClient: dayjs('2024-06-06').toDate(),
115
- firstExerciceNonExpresssEndDate,
116
- idPrestation,
117
- isWithApplicationFees: true,
118
- idLegalForm: types_1.LegalFormTypeEnum.SARL,
119
- prestationList,
120
- idVat,
121
- listPartialExercicePrestationExpress,
122
- listRegulations: [],
123
- yearlyAmountNonExpress,
124
- nextYearlyAmountNonExpress
125
- });
126
- }
127
- catch (error) {
128
- expect(error).toBeInstanceOf(Error);
129
- // @ts-ignore
130
- expect(error.message).toStrictEqual('List of regulations can not be empty');
131
- }
132
- });
133
- test('should listRegulations contain amount and amountUsed', () => {
134
- expect.assertions(2);
135
- try {
136
- (0, payment_1.calculatePaymentsAuto)({
137
- idTypeBrand: 1,
138
- goToClient: dayjs('2024-06-06').toDate(),
139
- firstExerciceNonExpresssEndDate,
140
- idPrestation,
141
- isWithApplicationFees: true,
142
- idLegalForm: types_1.LegalFormTypeEnum.SARL,
143
- prestationList,
144
- idVat,
145
- listPartialExercicePrestationExpress,
146
- listRegulations: [{ processed: true }],
147
- yearlyAmountNonExpress,
148
- nextYearlyAmountNonExpress
149
- });
150
- }
151
- catch (error) {
152
- expect(error).toBeInstanceOf(Error);
153
- // @ts-ignore
154
- expect(error.message).toStrictEqual('Amount and amountUsed are missing for regulations');
155
- }
156
- });
157
107
  // =====================
158
108
  // logical
159
109
  // =====================
@@ -178,7 +128,7 @@ describe('Payment', () => {
178
128
  expect(dayjs(firstNonExpressDatePayment).diff(firstExpressDatePayment, 'month')).toStrictEqual(0);
179
129
  }));
180
130
  test('if more than one express, monthly payments of actual exo should be in a row of express monthly payments and smoothed, smoothed in number of remaining months after express monthly payments (mini 3 months) (if in 3 last month of exercice)', () => __awaiter(void 0, void 0, void 0, function* () {
181
- var _c, _d, _e, _f;
131
+ var _a, _b, _c, _d;
182
132
  const payments = (0, payment_1.calculatePaymentsAuto)({
183
133
  idTypeBrand: 1,
184
134
  goToClient: dayjs('2024-06-06').toDate(),
@@ -193,8 +143,8 @@ describe('Payment', () => {
193
143
  yearlyAmountNonExpress,
194
144
  nextYearlyAmountNonExpress
195
145
  });
196
- const lastExpressDatePayment = (_d = (_c = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0).splice(-1)) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.datePayment;
197
- const firstNonExpressDatePayment = (_f = (_e = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.datePayment;
146
+ const lastExpressDatePayment = (_b = (_a = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0).splice(-1)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.datePayment;
147
+ const firstNonExpressDatePayment = (_d = (_c = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.datePayment;
198
148
  expect(dayjs(firstNonExpressDatePayment).diff(lastExpressDatePayment, 'month')).toStrictEqual(1);
199
149
  }));
200
150
  // non express
@@ -222,7 +172,7 @@ describe('Payment', () => {
222
172
  });
223
173
  // const listNonExpressPayments = payments.filter(p => p.closingDate === newFirstExerciceNonExpresssEndDate);
224
174
  const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
225
- expect(listNonExpressPayments.length).toStrictEqual(nbMonthDelay);
175
+ expect(listNonExpressPayments.length).toStrictEqual(1 + nbMonthDelay); //On ajoute 1 pour les frais de dossier
226
176
  mockdate_1.default.reset();
227
177
  }));
228
178
  test('should return a number of payments equal to 3 (if in 3 last month of exercice)', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -246,7 +196,7 @@ describe('Payment', () => {
246
196
  nextYearlyAmountNonExpress
247
197
  });
248
198
  const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
249
- expect(listNonExpressPayments.length).toStrictEqual(3);
199
+ expect(listNonExpressPayments.length).toStrictEqual(1 + 3); //On ajoute 1 pour les frais de dossier
250
200
  }));
251
201
  test('should (yearlyAmountNonExpress - sum of listRegulations) / count of monthly payments be equal to monthly payment amount (if not in 3 last month)', () => __awaiter(void 0, void 0, void 0, function* () {
252
202
  const mockedDate = dayjs('2024-05-15').toDate();
@@ -262,7 +212,7 @@ describe('Payment', () => {
262
212
  goToClient: dayjs('2024-06-06').toDate(),
263
213
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
264
214
  idPrestation,
265
- isWithApplicationFees: true,
215
+ isWithApplicationFees: false,
266
216
  idLegalForm: types_1.LegalFormTypeEnum.SARL,
267
217
  prestationList,
268
218
  idVat,
@@ -271,9 +221,9 @@ describe('Payment', () => {
271
221
  yearlyAmountNonExpress,
272
222
  nextYearlyAmountNonExpress
273
223
  });
274
- const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r) => acc + r.amount - r.amountUsed, 0);
224
+ const diff = (0, types_1.getTaxesIncludedAmount)(yearlyAmountNonExpress, idVat) - newListRegulations.reduce((acc, r) => acc + r.amount - r.amountUsed, 0);
275
225
  const amount = Math.round(100 * diff / nbMonthDelay) / 100;
276
- expect(payments[0].amount).toStrictEqual(Math.round(100 * amount * ((100 + vatRate) / 100)) / 100);
226
+ expect(payments[1].amount).toStrictEqual(amount);
277
227
  mockdate_1.default.reset();
278
228
  }));
279
229
  test('should (totalAmount - firstPaymentAmount) / 3 be equal to monthly payment amount (if in 3 last month of exercice)', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -288,7 +238,7 @@ describe('Payment', () => {
288
238
  goToClient: dayjs('2024-06-06').toDate(),
289
239
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
290
240
  idPrestation,
291
- isWithApplicationFees: true,
241
+ isWithApplicationFees: false,
292
242
  idLegalForm: types_1.LegalFormTypeEnum.SARL,
293
243
  prestationList,
294
244
  idVat,
@@ -297,9 +247,9 @@ describe('Payment', () => {
297
247
  yearlyAmountNonExpress,
298
248
  nextYearlyAmountNonExpress
299
249
  });
300
- const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r) => acc + r.amount - r.amountUsed, 0);
250
+ const diff = (0, types_1.getTaxesIncludedAmount)(yearlyAmountNonExpress, idVat) - newListRegulations.reduce((acc, r) => acc + r.amount - r.amountUsed, 0);
301
251
  const amount = Math.round(100 * diff / 3) / 100;
302
- expect(payments[0].amount).toStrictEqual(Math.round(100 * amount * ((100 + vatRate) / 100)) / 100);
252
+ expect(payments[1].amount).toStrictEqual(amount);
303
253
  }));
304
254
  // annual price increase
305
255
  test('should apply annual price increase (2,75%) if signed before last 3 months of civil year', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -324,7 +274,8 @@ describe('Payment', () => {
324
274
  nextYearlyAmountNonExpress
325
275
  });
326
276
  const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
327
- expect(Math.round(100 * listNonExpressPayments[0].amount * 1.0275) / 100).toStrictEqual(listNonExpressPayments.splice(-2)[0].amount);
277
+ const firstPaymentWithTaxRateForced = listNonExpressPayments[1].amount * 1.0275;
278
+ expect(firstPaymentWithTaxRateForced - listNonExpressPayments.splice(-2)[0].amount).toBeLessThanOrEqual(0.01); //Permet de gérer le pb d'arrondi
328
279
  mockdate_1.default.reset();
329
280
  }));
330
281
  test('should not apply annual price increase (2,75%) if signed in last 3 months of civil year', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -353,7 +304,7 @@ describe('Payment', () => {
353
304
  mockdate_1.default.reset();
354
305
  }));
355
306
  test('should apply 14,9€ HT increase for the second exercice created (only offered on first exo) (no rules for 3 last months)', () => __awaiter(void 0, void 0, void 0, function* () {
356
- var _g, _h;
307
+ var _e, _f;
357
308
  const mockedDate = dayjs('2024-06-15').toDate();
358
309
  mockdate_1.default.set(mockedDate);
359
310
  const newFirstExerciceNonExpresssEndDate = dayjs().add(12, 'month').endOf('month').toDate();
@@ -362,7 +313,7 @@ describe('Payment', () => {
362
313
  goToClient: dayjs('2024-06-06').toDate(),
363
314
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
364
315
  idPrestation,
365
- isWithApplicationFees: true,
316
+ isWithApplicationFees: false,
366
317
  idLegalForm: types_1.LegalFormTypeEnum.SARL,
367
318
  prestationList,
368
319
  idVat,
@@ -374,14 +325,14 @@ describe('Payment', () => {
374
325
  yearlyAmountNonExpress,
375
326
  nextYearlyAmountNonExpress
376
327
  });
377
- const paymentsOfFirstExo = (_g = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0).splice(-1)[0].amount) !== null && _g !== void 0 ? _g : 0;
378
- const paymentsOfSecondExo = (_h = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-07-01')) === 0).splice(-1)[0].amount) !== null && _h !== void 0 ? _h : 0;
379
- expect(paymentsOfFirstExo + appCost * ((100 + vatRate) / 100)).toStrictEqual(paymentsOfSecondExo);
328
+ const paymentsOfFirstExo = (_e = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0)[0].amount) !== null && _e !== void 0 ? _e : 0;
329
+ const paymentsOfSecondExo = (_f = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-07-01')) === 0).splice(-1)[0].amount) !== null && _f !== void 0 ? _f : 0;
330
+ expect(Math.round(100 * (paymentsOfFirstExo + (0, types_1.getTaxesIncludedAmount)(appCost, idVat) * 1.0275)) / 100).toStrictEqual(paymentsOfSecondExo);
380
331
  mockdate_1.default.reset();
381
332
  }));
382
333
  // misc
383
334
  test('should payments been generated sorted by exercices start date', () => __awaiter(void 0, void 0, void 0, function* () {
384
- var _j;
335
+ var _g;
385
336
  const listPartialExercicePrestationExpressCloned = [...listPartialExercicePrestationExpress];
386
337
  listPartialExercicePrestationExpressCloned[0] = Object.assign(Object.assign({}, listPartialExercicePrestationExpress[0]), { startDate: dayjs().add(1, 'year').startOf('month').toDate() });
387
338
  listPartialExercicePrestationExpressCloned[1] = Object.assign(Object.assign({}, listPartialExercicePrestationExpress[1]), { startDate: dayjs().startOf('month').toDate() });
@@ -400,7 +351,7 @@ describe('Payment', () => {
400
351
  nextYearlyAmountNonExpress
401
352
  });
402
353
  expect(payments.length).toBeGreaterThanOrEqual(4);
403
- expect(dayjs(payments[payments.length - 1].datePayment).diff(dayjs((_j = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _j === void 0 ? void 0 : _j.datePayment), 'month')).toBeGreaterThan(0);
354
+ expect(dayjs(payments[payments.length - 1].datePayment).diff(dayjs((_g = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _g === void 0 ? void 0 : _g.datePayment), 'month')).toBeGreaterThan(0);
404
355
  }));
405
356
  test('if regulations are bigger than sum exercice prestation amounts, should pass some exercice payments', () => __awaiter(void 0, void 0, void 0, function* () {
406
357
  const mockedDate = dayjs('2024-03-15').toDate();
@@ -410,7 +361,7 @@ describe('Payment', () => {
410
361
  goToClient: dayjs('2024-06-06').toDate(),
411
362
  firstExerciceNonExpresssEndDate,
412
363
  idPrestation,
413
- isWithApplicationFees: true,
364
+ isWithApplicationFees: false,
414
365
  idLegalForm: types_1.LegalFormTypeEnum.SARL,
415
366
  prestationList,
416
367
  idVat,
@@ -428,21 +379,19 @@ describe('Payment', () => {
428
379
  });
429
380
  expect(payments.length).toBeGreaterThanOrEqual(2);
430
381
  expect(payments[0]).toMatchObject({
431
- amount: 550,
432
- datePayment: dayjs(mockedDate).add(1, 'month').startOf('month').toDate(),
382
+ amount: 1320, // 1200 * 1,1
433
383
  idPrestation: 1,
434
- idPaymentMethod: 1,
384
+ idPaymentMethod: types_1.PaymentMethod.BANK_CARD.id,
435
385
  });
436
386
  expect(payments[1]).toMatchObject({
437
- amount: 550,
438
- datePayment: dayjs(mockedDate).add(2, 'month').startOf('month').toDate(),
387
+ amount: 680, // 2000 - (1200 * 1,1)
439
388
  idPrestation: 1,
440
- idPaymentMethod: 1,
389
+ idPaymentMethod: types_1.PaymentMethod.BANK_CARD.id,
441
390
  });
442
391
  mockdate_1.default.reset();
443
392
  }));
444
393
  test('should not consider actual month if signed in last 3 days of month', () => __awaiter(void 0, void 0, void 0, function* () {
445
- var _k;
394
+ var _h;
446
395
  const mockedDate = dayjs('2024-03-29').toDate();
447
396
  mockdate_1.default.set(mockedDate);
448
397
  const payments = (0, payment_1.calculatePaymentsAuto)({
@@ -450,7 +399,7 @@ describe('Payment', () => {
450
399
  goToClient: dayjs('2024-06-06').toDate(),
451
400
  firstExerciceNonExpresssEndDate,
452
401
  idPrestation,
453
- isWithApplicationFees: true,
402
+ isWithApplicationFees: false,
454
403
  idLegalForm: types_1.LegalFormTypeEnum.SARL,
455
404
  prestationList,
456
405
  idVat,
@@ -460,7 +409,7 @@ describe('Payment', () => {
460
409
  nextYearlyAmountNonExpress
461
410
  });
462
411
  expect(payments.length).toBeGreaterThanOrEqual(4);
463
- expect((_k = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _k === void 0 ? void 0 : _k.datePayment).toStrictEqual(dayjs(mockedDate).add(2, 'month').startOf('month').toDate());
412
+ expect((_h = payments === null || payments === void 0 ? void 0 : payments[1]) === null || _h === void 0 ? void 0 : _h.datePayment).toStrictEqual(dayjs().add(2, 'month').startOf('month').toDate());
464
413
  mockdate_1.default.reset();
465
414
  }));
466
415
  test('last payment returned should be last of a year (12/XX)', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -484,7 +433,7 @@ describe('Payment', () => {
484
433
  expect(dayjs(payments[payments.length - 1].datePayment).month()).toStrictEqual(11);
485
434
  }));
486
435
  test('first payment and last payment should have at least one year difference (ex. : 23 - 24)', () => __awaiter(void 0, void 0, void 0, function* () {
487
- var _l, _m, _o;
436
+ var _j, _k, _l;
488
437
  const payments = (0, payment_1.calculatePaymentsAuto)({
489
438
  idTypeBrand: 1,
490
439
  goToClient: dayjs('2024-06-06').toDate(),
@@ -499,10 +448,10 @@ describe('Payment', () => {
499
448
  yearlyAmountNonExpress,
500
449
  nextYearlyAmountNonExpress
501
450
  });
502
- expect(dayjs((_m = (_l = payments.slice(-1)) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.datePayment).diff(dayjs((_o = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _o === void 0 ? void 0 : _o.datePayment), 'year', true)).toBeGreaterThan(1);
451
+ expect(dayjs((_k = (_j = payments.slice(-1)) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.datePayment).diff(dayjs((_l = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _l === void 0 ? void 0 : _l.datePayment), 'year', true)).toBeGreaterThan(1);
503
452
  }));
504
453
  test('real case : idSociety 114440', () => __awaiter(void 0, void 0, void 0, function* () {
505
- var _p, _q, _r;
454
+ var _m, _o, _p;
506
455
  const payments = (0, payment_1.calculatePaymentsAuto)({
507
456
  idTypeBrand: 1,
508
457
  goToClient: dayjs('2024-06-06').toDate(),
@@ -523,7 +472,7 @@ describe('Payment', () => {
523
472
  }],
524
473
  yearlyAmountNonExpress: 1433, nextYearlyAmountNonExpress: 1433
525
474
  });
526
- expect(dayjs((_q = (_p = payments.slice(-1)) === null || _p === void 0 ? void 0 : _p[0]) === null || _q === void 0 ? void 0 : _q.datePayment).diff(dayjs((_r = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _r === void 0 ? void 0 : _r.datePayment), 'year', true)).toBeGreaterThan(1);
475
+ expect(dayjs((_o = (_m = payments.slice(-1)) === null || _m === void 0 ? void 0 : _m[0]) === null || _o === void 0 ? void 0 : _o.datePayment).diff(dayjs((_p = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _p === void 0 ? void 0 : _p.datePayment), 'year', true)).toBeGreaterThan(1);
527
476
  }));
528
477
  });
529
478
  });
@@ -1 +1 @@
1
- {"version":3,"file":"payment.spec.js","sourceRoot":"","sources":["../../../../ts/utils/tests/payment.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+BAA+B;AAC/B,uCAAiF;AACjF,uCAAgC;AAEhC,wCAAmD;AAGnD,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;;QACjC,MAAM,YAAY,GAAG,CAAC,CAAC;QACvB,MAAM,SAAS,GAAG,CAAC,CAAC;QACpB,MAAM,sBAAsB,GAAG,IAAI,CAAC;QACpC,MAAM,0BAA0B,GAAG,IAAI,CAAC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC;QAErB,MAAM,+BAA+B,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAA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AI,CAAC,8BAA8B,EAAE,GAAS,EAAE;;YAC9C,MAAM,QAAQ,GAAG,IAAA,+BAAqB,EAAC;gBACrC,WAAW,EAAE,CAAC;gBACd,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;gBACxC,+BAA+B,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;gBAC7D,YAAY;gBACZ,qBAAqB,EAAE,IAAI;gBAC3B,WAAW,EAAE,yBAAiB,CAAC,IAAI;gBACnC,cAAc;gBACd,KAAK,EAAE,WAAG,CAAC,KAAK,CAAC,EAAE;gBACnB,oCAAoC,EAAE,EAAE;gBACxC,eAAe,EAAE,CAAC;wBAChB,MAAM,EAAE,MAAM;wBACd,UAAU,EAAE,CAAC;wBACb,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;wBAClC,SAAS,EAAE,KAAK;wBAChB,eAAe,EAAE,qBAAa,CAAC,SAAS,CAAC,EAAE;wBAC3C,SAAS;qBACV,CAAC;gBACF,sBAAsB,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI;aAAE,CAAC,CAAC;YACpE,MAAM,CAAC,KAAK,CAAC,MAAA,MAAA,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,0CAAG,CAAC,CAAC,0CAAE,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,CAAC,CAAC,0CAAE,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC/H,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as dayjs from 'dayjs';\nimport { IRegulation, Vat, PaymentMethod, LegalFormTypeEnum } from '../../types';\nimport MockDate from 'mockdate';\n\nimport { calculatePaymentsAuto } from '../payment';\nimport { PartialExercicePrestationExpress } from '../../types/Interface/api/payment/Util';\n\ndescribe('Payment', () => {\n describe('calculatePayments', () => {\n const idPrestation = 1;\n const idSociety = 1;\n const yearlyAmountNonExpress = 1800;\n const nextYearlyAmountNonExpress = 1800;\n const appCost = 14.9;\n\n const firstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate(); \n const prestationList = {\n id: 34,\n name: 'Compta Pro',\n isComptable: true,\n isJuridique: false,\n isSocial: false,\n isAttestation: false,\n inAverageCart: true,\n isBack: false,\n minimumPrice: null,\n price: null,\n isCatalog: false,\n isPlannable: false,\n hidden: false,\n isComplementary: false,\n signaturePosition: '400,54,569,90',\n signaturePage: 7,\n };\n const idVat = Vat.TX_10.id;\n const vatRate = Object.values(Vat).find(v => v.id === idVat)?.value ?? 20;\n const listPartialExercicePrestationExpress:PartialExercicePrestationExpress[] = [\n {\n startDate: dayjs().subtract(2, 'year').startOf('month').toDate(), \n endDate: dayjs().subtract(13, 'month').endOf('month').toDate(), \n countExpressMonthlyPayment: 2,\n totalAmount: 1200,\n },\n {\n startDate: dayjs().subtract(1, 'year').startOf('month').toDate(), \n endDate: dayjs().subtract(1, 'month').endOf('month').toDate(), \n countExpressMonthlyPayment: 2,\n totalAmount: 1800,\n },\n ];\n const listRegulations:IRegulation[] = [{\n amount: 600,\n amountUsed: 0,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }, {\n amount: 300,\n amountUsed: 0,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }, {\n amount: 300,\n amountUsed: 300,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }];\n\n // =====================\n // errors handling\n // =====================\n test('should return error if prestationList doesn\\'t correspond (!hidden, isCatalog, isComptable)', () => {\n expect.assertions(2);\n try {\n prestationList.hidden = true;\n calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList: {\n ...prestationList,\n isCatalog: true,\n },\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n } catch (error) {\n expect(error).toBeInstanceOf(Error);\n // @ts-ignore\n expect(error.message).toStrictEqual('Ce type de prestation ne correspond pas aux conditions attendues.');\n }\n });\n test('should return error if listRegulations is empty', () => {\n expect.assertions(2);\n try {\n calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations: [],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n } catch (error) {\n expect(error).toBeInstanceOf(Error);\n // @ts-ignore\n expect(error.message).toStrictEqual('List of regulations can not be empty');\n }\n });\n test('should listRegulations contain amount and amountUsed', () => {\n expect.assertions(2);\n try {\n calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations: [{ processed: true } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n } catch (error) {\n expect(error).toBeInstanceOf(Error);\n // @ts-ignore\n expect(error.message).toStrictEqual('Amount and amountUsed are missing for regulations');\n }\n });\n\n // =====================\n // logical\n // =====================\n // express\n test('if only one express, monthly payments of actual exo should be in parallel of express monthly payments, smoothed in number of remaining months (mini 3 months) (if not in 3 last month)', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [listPartialExercicePrestationExpress[0]],\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const firstExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0)[0].datePayment;\n const firstNonExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)[0].datePayment;\n expect(dayjs(firstNonExpressDatePayment).diff(firstExpressDatePayment, 'month')).toStrictEqual(0);\n });\n test('if more than one express, monthly payments of actual exo should be in a row of express monthly payments and smoothed, smoothed in number of remaining months after express monthly payments (mini 3 months) (if in 3 last month of exercice)', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const lastExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0).splice(-1)?.[0]?.datePayment;\n const firstNonExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)?.[0]?.datePayment;\n expect(dayjs(firstNonExpressDatePayment).diff(lastExpressDatePayment, 'month')).toStrictEqual(1);\n });\n // non express\n test('should return a number of payments equal to nb of remaining months in exercice (if not in 3 last months)', async () => {\n const mockedDate = dayjs('2024-05-15').toDate();\n MockDate.set(mockedDate);\n \n const nbMonthDelay = 6;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n // const listNonExpressPayments = payments.filter(p => p.closingDate === newFirstExerciceNonExpresssEndDate);\n const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);\n expect(listNonExpressPayments.length).toStrictEqual(nbMonthDelay);\n \n MockDate.reset();\n });\n test('should return a number of payments equal to 3 (if in 3 last month of exercice)', async () => {\n const nbMonthDelay = 1;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);\n expect(listNonExpressPayments.length).toStrictEqual(3);\n });\n test('should (yearlyAmountNonExpress - sum of listRegulations) / count of monthly payments be equal to monthly payment amount (if not in 3 last month)', async () => {\n const mockedDate = dayjs('2024-05-15').toDate();\n MockDate.set(mockedDate);\n \n const nbMonthDelay = 6;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n const newListRegulations = [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation];\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: newListRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n \n const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);\n const amount = Math.round(100 * diff / nbMonthDelay) / 100;\n\n expect(payments[0].amount).toStrictEqual(Math.round(100 * amount * ((100 + vatRate) / 100)) / 100);\n \n MockDate.reset();\n });\n test('should (totalAmount - firstPaymentAmount) / 3 be equal to monthly payment amount (if in 3 last month of exercice)', async () => {\n const nbMonthDelay = 1;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n const newListRegulations = [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation];\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: newListRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);\n const amount = Math.round(100 * diff / 3) / 100;\n\n expect(payments[0].amount).toStrictEqual(Math.round(100 * amount * ((100 + vatRate) / 100)) / 100);\n });\n // annual price increase\n test('should apply annual price increase (2,75%) if signed before last 3 months of civil year', async () => {\n const mockedDate = dayjs('2024-08-15').toDate();\n MockDate.set(mockedDate);\n\n const newFirstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate();\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);\n expect(Math.round(100 * listNonExpressPayments[0].amount * 1.0275) / 100).toStrictEqual(listNonExpressPayments.splice(-2)[0].amount);\n\n MockDate.reset();\n });\n test('should not apply annual price increase (2,75%) if signed in last 3 months of civil year', async () => {\n const mockedDate = dayjs('2024-11-15').toDate();\n MockDate.set(mockedDate);\n \n const newFirstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate();\n \n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n \n const listNonExpressPayments = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0);\n expect(listNonExpressPayments[0].amount).toStrictEqual(listNonExpressPayments.splice(-2)[0].amount);\n \n MockDate.reset();\n });\n\n test('should apply 14,9€ HT increase for the second exercice created (only offered on first exo) (no rules for 3 last months)', async () => {\n const mockedDate = dayjs('2024-06-15').toDate();\n MockDate.set(mockedDate);\n \n const newFirstExerciceNonExpresssEndDate = dayjs().add(12, 'month').endOf('month').toDate();\n \n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 50,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n \n const paymentsOfFirstExo = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0).splice(-1)[0].amount ?? 0;\n const paymentsOfSecondExo = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-07-01')) === 0).splice(-1)[0].amount ?? 0;\n expect(paymentsOfFirstExo + appCost * ((100 + vatRate) / 100)).toStrictEqual(paymentsOfSecondExo);\n \n MockDate.reset();\n });\n \n // misc\n test('should payments been generated sorted by exercices start date', async () => {\n const listPartialExercicePrestationExpressCloned = [...listPartialExercicePrestationExpress];\n listPartialExercicePrestationExpressCloned[0] = { \n ...listPartialExercicePrestationExpress[0],\n startDate: dayjs().add(1, 'year').startOf('month').toDate(), \n };\n listPartialExercicePrestationExpressCloned[1] = { \n ...listPartialExercicePrestationExpress[1],\n startDate: dayjs().startOf('month').toDate(), \n };\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: listPartialExercicePrestationExpressCloned,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(4);\n expect(dayjs(payments[payments.length - 1].datePayment).diff(dayjs(payments?.[0]?.datePayment), 'month')).toBeGreaterThan(0);\n });\n test('if regulations are bigger than sum exercice prestation amounts, should pass some exercice payments', async () => {\n const mockedDate = dayjs('2024-03-15').toDate();\n MockDate.set(mockedDate);\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations: [{\n amount: 2000,\n amountUsed: 0,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(2);\n expect(payments[0]).toMatchObject(\n {\n amount: 550,\n datePayment: dayjs(mockedDate).add(1, 'month').startOf('month').toDate(),\n idPrestation: 1,\n idPaymentMethod: 1,\n });\n expect(payments[1]).toMatchObject(\n {\n amount: 550,\n datePayment: dayjs(mockedDate).add(2, 'month').startOf('month').toDate(),\n idPrestation: 1,\n idPaymentMethod: 1,\n });\n MockDate.reset();\n });\n test('should not consider actual month if signed in last 3 days of month', async () => {\n const mockedDate = dayjs('2024-03-29').toDate();\n MockDate.set(mockedDate);\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(4);\n expect(payments?.[0]?.datePayment).toStrictEqual(dayjs(mockedDate).add(2, 'month').startOf('month').toDate());\n MockDate.reset();\n });\n test('last payment returned should be last of a year (12/XX)', async () => {\n const mockedDate = dayjs('2024-03-29').toDate();\n MockDate.set(mockedDate);\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(4);\n expect(dayjs(payments[payments.length - 1].datePayment).month()).toStrictEqual(11);\n });\n test('first payment and last payment should have at least one year difference (ex. : 23 - 24)', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(dayjs(payments.slice(-1)?.[0]?.datePayment).diff(dayjs(payments?.[0]?.datePayment), 'year', true)).toBeGreaterThan(1);\n });\n test('real case : idSociety 114440', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: dayjs('2024-12-31').toDate(), \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat: Vat.TX_20.id,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 1006.8,\n amountUsed: 0,\n date: dayjs('2024-06-06').toDate(), \n processed: false,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }],\n yearlyAmountNonExpress: 1433, nextYearlyAmountNonExpress: 1433 });\n expect(dayjs(payments.slice(-1)?.[0]?.datePayment).diff(dayjs(payments?.[0]?.datePayment), 'year', true)).toBeGreaterThan(1);\n });\n });\n});"]}
1
+ {"version":3,"file":"payment.spec.js","sourceRoot":"","sources":["../../../../ts/utils/tests/payment.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+BAA+B;AAC/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AAK,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;gBAC7D,YAAY;gBACZ,qBAAqB,EAAE,IAAI;gBAC3B,WAAW,EAAE,yBAAiB,CAAC,IAAI;gBACnC,cAAc;gBACd,KAAK,EAAE,WAAG,CAAC,KAAK,CAAC,EAAE;gBACnB,oCAAoC,EAAE,EAAE;gBACxC,eAAe,EAAE,CAAC;wBAChB,MAAM,EAAE,MAAM;wBACd,UAAU,EAAE,CAAC;wBACb,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;wBAClC,SAAS,EAAE,KAAK;wBAChB,eAAe,EAAE,qBAAa,CAAC,SAAS,CAAC,EAAE;wBAC3C,SAAS;qBACV,CAAC;gBACF,sBAAsB,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI;aAAE,CAAC,CAAC;YACpE,MAAM,CAAC,KAAK,CAAC,MAAA,MAAA,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,0CAAG,CAAC,CAAC,0CAAE,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,CAAC,CAAC,0CAAE,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC/H,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as dayjs from 'dayjs';\nimport { IRegulation, Vat, PaymentMethod, LegalFormTypeEnum, getTaxesIncludedAmount } from '../../types';\nimport MockDate from 'mockdate';\n\nimport { calculatePaymentsAuto } from '../payment';\nimport { PartialExercicePrestationExpress } from '../../types/Interface/api/payment/Util';\n\ndescribe('Payment', () => {\n describe('calculatePayments', () => {\n const idPrestation = 1;\n const idSociety = 1;\n const yearlyAmountNonExpress = 1800;\n const nextYearlyAmountNonExpress = 1800;\n const appCost = 14.9;\n\n const firstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate(); \n const prestationList = {\n id: 34,\n name: 'Compta Pro',\n isComptable: true,\n isJuridique: false,\n isSocial: false,\n isAttestation: false,\n inAverageCart: true,\n isBack: false,\n minimumPrice: null,\n price: null,\n isCatalog: false,\n isPlannable: false,\n hidden: false,\n isComplementary: false,\n signaturePosition: '400,54,569,90',\n signaturePage: 7,\n };\n const idVat = Vat.TX_10.id;\n const listPartialExercicePrestationExpress:PartialExercicePrestationExpress[] = [\n {\n startDate: dayjs().subtract(2, 'year').startOf('month').toDate(), \n endDate: dayjs().subtract(13, 'month').endOf('month').toDate(), \n countExpressMonthlyPayment: 2,\n totalAmount: 1200,\n },\n {\n startDate: dayjs().subtract(1, 'year').startOf('month').toDate(), \n endDate: dayjs().subtract(1, 'month').endOf('month').toDate(), \n countExpressMonthlyPayment: 2,\n totalAmount: 1800,\n },\n ];\n const listRegulations:IRegulation[] = [{\n amount: 600,\n amountUsed: 0,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }, {\n amount: 300,\n amountUsed: 0,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }, {\n amount: 300,\n amountUsed: 300,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }];\n\n // =====================\n // errors handling\n // =====================\n test('should return error if prestationList doesn\\'t correspond (!hidden, isCatalog, isComptable)', () => {\n expect.assertions(2);\n try {\n prestationList.hidden = true;\n calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList: {\n ...prestationList,\n isCatalog: true,\n },\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n } catch (error) {\n expect(error).toBeInstanceOf(Error);\n // @ts-ignore\n expect(error.message).toStrictEqual('Ce type de prestation ne correspond pas aux conditions attendues.');\n }\n });\n\n // =====================\n // logical\n // =====================\n // express\n test('if only one express, monthly payments of actual exo should be in parallel of express monthly payments, smoothed in number of remaining months (mini 3 months) (if not in 3 last month)', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [listPartialExercicePrestationExpress[0]],\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const firstExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0)[0].datePayment;\n const firstNonExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)[0].datePayment;\n expect(dayjs(firstNonExpressDatePayment).diff(firstExpressDatePayment, 'month')).toStrictEqual(0);\n });\n test('if more than one express, monthly payments of actual exo should be in a row of express monthly payments and smoothed, smoothed in number of remaining months after express monthly payments (mini 3 months) (if in 3 last month of exercice)', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const lastExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0).splice(-1)?.[0]?.datePayment;\n const firstNonExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)?.[0]?.datePayment;\n expect(dayjs(firstNonExpressDatePayment).diff(lastExpressDatePayment, 'month')).toStrictEqual(1);\n });\n // non express\n test('should return a number of payments equal to nb of remaining months in exercice (if not in 3 last months)', async () => {\n const mockedDate = dayjs('2024-05-15').toDate();\n MockDate.set(mockedDate);\n \n const nbMonthDelay = 6;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n // const listNonExpressPayments = payments.filter(p => p.closingDate === newFirstExerciceNonExpresssEndDate);\n const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);\n expect(listNonExpressPayments.length).toStrictEqual(1 + nbMonthDelay); //On ajoute 1 pour les frais de dossier\n \n MockDate.reset();\n });\n test('should return a number of payments equal to 3 (if in 3 last month of exercice)', async () => {\n const nbMonthDelay = 1;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);\n expect(listNonExpressPayments.length).toStrictEqual(1 + 3); //On ajoute 1 pour les frais de dossier\n });\n test('should (yearlyAmountNonExpress - sum of listRegulations) / count of monthly payments be equal to monthly payment amount (if not in 3 last month)', async () => {\n const mockedDate = dayjs('2024-05-15').toDate();\n MockDate.set(mockedDate);\n \n const nbMonthDelay = 6;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n const newListRegulations = [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation];\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: false,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: newListRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n \n const diff = getTaxesIncludedAmount(yearlyAmountNonExpress, idVat) - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);\n const amount = Math.round(100 * diff / nbMonthDelay) / 100;\n\n expect(payments[1].amount).toStrictEqual(amount);\n \n MockDate.reset();\n });\n test('should (totalAmount - firstPaymentAmount) / 3 be equal to monthly payment amount (if in 3 last month of exercice)', async () => {\n const nbMonthDelay = 1;\n const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();\n const newListRegulations = [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation];\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: false,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: newListRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const diff = getTaxesIncludedAmount(yearlyAmountNonExpress, idVat) - newListRegulations.reduce((acc, r:IRegulation) => acc + r.amount - r.amountUsed, 0);\n const amount = Math.round(100 * diff / 3) / 100;\n\n expect(payments[1].amount).toStrictEqual(amount);\n });\n // annual price increase\n test('should apply annual price increase (2,75%) if signed before last 3 months of civil year', async () => {\n const mockedDate = dayjs('2024-08-15').toDate();\n MockDate.set(mockedDate);\n\n const newFirstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate();\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);\n const firstPaymentWithTaxRateForced = listNonExpressPayments[1].amount * 1.0275;\n expect(firstPaymentWithTaxRateForced - listNonExpressPayments.splice(-2)[0].amount).toBeLessThanOrEqual(0.01); //Permet de gérer le pb d'arrondi\n\n MockDate.reset();\n });\n test('should not apply annual price increase (2,75%) if signed in last 3 months of civil year', async () => {\n const mockedDate = dayjs('2024-11-15').toDate();\n MockDate.set(mockedDate);\n \n const newFirstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate();\n \n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 0,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n \n const listNonExpressPayments = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0);\n expect(listNonExpressPayments[0].amount).toStrictEqual(listNonExpressPayments.splice(-2)[0].amount);\n \n MockDate.reset();\n });\n\n test('should apply 14,9€ HT increase for the second exercice created (only offered on first exo) (no rules for 3 last months)', async () => {\n const mockedDate = dayjs('2024-06-15').toDate();\n MockDate.set(mockedDate);\n \n const newFirstExerciceNonExpresssEndDate = dayjs().add(12, 'month').endOf('month').toDate();\n \n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: false,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 50,\n amountUsed: 50,\n } as IRegulation],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n\n const paymentsOfFirstExo = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0)[0].amount ?? 0;\n const paymentsOfSecondExo = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-07-01')) === 0).splice(-1)[0].amount ?? 0;\n expect(Math.round(100 * (paymentsOfFirstExo + getTaxesIncludedAmount(appCost, idVat) * 1.0275)) / 100).toStrictEqual(paymentsOfSecondExo);\n \n MockDate.reset();\n });\n \n // misc\n test('should payments been generated sorted by exercices start date', async () => {\n const listPartialExercicePrestationExpressCloned = [...listPartialExercicePrestationExpress];\n listPartialExercicePrestationExpressCloned[0] = { \n ...listPartialExercicePrestationExpress[0],\n startDate: dayjs().add(1, 'year').startOf('month').toDate(), \n };\n listPartialExercicePrestationExpressCloned[1] = { \n ...listPartialExercicePrestationExpress[1],\n startDate: dayjs().startOf('month').toDate(), \n };\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: listPartialExercicePrestationExpressCloned,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(4);\n expect(dayjs(payments[payments.length - 1].datePayment).diff(dayjs(payments?.[0]?.datePayment), 'month')).toBeGreaterThan(0);\n });\n test('if regulations are bigger than sum exercice prestation amounts, should pass some exercice payments', async () => {\n const mockedDate = dayjs('2024-03-15').toDate();\n MockDate.set(mockedDate);\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: false,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations: [{\n amount: 2000,\n amountUsed: 0,\n date: new Date(),\n processed: true,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }],\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(2);\n expect(payments[0]).toMatchObject(\n {\n amount: 1320, // 1200 * 1,1\n idPrestation: 1,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n });\n expect(payments[1]).toMatchObject(\n {\n amount: 680, // 2000 - (1200 * 1,1)\n idPrestation: 1,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n });\n MockDate.reset();\n });\n test('should not consider actual month if signed in last 3 days of month', async () => {\n const mockedDate = dayjs('2024-03-29').toDate();\n MockDate.set(mockedDate);\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: false,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(4);\n expect(payments?.[1]?.datePayment).toStrictEqual(dayjs().add(2, 'month').startOf('month').toDate());\n MockDate.reset();\n });\n test('last payment returned should be last of a year (12/XX)', async () => {\n const mockedDate = dayjs('2024-03-29').toDate();\n MockDate.set(mockedDate);\n\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress,\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(payments.length).toBeGreaterThanOrEqual(4);\n expect(dayjs(payments[payments.length - 1].datePayment).month()).toStrictEqual(11);\n });\n test('first payment and last payment should have at least one year difference (ex. : 23 - 24)', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate, \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat,\n listPartialExercicePrestationExpress: [],\n listRegulations,\n yearlyAmountNonExpress,\n nextYearlyAmountNonExpress });\n expect(dayjs(payments.slice(-1)?.[0]?.datePayment).diff(dayjs(payments?.[0]?.datePayment), 'year', true)).toBeGreaterThan(1);\n });\n test('real case : idSociety 114440', async () => {\n const payments = calculatePaymentsAuto({ \n idTypeBrand: 1,\n goToClient: dayjs('2024-06-06').toDate(),\n firstExerciceNonExpresssEndDate: dayjs('2024-12-31').toDate(), \n idPrestation,\n isWithApplicationFees: true,\n idLegalForm: LegalFormTypeEnum.SARL,\n prestationList,\n idVat: Vat.TX_20.id,\n listPartialExercicePrestationExpress: [],\n listRegulations: [{\n amount: 1006.8,\n amountUsed: 0,\n date: dayjs('2024-06-06').toDate(), \n processed: false,\n idPaymentMethod: PaymentMethod.BANK_CARD.id,\n idSociety,\n }],\n yearlyAmountNonExpress: 1433, nextYearlyAmountNonExpress: 1433 });\n expect(dayjs(payments.slice(-1)?.[0]?.datePayment).diff(dayjs(payments?.[0]?.datePayment), 'year', true)).toBeGreaterThan(1);\n });\n });\n});"]}
@@ -514,7 +514,7 @@ export const TaskResponseType = {
514
514
  label: 'Mettre à jour l\'application',
515
515
  role: Role.DATA_OFFICER,
516
516
  deadline: Deadline,
517
- isForWholeRole: false,
517
+ isForWholeRole: true,
518
518
  backToClient: true,
519
519
  goToCalendar: false,
520
520
  responseType: ResponseType.CALL,