@silexpert/core 1.1.308 → 1.1.310

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/cjs/api/resources/CommercialDocument.d.ts +3 -1
  2. package/dist/cjs/api/resources/CommercialDocument.d.ts.map +1 -1
  3. package/dist/cjs/api/resources/CommercialDocument.js +9 -0
  4. package/dist/cjs/api/resources/CommercialDocument.js.map +1 -1
  5. package/dist/cjs/api/resources/KilometricAllowance.d.ts +2 -0
  6. package/dist/cjs/api/resources/KilometricAllowance.d.ts.map +1 -1
  7. package/dist/cjs/api/resources/KilometricAllowance.js +9 -0
  8. package/dist/cjs/api/resources/KilometricAllowance.js.map +1 -1
  9. package/dist/cjs/types/Enum/EstimateInvoice.d.ts +4 -0
  10. package/dist/cjs/types/Enum/EstimateInvoice.d.ts.map +1 -1
  11. package/dist/cjs/types/Enum/EstimateInvoice.js +27 -1
  12. package/dist/cjs/types/Enum/EstimateInvoice.js.map +1 -1
  13. package/dist/cjs/types/Enum/PriceGridClementine.js +1 -1
  14. package/dist/cjs/types/Enum/PriceGridClementine.js.map +1 -1
  15. package/dist/cjs/types/Interface/api/bankAccount/Read.d.ts +1 -0
  16. package/dist/cjs/types/Interface/api/bankAccount/Read.d.ts.map +1 -1
  17. package/dist/cjs/types/Interface/api/bankAccount/Read.js.map +1 -1
  18. package/dist/cjs/types/Interface/api/commercialManagement/Query.d.ts +6 -0
  19. package/dist/cjs/types/Interface/api/commercialManagement/Query.d.ts.map +1 -1
  20. package/dist/cjs/types/Interface/api/commercialManagement/Query.js +26 -1
  21. package/dist/cjs/types/Interface/api/commercialManagement/Query.js.map +1 -1
  22. package/dist/cjs/types/Interface/api/payment/Util.d.ts +2 -0
  23. package/dist/cjs/types/Interface/api/payment/Util.d.ts.map +1 -1
  24. package/dist/cjs/types/Interface/api/payment/Util.js.map +1 -1
  25. package/dist/cjs/types/Interface/models/IPrestation.d.ts +1 -0
  26. package/dist/cjs/types/Interface/models/IPrestation.d.ts.map +1 -1
  27. package/dist/cjs/types/Interface/models/IPrestation.js.map +1 -1
  28. package/dist/cjs/utils/payment.d.ts +2 -0
  29. package/dist/cjs/utils/payment.d.ts.map +1 -1
  30. package/dist/cjs/utils/payment.js +83 -33
  31. package/dist/cjs/utils/payment.js.map +1 -1
  32. package/dist/cjs/utils/tests/payment.spec.js +36 -0
  33. package/dist/cjs/utils/tests/payment.spec.js.map +1 -1
  34. package/dist/mjs/api/resources/CommercialDocument.d.ts +3 -1
  35. package/dist/mjs/api/resources/CommercialDocument.d.ts.map +1 -1
  36. package/dist/mjs/api/resources/CommercialDocument.js +9 -0
  37. package/dist/mjs/api/resources/CommercialDocument.js.map +1 -1
  38. package/dist/mjs/api/resources/KilometricAllowance.d.ts +2 -0
  39. package/dist/mjs/api/resources/KilometricAllowance.d.ts.map +1 -1
  40. package/dist/mjs/api/resources/KilometricAllowance.js +9 -0
  41. package/dist/mjs/api/resources/KilometricAllowance.js.map +1 -1
  42. package/dist/mjs/types/Enum/EstimateInvoice.d.ts +4 -0
  43. package/dist/mjs/types/Enum/EstimateInvoice.d.ts.map +1 -1
  44. package/dist/mjs/types/Enum/EstimateInvoice.js +26 -0
  45. package/dist/mjs/types/Enum/EstimateInvoice.js.map +1 -1
  46. package/dist/mjs/types/Enum/PriceGridClementine.js +1 -1
  47. package/dist/mjs/types/Enum/PriceGridClementine.js.map +1 -1
  48. package/dist/mjs/types/Interface/api/bankAccount/Read.d.ts +1 -0
  49. package/dist/mjs/types/Interface/api/bankAccount/Read.d.ts.map +1 -1
  50. package/dist/mjs/types/Interface/api/bankAccount/Read.js.map +1 -1
  51. package/dist/mjs/types/Interface/api/commercialManagement/Query.d.ts +6 -0
  52. package/dist/mjs/types/Interface/api/commercialManagement/Query.d.ts.map +1 -1
  53. package/dist/mjs/types/Interface/api/commercialManagement/Query.js +29 -1
  54. package/dist/mjs/types/Interface/api/commercialManagement/Query.js.map +1 -1
  55. package/dist/mjs/types/Interface/api/payment/Util.d.ts +2 -0
  56. package/dist/mjs/types/Interface/api/payment/Util.d.ts.map +1 -1
  57. package/dist/mjs/types/Interface/api/payment/Util.js.map +1 -1
  58. package/dist/mjs/types/Interface/models/IPrestation.d.ts +1 -0
  59. package/dist/mjs/types/Interface/models/IPrestation.d.ts.map +1 -1
  60. package/dist/mjs/types/Interface/models/IPrestation.js.map +1 -1
  61. package/dist/mjs/utils/payment.d.ts +2 -0
  62. package/dist/mjs/utils/payment.d.ts.map +1 -1
  63. package/dist/mjs/utils/payment.js +83 -34
  64. package/dist/mjs/utils/payment.js.map +1 -1
  65. package/dist/mjs/utils/tests/payment.spec.js +37 -1
  66. package/dist/mjs/utils/tests/payment.spec.js.map +1 -1
  67. package/package.json +1 -1
  68. package/ts/api/resources/CommercialDocument.ts +11 -0
  69. package/ts/api/resources/KilometricAllowance.ts +10 -0
  70. package/ts/types/Enum/EstimateInvoice.ts +28 -1
  71. package/ts/types/Enum/PriceGridClementine.ts +1 -1
  72. package/ts/types/Interface/api/bankAccount/Read.ts +1 -0
  73. package/ts/types/Interface/api/commercialManagement/Query.ts +21 -1
  74. package/ts/types/Interface/api/payment/Util.ts +2 -0
  75. package/ts/types/Interface/models/IPrestation.ts +1 -0
  76. package/ts/utils/payment.ts +86 -34
  77. package/ts/utils/tests/payment.spec.ts +37 -1
