@silexpert/core 1.1.307 → 1.1.309

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 (70) 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/types/Enum/Card.d.ts +24 -2
  6. package/dist/cjs/types/Enum/Card.d.ts.map +1 -1
  7. package/dist/cjs/types/Enum/Card.js +26 -0
  8. package/dist/cjs/types/Enum/Card.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/commercialManagement/Query.d.ts +6 -0
  16. package/dist/cjs/types/Interface/api/commercialManagement/Query.d.ts.map +1 -1
  17. package/dist/cjs/types/Interface/api/commercialManagement/Query.js +26 -1
  18. package/dist/cjs/types/Interface/api/commercialManagement/Query.js.map +1 -1
  19. package/dist/cjs/types/Interface/api/payment/Util.d.ts +3 -0
  20. package/dist/cjs/types/Interface/api/payment/Util.d.ts.map +1 -1
  21. package/dist/cjs/types/Interface/api/payment/Util.js.map +1 -1
  22. package/dist/cjs/types/Interface/models/IPrestation.d.ts +1 -0
  23. package/dist/cjs/types/Interface/models/IPrestation.d.ts.map +1 -1
  24. package/dist/cjs/types/Interface/models/IPrestation.js.map +1 -1
  25. package/dist/cjs/utils/payment.d.ts +2 -0
  26. package/dist/cjs/utils/payment.d.ts.map +1 -1
  27. package/dist/cjs/utils/payment.js +84 -33
  28. package/dist/cjs/utils/payment.js.map +1 -1
  29. package/dist/cjs/utils/tests/payment.spec.js +36 -0
  30. package/dist/cjs/utils/tests/payment.spec.js.map +1 -1
  31. package/dist/mjs/api/resources/CommercialDocument.d.ts +3 -1
  32. package/dist/mjs/api/resources/CommercialDocument.d.ts.map +1 -1
  33. package/dist/mjs/api/resources/CommercialDocument.js +9 -0
  34. package/dist/mjs/api/resources/CommercialDocument.js.map +1 -1
  35. package/dist/mjs/types/Enum/Card.d.ts +24 -2
  36. package/dist/mjs/types/Enum/Card.d.ts.map +1 -1
  37. package/dist/mjs/types/Enum/Card.js +26 -0
  38. package/dist/mjs/types/Enum/Card.js.map +1 -1
  39. package/dist/mjs/types/Enum/EstimateInvoice.d.ts +4 -0
  40. package/dist/mjs/types/Enum/EstimateInvoice.d.ts.map +1 -1
  41. package/dist/mjs/types/Enum/EstimateInvoice.js +26 -0
  42. package/dist/mjs/types/Enum/EstimateInvoice.js.map +1 -1
  43. package/dist/mjs/types/Enum/PriceGridClementine.js +1 -1
  44. package/dist/mjs/types/Enum/PriceGridClementine.js.map +1 -1
  45. package/dist/mjs/types/Interface/api/commercialManagement/Query.d.ts +6 -0
  46. package/dist/mjs/types/Interface/api/commercialManagement/Query.d.ts.map +1 -1
  47. package/dist/mjs/types/Interface/api/commercialManagement/Query.js +29 -1
  48. package/dist/mjs/types/Interface/api/commercialManagement/Query.js.map +1 -1
  49. package/dist/mjs/types/Interface/api/payment/Util.d.ts +3 -0
  50. package/dist/mjs/types/Interface/api/payment/Util.d.ts.map +1 -1
  51. package/dist/mjs/types/Interface/api/payment/Util.js.map +1 -1
  52. package/dist/mjs/types/Interface/models/IPrestation.d.ts +1 -0
  53. package/dist/mjs/types/Interface/models/IPrestation.d.ts.map +1 -1
  54. package/dist/mjs/types/Interface/models/IPrestation.js.map +1 -1
  55. package/dist/mjs/utils/payment.d.ts +2 -0
  56. package/dist/mjs/utils/payment.d.ts.map +1 -1
  57. package/dist/mjs/utils/payment.js +84 -34
  58. package/dist/mjs/utils/payment.js.map +1 -1
  59. package/dist/mjs/utils/tests/payment.spec.js +37 -1
  60. package/dist/mjs/utils/tests/payment.spec.js.map +1 -1
  61. package/package.json +1 -1
  62. package/ts/api/resources/CommercialDocument.ts +11 -0
  63. package/ts/types/Enum/Card.ts +27 -0
  64. package/ts/types/Enum/EstimateInvoice.ts +28 -1
  65. package/ts/types/Enum/PriceGridClementine.ts +1 -1
  66. package/ts/types/Interface/api/commercialManagement/Query.ts +21 -1
  67. package/ts/types/Interface/api/payment/Util.ts +3 -0
  68. package/ts/types/Interface/models/IPrestation.ts +1 -0
  69. package/ts/utils/payment.ts +87 -34
  70. package/ts/utils/tests/payment.spec.ts +37 -1
