@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.
- package/dist/cjs/api/resources/CommercialDocument.d.ts +3 -1
- package/dist/cjs/api/resources/CommercialDocument.d.ts.map +1 -1
- package/dist/cjs/api/resources/CommercialDocument.js +9 -0
- package/dist/cjs/api/resources/CommercialDocument.js.map +1 -1
- package/dist/cjs/api/resources/KilometricAllowance.d.ts +2 -0
- package/dist/cjs/api/resources/KilometricAllowance.d.ts.map +1 -1
- package/dist/cjs/api/resources/KilometricAllowance.js +9 -0
- package/dist/cjs/api/resources/KilometricAllowance.js.map +1 -1
- package/dist/cjs/types/Enum/EstimateInvoice.d.ts +4 -0
- package/dist/cjs/types/Enum/EstimateInvoice.d.ts.map +1 -1
- package/dist/cjs/types/Enum/EstimateInvoice.js +27 -1
- package/dist/cjs/types/Enum/EstimateInvoice.js.map +1 -1
- package/dist/cjs/types/Enum/PriceGridClementine.js +1 -1
- package/dist/cjs/types/Enum/PriceGridClementine.js.map +1 -1
- package/dist/cjs/types/Interface/api/bankAccount/Read.d.ts +1 -0
- package/dist/cjs/types/Interface/api/bankAccount/Read.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/bankAccount/Read.js.map +1 -1
- package/dist/cjs/types/Interface/api/commercialManagement/Query.d.ts +6 -0
- package/dist/cjs/types/Interface/api/commercialManagement/Query.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/commercialManagement/Query.js +26 -1
- package/dist/cjs/types/Interface/api/commercialManagement/Query.js.map +1 -1
- package/dist/cjs/types/Interface/api/payment/Util.d.ts +2 -0
- package/dist/cjs/types/Interface/api/payment/Util.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/payment/Util.js.map +1 -1
- package/dist/cjs/types/Interface/models/IPrestation.d.ts +1 -0
- package/dist/cjs/types/Interface/models/IPrestation.d.ts.map +1 -1
- package/dist/cjs/types/Interface/models/IPrestation.js.map +1 -1
- package/dist/cjs/utils/payment.d.ts +2 -0
- package/dist/cjs/utils/payment.d.ts.map +1 -1
- package/dist/cjs/utils/payment.js +83 -33
- package/dist/cjs/utils/payment.js.map +1 -1
- package/dist/cjs/utils/tests/payment.spec.js +36 -0
- package/dist/cjs/utils/tests/payment.spec.js.map +1 -1
- package/dist/mjs/api/resources/CommercialDocument.d.ts +3 -1
- package/dist/mjs/api/resources/CommercialDocument.d.ts.map +1 -1
- package/dist/mjs/api/resources/CommercialDocument.js +9 -0
- package/dist/mjs/api/resources/CommercialDocument.js.map +1 -1
- package/dist/mjs/api/resources/KilometricAllowance.d.ts +2 -0
- package/dist/mjs/api/resources/KilometricAllowance.d.ts.map +1 -1
- package/dist/mjs/api/resources/KilometricAllowance.js +9 -0
- package/dist/mjs/api/resources/KilometricAllowance.js.map +1 -1
- package/dist/mjs/types/Enum/EstimateInvoice.d.ts +4 -0
- package/dist/mjs/types/Enum/EstimateInvoice.d.ts.map +1 -1
- package/dist/mjs/types/Enum/EstimateInvoice.js +26 -0
- package/dist/mjs/types/Enum/EstimateInvoice.js.map +1 -1
- package/dist/mjs/types/Enum/PriceGridClementine.js +1 -1
- package/dist/mjs/types/Enum/PriceGridClementine.js.map +1 -1
- package/dist/mjs/types/Interface/api/bankAccount/Read.d.ts +1 -0
- package/dist/mjs/types/Interface/api/bankAccount/Read.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/bankAccount/Read.js.map +1 -1
- package/dist/mjs/types/Interface/api/commercialManagement/Query.d.ts +6 -0
- package/dist/mjs/types/Interface/api/commercialManagement/Query.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/commercialManagement/Query.js +29 -1
- package/dist/mjs/types/Interface/api/commercialManagement/Query.js.map +1 -1
- package/dist/mjs/types/Interface/api/payment/Util.d.ts +2 -0
- package/dist/mjs/types/Interface/api/payment/Util.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/payment/Util.js.map +1 -1
- package/dist/mjs/types/Interface/models/IPrestation.d.ts +1 -0
- package/dist/mjs/types/Interface/models/IPrestation.d.ts.map +1 -1
- package/dist/mjs/types/Interface/models/IPrestation.js.map +1 -1
- package/dist/mjs/utils/payment.d.ts +2 -0
- package/dist/mjs/utils/payment.d.ts.map +1 -1
- package/dist/mjs/utils/payment.js +83 -34
- package/dist/mjs/utils/payment.js.map +1 -1
- package/dist/mjs/utils/tests/payment.spec.js +37 -1
- package/dist/mjs/utils/tests/payment.spec.js.map +1 -1
- package/package.json +1 -1
- package/ts/api/resources/CommercialDocument.ts +11 -0
- package/ts/api/resources/KilometricAllowance.ts +10 -0
- package/ts/types/Enum/EstimateInvoice.ts +28 -1
- package/ts/types/Enum/PriceGridClementine.ts +1 -1
- package/ts/types/Interface/api/bankAccount/Read.ts +1 -0
- package/ts/types/Interface/api/commercialManagement/Query.ts +21 -1
- package/ts/types/Interface/api/payment/Util.ts +2 -0
- package/ts/types/Interface/models/IPrestation.ts +1 -0
- package/ts/utils/payment.ts +86 -34
- package/ts/utils/tests/payment.spec.ts +37 -1
|
@@ -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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;gBACxC,+BAA+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":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,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, 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.
|
|
3
|
+
"version": "1.1.310",
|
|
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
|
}
|
|
@@ -18,4 +18,14 @@ export class KilometricAllowance extends Resource {
|
|
|
18
18
|
...(signal ? { signal } : {}),
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
exportIntoCSV(idSociety: number, query: QueryKilometricAllowance): Promise<Buffer> {
|
|
23
|
+
return this.axios.$get(`/societies/${idSociety}/kilometric-allowances/exports/csv`, {
|
|
24
|
+
params: query,
|
|
25
|
+
responseType: 'arraybuffer',
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: 'application/csv',
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
21
31
|
}
|
|
@@ -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
|
|
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,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
IsArray, IsBoolean, IsDateString, IsOptional, IsString,
|
|
2
|
+
IsArray, IsBoolean, IsDateString, IsInt, IsOptional, IsString,
|
|
3
3
|
} from 'class-validator';
|
|
4
4
|
import { Order } from '../../..';
|
|
5
5
|
import { ApiProperty, ApiPropertyOptional } from '../../../../utils';
|
|
@@ -150,4 +150,24 @@ export class QueryCountByStatus {
|
|
|
150
150
|
@ToBoolean()
|
|
151
151
|
@IsOptional()
|
|
152
152
|
isDraft?: boolean;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export class QueryExportCommercialManagementIntoCSV {
|
|
156
|
+
@ApiPropertyOptional()
|
|
157
|
+
@IsDateString()
|
|
158
|
+
@IsOptional()
|
|
159
|
+
startDate?: string;
|
|
160
|
+
|
|
161
|
+
@ApiPropertyOptional()
|
|
162
|
+
@IsOptional()
|
|
163
|
+
@IsDateString()
|
|
164
|
+
endDate?: string;
|
|
165
|
+
|
|
166
|
+
@ApiProperty()
|
|
167
|
+
@IsInt()
|
|
168
|
+
idSociety: number;
|
|
169
|
+
|
|
170
|
+
@ApiProperty()
|
|
171
|
+
@IsArray()
|
|
172
|
+
types: EstimateInvoiceType[];
|
|
153
173
|
}
|
|
@@ -11,6 +11,8 @@ export interface ParamsForPaymentsAuto {
|
|
|
11
11
|
firstExerciceNonExpresssEndDate: Date;
|
|
12
12
|
goToClient: Date;
|
|
13
13
|
idPrestation: number;
|
|
14
|
+
idLegalForm: number;
|
|
15
|
+
isWithApplicationFees: boolean;
|
|
14
16
|
idVat: number;
|
|
15
17
|
prestationList: IPrestationList;
|
|
16
18
|
yearlyAmountNonExpress: number;
|
package/ts/utils/payment.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount } from '../types';
|
|
3
|
+
import { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount, LegalFormTypeEnum } from '../types';
|
|
4
4
|
import * as dayjs from 'dayjs';
|
|
5
5
|
import { PartialExercicePrestationExpress } from '../types/Interface/api/payment/Util';
|
|
6
6
|
import { getPriceGrid } from './prestation';
|
|
@@ -78,6 +78,8 @@ const calculateFees = (amount: number, goToClient: Date, paymentDate: Date):numb
|
|
|
78
78
|
// * @param {number} firstPaymentAmount - amount of the first payment (first regulation of the customer)
|
|
79
79
|
* @param {Date} firstExerciceNonExpresssEndDate - end date of the first exercice non express
|
|
80
80
|
* @param {number} idPrestation - prestation id
|
|
81
|
+
* @param {number} idLegalForm - legal form id of the society
|
|
82
|
+
* @param {boolean} isWithApplicationFees - if the prestation has application fees to paid
|
|
81
83
|
* @param {IPrestationList} prestationList - type of prestation (hidden: 0, isCatalog: 1, isComptable: 1)
|
|
82
84
|
* @param {number} idVat - vat id of society linked
|
|
83
85
|
* @param {number} yearlyAmountNonExpress - yearly amount of non express prestation (HT)
|
|
@@ -87,11 +89,10 @@ const calculateFees = (amount: number, goToClient: Date, paymentDate: Date):numb
|
|
|
87
89
|
* @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding
|
|
88
90
|
*/
|
|
89
91
|
const calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {
|
|
90
|
-
const { idTypeBrand, goToClient, firstExerciceNonExpresssEndDate, idPrestation, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;
|
|
92
|
+
const { idTypeBrand, goToClient, isWithApplicationFees, firstExerciceNonExpresssEndDate, idPrestation, idLegalForm, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;
|
|
91
93
|
const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3/* || dayjs().date() >= 15 */
|
|
92
94
|
? dayjs().add(2, 'month').startOf('month').toDate()
|
|
93
95
|
: dayjs().add(1, 'month').startOf('month').toDate();
|
|
94
|
-
let isApplicationAlreadyPaid = false;
|
|
95
96
|
|
|
96
97
|
// On récupère la grille tarifaire pour savoir si les tarifs sont HT ou TTC
|
|
97
98
|
// et pour connaitre le montant du coût de l'app
|
|
@@ -100,6 +101,7 @@ const calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {
|
|
|
100
101
|
if (!priceGrid) throw new Error('Impossible de trouver la grille tarifaire correspondante');
|
|
101
102
|
const { applicationCost, priceWithTaxesIncluded } = priceGrid;
|
|
102
103
|
const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : getTaxesIncludedAmount(applicationCost, idVat)) * 12;
|
|
104
|
+
const applicationFeesAmount = (idLegalForm === LegalFormTypeEnum.SCI) ? 150 : 50;
|
|
103
105
|
|
|
104
106
|
if (prestationList?.isCatalog || !prestationList?.isComptable) throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');
|
|
105
107
|
// if (!listRegulations?.length) throw new Error('List of regulations can not be empty');
|
|
@@ -110,7 +112,21 @@ const calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {
|
|
|
110
112
|
const listPayments:PaymentAuto[] = [];
|
|
111
113
|
|
|
112
114
|
// on récupère le/les premiers réglements effectués, non alloués
|
|
113
|
-
|
|
115
|
+
let isApplicationFeesAlreadyPaid = false;
|
|
116
|
+
const sumRegulations = listRegulations.reduce((acc: number, r:IRegulation) => {
|
|
117
|
+
//Si la regulation est rattachée à un paymentExpectation, on récupère le détail
|
|
118
|
+
// et on ne prend que les frais de dossier (applicationFee) + le montant de la compta (accountingFee)
|
|
119
|
+
if (r.paymentsExpectation?.payload) {
|
|
120
|
+
const payload = JSON.parse(r.paymentsExpectation?.payload);
|
|
121
|
+
if (+payload?.applicationFee > 0) {
|
|
122
|
+
isApplicationFeesAlreadyPaid = true;
|
|
123
|
+
}
|
|
124
|
+
if (+payload?.accountingFee > 0) acc += +payload?.accountingFee;
|
|
125
|
+
return acc;
|
|
126
|
+
} else {
|
|
127
|
+
return acc + r.amount - r.amountUsed;
|
|
128
|
+
}
|
|
129
|
+
}, 0);
|
|
114
130
|
let remainingAmount = -sumRegulations; //TTC
|
|
115
131
|
let paymentDate = initializedPaymentDate;
|
|
116
132
|
|
|
@@ -132,6 +148,19 @@ const calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {
|
|
|
132
148
|
closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
|
|
133
149
|
});
|
|
134
150
|
}
|
|
151
|
+
|
|
152
|
+
// Si les frais de dossiers sont facturés et qu'ils n'ont pas déjà été payés,
|
|
153
|
+
// on ajoute un paiement sur la première mensualité non express
|
|
154
|
+
if (isWithApplicationFees && !isApplicationFeesAlreadyPaid) {
|
|
155
|
+
listPayments.push({
|
|
156
|
+
amount: getTaxesIncludedAmount(applicationFeesAmount, idVat), //TTC
|
|
157
|
+
isPaid: false,
|
|
158
|
+
datePayment: dayjs().startOf('month').add(1, 'month').toDate(),
|
|
159
|
+
idPrestation,
|
|
160
|
+
idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,
|
|
161
|
+
closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
135
164
|
|
|
136
165
|
// =========================
|
|
137
166
|
// EXPRESS
|
|
@@ -176,37 +205,61 @@ const calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {
|
|
|
176
205
|
// sinon, ils sont à la suite des express
|
|
177
206
|
if (nbExoExpress <= 1) paymentDate = initializedPaymentDate;
|
|
178
207
|
let exerciceEndDate = dayjs(firstExerciceNonExpresssEndDate).toDate();
|
|
208
|
+
|
|
209
|
+
let hasGeneratedWholeYear = false;
|
|
210
|
+
let isFirstNonExpress = true;
|
|
179
211
|
|
|
180
|
-
//On génère un
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
remainingAmount += priceWithTaxesIncluded ? exoAmount : getTaxesIncludedAmount(exoAmount, idVat);
|
|
212
|
+
//On génère des paiements jusqu'à ce qu'un exercice soit entier (12 mois), non express
|
|
213
|
+
while (!hasGeneratedWholeYear) {
|
|
214
|
+
|
|
215
|
+
//On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice
|
|
216
|
+
let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));
|
|
217
|
+
if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;
|
|
187
218
|
|
|
188
|
-
|
|
189
|
-
|
|
219
|
+
const exoAmount = isFirstNonExpress ? yearlyAmountNonExpress : nextYearlyAmountNonExpress;
|
|
220
|
+
remainingAmount += priceWithTaxesIncluded ? exoAmount : getTaxesIncludedAmount(exoAmount, idVat);
|
|
221
|
+
|
|
222
|
+
//TODO: CAS A TESTER : si sumRegulations couvre le premier exercice par exemple (cas rar mais à envisager)
|
|
223
|
+
//Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant
|
|
224
|
+
// if (remainingAmount <= 0) {
|
|
225
|
+
// continue;
|
|
226
|
+
// }
|
|
190
227
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
228
|
+
// Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total
|
|
229
|
+
if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {
|
|
230
|
+
remainingAmount -= getTaxesIncludedAmount(applicationFeesAmount, idVat);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
let remainingAmountByExercicePrestation = remainingAmount;
|
|
234
|
+
|
|
235
|
+
// - frais d'application dès les second exo non express
|
|
236
|
+
if (!isFirstNonExpress) remainingAmountByExercicePrestation += applicationCostTotalTTC;
|
|
237
|
+
|
|
238
|
+
const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC
|
|
239
|
+
|
|
240
|
+
if (monthlyAmount > 0) {
|
|
241
|
+
for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {
|
|
242
|
+
let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;
|
|
194
243
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
244
|
+
// Si besoin, on applique les frais nécessaires :
|
|
245
|
+
// - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)
|
|
246
|
+
amount = calculateFees(amount, goToClient, paymentDate);
|
|
198
247
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
248
|
+
listPayments.push({
|
|
249
|
+
amount: Math.round(100 * amount) / 100,
|
|
250
|
+
datePayment: paymentDate,
|
|
251
|
+
idPrestation,
|
|
252
|
+
idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,
|
|
253
|
+
closingDate: exerciceEndDate,
|
|
254
|
+
});
|
|
255
|
+
remainingAmountByExercicePrestation -= monthlyAmount;
|
|
256
|
+
paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();
|
|
257
|
+
}
|
|
258
|
+
exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();
|
|
208
259
|
}
|
|
209
|
-
|
|
260
|
+
remainingAmount = 0;
|
|
261
|
+
if (countMonthsBeforeExerciceEnd === 12) hasGeneratedWholeYear = true;
|
|
262
|
+
isFirstNonExpress = false;
|
|
210
263
|
}
|
|
211
264
|
|
|
212
265
|
remainingAmount = 0;
|
|
@@ -217,20 +270,20 @@ const calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {
|
|
|
217
270
|
// On applique le taux de tva de la société, si besoin, selon la grille tarifaire
|
|
218
271
|
remainingAmount += priceWithTaxesIncluded ? nextYearlyAmountNonExpress : getTaxesIncludedAmount(nextYearlyAmountNonExpress, idVat);
|
|
219
272
|
|
|
220
|
-
remainingAmountByExercicePrestation = remainingAmount;
|
|
273
|
+
let remainingAmountByExercicePrestation = remainingAmount;
|
|
221
274
|
//On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice
|
|
222
|
-
countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));
|
|
275
|
+
let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));
|
|
223
276
|
if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;
|
|
224
277
|
|
|
225
278
|
// - frais d'application dès les second exo non express
|
|
226
279
|
remainingAmountByExercicePrestation += applicationCostTotalTTC;
|
|
227
280
|
|
|
228
|
-
monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;
|
|
281
|
+
const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;
|
|
229
282
|
|
|
230
283
|
// Si aucun paiement généré, on stoppe là
|
|
231
284
|
if (!listPayments.length) return [];
|
|
232
285
|
|
|
233
|
-
while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11
|
|
286
|
+
while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11) {
|
|
234
287
|
let amount = monthlyAmount;
|
|
235
288
|
|
|
236
289
|
// Si besoin, on applique les frais nécessaires :
|
|
@@ -246,7 +299,6 @@ const calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {
|
|
|
246
299
|
closingDate: exerciceEndDate,
|
|
247
300
|
});
|
|
248
301
|
paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();
|
|
249
|
-
isApplicationAlreadyPaid = true;
|
|
250
302
|
}
|
|
251
303
|
|
|
252
304
|
return listPayments;
|