@@ -52,6 +52,8 @@ const calculateFees = (amount, goToClient, paymentDate) => {
52
52
  // * @param {number} firstPaymentAmount - amount of the first payment (first regulation of the customer)
53
53
  * @param {Date} firstExerciceNonExpresssEndDate - end date of the first exercice non express
54
54
  * @param {number} idPrestation - prestation id
55
+ * @param {number} idLegalForm - legal form id of the society
56
+ * @param {boolean} isWithApplicationFees - if the prestation has application fees to paid
55
57
  * @param {IPrestationList} prestationList - type of prestation (hidden: 0, isCatalog: 1, isComptable: 1)
56
58
  * @param {number} idVat - vat id of society linked
57
59
  * @param {number} yearlyAmountNonExpress - yearly amount of non express prestation (HT)
@@ -61,11 +63,10 @@ const calculateFees = (amount, goToClient, paymentDate) => {
61
63
  * @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding
62
64
  */
63
65
  const calculatePaymentsAuto = (params) => {
64
- const { idTypeBrand, goToClient, firstExerciceNonExpresssEndDate, idPrestation, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;
66
+ const { idTypeBrand, goToClient, isWithApplicationFees, firstExerciceNonExpresssEndDate, idPrestation, idLegalForm, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;
65
67
  const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3 /* || dayjs().date() >= 15 */
66
68
  ? dayjs().add(2, 'month').startOf('month').toDate()
67
69
  : dayjs().add(1, 'month').startOf('month').toDate();
68
- let isApplicationAlreadyPaid = false;
69
70
  // On récupère la grille tarifaire pour savoir si les tarifs sont HT ou TTC
70
71
  // et pour connaitre le montant du coût de l'app
71
72
  if (!prestationList.id)
@@ -75,6 +76,7 @@ const calculatePaymentsAuto = (params) => {
75
76
  throw new Error('Impossible de trouver la grille tarifaire correspondante');
76
77
  const { applicationCost, priceWithTaxesIncluded } = priceGrid;
77
78
  const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : (0, types_1.getTaxesIncludedAmount)(applicationCost, idVat)) * 12;
79
+ const applicationFeesAmount = (idLegalForm === types_1.LegalFormTypeEnum.SCI) ? 150 : 50;
78
80
  if ((prestationList === null || prestationList === void 0 ? void 0 : prestationList.isCatalog) || !(prestationList === null || prestationList === void 0 ? void 0 : prestationList.isComptable))
79
81
  throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');
80
82
  // if (!listRegulations?.length) throw new Error('List of regulations can not be empty');
@@ -85,7 +87,24 @@ const calculatePaymentsAuto = (params) => {
85
87
  const nbExoExpress = listPartialExercicePrestationExpress.length;
86
88
  const listPayments = [];
87
89
  // on récupère le/les premiers réglements effectués, non alloués
88
- const sumRegulations = listRegulations.reduce((acc, r) => acc + r.amount - r.amountUsed, 0);
90
+ let isApplicationFeesAlreadyPaid = false;
91
+ const sumRegulations = listRegulations.reduce((acc, r) => {
92
+ var _a, _b;
93
+ //Si la regulation est rattachée à un paymentExpectation, on récupère le détail
94
+ // et on ne prend que les frais de dossier (applicationFee) + le montant de la compta (accountingFee)
95
+ if ((_a = r.paymentsExpectation) === null || _a === void 0 ? void 0 : _a.payload) {
96
+ const payload = JSON.parse((_b = r.paymentsExpectation) === null || _b === void 0 ? void 0 : _b.payload);
97
+ if (+(payload === null || payload === void 0 ? void 0 : payload.applicationFee) > 0) {
98
+ isApplicationFeesAlreadyPaid = true;
99
+ }
100
+ if (+(payload === null || payload === void 0 ? void 0 : payload.accountingFee) > 0)
101
+ acc += +(payload === null || payload === void 0 ? void 0 : payload.accountingFee);
102
+ return acc;
103
+ }
104
+ else {
105
+ return acc + r.amount - r.amountUsed;
106
+ }
107
+ }, 0);
89
108
  let remainingAmount = -sumRegulations; //TTC
90
109
  let paymentDate = initializedPaymentDate;
91
110
  //On order les exercicePrestation par startDate ASC et id ASC
@@ -105,6 +124,18 @@ const calculatePaymentsAuto = (params) => {
105
124
  closingDate: (listPartialExercicePrestationExpress === null || listPartialExercicePrestationExpress === void 0 ? void 0 : listPartialExercicePrestationExpress.length) ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
106
125
  });
107
126
  }
127
+ // Si les frais de dossiers sont facturés et qu'ils n'ont pas déjà été payés,
128
+ // on ajoute un paiement sur la première mensualité non express
129
+ if (isWithApplicationFees && !isApplicationFeesAlreadyPaid) {
130
+ listPayments.push({
131
+ amount: (0, types_1.getTaxesIncludedAmount)(applicationFeesAmount, idVat),
132
+ isPaid: false,
133
+ datePayment: dayjs().startOf('month').add(1, 'month').toDate(),
134
+ idPrestation,
135
+ idPaymentMethod: types_1.PaymentMethod.DIRECT_DEBIT.id,
136
+ closingDate: (listPartialExercicePrestationExpress === null || listPartialExercicePrestationExpress === void 0 ? void 0 : listPartialExercicePrestationExpress.length) ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
137
+ });
138
+ }
108
139
  // =========================
109
140
  // EXPRESS
110
141
  // =========================
@@ -148,32 +179,52 @@ const calculatePaymentsAuto = (params) => {
148
179
  if (nbExoExpress <= 1)
149
180
  paymentDate = initializedPaymentDate;
150
181
  let exerciceEndDate = dayjs(firstExerciceNonExpresssEndDate).toDate();
151
- //On génère un seul exercices plein, non express
152
- //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice
153
- let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));
154
- if (countMonthsBeforeExerciceEnd < 3)
155
- countMonthsBeforeExerciceEnd = 3;
156
- const exoAmount = yearlyAmountNonExpress;
157
- remainingAmount += priceWithTaxesIncluded ? exoAmount : (0, types_1.getTaxesIncludedAmount)(exoAmount, idVat);
158
- let remainingAmountByExercicePrestation = remainingAmount;
159
- let monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC
160
- if (monthlyAmount > 0) {
161
- for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {
162
- let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;
163
- // Si besoin, on applique les frais nécessaires :
164
- // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)
165
- amount = calculateFees(amount, goToClient, paymentDate);
166
- listPayments.push({
167
- amount: Math.round(100 * amount) / 100,
168
- datePayment: paymentDate,
169
- idPrestation,
170
- idPaymentMethod: types_1.PaymentMethod.DIRECT_DEBIT.id,
171
- closingDate: exerciceEndDate,
172
- });
173
- remainingAmountByExercicePrestation -= monthlyAmount;
174
- paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();
182
+ let hasGeneratedWholeYear = false;
183
+ let isFirstNonExpress = true;
184
+ //On génère des paiements jusqu'à ce qu'un exercice soit entier (12 mois), non express
185
+ while (!hasGeneratedWholeYear) {
186
+ //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice
187
+ let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));
188
+ if (countMonthsBeforeExerciceEnd < 3)
189
+ countMonthsBeforeExerciceEnd = 3;
190
+ const exoAmount = isFirstNonExpress ? yearlyAmountNonExpress : nextYearlyAmountNonExpress;
191
+ remainingAmount += priceWithTaxesIncluded ? exoAmount : (0, types_1.getTaxesIncludedAmount)(exoAmount, idVat);
192
+ //TODO: CAS A TESTER : si sumRegulations couvre le premier exercice par exemple (cas rar mais à envisager)
193
+ //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant
194
+ // if (remainingAmount <= 0) {
195
+ // continue;
196
+ // }
197
+ // Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total
198
+ if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {
199
+ remainingAmount -= (0, types_1.getTaxesIncludedAmount)(applicationFeesAmount, idVat);
200
+ }
201
+ let remainingAmountByExercicePrestation = remainingAmount;
202
+ // - frais d'application dès les second exo non express
203
+ if (!isFirstNonExpress)
204
+ remainingAmountByExercicePrestation += applicationCostTotalTTC;
205
+ const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC
206
+ if (monthlyAmount > 0) {
207
+ for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {
208
+ let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;
209
+ // Si besoin, on applique les frais nécessaires :
210
+ // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)
211
+ amount = calculateFees(amount, goToClient, paymentDate);
212
+ listPayments.push({
213
+ amount: Math.round(100 * amount) / 100,
214
+ datePayment: paymentDate,
215
+ idPrestation,
216
+ idPaymentMethod: types_1.PaymentMethod.DIRECT_DEBIT.id,
217
+ closingDate: exerciceEndDate,
218
+ });
219
+ remainingAmountByExercicePrestation -= monthlyAmount;
220
+ paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();
221
+ }
222
+ exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();
175
223
  }
176
- exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();
224
+ remainingAmount = 0;
225
+ if (countMonthsBeforeExerciceEnd === 12)
226
+ hasGeneratedWholeYear = true;
227
+ isFirstNonExpress = false;
177
228
  }
178
229
  remainingAmount = 0;
179
230
  // =========================
@@ -181,18 +232,18 @@ const calculatePaymentsAuto = (params) => {
181
232
  // =========================
182
233
  // On applique le taux de tva de la société, si besoin, selon la grille tarifaire
183
234
  remainingAmount += priceWithTaxesIncluded ? nextYearlyAmountNonExpress : (0, types_1.getTaxesIncludedAmount)(nextYearlyAmountNonExpress, idVat);
184
- remainingAmountByExercicePrestation = remainingAmount;
235
+ let remainingAmountByExercicePrestation = remainingAmount;
185
236
  //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice
186
- countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));
237
+ let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));
187
238
  if (countMonthsBeforeExerciceEnd < 3)