@@ -1 +1 @@
1
- {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../ts/utils/payment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAgD,aAAa,EAAe,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC5H,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;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,CAAC,EAAE,EAAE,mBAAmB,EAAE,eAAe,EAAE,WAAW,IAAI,KAAK,CAAC,CAAC;IAChH,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,mBAAmB,EAAE,eAAe,EAAE,WAAW,IAAI,EAAE,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IAC3J,MAAM,eAAe,GAAG,QAAQ,C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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,aAAa,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;QAC3E,wBAAwB,GAAG,IAAI,CAAC;KACjC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EACL,0BAA0B,EAAE,qBAAqB,GAClD,CAAC","sourcesContent":["'use strict';\n\nimport { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount } 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 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,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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,aAAa,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;AAEF,OAAO,EACL,0BAA0B,EAAE,qBAAqB,GAClD,CAAC","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};"]}
@@ -1,5 +1,5 @@
1
1
  import * as dayjs from 'dayjs';
2
- import { Vat, PaymentMethod } from '../../types';
2
+ import { Vat, PaymentMethod, LegalFormTypeEnum } from '../../types';
3
3
  import MockDate from 'mockdate';
4
4
  import { calculatePaymentsAuto } from '../payment';
5
5
  describe('Payment', () => {
@@ -78,6 +78,8 @@ describe('Payment', () => {
78
78
  goToClient: dayjs('2024-06-06').toDate(),
79
79
  firstExerciceNonExpresssEndDate,
80
80
  idPrestation,
81
+ isWithApplicationFees: true,
82
+ idLegalForm: LegalFormTypeEnum.SARL,
81
83
  prestationList: {
82
84
  ...prestationList,
83
85
  isCatalog: true,
@@ -103,6 +105,8 @@ describe('Payment', () => {
103
105
  goToClient: dayjs('2024-06-06').toDate(),
104
106
  firstExerciceNonExpresssEndDate,
105
107
  idPrestation,
108
+ isWithApplicationFees: true,
109
+ idLegalForm: LegalFormTypeEnum.SARL,
106
110
  prestationList,
107
111
  idVat,
108
112
  listPartialExercicePrestationExpress,
@@ -125,6 +129,8 @@ describe('Payment', () => {
125
129
  goToClient: dayjs('2024-06-06').toDate(),
126
130
  firstExerciceNonExpresssEndDate,
127
131
  idPrestation,
132
+ isWithApplicationFees: true,
133
+ idLegalForm: LegalFormTypeEnum.SARL,
128
134
  prestationList,
129
135
  idVat,
130
136
  listPartialExercicePrestationExpress,
@@ -149,6 +155,8 @@ describe('Payment', () => {
149
155
  goToClient: dayjs('2024-06-06').toDate(),
150
156
  firstExerciceNonExpresssEndDate,
151
157
  idPrestation,
158
+ isWithApplicationFees: true,
159
+ idLegalForm: LegalFormTypeEnum.SARL,
152
160
  prestationList,
153
161
  idVat,
154
162
  listPartialExercicePrestationExpress: [listPartialExercicePrestationExpress[0]],
@@ -166,6 +174,8 @@ describe('Payment', () => {
166
174
  goToClient: dayjs('2024-06-06').toDate(),
167
175
  firstExerciceNonExpresssEndDate,
168
176
  idPrestation,
177
+ isWithApplicationFees: true,
178
+ idLegalForm: LegalFormTypeEnum.SARL,
169
179
  prestationList,
170
180
  idVat,
171
181
  listPartialExercicePrestationExpress,
@@ -188,6 +198,8 @@ describe('Payment', () => {
188
198
  goToClient: dayjs('2024-06-06').toDate(),
189
199
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
190
200
  idPrestation,
201
+ isWithApplicationFees: true,
202
+ idLegalForm: LegalFormTypeEnum.SARL,
191
203
  prestationList,
192
204
  idVat,
193
205
  listPartialExercicePrestationExpress: [],
@@ -211,6 +223,8 @@ describe('Payment', () => {
211
223
  goToClient: dayjs('2024-06-06').toDate(),
212
224
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
213
225
  idPrestation,
226
+ isWithApplicationFees: true,
227
+ idLegalForm: LegalFormTypeEnum.SARL,
214
228
  prestationList,
215
229
  idVat,
216
230
  listPartialExercicePrestationExpress: [],
@@ -238,6 +252,8 @@ describe('Payment', () => {
238
252
  goToClient: dayjs('2024-06-06').toDate(),
239
253
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
240
254
  idPrestation,
255
+ isWithApplicationFees: true,
256
+ idLegalForm: LegalFormTypeEnum.SARL,
241
257
  prestationList,
242
258
  idVat,
243
259
  listPartialExercicePrestationExpress: [],
@@ -262,6 +278,8 @@ describe('Payment', () => {
262
278
  goToClient: dayjs('2024-06-06').toDate(),
263
279
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
264
280
  idPrestation,
281
+ isWithApplicationFees: true,
282
+ idLegalForm: LegalFormTypeEnum.SARL,
265
283
  prestationList,
266
284
  idVat,
267
285
  listPartialExercicePrestationExpress: [],
@@ -283,6 +301,8 @@ describe('Payment', () => {
283
301
  goToClient: dayjs('2024-06-06').toDate(),
284
302
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
285
303
  idPrestation,
304
+ isWithApplicationFees: true,
305
+ idLegalForm: LegalFormTypeEnum.SARL,
286
306
  prestationList,
287
307
  idVat,
288
308
  listPartialExercicePrestationExpress: [],
@@ -306,6 +326,8 @@ describe('Payment', () => {
306
326
  goToClient: dayjs('2024-06-06').toDate(),
307
327
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
308
328
  idPrestation,
329
+ isWithApplicationFees: true,
330
+ idLegalForm: LegalFormTypeEnum.SARL,
309
331
  prestationList,
310
332
  idVat,
311
333
  listPartialExercicePrestationExpress: [],
@@ -329,6 +351,8 @@ describe('Payment', () => {
329
351
  goToClient: dayjs('2024-06-06').toDate(),
330
352
  firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
331
353
  idPrestation,
354
+ isWithApplicationFees: true,
355
+ idLegalForm: LegalFormTypeEnum.SARL,
332
356
  prestationList,
333
357
  idVat,
334
358
  listPartialExercicePrestationExpress: [],
@@ -360,6 +384,8 @@ describe('Payment', () => {
360
384
  goToClient: dayjs('2024-06-06').toDate(),
361
385
  firstExerciceNonExpresssEndDate,
362
386
  idPrestation,
387
+ isWithApplicationFees: true,
388
+ idLegalForm: LegalFormTypeEnum.SARL,
363
389
  prestationList,
364
390
  idVat,
365
391
  listPartialExercicePrestationExpress: listPartialExercicePrestationExpressCloned,
@@ -378,6 +404,8 @@ describe('Payment', () => {
378
404
  goToClient: dayjs('2024-06-06').toDate(),
379
405
  firstExerciceNonExpresssEndDate,
380
406
  idPrestation,
407
+ isWithApplicationFees: true,
408
+ idLegalForm: LegalFormTypeEnum.SARL,
381
409
  prestationList,
382
410
  idVat,
383
411
  listPartialExercicePrestationExpress,
@@ -415,6 +443,8 @@ describe('Payment', () => {
415
443
  goToClient: dayjs('2024-06-06').toDate(),
416
444
  firstExerciceNonExpresssEndDate,
417
445
  idPrestation,
446
+ isWithApplicationFees: true,
447
+ idLegalForm: LegalFormTypeEnum.SARL,
418
448
  prestationList,
419
449
  idVat,
420
450
  listPartialExercicePrestationExpress,
@@ -434,6 +464,8 @@ describe('Payment', () => {
434
464
  goToClient: dayjs('2024-06-06').toDate(),
435
465
  firstExerciceNonExpresssEndDate,
436
466
  idPrestation,
467
+ isWithApplicationFees: true,
468
+ idLegalForm: LegalFormTypeEnum.SARL,
437
469
  prestationList,
438
470
  idVat,
439
471
  listPartialExercicePrestationExpress,
@@ -450,6 +482,8 @@ describe('Payment', () => {
450
482
  goToClient: dayjs('2024-06-06').toDate(),
451
483
  firstExerciceNonExpresssEndDate,
452
484
  idPrestation,
485
+ isWithApplicationFees: true,
486
+ idLegalForm: LegalFormTypeEnum.SARL,
453
487
  prestationList,
454
488
  idVat,
455
489
  listPartialExercicePrestationExpress: [],
@@ -465,6 +499,8 @@ describe('Payment', () => {
465
499
  goToClient: dayjs('2024-06-06').toDate(),
466
500
  firstExerciceNonExpresssEndDate: dayjs('2024-12-31').toDate(),
467
501
  idPrestation,
502
+ isWithApplicationFees: true,
503
+ idLegalForm: LegalFormTypeEnum.SARL,
468
504
  prestationList,
469
505
  idVat: Vat.TX_20.id,
470
506
  listPartialExercicePrestationExpress: [],
@@ -1 +1 @@
1
- {"version":3,"file":"payment.spec.js","sourceRoot":"","sources":["../../../../ts/utils/tests/payment.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAe,GAAG,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;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,KAA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+B,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;gBAC7D,YAAY;gBACZ,cAAc;gBACd,KAAK,EAAE,GAAG,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,aAAa,CAAC,SAAS,CAAC,EAAE;wBAC3C,SAAS;qBACV,CAAC;gBACF,sBAAsB,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI;aAAE,CAAC,CAAC;YACpE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC/H,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as dayjs from 'dayjs';\nimport { IRegulation, Vat, PaymentMethod } 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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":"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AAE,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC/H,CAAC,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});"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "1.1.307",
3
+ "version": "1.1.309",
4
4
  "description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
5
5
  "homepage": "https://gitlab.compta-clementine.fr/dev/silex-api",
6
6
  "main": "dist/cjs/index.js",
@@ -9,6 +9,7 @@ import {
9
9
  IEstimateInvoice,
10
10
  QueryCountByStatus,
11
11
  QueryDocumentPaginated,
12
+ QueryExportCommercialManagementIntoCSV,
12
13
  QueryNextReference,
13
14
  QueryPaginate,
14
15
  ReadCountDocumentByStatus,
@@ -115,4 +116,14 @@ export class CommercialDocument extends Resource {
115
116
  { params },
116
117
  );
117
118
  }
119
+
120
+ export(payload: QueryExportCommercialManagementIntoCSV): Promise<Buffer> {
121
+ return this.axios.$get('/commercial-management/exports/csv', {
122
+ params: payload,
123
+ responseType: 'arraybuffer',
124
+ headers: {
125
+ Accept: 'application/csv',
126
+ },
127
+ });
128
+ }
118
129
  }
@@ -1,3 +1,5 @@
1
+ import { Role } from './Role';
2
+
1
3
  export enum CardType {
2
4
  BALANCE_SHEET = 1,
3
5
  BALANCE_SHEET_INTERMEDIATE = 2,
@@ -6,6 +8,8 @@ export enum CardType {
6
8
  BALANCE_SHEET_EXPRESS = 5,
7
9
  VAT = 6,
8
10
  // REINFORCED_CHECKLIST = 7,
11
+ CHECK_BALANCE_ANNOTATION_NEW_CLIENT = 8,
12
+ CHECK_BALANCE_ANNOTATION = 9,
9
13
  }
10
14
 
11
15
  export enum CardState {
@@ -23,6 +27,7 @@ export enum CardGroupEnum {
23
27
  BALANCE_SHEET_GROUP = 1,
24
28
  VAT_GROUP = 2,
25
29
  // REINFORCED_CHECKLIST_GROUP = 3,
30
+ ACCEPTATION_GROUP = 4,
26
31
  }
27
32
 
28
33
  export const CardGroup = [
@@ -30,20 +35,30 @@ export const CardGroup = [
30
35
  id: CardGroupEnum.BALANCE_SHEET_GROUP,
31
36
  label: 'Bilans',
32
37
  types: [CardType.BALANCE_SHEET, CardType.BALANCE_SHEET_INTERMEDIATE, CardType.BALANCE_SHEET_PREVISIONAL, CardType.BALANCE_SHEET_LIQUIDATION, CardType.BALANCE_SHEET_EXPRESS] as CardType[],
38
+ roles: [Role.FRONT_OFFICE],
33
39
  maxByDay: 3,
34
40
  },
35
41
  {
36
42
  id: CardGroupEnum.VAT_GROUP,
37
43
  label: 'Déclarations',
38
44
  types: [CardType.VAT] as CardType[],
45
+ roles: [Role.FRONT_OFFICE],
39
46
  maxByDay: 6,
40
47
  },
41
48
  // {
42
49
  // id: CardGroupEnum.REINFORCED_CHECKLIST_GROUP,
43
50
  // label: 'Checklist',
44
51
  // types: [CardType.REINFORCED_CHECKLIST],
52
+ // roles: [Role.FRONT_OFFICE],
45
53
  // maxByDay: 6,
46
54
  // },
55
+ {
56
+ id: CardGroupEnum.ACCEPTATION_GROUP,
57
+ label: 'Contrôle solde bancaire & annotations',
58
+ types: [CardType.CHECK_BALANCE_ANNOTATION_NEW_CLIENT, CardType.CHECK_BALANCE_ANNOTATION] as CardType[],
59
+ roles: [Role.DATA_OFFICER],
60
+ maxByDay: 25,
61
+ },
47
62
  ] as const;
48
63
 
49
64
  export const CardTypeLabel = [
@@ -88,6 +103,18 @@ export const CardTypeLabel = [
88
103
  // label: 'Checklist',
89
104
  // groupId: CardGroupEnum.REINFORCED_CHECKLIST_GROUP,
90
105
  // },
106
+ {
107
+ id: CardType.CHECK_BALANCE_ANNOTATION_NEW_CLIENT,
108
+ label: 'Contrôle solde bancaire & mise en place annotation nouveau client',
109
+ refLabel: 'LABNC',
110
+ groupId: CardGroupEnum.ACCEPTATION_GROUP,
111
+ },
112
+ {
113
+ id: CardType.CHECK_BALANCE_ANNOTATION,
114
+ label: 'Contrôle solde bancaire & contrôle annotations client',
115
+ refLabel: 'LABC',
116
+ groupId: CardGroupEnum.ACCEPTATION_GROUP,
117
+ },
91
118
  ] as const;
92
119
 
93
120
  export interface UserCardsStats {
@@ -5,4 +5,31 @@ export enum EstimateInvoiceType {
5
5
  AVOIR = 4,
6
6
  RESTE = 5,
7
7
  ACOMPTE = 6,
8
- }
8
+ }
9
+
10
+ export const EstimateInvoiceTypeList: Array<{ id: EstimateInvoiceType; label: string; }> = [
11
+ {
12
+ id: EstimateInvoiceType.FACTURE,
13
+ label: 'Facture',
14
+ },
15
+ {
16
+ id: EstimateInvoiceType.DEVIS,
17
+ label: 'Devis',
18
+ },
19
+ {
20
+ id: EstimateInvoiceType.BON,
21
+ label: 'Bon de commande',
22
+ },
23
+ {
24
+ id: EstimateInvoiceType.AVOIR,
25
+ label: 'Avoir',
26
+ },
27
+ {
28
+ id: EstimateInvoiceType.RESTE,
29
+ label: 'Facture de solde',
30
+ },
31
+ {
32
+ id: EstimateInvoiceType.ACOMPTE,
33
+ label: 'Facture d\'acompte',
34
+ },
35
+ ];
@@ -479,7 +479,7 @@ export const PriceGridClementine = [
479
479
  ],
480
480
  },
481
481
  {
482
- /* Compta SCI Clems */
482
+ /* Compta LMNP Clems */
483
483
  idPrestationList: [PrestationType.COMPTA_LOUEUR_MEUBLE_NON_PRO_KLEMS, PrestationType.COMPTA_LOUEUR_MEUBLE_NON_PRO_KLEMS_EXPRESS],
484
484
  priceWithTaxesIncluded: true,
485
485
  applicationCost: 0,