@silexpert/core 1.1.305 → 1.1.307
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/Closing.d.ts +2 -1
- package/dist/cjs/api/resources/Closing.d.ts.map +1 -1
- package/dist/cjs/api/resources/Closing.js +3 -0
- package/dist/cjs/api/resources/Closing.js.map +1 -1
- package/dist/cjs/api/resources/Commercial.d.ts +4 -1
- package/dist/cjs/api/resources/Commercial.d.ts.map +1 -1
- package/dist/cjs/api/resources/Commercial.js +3 -0
- package/dist/cjs/api/resources/Commercial.js.map +1 -1
- package/dist/cjs/api/resources/Exercice.d.ts +2 -2
- package/dist/cjs/api/resources/Exercice.d.ts.map +1 -1
- package/dist/cjs/api/resources/Exercice.js +2 -2
- package/dist/cjs/api/resources/Exercice.js.map +1 -1
- package/dist/cjs/api/resources/IntermediateManagementRebate.d.ts.map +1 -1
- package/dist/cjs/api/resources/IntermediateManagementRebate.js +6 -1
- package/dist/cjs/api/resources/IntermediateManagementRebate.js.map +1 -1
- package/dist/cjs/api/resources/Payment.d.ts +2 -1
- package/dist/cjs/api/resources/Payment.d.ts.map +1 -1
- package/dist/cjs/api/resources/Payment.js +3 -0
- package/dist/cjs/api/resources/Payment.js.map +1 -1
- package/dist/cjs/types/Enum/PriceGridClementine.d.ts +22 -0
- package/dist/cjs/types/Enum/PriceGridClementine.d.ts.map +1 -1
- package/dist/cjs/types/Enum/PriceGridClementine.js +27 -1
- package/dist/cjs/types/Enum/PriceGridClementine.js.map +1 -1
- package/dist/cjs/types/Enum/PriceGridLegalstart.d.ts +8 -0
- package/dist/cjs/types/Enum/PriceGridLegalstart.d.ts.map +1 -1
- package/dist/cjs/types/Enum/PriceGridLegalstart.js +8 -0
- package/dist/cjs/types/Enum/PriceGridLegalstart.js.map +1 -1
- package/dist/cjs/types/Enum/PriceGridPourcentage.d.ts +10 -0
- package/dist/cjs/types/Enum/PriceGridPourcentage.d.ts.map +1 -1
- package/dist/cjs/types/Enum/PriceGridPourcentage.js +84 -0
- package/dist/cjs/types/Enum/PriceGridPourcentage.js.map +1 -1
- package/dist/cjs/types/Enum/StatisticType.d.ts +2 -1
- package/dist/cjs/types/Enum/StatisticType.d.ts.map +1 -1
- package/dist/cjs/types/Enum/StatisticType.js +1 -0
- package/dist/cjs/types/Enum/StatisticType.js.map +1 -1
- package/dist/cjs/types/Interface/api/authentification/ConnectFromSSO.d.ts +4 -0
- package/dist/cjs/types/Interface/api/authentification/ConnectFromSSO.d.ts.map +1 -0
- package/dist/cjs/types/Interface/api/authentification/ConnectFromSSO.js +23 -0
- package/dist/cjs/types/Interface/api/authentification/ConnectFromSSO.js.map +1 -0
- package/dist/cjs/types/Interface/api/commercial/QueryGetStatsHistory.d.ts +7 -0
- package/dist/cjs/types/Interface/api/commercial/QueryGetStatsHistory.d.ts.map +1 -0
- package/dist/cjs/types/Interface/api/commercial/QueryGetStatsHistory.js +42 -0
- package/dist/cjs/types/Interface/api/commercial/QueryGetStatsHistory.js.map +1 -0
- package/dist/cjs/types/Interface/api/exercice/QueryExercice.d.ts +3 -0
- package/dist/cjs/types/Interface/api/exercice/QueryExercice.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/exercice/QueryExercice.js +11 -1
- package/dist/cjs/types/Interface/api/exercice/QueryExercice.js.map +1 -1
- package/dist/cjs/types/Interface/api/exercice/UpdateExercice.d.ts +1 -0
- package/dist/cjs/types/Interface/api/exercice/UpdateExercice.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/exercice/UpdateExercice.js +7 -0
- package/dist/cjs/types/Interface/api/exercice/UpdateExercice.js.map +1 -1
- package/dist/cjs/types/Interface/api/payment/Params.d.ts +4 -0
- package/dist/cjs/types/Interface/api/payment/Params.d.ts.map +1 -0
- package/dist/cjs/types/Interface/api/payment/Params.js +24 -0
- package/dist/cjs/types/Interface/api/payment/Params.js.map +1 -0
- package/dist/cjs/types/Interface/api/payment/Util.d.ts +27 -0
- package/dist/cjs/types/Interface/api/payment/Util.d.ts.map +1 -0
- package/dist/cjs/types/Interface/api/payment/Util.js +3 -0
- package/dist/cjs/types/Interface/api/payment/Util.js.map +1 -0
- package/dist/cjs/types/Interface/api/society/QueryPaginatedSociety.d.ts +1 -0
- package/dist/cjs/types/Interface/api/society/QueryPaginatedSociety.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/society/QueryPaginatedSociety.js +8 -0
- package/dist/cjs/types/Interface/api/society/QueryPaginatedSociety.js.map +1 -1
- package/dist/cjs/types/Interface/api/statistic/QueryInternal.d.ts +1 -1
- package/dist/cjs/types/Interface/api/statistic/QueryInternal.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/statistic/QueryInternal.js +5 -5
- package/dist/cjs/types/Interface/api/statistic/QueryInternal.js.map +1 -1
- package/dist/cjs/types/Interface/api/user/ParamsGetAllUserWithRoles.js +1 -1
- package/dist/cjs/types/Interface/api/user/ParamsGetAllUserWithRoles.js.map +1 -1
- package/dist/cjs/types/Interface/models/IExercicePrestation.d.ts +1 -0
- package/dist/cjs/types/Interface/models/IExercicePrestation.d.ts.map +1 -1
- package/dist/cjs/types/Interface/models/IExercicePrestation.js.map +1 -1
- package/dist/cjs/types/Interface/models/ISociety.d.ts +2 -1
- package/dist/cjs/types/Interface/models/ISociety.d.ts.map +1 -1
- package/dist/cjs/types/Interface/models/ISociety.js.map +1 -1
- package/dist/cjs/types/index.d.ts +4 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +4 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/payment.d.ts +15 -2
- package/dist/cjs/utils/payment.d.ts.map +1 -1
- package/dist/cjs/utils/payment.js +180 -2
- package/dist/cjs/utils/payment.js.map +1 -1
- package/dist/cjs/utils/prestation.d.ts +60 -0
- package/dist/cjs/utils/prestation.d.ts.map +1 -1
- package/dist/cjs/utils/prestation.js +4 -3
- package/dist/cjs/utils/prestation.js.map +1 -1
- package/dist/cjs/utils/tests/payment.spec.d.ts +2 -0
- package/dist/cjs/utils/tests/payment.spec.d.ts.map +1 -0
- package/dist/cjs/utils/tests/payment.spec.js +494 -0
- package/dist/cjs/utils/tests/payment.spec.js.map +1 -0
- package/dist/cjs/utils/vat/utils.d.ts +2 -0
- package/dist/cjs/utils/vat/utils.d.ts.map +1 -1
- package/dist/cjs/utils/vat/utils.js +19 -1
- package/dist/cjs/utils/vat/utils.js.map +1 -1
- package/dist/mjs/api/resources/Closing.d.ts +2 -1
- package/dist/mjs/api/resources/Closing.d.ts.map +1 -1
- package/dist/mjs/api/resources/Closing.js +3 -0
- package/dist/mjs/api/resources/Closing.js.map +1 -1
- package/dist/mjs/api/resources/Commercial.d.ts +4 -1
- package/dist/mjs/api/resources/Commercial.d.ts.map +1 -1
- package/dist/mjs/api/resources/Commercial.js +7 -0
- package/dist/mjs/api/resources/Commercial.js.map +1 -1
- package/dist/mjs/api/resources/Exercice.d.ts +2 -2
- package/dist/mjs/api/resources/Exercice.d.ts.map +1 -1
- package/dist/mjs/api/resources/Exercice.js +2 -2
- package/dist/mjs/api/resources/Exercice.js.map +1 -1
- package/dist/mjs/api/resources/IntermediateManagementRebate.d.ts.map +1 -1
- package/dist/mjs/api/resources/IntermediateManagementRebate.js +6 -1
- package/dist/mjs/api/resources/IntermediateManagementRebate.js.map +1 -1
- package/dist/mjs/api/resources/Payment.d.ts +2 -1
- package/dist/mjs/api/resources/Payment.d.ts.map +1 -1
- package/dist/mjs/api/resources/Payment.js +3 -0
- package/dist/mjs/api/resources/Payment.js.map +1 -1
- package/dist/mjs/types/Enum/PriceGridClementine.d.ts +22 -0
- package/dist/mjs/types/Enum/PriceGridClementine.d.ts.map +1 -1
- package/dist/mjs/types/Enum/PriceGridClementine.js +27 -1
- package/dist/mjs/types/Enum/PriceGridClementine.js.map +1 -1
- package/dist/mjs/types/Enum/PriceGridLegalstart.d.ts +8 -0
- package/dist/mjs/types/Enum/PriceGridLegalstart.d.ts.map +1 -1
- package/dist/mjs/types/Enum/PriceGridLegalstart.js +8 -0
- package/dist/mjs/types/Enum/PriceGridLegalstart.js.map +1 -1
- package/dist/mjs/types/Enum/PriceGridPourcentage.d.ts +10 -0
- package/dist/mjs/types/Enum/PriceGridPourcentage.d.ts.map +1 -1
- package/dist/mjs/types/Enum/PriceGridPourcentage.js +84 -0
- package/dist/mjs/types/Enum/PriceGridPourcentage.js.map +1 -1
- package/dist/mjs/types/Enum/StatisticType.d.ts +2 -1
- package/dist/mjs/types/Enum/StatisticType.d.ts.map +1 -1
- package/dist/mjs/types/Enum/StatisticType.js +1 -0
- package/dist/mjs/types/Enum/StatisticType.js.map +1 -1
- package/dist/mjs/types/Interface/api/authentification/ConnectFromSSO.d.ts +4 -0
- package/dist/mjs/types/Interface/api/authentification/ConnectFromSSO.d.ts.map +1 -0
- package/dist/mjs/types/Interface/api/authentification/ConnectFromSSO.js +20 -0
- package/dist/mjs/types/Interface/api/authentification/ConnectFromSSO.js.map +1 -0
- package/dist/mjs/types/Interface/api/commercial/QueryGetStatsHistory.d.ts +7 -0
- package/dist/mjs/types/Interface/api/commercial/QueryGetStatsHistory.d.ts.map +1 -0
- package/dist/mjs/types/Interface/api/commercial/QueryGetStatsHistory.js +42 -0
- package/dist/mjs/types/Interface/api/commercial/QueryGetStatsHistory.js.map +1 -0
- package/dist/mjs/types/Interface/api/exercice/QueryExercice.d.ts +3 -0
- package/dist/mjs/types/Interface/api/exercice/QueryExercice.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/exercice/QueryExercice.js +10 -0
- package/dist/mjs/types/Interface/api/exercice/QueryExercice.js.map +1 -1
- package/dist/mjs/types/Interface/api/exercice/UpdateExercice.d.ts +1 -0
- package/dist/mjs/types/Interface/api/exercice/UpdateExercice.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/exercice/UpdateExercice.js +8 -0
- package/dist/mjs/types/Interface/api/exercice/UpdateExercice.js.map +1 -1
- package/dist/mjs/types/Interface/api/payment/Params.d.ts +4 -0
- package/dist/mjs/types/Interface/api/payment/Params.d.ts.map +1 -0
- package/dist/mjs/types/Interface/api/payment/Params.js +21 -0
- package/dist/mjs/types/Interface/api/payment/Params.js.map +1 -0
- package/dist/mjs/types/Interface/api/payment/Util.d.ts +27 -0
- package/dist/mjs/types/Interface/api/payment/Util.d.ts.map +1 -0
- package/dist/mjs/types/Interface/api/payment/Util.js +2 -0
- package/dist/mjs/types/Interface/api/payment/Util.js.map +1 -0
- package/dist/mjs/types/Interface/api/society/QueryPaginatedSociety.d.ts +1 -0
- package/dist/mjs/types/Interface/api/society/QueryPaginatedSociety.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/society/QueryPaginatedSociety.js +8 -0
- package/dist/mjs/types/Interface/api/society/QueryPaginatedSociety.js.map +1 -1
- package/dist/mjs/types/Interface/api/statistic/QueryInternal.d.ts +1 -1
- package/dist/mjs/types/Interface/api/statistic/QueryInternal.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/statistic/QueryInternal.js +3 -3
- package/dist/mjs/types/Interface/api/statistic/QueryInternal.js.map +1 -1
- package/dist/mjs/types/Interface/api/user/ParamsGetAllUserWithRoles.js +1 -1
- package/dist/mjs/types/Interface/api/user/ParamsGetAllUserWithRoles.js.map +1 -1
- package/dist/mjs/types/Interface/models/IExercicePrestation.d.ts +1 -0
- package/dist/mjs/types/Interface/models/IExercicePrestation.d.ts.map +1 -1
- package/dist/mjs/types/Interface/models/IExercicePrestation.js.map +1 -1
- package/dist/mjs/types/Interface/models/ISociety.d.ts +2 -1
- package/dist/mjs/types/Interface/models/ISociety.d.ts.map +1 -1
- package/dist/mjs/types/Interface/models/ISociety.js.map +1 -1
- package/dist/mjs/types/index.d.ts +4 -0
- package/dist/mjs/types/index.d.ts.map +1 -1
- package/dist/mjs/types/index.js +4 -0
- package/dist/mjs/types/index.js.map +1 -1
- package/dist/mjs/utils/payment.d.ts +15 -2
- package/dist/mjs/utils/payment.d.ts.map +1 -1
- package/dist/mjs/utils/payment.js +178 -1
- package/dist/mjs/utils/payment.js.map +1 -1
- package/dist/mjs/utils/prestation.d.ts +60 -0
- package/dist/mjs/utils/prestation.d.ts.map +1 -1
- package/dist/mjs/utils/prestation.js +1 -1
- package/dist/mjs/utils/prestation.js.map +1 -1
- package/dist/mjs/utils/tests/payment.spec.d.ts +2 -0
- package/dist/mjs/utils/tests/payment.spec.d.ts.map +1 -0
- package/dist/mjs/utils/tests/payment.spec.js +485 -0
- package/dist/mjs/utils/tests/payment.spec.js.map +1 -0
- package/dist/mjs/utils/vat/utils.d.ts +2 -0
- package/dist/mjs/utils/vat/utils.d.ts.map +1 -1
- package/dist/mjs/utils/vat/utils.js +14 -0
- package/dist/mjs/utils/vat/utils.js.map +1 -1
- package/package.json +1 -1
- package/ts/api/resources/Closing.ts +6 -1
- package/ts/api/resources/Commercial.ts +8 -0
- package/ts/api/resources/Exercice.ts +3 -3
- package/ts/api/resources/IntermediateManagementRebate.ts +6 -1
- package/ts/api/resources/Payment.ts +5 -1
- package/ts/types/Enum/PriceGridClementine.ts +27 -1
- package/ts/types/Enum/PriceGridLegalstart.ts +8 -0
- package/ts/types/Enum/PriceGridPourcentage.ts +84 -0
- package/ts/types/Enum/StatisticType.ts +1 -0
- package/ts/types/Interface/api/authentification/ConnectFromSSO.ts +8 -0
- package/ts/types/Interface/api/commercial/QueryGetStatsHistory.ts +26 -0
- package/ts/types/Interface/api/exercice/QueryExercice.ts +8 -0
- package/ts/types/Interface/api/exercice/UpdateExercice.ts +6 -0
- package/ts/types/Interface/api/payment/Params.ts +9 -0
- package/ts/types/Interface/api/payment/Util.ts +28 -0
- package/ts/types/Interface/api/society/QueryPaginatedSociety.ts +6 -0
- package/ts/types/Interface/api/statistic/QueryInternal.ts +1 -1
- package/ts/types/Interface/api/user/ParamsGetAllUserWithRoles.ts +1 -1
- package/ts/types/Interface/models/IExercicePrestation.ts +1 -0
- package/ts/types/Interface/models/ISociety.ts +2 -0
- package/ts/types/index.ts +4 -0
- package/ts/utils/payment.ts +200 -2
- package/ts/utils/prestation.ts +3 -1
- package/ts/utils/tests/payment.spec.ts +502 -0
- package/ts/utils/vat/utils.ts +16 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const dayjs = require("dayjs");
|
|
13
|
+
const types_1 = require("../../types");
|
|
14
|
+
const mockdate_1 = require("mockdate");
|
|
15
|
+
const payment_1 = require("../payment");
|
|
16
|
+
describe('Payment', () => {
|
|
17
|
+
describe('calculatePayments', () => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const idPrestation = 1;
|
|
20
|
+
const idSociety = 1;
|
|
21
|
+
const yearlyAmountNonExpress = 1800;
|
|
22
|
+
const nextYearlyAmountNonExpress = 1800;
|
|
23
|
+
const appCost = 14.9;
|
|
24
|
+
const firstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate();
|
|
25
|
+
const prestationList = {
|
|
26
|
+
id: 34,
|
|
27
|
+
name: 'Compta Pro',
|
|
28
|
+
isComptable: true,
|
|
29
|
+
isJuridique: false,
|
|
30
|
+
isSocial: false,
|
|
31
|
+
isAttestation: false,
|
|
32
|
+
inAverageCart: true,
|
|
33
|
+
isBack: false,
|
|
34
|
+
minimumPrice: null,
|
|
35
|
+
price: null,
|
|
36
|
+
isCatalog: false,
|
|
37
|
+
isPlannable: false,
|
|
38
|
+
hidden: false,
|
|
39
|
+
isComplementary: false,
|
|
40
|
+
signaturePosition: '400,54,569,90',
|
|
41
|
+
signaturePage: 7,
|
|
42
|
+
};
|
|
43
|
+
const idVat = types_1.Vat.TX_10.id;
|
|
44
|
+
const vatRate = (_b = (_a = Object.values(types_1.Vat).find(v => v.id === idVat)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 20;
|
|
45
|
+
const listPartialExercicePrestationExpress = [
|
|
46
|
+
{
|
|
47
|
+
startDate: dayjs().subtract(2, 'year').startOf('month').toDate(),
|
|
48
|
+
endDate: dayjs().subtract(13, 'month').endOf('month').toDate(),
|
|
49
|
+
countExpressMonthlyPayment: 2,
|
|
50
|
+
totalAmount: 1200,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
startDate: dayjs().subtract(1, 'year').startOf('month').toDate(),
|
|
54
|
+
endDate: dayjs().subtract(1, 'month').endOf('month').toDate(),
|
|
55
|
+
countExpressMonthlyPayment: 2,
|
|
56
|
+
totalAmount: 1800,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
const listRegulations = [{
|
|
60
|
+
amount: 600,
|
|
61
|
+
amountUsed: 0,
|
|
62
|
+
date: new Date(),
|
|
63
|
+
processed: true,
|
|
64
|
+
idPaymentMethod: types_1.PaymentMethod.BANK_CARD.id,
|
|
65
|
+
idSociety,
|
|
66
|
+
}, {
|
|
67
|
+
amount: 300,
|
|
68
|
+
amountUsed: 0,
|
|
69
|
+
date: new Date(),
|
|
70
|
+
processed: true,
|
|
71
|
+
idPaymentMethod: types_1.PaymentMethod.BANK_CARD.id,
|
|
72
|
+
idSociety,
|
|
73
|
+
}, {
|
|
74
|
+
amount: 300,
|
|
75
|
+
amountUsed: 300,
|
|
76
|
+
date: new Date(),
|
|
77
|
+
processed: true,
|
|
78
|
+
idPaymentMethod: types_1.PaymentMethod.BANK_CARD.id,
|
|
79
|
+
idSociety,
|
|
80
|
+
}];
|
|
81
|
+
// =====================
|
|
82
|
+
// errors handling
|
|
83
|
+
// =====================
|
|
84
|
+
test('should return error if prestationList doesn\'t correspond (!hidden, isCatalog, isComptable)', () => {
|
|
85
|
+
expect.assertions(2);
|
|
86
|
+
try {
|
|
87
|
+
prestationList.hidden = true;
|
|
88
|
+
(0, payment_1.calculatePaymentsAuto)({
|
|
89
|
+
idTypeBrand: 1,
|
|
90
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
91
|
+
firstExerciceNonExpresssEndDate,
|
|
92
|
+
idPrestation,
|
|
93
|
+
prestationList: Object.assign(Object.assign({}, prestationList), { isCatalog: true }),
|
|
94
|
+
idVat,
|
|
95
|
+
listPartialExercicePrestationExpress,
|
|
96
|
+
listRegulations,
|
|
97
|
+
yearlyAmountNonExpress,
|
|
98
|
+
nextYearlyAmountNonExpress
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
expect(error).toBeInstanceOf(Error);
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
expect(error.message).toStrictEqual('Ce type de prestation ne correspond pas aux conditions attendues.');
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
test('should return error if listRegulations is empty', () => {
|
|
108
|
+
expect.assertions(2);
|
|
109
|
+
try {
|
|
110
|
+
(0, payment_1.calculatePaymentsAuto)({
|
|
111
|
+
idTypeBrand: 1,
|
|
112
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
113
|
+
firstExerciceNonExpresssEndDate,
|
|
114
|
+
idPrestation,
|
|
115
|
+
prestationList,
|
|
116
|
+
idVat,
|
|
117
|
+
listPartialExercicePrestationExpress,
|
|
118
|
+
listRegulations: [],
|
|
119
|
+
yearlyAmountNonExpress,
|
|
120
|
+
nextYearlyAmountNonExpress
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
expect(error).toBeInstanceOf(Error);
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
expect(error.message).toStrictEqual('List of regulations can not be empty');
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
test('should listRegulations contain amount and amountUsed', () => {
|
|
130
|
+
expect.assertions(2);
|
|
131
|
+
try {
|
|
132
|
+
(0, payment_1.calculatePaymentsAuto)({
|
|
133
|
+
idTypeBrand: 1,
|
|
134
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
135
|
+
firstExerciceNonExpresssEndDate,
|
|
136
|
+
idPrestation,
|
|
137
|
+
prestationList,
|
|
138
|
+
idVat,
|
|
139
|
+
listPartialExercicePrestationExpress,
|
|
140
|
+
listRegulations: [{ processed: true }],
|
|
141
|
+
yearlyAmountNonExpress,
|
|
142
|
+
nextYearlyAmountNonExpress
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
expect(error).toBeInstanceOf(Error);
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
expect(error.message).toStrictEqual('Amount and amountUsed are missing for regulations');
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
// =====================
|
|
152
|
+
// logical
|
|
153
|
+
// =====================
|
|
154
|
+
// express
|
|
155
|
+
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)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
157
|
+
idTypeBrand: 1,
|
|
158
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
159
|
+
firstExerciceNonExpresssEndDate,
|
|
160
|
+
idPrestation,
|
|
161
|
+
prestationList,
|
|
162
|
+
idVat,
|
|
163
|
+
listPartialExercicePrestationExpress: [listPartialExercicePrestationExpress[0]],
|
|
164
|
+
listRegulations,
|
|
165
|
+
yearlyAmountNonExpress,
|
|
166
|
+
nextYearlyAmountNonExpress
|
|
167
|
+
});
|
|
168
|
+
const firstExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0)[0].datePayment;
|
|
169
|
+
const firstNonExpressDatePayment = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)[0].datePayment;
|
|
170
|
+
expect(dayjs(firstNonExpressDatePayment).diff(firstExpressDatePayment, 'month')).toStrictEqual(0);
|
|
171
|
+
}));
|
|
172
|
+
test('if more than one express, monthly payments of actual exo should be in a row of express monthly payments and smoothed, smoothed in number of remaining months after express monthly payments (mini 3 months) (if in 3 last month of exercice)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
+
var _c, _d, _e, _f;
|
|
174
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
175
|
+
idTypeBrand: 1,
|
|
176
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
177
|
+
firstExerciceNonExpresssEndDate,
|
|
178
|
+
idPrestation,
|
|
179
|
+
prestationList,
|
|
180
|
+
idVat,
|
|
181
|
+
listPartialExercicePrestationExpress,
|
|
182
|
+
listRegulations,
|
|
183
|
+
yearlyAmountNonExpress,
|
|
184
|
+
nextYearlyAmountNonExpress
|
|
185
|
+
});
|
|
186
|
+
const lastExpressDatePayment = (_d = (_c = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) < 0).splice(-1)) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.datePayment;
|
|
187
|
+
const firstNonExpressDatePayment = (_f = (_e = payments.filter(p => dayjs(p.closingDate).diff(firstExerciceNonExpresssEndDate) === 0)) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.datePayment;
|
|
188
|
+
expect(dayjs(firstNonExpressDatePayment).diff(lastExpressDatePayment, 'month')).toStrictEqual(1);
|
|
189
|
+
}));
|
|
190
|
+
// non express
|
|
191
|
+
test('should return a number of payments equal to nb of remaining months in exercice (if not in 3 last months)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
|
+
const mockedDate = dayjs('2024-05-15').toDate();
|
|
193
|
+
mockdate_1.default.set(mockedDate);
|
|
194
|
+
const nbMonthDelay = 6;
|
|
195
|
+
const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();
|
|
196
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
197
|
+
idTypeBrand: 1,
|
|
198
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
199
|
+
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
200
|
+
idPrestation,
|
|
201
|
+
prestationList,
|
|
202
|
+
idVat,
|
|
203
|
+
listPartialExercicePrestationExpress: [],
|
|
204
|
+
listRegulations: [{
|
|
205
|
+
amount: 50,
|
|
206
|
+
amountUsed: 0,
|
|
207
|
+
}],
|
|
208
|
+
yearlyAmountNonExpress,
|
|
209
|
+
nextYearlyAmountNonExpress
|
|
210
|
+
});
|
|
211
|
+
// const listNonExpressPayments = payments.filter(p => p.closingDate === newFirstExerciceNonExpresssEndDate);
|
|
212
|
+
const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
|
|
213
|
+
expect(listNonExpressPayments.length).toStrictEqual(nbMonthDelay);
|
|
214
|
+
mockdate_1.default.reset();
|
|
215
|
+
}));
|
|
216
|
+
test('should return a number of payments equal to 3 (if in 3 last month of exercice)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
217
|
+
const nbMonthDelay = 1;
|
|
218
|
+
const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();
|
|
219
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
220
|
+
idTypeBrand: 1,
|
|
221
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
222
|
+
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
223
|
+
idPrestation,
|
|
224
|
+
prestationList,
|
|
225
|
+
idVat,
|
|
226
|
+
listPartialExercicePrestationExpress: [],
|
|
227
|
+
listRegulations: [{
|
|
228
|
+
amount: 50,
|
|
229
|
+
amountUsed: 0,
|
|
230
|
+
}],
|
|
231
|
+
yearlyAmountNonExpress,
|
|
232
|
+
nextYearlyAmountNonExpress
|
|
233
|
+
});
|
|
234
|
+
const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
|
|
235
|
+
expect(listNonExpressPayments.length).toStrictEqual(3);
|
|
236
|
+
}));
|
|
237
|
+
test('should (yearlyAmountNonExpress - sum of listRegulations) / count of monthly payments be equal to monthly payment amount (if not in 3 last month)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
238
|
+
const mockedDate = dayjs('2024-05-15').toDate();
|
|
239
|
+
mockdate_1.default.set(mockedDate);
|
|
240
|
+
const nbMonthDelay = 6;
|
|
241
|
+
const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();
|
|
242
|
+
const newListRegulations = [{
|
|
243
|
+
amount: 50,
|
|
244
|
+
amountUsed: 0,
|
|
245
|
+
}];
|
|
246
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
247
|
+
idTypeBrand: 1,
|
|
248
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
249
|
+
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
250
|
+
idPrestation,
|
|
251
|
+
prestationList,
|
|
252
|
+
idVat,
|
|
253
|
+
listPartialExercicePrestationExpress: [],
|
|
254
|
+
listRegulations: newListRegulations,
|
|
255
|
+
yearlyAmountNonExpress,
|
|
256
|
+
nextYearlyAmountNonExpress
|
|
257
|
+
});
|
|
258
|
+
const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r) => acc + r.amount - r.amountUsed, 0);
|
|
259
|
+
const amount = Math.round(100 * diff / nbMonthDelay) / 100;
|
|
260
|
+
expect(payments[0].amount).toStrictEqual(Math.round(100 * amount * ((100 + vatRate) / 100)) / 100);
|
|
261
|
+
mockdate_1.default.reset();
|
|
262
|
+
}));
|
|
263
|
+
test('should (totalAmount - firstPaymentAmount) / 3 be equal to monthly payment amount (if in 3 last month of exercice)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
264
|
+
const nbMonthDelay = 1;
|
|
265
|
+
const newFirstExerciceNonExpresssEndDate = dayjs().add(nbMonthDelay, 'month').endOf('month').toDate();
|
|
266
|
+
const newListRegulations = [{
|
|
267
|
+
amount: 50,
|
|
268
|
+
amountUsed: 0,
|
|
269
|
+
}];
|
|
270
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
271
|
+
idTypeBrand: 1,
|
|
272
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
273
|
+
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
274
|
+
idPrestation,
|
|
275
|
+
prestationList,
|
|
276
|
+
idVat,
|
|
277
|
+
listPartialExercicePrestationExpress: [],
|
|
278
|
+
listRegulations: newListRegulations,
|
|
279
|
+
yearlyAmountNonExpress,
|
|
280
|
+
nextYearlyAmountNonExpress
|
|
281
|
+
});
|
|
282
|
+
const diff = yearlyAmountNonExpress - newListRegulations.reduce((acc, r) => acc + r.amount - r.amountUsed, 0);
|
|
283
|
+
const amount = Math.round(100 * diff / 3) / 100;
|
|
284
|
+
expect(payments[0].amount).toStrictEqual(Math.round(100 * amount * ((100 + vatRate) / 100)) / 100);
|
|
285
|
+
}));
|
|
286
|
+
// annual price increase
|
|
287
|
+
test('should apply annual price increase (2,75%) if signed before last 3 months of civil year', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
288
|
+
const mockedDate = dayjs('2024-08-15').toDate();
|
|
289
|
+
mockdate_1.default.set(mockedDate);
|
|
290
|
+
const newFirstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate();
|
|
291
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
292
|
+
idTypeBrand: 1,
|
|
293
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
294
|
+
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
295
|
+
idPrestation,
|
|
296
|
+
prestationList,
|
|
297
|
+
idVat,
|
|
298
|
+
listPartialExercicePrestationExpress: [],
|
|
299
|
+
listRegulations: [{
|
|
300
|
+
amount: 50,
|
|
301
|
+
amountUsed: 0,
|
|
302
|
+
}],
|
|
303
|
+
yearlyAmountNonExpress,
|
|
304
|
+
nextYearlyAmountNonExpress
|
|
305
|
+
});
|
|
306
|
+
const listNonExpressPayments = payments.filter(p => dayjs(p.closingDate).diff(newFirstExerciceNonExpresssEndDate) === 0);
|
|
307
|
+
expect(Math.round(100 * listNonExpressPayments[0].amount * 1.0275) / 100).toStrictEqual(listNonExpressPayments.splice(-2)[0].amount);
|
|
308
|
+
mockdate_1.default.reset();
|
|
309
|
+
}));
|
|
310
|
+
test('should not apply annual price increase (2,75%) if signed in last 3 months of civil year', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
311
|
+
const mockedDate = dayjs('2024-11-15').toDate();
|
|
312
|
+
mockdate_1.default.set(mockedDate);
|
|
313
|
+
const newFirstExerciceNonExpresssEndDate = dayjs().add(11, 'month').endOf('month').toDate();
|
|
314
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
315
|
+
idTypeBrand: 1,
|
|
316
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
317
|
+
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
318
|
+
idPrestation,
|
|
319
|
+
prestationList,
|
|
320
|
+
idVat,
|
|
321
|
+
listPartialExercicePrestationExpress: [],
|
|
322
|
+
listRegulations: [{
|
|
323
|
+
amount: 50,
|
|
324
|
+
amountUsed: 0,
|
|
325
|
+
}],
|
|
326
|
+
yearlyAmountNonExpress,
|
|
327
|
+
nextYearlyAmountNonExpress
|
|
328
|
+
});
|
|
329
|
+
const listNonExpressPayments = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0);
|
|
330
|
+
expect(listNonExpressPayments[0].amount).toStrictEqual(listNonExpressPayments.splice(-2)[0].amount);
|
|
331
|
+
mockdate_1.default.reset();
|
|
332
|
+
}));
|
|
333
|
+
test('should apply 14,9€ HT increase for the second exercice created (only offered on first exo) (no rules for 3 last months)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
334
|
+
var _g, _h;
|
|
335
|
+
const mockedDate = dayjs('2024-06-15').toDate();
|
|
336
|
+
mockdate_1.default.set(mockedDate);
|
|
337
|
+
const newFirstExerciceNonExpresssEndDate = dayjs().add(12, 'month').endOf('month').toDate();
|
|
338
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
339
|
+
idTypeBrand: 1,
|
|
340
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
341
|
+
firstExerciceNonExpresssEndDate: newFirstExerciceNonExpresssEndDate,
|
|
342
|
+
idPrestation,
|
|
343
|
+
prestationList,
|
|
344
|
+
idVat,
|
|
345
|
+
listPartialExercicePrestationExpress: [],
|
|
346
|
+
listRegulations: [{
|
|
347
|
+
amount: 50,
|
|
348
|
+
amountUsed: 50,
|
|
349
|
+
}],
|
|
350
|
+
yearlyAmountNonExpress,
|
|
351
|
+
nextYearlyAmountNonExpress
|
|
352
|
+
});
|
|
353
|
+
const paymentsOfFirstExo = (_g = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-06-01')) === 0).splice(-1)[0].amount) !== null && _g !== void 0 ? _g : 0;
|
|
354
|
+
const paymentsOfSecondExo = (_h = payments.filter(p => dayjs(p.datePayment).diff(dayjs('2025-07-01')) === 0).splice(-1)[0].amount) !== null && _h !== void 0 ? _h : 0;
|
|
355
|
+
expect(paymentsOfFirstExo + appCost * ((100 + vatRate) / 100)).toStrictEqual(paymentsOfSecondExo);
|
|
356
|
+
mockdate_1.default.reset();
|
|
357
|
+
}));
|
|
358
|
+
// misc
|
|
359
|
+
test('should payments been generated sorted by exercices start date', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
360
|
+
var _j;
|
|
361
|
+
const listPartialExercicePrestationExpressCloned = [...listPartialExercicePrestationExpress];
|
|
362
|
+
listPartialExercicePrestationExpressCloned[0] = Object.assign(Object.assign({}, listPartialExercicePrestationExpress[0]), { startDate: dayjs().add(1, 'year').startOf('month').toDate() });
|
|
363
|
+
listPartialExercicePrestationExpressCloned[1] = Object.assign(Object.assign({}, listPartialExercicePrestationExpress[1]), { startDate: dayjs().startOf('month').toDate() });
|
|
364
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
365
|
+
idTypeBrand: 1,
|
|
366
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
367
|
+
firstExerciceNonExpresssEndDate,
|
|
368
|
+
idPrestation,
|
|
369
|
+
prestationList,
|
|
370
|
+
idVat,
|
|
371
|
+
listPartialExercicePrestationExpress: listPartialExercicePrestationExpressCloned,
|
|
372
|
+
listRegulations,
|
|
373
|
+
yearlyAmountNonExpress,
|
|
374
|
+
nextYearlyAmountNonExpress
|
|
375
|
+
});
|
|
376
|
+
expect(payments.length).toBeGreaterThanOrEqual(4);
|
|
377
|
+
expect(dayjs(payments[payments.length - 1].datePayment).diff(dayjs((_j = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _j === void 0 ? void 0 : _j.datePayment), 'month')).toBeGreaterThan(0);
|
|
378
|
+
}));
|
|
379
|
+
test('if regulations are bigger than sum exercice prestation amounts, should pass some exercice payments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
380
|
+
const mockedDate = dayjs('2024-03-15').toDate();
|
|
381
|
+
mockdate_1.default.set(mockedDate);
|
|
382
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
383
|
+
idTypeBrand: 1,
|
|
384
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
385
|
+
firstExerciceNonExpresssEndDate,
|
|
386
|
+
idPrestation,
|
|
387
|
+
prestationList,
|
|
388
|
+
idVat,
|
|
389
|
+
listPartialExercicePrestationExpress,
|
|
390
|
+
listRegulations: [{
|
|
391
|
+
amount: 2000,
|
|
392
|
+
amountUsed: 0,
|
|
393
|
+
date: new Date(),
|
|
394
|
+
processed: true,
|
|
395
|
+
idPaymentMethod: types_1.PaymentMethod.BANK_CARD.id,
|
|
396
|
+
idSociety,
|
|
397
|
+
}],
|
|
398
|
+
yearlyAmountNonExpress,
|
|
399
|
+
nextYearlyAmountNonExpress
|
|
400
|
+
});
|
|
401
|
+
expect(payments.length).toBeGreaterThanOrEqual(2);
|
|
402
|
+
expect(payments[0]).toMatchObject({
|
|
403
|
+
amount: 550,
|
|
404
|
+
datePayment: dayjs(mockedDate).add(1, 'month').startOf('month').toDate(),
|
|
405
|
+
idPrestation: 1,
|
|
406
|
+
idPaymentMethod: 1,
|
|
407
|
+
});
|
|
408
|
+
expect(payments[1]).toMatchObject({
|
|
409
|
+
amount: 550,
|
|
410
|
+
datePayment: dayjs(mockedDate).add(2, 'month').startOf('month').toDate(),
|
|
411
|
+
idPrestation: 1,
|
|
412
|
+
idPaymentMethod: 1,
|
|
413
|
+
});
|
|
414
|
+
mockdate_1.default.reset();
|
|
415
|
+
}));
|
|
416
|
+
test('should not consider actual month if signed in last 3 days of month', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
417
|
+
var _k;
|
|
418
|
+
const mockedDate = dayjs('2024-03-29').toDate();
|
|
419
|
+
mockdate_1.default.set(mockedDate);
|
|
420
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
421
|
+
idTypeBrand: 1,
|
|
422
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
423
|
+
firstExerciceNonExpresssEndDate,
|
|
424
|
+
idPrestation,
|
|
425
|
+
prestationList,
|
|
426
|
+
idVat,
|
|
427
|
+
listPartialExercicePrestationExpress,
|
|
428
|
+
listRegulations,
|
|
429
|
+
yearlyAmountNonExpress,
|
|
430
|
+
nextYearlyAmountNonExpress
|
|
431
|
+
});
|
|
432
|
+
expect(payments.length).toBeGreaterThanOrEqual(4);
|
|
433
|
+
expect((_k = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _k === void 0 ? void 0 : _k.datePayment).toStrictEqual(dayjs(mockedDate).add(2, 'month').startOf('month').toDate());
|
|
434
|
+
mockdate_1.default.reset();
|
|
435
|
+
}));
|
|
436
|
+
test('last payment returned should be last of a year (12/XX)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
437
|
+
const mockedDate = dayjs('2024-03-29').toDate();
|
|
438
|
+
mockdate_1.default.set(mockedDate);
|
|
439
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
440
|
+
idTypeBrand: 1,
|
|
441
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
442
|
+
firstExerciceNonExpresssEndDate,
|
|
443
|
+
idPrestation,
|
|
444
|
+
prestationList,
|
|
445
|
+
idVat,
|
|
446
|
+
listPartialExercicePrestationExpress,
|
|
447
|
+
listRegulations,
|
|
448
|
+
yearlyAmountNonExpress,
|
|
449
|
+
nextYearlyAmountNonExpress
|
|
450
|
+
});
|
|
451
|
+
expect(payments.length).toBeGreaterThanOrEqual(4);
|
|
452
|
+
expect(dayjs(payments[payments.length - 1].datePayment).month()).toStrictEqual(11);
|
|
453
|
+
}));
|
|
454
|
+
test('first payment and last payment should have at least one year difference (ex. : 23 - 24)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
455
|
+
var _l, _m, _o;
|
|
456
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
457
|
+
idTypeBrand: 1,
|
|
458
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
459
|
+
firstExerciceNonExpresssEndDate,
|
|
460
|
+
idPrestation,
|
|
461
|
+
prestationList,
|
|
462
|
+
idVat,
|
|
463
|
+
listPartialExercicePrestationExpress: [],
|
|
464
|
+
listRegulations,
|
|
465
|
+
yearlyAmountNonExpress,
|
|
466
|
+
nextYearlyAmountNonExpress
|
|
467
|
+
});
|
|
468
|
+
expect(dayjs((_m = (_l = payments.slice(-1)) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.datePayment).diff(dayjs((_o = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _o === void 0 ? void 0 : _o.datePayment), 'year', true)).toBeGreaterThan(1);
|
|
469
|
+
}));
|
|
470
|
+
test('real case : idSociety 114440', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
471
|
+
var _p, _q, _r;
|
|
472
|
+
const payments = (0, payment_1.calculatePaymentsAuto)({
|
|
473
|
+
idTypeBrand: 1,
|
|
474
|
+
goToClient: dayjs('2024-06-06').toDate(),
|
|
475
|
+
firstExerciceNonExpresssEndDate: dayjs('2024-12-31').toDate(),
|
|
476
|
+
idPrestation,
|
|
477
|
+
prestationList,
|
|
478
|
+
idVat: types_1.Vat.TX_20.id,
|
|
479
|
+
listPartialExercicePrestationExpress: [],
|
|
480
|
+
listRegulations: [{
|
|
481
|
+
amount: 1006.8,
|
|
482
|
+
amountUsed: 0,
|
|
483
|
+
date: dayjs('2024-06-06').toDate(),
|
|
484
|
+
processed: false,
|
|
485
|
+
idPaymentMethod: types_1.PaymentMethod.BANK_CARD.id,
|
|
486
|
+
idSociety,
|
|
487
|
+
}],
|
|
488
|
+
yearlyAmountNonExpress: 1433, nextYearlyAmountNonExpress: 1433
|
|
489
|
+
});
|
|
490
|
+
expect(dayjs((_q = (_p = payments.slice(-1)) === null || _p === void 0 ? void 0 : _p[0]) === null || _q === void 0 ? void 0 : _q.datePayment).diff(dayjs((_r = payments === null || payments === void 0 ? void 0 : payments[0]) === null || _r === void 0 ? void 0 : _r.datePayment), 'year', true)).toBeGreaterThan(1);
|
|
491
|
+
}));
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
//# sourceMappingURL=payment.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.spec.js","sourceRoot":"","sources":["../../../../ts/utils/tests/payment.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+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,uBAAR,QAAQ,CAAG,CAAC,CAAC,0CAAE,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC/H,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as dayjs from 'dayjs';\nimport { IRegulation, Vat, PaymentMethod } 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});"]}
|
|
@@ -3,4 +3,6 @@ export declare function getAmountByAccountNumber(accountingEntries: IAccountingE
|
|
|
3
3
|
export declare function setZeroIfIsNegative(value: number): number;
|
|
4
4
|
export declare function getTaxAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision?: number, logging?: boolean): number;
|
|
5
5
|
export declare function textFormatting(value: any, length?: number | null): string | null;
|
|
6
|
+
export declare function getTaxesIncludedAmount(amountHt: number, idVat: number, isRounded?: boolean): number;
|
|
7
|
+
export declare function getTaxesExcludedAmount(amountTtc: number, idVat: number, isRounded?: boolean): number;
|
|
6
8
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../ts/utils/vat/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAGjF,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,EAAE,cAAc,EA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use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.textFormatting = exports.getTaxAmountByAccountNumber = exports.setZeroIfIsNegative = exports.getAmountByAccountNumber = void 0;
|
|
3
|
+
exports.getTaxesExcludedAmount = exports.getTaxesIncludedAmount = exports.textFormatting = exports.getTaxAmountByAccountNumber = exports.setZeroIfIsNegative = exports.getAmountByAccountNumber = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const Vat_1 = require("../../types/Enum/Vat");
|
|
6
6
|
function getAmountByAccountNumber(accountingEntries, accountsNumber, precision = 0, isAbs = false) {
|
|
@@ -63,4 +63,22 @@ function textFormatting(value, length = null) {
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
exports.textFormatting = textFormatting;
|
|
66
|
+
function getTaxesIncludedAmount(amountHt, idVat, isRounded = true) {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const vatRate = (_b = (_a = Object.values(Vat_1.Vat).find(v => v.id === idVat)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 20;
|
|
69
|
+
const amountNotRounded = amountHt * ((100 + vatRate) / 100);
|
|
70
|
+
if (!isRounded)
|
|
71
|
+
return amountNotRounded;
|
|
72
|
+
return (_c = Math.round(amountNotRounded * 100) / 100) !== null && _c !== void 0 ? _c : 0;
|
|
73
|
+
}
|
|
74
|
+
exports.getTaxesIncludedAmount = getTaxesIncludedAmount;
|
|
75
|
+
function getTaxesExcludedAmount(amountTtc, idVat, isRounded = true) {
|
|
76
|
+
var _a, _b, _c;
|
|
77
|
+
const vatRate = (_b = (_a = Object.values(Vat_1.Vat).find(v => v.id === idVat)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 20;
|
|
78
|
+
const amountNotRounded = amountTtc / ((100 + vatRate) / 100);
|
|
79
|
+
if (!isRounded)
|
|
80
|
+
return amountNotRounded;
|
|
81
|
+
return (_c = Math.round(amountNotRounded * 100) / 100) !== null && _c !== void 0 ? _c : 0;
|
|
82
|
+
}
|
|
83
|
+
exports.getTaxesExcludedAmount = getTaxesExcludedAmount;
|
|
66
84
|
//# sourceMappingURL=utils.js.map
|