188
239
  countMonthsBeforeExerciceEnd = 3;
189
240
  // - frais d'application dès les second exo non express
190
241
  remainingAmountByExercicePrestation += applicationCostTotalTTC;
191
- monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;
242
+ const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;
192
243
  // Si aucun paiement généré, on stoppe là
193
244
  if (!listPayments.length)
194
245
  return [];
195
- while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11 || !isApplicationAlreadyPaid) {
246
+ while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11) {
196
247
  let amount = monthlyAmount;
197
248
  // Si besoin, on applique les frais nécessaires :
198
249
  // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)
@@ -206,7 +257,6 @@ const calculatePaymentsAuto = (params) => {
206
257
  closingDate: exerciceEndDate,
207
258
  });
208
259
  paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();
209
- isApplicationAlreadyPaid = true;
210
260
  }
211
261
  return listPayments;
212
262
  };
@@ -1 +1 @@
1
- {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../ts/utils/payment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,oCAA4H;AAC5H,+BAA+B;AAE/B,6CAA4C;AAO5C;;;;;;;;;GASG;AACH,MAAM,0BAA0B,GAAG,CAAC,QAAoB,EAAE,QAAoE,CAAC,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,CAAC,EAAsB,EAAE;IACzM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,mBAAC,OAAA,MAAA,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,mBAAmB,0CAAE,eAAe,0CAAE,WAAW,mCAAI,KAAK,CAAA,EAAA,CAAC,CAAC;IAChH,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,uBAAC,OAAA,CAAC,CAAA,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,mBAAmB,0CAAE,eAAe,0CAAE,WAAW,CAAA,KAAI,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,mBAAmB,0CAAE,eAAe,0CAAE,QAAQ,CAAA,CAAA,EAAA,CAAC,CAAC;IAC3J,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE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} from '../types';\nimport * as dayjs from 'dayjs';\nimport { PartialExercicePrestationExpress } from '../types/Interface/api/payment/Util';\nimport { getPriceGrid } from './prestation';\n\ninterface PaymentsWithList extends IPayment {\n type: 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther',\n listPayments: IPayment[]\n}\n\n/**\n * A partir d'une liste de payment (avec include jusqu'à prestationList, \n * avec en attributs 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther')\n * permet de récupérer uniquement le premier paiement de chaque type \n * et les autres payments dans listPayments\n * avec possibilité de filtrer avec le tableau de filtres\n * @param payments \n * @param types \n * @returns \n */\nconst groupPaymentsByServiceType = (payments: IPayment[], types: ('isComptable' | 'isJuridique' | 'isSocial' | 'isOther')[] = ['isComptable', 'isJuridique', 'isSocial', 'isOther']): PaymentsWithList[] => {\n const prestaComptable = payments.filter((el) => el?.paymentsPrestations?.prestationsList?.isComptable ?? false);\n const prestaSocial = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isSocial);\n const prestaJuridique = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isJuridique);\n const prestaOther = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && !el?.paymentsPrestations?.prestationsList?.isJuridique && !el?.paymentsPrestations?.prestationsList?.isSocial);\n \n const societyPayment: PaymentsWithList[] = [];\n if (prestaComptable.length && types.includes('isComptable')) {\n societyPayment.push({\n ...prestaComptable[0], // Données de base\n type: 'isComptable',\n listPayments: prestaComptable,\n });\n }\n if (prestaSocial.length && types.includes('isSocial')) {\n societyPayment.push({\n ...prestaSocial[0], // Données de base\n type: 'isSocial',\n listPayments: prestaSocial,\n });\n }\n if (prestaJuridique.length && types.includes('isJuridique')) {\n societyPayment.push({\n ...prestaJuridique[0], // Données de base\n type: 'isJuridique',\n listPayments: prestaJuridique,\n });\n }\n if (prestaOther.length && types.includes('isOther')) {\n societyPayment.push({\n ...prestaOther[0], // Données de base\n type: 'isOther',\n listPayments: prestaOther,\n });\n }\n return societyPayment;\n};\n\nconst calculateFees = (amount: number, goToClient: Date, paymentDate: Date):number => {\n const yearlyPriceIncreasing = 1.0275;\n\n const oneYearLessIfIn3LastMonthsOfYear = dayjs(goToClient).month() >= 9 ? 1 : 0;\n\n if (dayjs(paymentDate).year() - dayjs().year() > 0) {\n const nbYearsMore = dayjs(paymentDate).year() - dayjs().year() - oneYearLessIfIn3LastMonthsOfYear;\n // on applique X fois l'augmentation\n // ex. : si on lance l'appel en 2024, et qu'on génére un paiement pour 2026, on applique 2 fois l'augmentation\n // soit amount * yearlyPriceIncreasing * yearlyPriceIncreasing\n // soit amount * yearlyPriceIncreasing ^ nbYearsMore\n amount = amount * Math.pow(yearlyPriceIncreasing, nbYearsMore);\n }\n return amount;\n};\n\n/**\n// * @param {number} firstPaymentAmount - amount of the first payment (first regulation of the customer)\n * @param {Date} firstExerciceNonExpresssEndDate - end date of the first exercice non express\n * @param {number} idPrestation - prestation id\n * @param {IPrestationList} prestationList - type of prestation (hidden: 0, isCatalog: 1, isComptable: 1)\n * @param {number} idVat - vat id of society linked\n * @param {number} yearlyAmountNonExpress - yearly amount of non express prestation (HT)\n * @param {number} nextYearlyAmountNonExpress - yearly amount of non express prestation for next years (HT)\n * @param {PartialExercicePrestationExpress[]} listPartialExercicePrestationExpress - list of exercicePrestation linked to idPrestation -> used to get express\n * @param {IRegulation[]} listRegulations - list of regulations linked to idPrestation (TTC)\n * @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding\n */\nconst calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {\n const { idTypeBrand, goToClient, firstExerciceNonExpresssEndDate, idPrestation, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;\n const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3/* || dayjs().date() >= 15 */\n ? dayjs().add(2, 'month').startOf('month').toDate()\n : dayjs().add(1, 'month').startOf('month').toDate();\n let isApplicationAlreadyPaid = false;\n\n // On récupère la grille tarifaire pour savoir si les tarifs sont HT ou TTC \n // et pour connaitre le montant du coût de l'app\n if (!prestationList.id) throw new Error('idPrestationList manquant');\n const priceGrid = getPriceGrid(idTypeBrand, prestationList.id);\n if (!priceGrid) throw new Error('Impossible de trouver la grille tarifaire correspondante');\n const { applicationCost, priceWithTaxesIncluded } = priceGrid;\n const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : getTaxesIncludedAmount(applicationCost, idVat)) * 12;\n\n if (prestationList?.isCatalog || !prestationList?.isComptable) throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');\n // if (!listRegulations?.length) throw new Error('List of regulations can not be empty');\n if (listPartialExercicePrestationExpress.length && listPartialExercicePrestationExpress?.some((ep: PartialExercicePrestationExpress) => !ep?.startDate)) throw new Error('Start date of some exercice are missing');\n if (!listRegulations?.every((r: IRegulation) => !!r?.amount || !!r?.amountUsed)) throw new Error('Amount and amountUsed are missing for regulations');\n\n const nbExoExpress = listPartialExercicePrestationExpress.length;\n const listPayments:PaymentAuto[] = [];\n\n // on récupère le/les premiers réglements effectués, non alloués\n const sumRegulations = listRegulations.reduce((acc: number, r:IRegulation) => acc + r.amount - r.amountUsed, 0);\n let remainingAmount = -sumRegulations; //TTC\n let paymentDate = initializedPaymentDate;\n\n //On order les exercicePrestation par startDate ASC et id ASC\n listPartialExercicePrestationExpress.sort((a, b) => {\n const aStartDate = a?.startDate as Date;\n const bStartDate = b?.startDate as Date;\n return dayjs(aStartDate).diff(bStartDate);\n });\n\n //On ajoute un paiement initial correspondant à la somme des régulations\n if (sumRegulations) {\n listPayments.push({\n amount:sumRegulations, //TTC\n isPaid: true,\n datePayment: dayjs().toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n \n // =========================\n // EXPRESS\n // =========================\n listPartialExercicePrestationExpress.forEach((exercicePrestation:PartialExercicePrestationExpress, indexEP: number) => {\n remainingAmount += !priceWithTaxesIncluded \n ? getTaxesIncludedAmount(exercicePrestation.totalAmount, idVat) \n : exercicePrestation.totalAmount; //TTC\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n if (remainingAmount <= 0) return;\n \n //express : on étale en countExpressMonthlyPayment (nb de mensualités)\n let remainingAmountByExercicePrestation = remainingAmount; //TTC\n let countExpressMonthlyPayment = exercicePrestation?.countExpressMonthlyPayment ?? 3; //TTC\n //Si un premier règlement est généré avec le montant des regulations, on le considère comme une mensualité (unioquement pour le premier express et la première mensualité)\n if (indexEP === 0 && sumRegulations > 0) countExpressMonthlyPayment -= 1;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countExpressMonthlyPayment; //TTC\n for (let index = 1; index <= countExpressMonthlyPayment; index++) {\n // On arrondis les 11 premières mensualités, mais on récupère le reste pour la dernière mensualité, pour éviter les centimes perdus en arrondis\n // et on applique le taux de tva de la société\n const amount = index < countExpressMonthlyPayment ? monthlyAmount : remainingAmountByExercicePrestation; //TTC\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exercicePrestation.endDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n remainingAmount = 0;\n });\n\n // =========================\n // NON EXPRESS\n // =========================\n // on lisse sur le nb de mois restants (avec au minimum 3 mensualités)\n // Si un seul exo express, alors on met les paiements de l'exo actuel en parallèle\n // sinon, ils sont à la suite des express\n if (nbExoExpress <= 1) paymentDate = initializedPaymentDate;\n let exerciceEndDate = dayjs(firstExerciceNonExpresssEndDate).toDate();\n \n //On génère un seul exercices plein, non express\n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n \n const exoAmount = yearlyAmountNonExpress;\n remainingAmount += priceWithTaxesIncluded ? exoAmount : getTaxesIncludedAmount(exoAmount, idVat);\n\n let remainingAmountByExercicePrestation = remainingAmount;\n let monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC\n\n if (monthlyAmount > 0) {\n for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {\n let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;\n \n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n amount = calculateFees(amount, goToClient, paymentDate);\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();\n }\n\n remainingAmount = 0;\n\n // =========================\n // JUSQU'EN DECEMBRE\n // =========================\n // On applique le taux de tva de la société, si besoin, selon la grille tarifaire\n remainingAmount += priceWithTaxesIncluded ? nextYearlyAmountNonExpress : getTaxesIncludedAmount(nextYearlyAmountNonExpress, idVat);\n\n remainingAmountByExercicePrestation = remainingAmount;\n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n // - frais d'application dès les second exo non express\n remainingAmountByExercicePrestation += applicationCostTotalTTC;\n \n monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;\n \n // Si aucun paiement généré, on stoppe là\n if (!listPayments.length) return [];\n\n while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11 || !isApplicationAlreadyPaid) {\n let amount = monthlyAmount;\n\n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n // - frais d'application dès les second exo non express\n amount = calculateFees(amount, goToClient, paymentDate);\n\n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n isApplicationAlreadyPaid = true;\n }\n\n return listPayments;\n};\n\nexport {\n groupPaymentsByServiceType, calculatePaymentsAuto,\n};"]}
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../ts/utils/payment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,oCAA+I;AAC/I,+BAA+B;AAE/B,6CAA4C;AAO5C;;;;;;;;;GASG;AACH,MAAM,0BAA0B,GAAG,CAAC,QAAoB,EAAE,QAAoE,CAAC,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,CAAC,EAAsB,EAAE;IACzM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,mBAAC,OAAA,MAAA,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,mBAAmB,0CAAE,eAAe,0CAAE,WAAW,mCAAI,KAAK,CAAA,EAAA,CAAC,CAAC;IAChH,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,uBAAC,OAAA,CAAC,CAAA,MAAA,MAAA,EAAE,aAAF,EAAE,uBAA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,YAAY,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEpC,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAChE,IAAI,MAAM,GAAG,aAAa,CAAC;QAE3B,iDAAiD;QACjD,yGAAyG;QACzG,uDAAuD;QACvD,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAExD,YAAY,CAAC,IAAI,CAAC;YAChB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG;YACtC,WAAW,EAAE,WAAW;YACxB,YAAY;YACZ,eAAe,EAAE,qBAAa,CAAC,YAAY,CAAC,EAAE;YAC9C,WAAW,EAAE,eAAe;SAC7B,CAAC,CAAC;QACH,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;KAC5E;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAG4B,sDAAqB","sourcesContent":["'use strict';\n\nimport { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount, LegalFormTypeEnum } from '../types';\nimport * as dayjs from 'dayjs';\nimport { PartialExercicePrestationExpress } from '../types/Interface/api/payment/Util';\nimport { getPriceGrid } from './prestation';\n\ninterface PaymentsWithList extends IPayment {\n type: 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther',\n listPayments: IPayment[]\n}\n\n/**\n * A partir d'une liste de payment (avec include jusqu'à prestationList, \n * avec en attributs 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther')\n * permet de récupérer uniquement le premier paiement de chaque type \n * et les autres payments dans listPayments\n * avec possibilité de filtrer avec le tableau de filtres\n * @param payments \n * @param types \n * @returns \n */\nconst groupPaymentsByServiceType = (payments: IPayment[], types: ('isComptable' | 'isJuridique' | 'isSocial' | 'isOther')[] = ['isComptable', 'isJuridique', 'isSocial', 'isOther']): PaymentsWithList[] => {\n const prestaComptable = payments.filter((el) => el?.paymentsPrestations?.prestationsList?.isComptable ?? false);\n const prestaSocial = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isSocial);\n const prestaJuridique = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isJuridique);\n const prestaOther = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && !el?.paymentsPrestations?.prestationsList?.isJuridique && !el?.paymentsPrestations?.prestationsList?.isSocial);\n \n const societyPayment: PaymentsWithList[] = [];\n if (prestaComptable.length && types.includes('isComptable')) {\n societyPayment.push({\n ...prestaComptable[0], // Données de base\n type: 'isComptable',\n listPayments: prestaComptable,\n });\n }\n if (prestaSocial.length && types.includes('isSocial')) {\n societyPayment.push({\n ...prestaSocial[0], // Données de base\n type: 'isSocial',\n listPayments: prestaSocial,\n });\n }\n if (prestaJuridique.length && types.includes('isJuridique')) {\n societyPayment.push({\n ...prestaJuridique[0], // Données de base\n type: 'isJuridique',\n listPayments: prestaJuridique,\n });\n }\n if (prestaOther.length && types.includes('isOther')) {\n societyPayment.push({\n ...prestaOther[0], // Données de base\n type: 'isOther',\n listPayments: prestaOther,\n });\n }\n return societyPayment;\n};\n\nconst calculateFees = (amount: number, goToClient: Date, paymentDate: Date):number => {\n const yearlyPriceIncreasing = 1.0275;\n\n const oneYearLessIfIn3LastMonthsOfYear = dayjs(goToClient).month() >= 9 ? 1 : 0;\n\n if (dayjs(paymentDate).year() - dayjs().year() > 0) {\n const nbYearsMore = dayjs(paymentDate).year() - dayjs().year() - oneYearLessIfIn3LastMonthsOfYear;\n // on applique X fois l'augmentation\n // ex. : si on lance l'appel en 2024, et qu'on génére un paiement pour 2026, on applique 2 fois l'augmentation\n // soit amount * yearlyPriceIncreasing * yearlyPriceIncreasing\n // soit amount * yearlyPriceIncreasing ^ nbYearsMore\n amount = amount * Math.pow(yearlyPriceIncreasing, nbYearsMore);\n }\n return amount;\n};\n\n/**\n// * @param {number} firstPaymentAmount - amount of the first payment (first regulation of the customer)\n * @param {Date} firstExerciceNonExpresssEndDate - end date of the first exercice non express\n * @param {number} idPrestation - prestation id\n * @param {number} idLegalForm - legal form id of the society\n * @param {boolean} isWithApplicationFees - if the prestation has application fees to paid\n * @param {IPrestationList} prestationList - type of prestation (hidden: 0, isCatalog: 1, isComptable: 1)\n * @param {number} idVat - vat id of society linked\n * @param {number} yearlyAmountNonExpress - yearly amount of non express prestation (HT)\n * @param {number} nextYearlyAmountNonExpress - yearly amount of non express prestation for next years (HT)\n * @param {PartialExercicePrestationExpress[]} listPartialExercicePrestationExpress - list of exercicePrestation linked to idPrestation -> used to get express\n * @param {IRegulation[]} listRegulations - list of regulations linked to idPrestation (TTC)\n * @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding\n */\nconst calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {\n const { idTypeBrand, goToClient, isWithApplicationFees, firstExerciceNonExpresssEndDate, idPrestation, idLegalForm, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;\n const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3/* || dayjs().date() >= 15 */\n ? dayjs().add(2, 'month').startOf('month').toDate()\n : dayjs().add(1, 'month').startOf('month').toDate();\n\n // On récupère la grille tarifaire pour savoir si les tarifs sont HT ou TTC \n // et pour connaitre le montant du coût de l'app\n if (!prestationList.id) throw new Error('idPrestationList manquant');\n const priceGrid = getPriceGrid(idTypeBrand, prestationList.id);\n if (!priceGrid) throw new Error('Impossible de trouver la grille tarifaire correspondante');\n const { applicationCost, priceWithTaxesIncluded } = priceGrid;\n const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : getTaxesIncludedAmount(applicationCost, idVat)) * 12;\n const applicationFeesAmount = (idLegalForm === LegalFormTypeEnum.SCI) ? 150 : 50;\n\n if (prestationList?.isCatalog || !prestationList?.isComptable) throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');\n // if (!listRegulations?.length) throw new Error('List of regulations can not be empty');\n if (listPartialExercicePrestationExpress.length && listPartialExercicePrestationExpress?.some((ep: PartialExercicePrestationExpress) => !ep?.startDate)) throw new Error('Start date of some exercice are missing');\n if (!listRegulations?.every((r: IRegulation) => !!r?.amount || !!r?.amountUsed)) throw new Error('Amount and amountUsed are missing for regulations');\n\n const nbExoExpress = listPartialExercicePrestationExpress.length;\n const listPayments:PaymentAuto[] = [];\n\n // on récupère le/les premiers réglements effectués, non alloués\n let isApplicationFeesAlreadyPaid = false;\n const sumRegulations = listRegulations.reduce((acc: number, r:IRegulation) => {\n //Si la regulation est rattachée à un paymentExpectation, on récupère le détail\n // et on ne prend que les frais de dossier (applicationFee) + le montant de la compta (accountingFee)\n if (r.paymentsExpectation?.payload) {\n const payload = JSON.parse(r.paymentsExpectation?.payload);\n if (+payload?.applicationFee > 0) {\n isApplicationFeesAlreadyPaid = true;\n }\n if (+payload?.accountingFee > 0) acc += +payload?.accountingFee;\n return acc;\n } else {\n return acc + r.amount - r.amountUsed;\n }\n }, 0);\n let remainingAmount = -sumRegulations; //TTC\n let paymentDate = initializedPaymentDate;\n\n //On order les exercicePrestation par startDate ASC et id ASC\n listPartialExercicePrestationExpress.sort((a, b) => {\n const aStartDate = a?.startDate as Date;\n const bStartDate = b?.startDate as Date;\n return dayjs(aStartDate).diff(bStartDate);\n });\n\n //On ajoute un paiement initial correspondant à la somme des régulations\n if (sumRegulations) {\n listPayments.push({\n amount:sumRegulations, //TTC\n isPaid: true,\n datePayment: dayjs().toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n\n // Si les frais de dossiers sont facturés et qu'ils n'ont pas déjà été payés,\n // on ajoute un paiement sur la première mensualité non express\n if (isWithApplicationFees && !isApplicationFeesAlreadyPaid) {\n listPayments.push({\n amount: getTaxesIncludedAmount(applicationFeesAmount, idVat), //TTC\n isPaid: false,\n datePayment: dayjs().startOf('month').add(1, 'month').toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n \n // =========================\n // EXPRESS\n // =========================\n listPartialExercicePrestationExpress.forEach((exercicePrestation:PartialExercicePrestationExpress, indexEP: number) => {\n remainingAmount += !priceWithTaxesIncluded \n ? getTaxesIncludedAmount(exercicePrestation.totalAmount, idVat) \n : exercicePrestation.totalAmount; //TTC\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n if (remainingAmount <= 0) return;\n \n //express : on étale en countExpressMonthlyPayment (nb de mensualités)\n let remainingAmountByExercicePrestation = remainingAmount; //TTC\n let countExpressMonthlyPayment = exercicePrestation?.countExpressMonthlyPayment ?? 3; //TTC\n //Si un premier règlement est généré avec le montant des regulations, on le considère comme une mensualité (unioquement pour le premier express et la première mensualité)\n if (indexEP === 0 && sumRegulations > 0) countExpressMonthlyPayment -= 1;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countExpressMonthlyPayment; //TTC\n for (let index = 1; index <= countExpressMonthlyPayment; index++) {\n // On arrondis les 11 premières mensualités, mais on récupère le reste pour la dernière mensualité, pour éviter les centimes perdus en arrondis\n // et on applique le taux de tva de la société\n const amount = index < countExpressMonthlyPayment ? monthlyAmount : remainingAmountByExercicePrestation; //TTC\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exercicePrestation.endDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n remainingAmount = 0;\n });\n\n // =========================\n // NON EXPRESS\n // =========================\n // on lisse sur le nb de mois restants (avec au minimum 3 mensualités)\n // Si un seul exo express, alors on met les paiements de l'exo actuel en parallèle\n // sinon, ils sont à la suite des express\n if (nbExoExpress <= 1) paymentDate = initializedPaymentDate;\n let exerciceEndDate = dayjs(firstExerciceNonExpresssEndDate).toDate();\n\n let hasGeneratedWholeYear = false;\n let isFirstNonExpress = true;\n \n //On génère des paiements jusqu'à ce qu'un exercice soit entier (12 mois), non express\n while (!hasGeneratedWholeYear) {\n \n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n const exoAmount = isFirstNonExpress ? yearlyAmountNonExpress : nextYearlyAmountNonExpress;\n remainingAmount += priceWithTaxesIncluded ? exoAmount : getTaxesIncludedAmount(exoAmount, idVat);\n\n //TODO: CAS A TESTER : si sumRegulations couvre le premier exercice par exemple (cas rar mais à envisager)\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n // if (remainingAmount <= 0) {\n // continue;\n // }\n\n // Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total\n if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {\n remainingAmount -= getTaxesIncludedAmount(applicationFeesAmount, idVat);\n }\n\n let remainingAmountByExercicePrestation = remainingAmount;\n\n // - frais d'application dès les second exo non express\n if (!isFirstNonExpress) remainingAmountByExercicePrestation += applicationCostTotalTTC;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC\n\n if (monthlyAmount > 0) {\n for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {\n let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;\n \n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n amount = calculateFees(amount, goToClient, paymentDate);\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();\n }\n remainingAmount = 0;\n if (countMonthsBeforeExerciceEnd === 12) hasGeneratedWholeYear = true;\n isFirstNonExpress = false;\n }\n\n remainingAmount = 0;\n\n // =========================\n // JUSQU'EN DECEMBRE\n // =========================\n // On applique le taux de tva de la société, si besoin, selon la grille tarifaire\n remainingAmount += priceWithTaxesIncluded ? nextYearlyAmountNonExpress : getTaxesIncludedAmount(nextYearlyAmountNonExpress, idVat);\n\n let remainingAmountByExercicePrestation = remainingAmount;\n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n // - frais d'application dès les second exo non express\n remainingAmountByExercicePrestation += applicationCostTotalTTC;\n \n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;\n \n // Si aucun paiement généré, on stoppe là\n if (!listPayments.length) return [];\n\n while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11) {\n let amount = monthlyAmount;\n\n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n // - frais d'application dès les second exo non express\n amount = calculateFees(amount, goToClient, paymentDate);\n\n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n\n return listPayments;\n};\n\nexport {\n groupPaymentsByServiceType, calculatePaymentsAuto,\n};"]}
@@ -90,6 +90,8 @@ describe('Payment', () => {
90
90
  goToClient: dayjs('2024-06-06').toDate(),
91
91
  firstExerciceNonExpresssEndDate,
92
92
  idPrestation,
93
+ isWithApplicationFees: true,
94
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
93
95
  prestationList: Object.assign(Object.assign({}, prestationList), { isCatalog: true }),
94
96
  idVat,
95
97
  listPartialExercicePrestationExpress,
@@ -112,6 +114,8 @@ describe('Payment', () => {
112
114
  goToClient: dayjs('2024-06-06').toDate(),
113
115
  firstExerciceNonExpresssEndDate,
114
116
  idPrestation,
117
+ isWithApplicationFees: true,
118
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
115
119
  prestationList,
116
120
  idVat,
117
121
  listPartialExercicePrestationExpress,
@@ -134,6 +138,8 @@ describe('Payment', () => {
134
138
  goToClient: dayjs('2024-06-06').toDate(),
135
139
  firstExerciceNonExpresssEndDate,
136
140
  idPrestation,
141
+ isWithApplicationFees: true,
142
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
137
143
  prestationList,
138
144
  idVat,
139
145
  listPartialExercicePrestationExpress,
@@ -158,6 +164,8 @@ describe('Payment', () => {
158
164
  goToClient: dayjs('2024-06-06').toDate(),
159
165
  firstExerciceNonExpresssEndDate,
160
166
  idPrestation,
167
+ isWithApplicationFees: true,
168
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
161
169
  prestationList,
162
170
  idVat,
163
171
  listPartialExercicePrestationExpress: [listPartialExercicePrestationExpress[0]],
@@ -176,6 +184,8 @@ describe('Payment', () => {
176
184
  goToClient: dayjs('2024-06-06').toDate(),
177
185
  firstExerciceNonExpresssEndDate,
178
186
  idPrestation,
187
+ isWithApplicationFees: true,
188
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
179
189
  prestationList,
180
190
  idVat,
181
191
  listPartialExercicePrestationExpress,
@@ -198,6 +208,8 @@ describe('Payment', () => {
198
208
  goToClient: dayjs('2024-06-06').toDate(),
199
209
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
200
210
  idPrestation,
211
+ isWithApplicationFees: true,
212
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
201
213
  prestationList,
202
214
  idVat,
203
215
  listPartialExercicePrestationExpress: [],
@@ -221,6 +233,8 @@ describe('Payment', () => {
221
233
  goToClient: dayjs('2024-06-06').toDate(),
222
234
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
223
235
  idPrestation,
236
+ isWithApplicationFees: true,
237
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
224
238
  prestationList,
225
239
  idVat,
226
240
  listPartialExercicePrestationExpress: [],
@@ -248,6 +262,8 @@ describe('Payment', () => {
248
262
  goToClient: dayjs('2024-06-06').toDate(),
249
263
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
250
264
  idPrestation,
265
+ isWithApplicationFees: true,
266
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
251
267
  prestationList,
252
268
  idVat,
253
269
  listPartialExercicePrestationExpress: [],
@@ -272,6 +288,8 @@ describe('Payment', () => {
272
288
  goToClient: dayjs('2024-06-06').toDate(),
273
289
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
274
290
  idPrestation,
291
+ isWithApplicationFees: true,
292
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
275
293
  prestationList,
276
294
  idVat,
277
295
  listPartialExercicePrestationExpress: [],
@@ -293,6 +311,8 @@ describe('Payment', () => {
293
311
  goToClient: dayjs('2024-06-06').toDate(),
294
312
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
295
313
  idPrestation,
314
+ isWithApplicationFees: true,
315
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
296
316
  prestationList,
297
317
  idVat,
298
318
  listPartialExercicePrestationExpress: [],
@@ -316,6 +336,8 @@ describe('Payment', () => {
316
336
  goToClient: dayjs('2024-06-06').toDate(),
317
337
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
318
338
  idPrestation,
339
+ isWithApplicationFees: true,
340
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
319
341
  prestationList,
320
342
  idVat,
321
343
  listPartialExercicePrestationExpress: [],
@@ -340,6 +362,8 @@ describe('Payment', () => {
340
362
  goToClient: dayjs('2024-06-06').toDate(),
341
363
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
342
364
  idPrestation,
365
+ isWithApplicationFees: true,
366
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
343
367
  prestationList,
344
368
  idVat,
345
369
  listPartialExercicePrestationExpress: [],
@@ -366,6 +390,8 @@ describe('Payment', () => {
366
390
  goToClient: dayjs('2024-06-06').toDate(),
367
391
  firstExerciceNonExpresssEndDate,
368
392
  idPrestation,
393
+ isWithApplicationFees: true,
394
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
369
395
  prestationList,
370
396
  idVat,
371
397
  listPartialExercicePrestationExpress: listPartialExercicePrestationExpressCloned,
@@ -384,6 +410,8 @@ describe('Payment', () => {
384
410
  goToClient: dayjs('2024-06-06').toDate(),
385
411
  firstExerciceNonExpresssEndDate,
386
412
  idPrestation,
413
+ isWithApplicationFees: true,
414
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
387
415
  prestationList,
388
416
  idVat,
389
417
  listPartialExercicePrestationExpress,
@@ -422,6 +450,8 @@ describe('Payment', () => {
422
450
  goToClient: dayjs('2024-06-06').toDate(),
423
451
  firstExerciceNonExpresssEndDate,
424
452
  idPrestation,
453
+ isWithApplicationFees: true,
454
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
425
455
  prestationList,
426
456
  idVat,
427
457
  listPartialExercicePrestationExpress,
@@ -441,6 +471,8 @@ describe('Payment', () => {
441
471
  goToClient: dayjs('2024-06-06').toDate(),
442
472
  firstExerciceNonExpresssEndDate,
443
473
  idPrestation,
474
+ isWithApplicationFees: true,
475
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
444
476
  prestationList,
445
477
  idVat,
446
478
  listPartialExercicePrestationExpress,
@@ -458,6 +490,8 @@ describe('Payment', () => {
458
490
  goToClient: dayjs('2024-06-06').toDate(),
459
491
  firstExerciceNonExpresssEndDate,
460
492
  idPrestation,
493
+ isWithApplicationFees: true,
494
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
461
495
  prestationList,
462
496
  idVat,
463
497
  listPartialExercicePrestationExpress: [],
@@ -474,6 +508,8 @@ describe('Payment', () => {
474
508
  goToClient: dayjs('2024-06-06').toDate(),
475
509
  firstExerciceNonExpresssEndDate: dayjs('2024-12-31').toDate(),
476
510
  idPrestation,
511
+ isWithApplicationFees: true,
512
+ idLegalForm: types_1.LegalFormTypeEnum.SARL,
477
513
  prestationList,
478
514
  idVat: types_1.Vat.TX_20.id,
479
515
  listPartialExercicePrestationExpress: [],