@silexpert/core 1.1.311 → 1.1.312
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/types/Enum/BalanceSheet.d.ts +21 -0
- package/dist/cjs/types/Enum/BalanceSheet.d.ts.map +1 -1
- package/dist/cjs/types/Enum/BalanceSheet.js +27 -1
- package/dist/cjs/types/Enum/BalanceSheet.js.map +1 -1
- package/dist/cjs/types/Enum/Contract.d.ts +2 -1
- package/dist/cjs/types/Enum/Contract.d.ts.map +1 -1
- package/dist/cjs/types/Enum/Contract.js +2 -0
- package/dist/cjs/types/Enum/Contract.js.map +1 -1
- package/dist/cjs/types/Enum/MailAuto.d.ts +3 -1
- package/dist/cjs/types/Enum/MailAuto.d.ts.map +1 -1
- package/dist/cjs/types/Enum/MailAuto.js +2 -0
- package/dist/cjs/types/Enum/MailAuto.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/Enum/Supervision.d.ts +0 -2
- package/dist/cjs/types/Enum/Supervision.d.ts.map +1 -1
- package/dist/cjs/types/Enum/Supervision.js +12 -12
- package/dist/cjs/types/Enum/Supervision.js.map +1 -1
- package/dist/cjs/types/Interface/api/payment/Util.d.ts +1 -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/api/supervision/Query.d.ts +4 -2
- package/dist/cjs/types/Interface/api/supervision/Query.d.ts.map +1 -1
- package/dist/cjs/types/Interface/api/supervision/Query.js +20 -8
- package/dist/cjs/types/Interface/api/supervision/Query.js.map +1 -1
- package/dist/cjs/types/Interface/models/ISocialDetail.d.ts +1 -0
- package/dist/cjs/types/Interface/models/ISocialDetail.d.ts.map +1 -1
- package/dist/cjs/types/Interface/models/ISocialDetail.js.map +1 -1
- package/dist/cjs/utils/payment.d.ts.map +1 -1
- package/dist/cjs/utils/payment.js +34 -15
- package/dist/cjs/utils/payment.js.map +1 -1
- package/dist/cjs/utils/prestation.d.ts +8 -1
- package/dist/cjs/utils/prestation.d.ts.map +1 -1
- package/dist/cjs/utils/prestation.js +35 -8
- package/dist/cjs/utils/prestation.js.map +1 -1
- package/dist/mjs/types/Enum/BalanceSheet.d.ts +21 -0
- package/dist/mjs/types/Enum/BalanceSheet.d.ts.map +1 -1
- package/dist/mjs/types/Enum/BalanceSheet.js +26 -0
- package/dist/mjs/types/Enum/BalanceSheet.js.map +1 -1
- package/dist/mjs/types/Enum/Contract.d.ts +2 -1
- package/dist/mjs/types/Enum/Contract.d.ts.map +1 -1
- package/dist/mjs/types/Enum/Contract.js +2 -0
- package/dist/mjs/types/Enum/Contract.js.map +1 -1
- package/dist/mjs/types/Enum/MailAuto.d.ts +3 -1
- package/dist/mjs/types/Enum/MailAuto.d.ts.map +1 -1
- package/dist/mjs/types/Enum/MailAuto.js +2 -0
- package/dist/mjs/types/Enum/MailAuto.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/Enum/Supervision.d.ts +0 -2
- package/dist/mjs/types/Enum/Supervision.d.ts.map +1 -1
- package/dist/mjs/types/Enum/Supervision.js +12 -12
- package/dist/mjs/types/Enum/Supervision.js.map +1 -1
- package/dist/mjs/types/Interface/api/payment/Util.d.ts +1 -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/api/supervision/Query.d.ts +4 -2
- package/dist/mjs/types/Interface/api/supervision/Query.d.ts.map +1 -1
- package/dist/mjs/types/Interface/api/supervision/Query.js +24 -10
- package/dist/mjs/types/Interface/api/supervision/Query.js.map +1 -1
- package/dist/mjs/types/Interface/models/ISocialDetail.d.ts +1 -0
- package/dist/mjs/types/Interface/models/ISocialDetail.d.ts.map +1 -1
- package/dist/mjs/types/Interface/models/ISocialDetail.js.map +1 -1
- package/dist/mjs/utils/payment.d.ts.map +1 -1
- package/dist/mjs/utils/payment.js +35 -17
- package/dist/mjs/utils/payment.js.map +1 -1
- package/dist/mjs/utils/prestation.d.ts +8 -1
- package/dist/mjs/utils/prestation.d.ts.map +1 -1
- package/dist/mjs/utils/prestation.js +34 -8
- package/dist/mjs/utils/prestation.js.map +1 -1
- package/package.json +1 -1
- package/ts/types/Enum/BalanceSheet.ts +28 -1
- package/ts/types/Enum/Contract.ts +2 -0
- package/ts/types/Enum/MailAuto.ts +2 -0
- package/ts/types/Enum/PriceGridClementine.ts +1 -1
- package/ts/types/Enum/Supervision.ts +4 -4
- package/ts/types/Interface/api/payment/Util.ts +1 -0
- package/ts/types/Interface/api/supervision/Query.ts +17 -7
- package/ts/types/Interface/models/ISocialDetail.ts +1 -0
- package/ts/utils/payment.ts +34 -17
- package/ts/utils/prestation.ts +43 -15
|
@@ -4,8 +4,8 @@ exports.SupervisionStateList = exports.Supervision = void 0;
|
|
|
4
4
|
var Supervision;
|
|
5
5
|
(function (Supervision) {
|
|
6
6
|
Supervision[Supervision["WAITING"] = 1] = "WAITING";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/* SIGNED = 3,
|
|
8
|
+
TO_ATTEST = 6, */
|
|
9
9
|
Supervision[Supervision["ATTESTED"] = 7] = "ATTESTED";
|
|
10
10
|
Supervision[Supervision["ATTEST_REFUSED"] = 8] = "ATTEST_REFUSED";
|
|
11
11
|
Supervision[Supervision["ATTEST_WITH_OBSERVATIONS"] = 9] = "ATTEST_WITH_OBSERVATIONS";
|
|
@@ -21,18 +21,18 @@ exports.SupervisionStateList = [
|
|
|
21
21
|
color: 'grey',
|
|
22
22
|
textColor: 'grey--text',
|
|
23
23
|
},
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
/* {
|
|
25
|
+
id: Supervision.SIGNED,
|
|
26
|
+
label: 'Signé',
|
|
27
|
+
color: 'green darken-1',
|
|
28
|
+
textColor: 'green--text text--darken-1',
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
31
|
+
id: Supervision.TO_ATTEST,
|
|
32
|
+
label: 'A attesté',
|
|
33
|
+
color: 'yellow darken-3',
|
|
34
|
+
textColor: 'yellow--text text--darken-1',
|
|
35
|
+
}, */
|
|
36
36
|
{
|
|
37
37
|
id: Supervision.ATTESTED,
|
|
38
38
|
label: 'Attesté',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Supervision.js","sourceRoot":"","sources":["../../../../ts/types/Enum/Supervision.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAWX;AAXD,WAAY,WAAW;IACrB,mDAAW,CAAA;IACX
|
|
1
|
+
{"version":3,"file":"Supervision.js","sourceRoot":"","sources":["../../../../ts/types/Enum/Supervision.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAWX;AAXD,WAAY,WAAW;IACrB,mDAAW,CAAA;IACX;qBACiB;IACjB,qDAAY,CAAA;IACZ,iEAAkB,CAAA;IAClB,qFAA4B,CAAA;IAC5B,wDAAc,CAAA;IACd,4EAAwB,CAAA;IACxB,wEAAsB,CAAA;IACtB,4EAAwB,CAAA;AAC1B,CAAC,EAXW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAWtB;AAEY,QAAA,oBAAoB,GAAG;IAClC;QACE,EAAE,EAAE,WAAW,CAAC,OAAO;QACvB,KAAK,EAAE,YAAY;QACnB,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,YAAY;KACxB;IACD;;;;;;;;;;;SAWK;IACL;QACE,EAAE,EAAE,WAAW,CAAC,QAAQ;QACxB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,gBAAgB;QACvB,SAAS,EAAE,4BAA4B;KACxC;IACD;QACE,EAAE,EAAE,WAAW,CAAC,cAAc;QAC9B,KAAK,EAAE,oBAAoB;QAC3B,KAAK,EAAE,gBAAgB;QACvB,SAAS,EAAE,4BAA4B;KACxC;IACD;QACE,EAAE,EAAE,WAAW,CAAC,wBAAwB;QACxC,KAAK,EAAE,2BAA2B;QAClC,KAAK,EAAE,gBAAgB;QACvB,SAAS,EAAE,4BAA4B;KACxC;IACD;QACE,EAAE,EAAE,WAAW,CAAC,SAAS;QACzB,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,eAAe;QACtB,SAAS,EAAE,0BAA0B;KACtC;IACD;QACE,EAAE,EAAE,WAAW,CAAC,mBAAmB;QACnC,KAAK,EAAE,yBAAyB;QAChC,KAAK,EAAE,iBAAiB;QACxB,SAAS,EAAE,6BAA6B;KACzC;IACD;QACE,EAAE,EAAE,WAAW,CAAC,iBAAiB;QACjC,KAAK,EAAE,kBAAkB;QACzB,KAAK,EAAE,iBAAiB;QACxB,SAAS,EAAE,6BAA6B;KACzC;IACD;QACE,EAAE,EAAE,WAAW,CAAC,mBAAmB;QACnC,KAAK,EAAE,kBAAkB;QACzB,KAAK,EAAE,kBAAkB;QACzB,SAAS,EAAE,8BAA8B;KAC1C;CACF,CAAC","sourcesContent":["export enum Supervision {\n WAITING = 1,\n /* SIGNED = 3,\n TO_ATTEST = 6, */\n ATTESTED = 7,\n ATTEST_REFUSED = 8,\n ATTEST_WITH_OBSERVATIONS = 9,\n TO_REVIEW = 10,\n SUPERVISION_WAITING = 11,\n ESTABLISH_REFUSED = 12,\n WITHOUT_ATTESTATION = 13,\n}\n\nexport const SupervisionStateList = [\n {\n id: Supervision.WAITING,\n label: 'En attente',\n color: 'grey',\n textColor: 'grey--text',\n },\n /* {\n id: Supervision.SIGNED,\n label: 'Signé',\n color: 'green darken-1',\n textColor: 'green--text text--darken-1',\n },\n {\n id: Supervision.TO_ATTEST,\n label: 'A attesté',\n color: 'yellow darken-3',\n textColor: 'yellow--text text--darken-1',\n }, */\n {\n id: Supervision.ATTESTED,\n label: 'Attesté',\n color: 'green darken-1',\n textColor: 'green--text text--darken-1',\n },\n {\n id: Supervision.ATTEST_REFUSED,\n label: 'Attesté avec refus',\n color: 'green darken-1',\n textColor: 'green--text text--darken-1',\n },\n {\n id: Supervision.ATTEST_WITH_OBSERVATIONS,\n label: 'Attesté avec observations',\n color: 'green darken-1',\n textColor: 'green--text text--darken-1',\n },\n {\n id: Supervision.TO_REVIEW,\n label: 'A revoir',\n color: 'red lighten-2',\n textColor: 'red--text red--lighten-3',\n },\n {\n id: Supervision.SUPERVISION_WAITING,\n label: 'En cours de supervision',\n color: 'yellow darken-3',\n textColor: 'yellow--text text--darken-1',\n },\n {\n id: Supervision.ESTABLISH_REFUSED,\n label: 'Refus d\\'établir',\n color: 'orange darken-1',\n textColor: 'orange--text text--darken-1',\n },\n {\n id: Supervision.WITHOUT_ATTESTATION,\n label: 'Sans attestation',\n color: 'orange lighten-1',\n textColor: 'orange--text text--lighten-1',\n },\n];"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/payment/Util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,WAAW,gCAAgC;IAC/C,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAA;CACpB;AACD,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B,EAAE,IAAI,CAAC;IACtC,UAAU,EAAE,IAAI,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,eAAe,CAAC;IAChC,sBA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AAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.js","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/payment/Util.ts"],"names":[],"mappings":"","sourcesContent":["import { IPrestationList, IRegulation } from '../../..';\n\nexport interface PartialExercicePrestationExpress {\n startDate: Date;\n endDate: Date;\n countExpressMonthlyPayment: number | null; // if null, non express | if not null, express\n totalAmount: number\n}\nexport interface ParamsForPaymentsAuto {\n idTypeBrand: number;\n firstExerciceNonExpresssEndDate: Date;\n goToClient: Date;\n idPrestation: number;\n idLegalForm: number;\n isWithApplicationFees: boolean;\n idVat: number;\n prestationList: IPrestationList;\n yearlyAmountNonExpress: number;\n nextYearlyAmountNonExpress: number;\n listPartialExercicePrestationExpress: PartialExercicePrestationExpress[];\n listRegulations: IRegulation[];\n}\n\nexport interface PaymentAuto {\n amount: number;\n isPaid?: boolean;\n datePayment: Date;\n idPrestation: number;\n idPaymentMethod: number;\n closingDate: Date;\n}"]}
|
|
1
|
+
{"version":3,"file":"Util.js","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/payment/Util.ts"],"names":[],"mappings":"","sourcesContent":["import { IPrestationList, IRegulation } from '../../..';\n\nexport interface PartialExercicePrestationExpress {\n startDate: Date;\n endDate: Date;\n countExpressMonthlyPayment: number | null; // if null, non express | if not null, express\n totalAmount: number\n}\nexport interface ParamsForPaymentsAuto {\n idTypeBrand: number;\n firstExerciceNonExpresssEndDate: Date;\n goToClient: Date;\n idPrestation: number;\n idLegalForm: number;\n isWithApplicationFees: boolean;\n idVat: number;\n prestationList: IPrestationList;\n yearlyAmountNonExpress: number;\n nextYearlyAmountNonExpress: number;\n listPartialExercicePrestationExpress: PartialExercicePrestationExpress[];\n listRegulations: IRegulation[];\n}\n\nexport interface PaymentAuto {\n amount: number;\n isPaid?: boolean;\n datePayment: Date;\n idPrestation: number;\n idPaymentMethod: number;\n closingDate: Date;\n comment?: string;\n}"]}
|
|
@@ -5,13 +5,15 @@ export declare class QueryPaginatedBalanceSheetSupervision extends RequiredQuery
|
|
|
5
5
|
state?: number | null;
|
|
6
6
|
balanceSheetState?: number[];
|
|
7
7
|
bankCollectingState?: number[];
|
|
8
|
-
|
|
8
|
+
typeBrand?: number[];
|
|
9
|
+
totalRange?: number | null;
|
|
9
10
|
month?: number | null;
|
|
10
11
|
endDate?: number | null;
|
|
11
12
|
year?: number | null;
|
|
12
13
|
isBack?: boolean | null;
|
|
13
|
-
displayArchive?: boolean | null;
|
|
14
14
|
userSelected?: number[];
|
|
15
15
|
expertSelected?: number | null;
|
|
16
|
+
orderBy?: string | null;
|
|
17
|
+
descending?: boolean | null;
|
|
16
18
|
}
|
|
17
19
|
//# sourceMappingURL=Query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/supervision/Query.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,qBAAa,qCAAsC,SAAQ,qBAAqB;IAK5E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAK9B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAKvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAKtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAK7B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAK/B,
|
|
1
|
+
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/supervision/Query.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,qBAAa,qCAAsC,SAAQ,qBAAqB;IAK5E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAK9B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAKvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAKtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAK7B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAK/B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAKrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAK3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAKtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAKxB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAMrB,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAKxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAKxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAK/B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAMxB,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAE/B"}
|
|
@@ -46,12 +46,18 @@ __decorate([
|
|
|
46
46
|
(0, class_validator_1.IsArray)(),
|
|
47
47
|
__metadata("design:type", Array)
|
|
48
48
|
], QueryPaginatedBalanceSheetSupervision.prototype, "bankCollectingState", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, utils_1.ApiPropertyOptional)(),
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
(0, class_validator_1.IsArray)(),
|
|
53
|
+
__metadata("design:type", Array)
|
|
54
|
+
], QueryPaginatedBalanceSheetSupervision.prototype, "typeBrand", void 0);
|
|
49
55
|
__decorate([
|
|
50
56
|
(0, utils_1.ApiPropertyOptional)(),
|
|
51
57
|
(0, class_validator_1.IsOptional)(),
|
|
52
58
|
(0, class_validator_1.IsInt)(),
|
|
53
59
|
__metadata("design:type", Object)
|
|
54
|
-
], QueryPaginatedBalanceSheetSupervision.prototype, "
|
|
60
|
+
], QueryPaginatedBalanceSheetSupervision.prototype, "totalRange", void 0);
|
|
55
61
|
__decorate([
|
|
56
62
|
(0, utils_1.ApiPropertyOptional)(),
|
|
57
63
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -77,13 +83,6 @@ __decorate([
|
|
|
77
83
|
(0, boolean_transform_1.ToBoolean)(),
|
|
78
84
|
__metadata("design:type", Object)
|
|
79
85
|
], QueryPaginatedBalanceSheetSupervision.prototype, "isBack", void 0);
|
|
80
|
-
__decorate([
|
|
81
|
-
(0, utils_1.ApiPropertyOptional)(),
|
|
82
|
-
(0, class_validator_1.IsOptional)(),
|
|
83
|
-
(0, class_validator_1.IsBoolean)(),
|
|
84
|
-
(0, boolean_transform_1.ToBoolean)(),
|
|
85
|
-
__metadata("design:type", Object)
|
|
86
|
-
], QueryPaginatedBalanceSheetSupervision.prototype, "displayArchive", void 0);
|
|
87
86
|
__decorate([
|
|
88
87
|
(0, utils_1.ApiPropertyOptional)(),
|
|
89
88
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -96,5 +95,18 @@ __decorate([
|
|
|
96
95
|
(0, class_validator_1.IsInt)(),
|
|
97
96
|
__metadata("design:type", Object)
|
|
98
97
|
], QueryPaginatedBalanceSheetSupervision.prototype, "expertSelected", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, utils_1.ApiPropertyOptional)(),
|
|
100
|
+
(0, class_validator_1.IsOptional)(),
|
|
101
|
+
(0, class_validator_1.IsString)(),
|
|
102
|
+
__metadata("design:type", Object)
|
|
103
|
+
], QueryPaginatedBalanceSheetSupervision.prototype, "orderBy", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, utils_1.ApiPropertyOptional)(),
|
|
106
|
+
(0, class_validator_1.IsOptional)(),
|
|
107
|
+
(0, class_validator_1.IsBoolean)(),
|
|
108
|
+
(0, boolean_transform_1.ToBoolean)(),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], QueryPaginatedBalanceSheetSupervision.prototype, "descending", void 0);
|
|
99
111
|
exports.QueryPaginatedBalanceSheetSupervision = QueryPaginatedBalanceSheetSupervision;
|
|
100
112
|
//# sourceMappingURL=Query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Query.js","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/supervision/Query.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAkF;AAClF,6CAAwD;AACxD,sFAA2E;AAC3E,kDAAwD;AAExD,MAAa,qCAAsC,SAAQ,oCAAqB;
|
|
1
|
+
{"version":3,"file":"Query.js","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/supervision/Query.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAkF;AAClF,6CAAwD;AACxD,sFAA2E;AAC3E,kDAAwD;AAExD,MAAa,qCAAsC,SAAQ,oCAAqB;CA+E/E;AA7EC;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;4EACwB;AAEhC;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qEACc;AAEzB;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;oEACgB;AAExB;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;;gFACqB;AAE/B;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;;kFACuB;AAEjC;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;;wEACa;AAEvB;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;yEACqB;AAE7B;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;oEACgB;AAExB;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;sEACkB;AAE1B;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;mEACe;AAEvB;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;IACX,IAAA,6BAAS,GAAE;;qEACc;AAE1B;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;;2EACgB;AAE1B;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;6EACyB;AAEjC;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;sEACe;AAE1B;IAAC,IAAA,2BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;IACX,IAAA,6BAAS,GAAE;;yEACkB;AA7EhC,sFA+EC","sourcesContent":["import { IsArray, IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';\nimport { ApiPropertyOptional } from '../../../../utils';\nimport { ToBoolean } from '../../../../utils/transforms/boolean.transform';\nimport { RequiredQueryPaginate } from '../BasePaginate';\n\nexport class QueryPaginatedBalanceSheetSupervision extends RequiredQueryPaginate {\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsInt()\n idSupervision?: number | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsString()\n search?: string | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsInt()\n state?: number | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsArray()\n balanceSheetState?: number[];\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsArray()\n bankCollectingState?: number[];\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsArray()\n typeBrand?: number[];\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsInt()\n totalRange?: number | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsInt()\n month?: number | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsInt()\n endDate?: number | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsInt()\n year?: number | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsBoolean()\n @ToBoolean()\n isBack?: boolean | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsArray()\n userSelected?: number[];\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsInt()\n expertSelected?: number | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsString()\n orderBy?: string | null;\n\n @ApiPropertyOptional()\n @IsOptional()\n @IsBoolean()\n @ToBoolean()\n descending?: boolean | null;\n\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISocialDetail.d.ts","sourceRoot":"","sources":["../../../../../ts/types/Interface/models/ISocialDetail.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACzB"}
|
|
1
|
+
{"version":3,"file":"ISocialDetail.d.ts","sourceRoot":"","sources":["../../../../../ts/types/Interface/models/ISocialDetail.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISocialDetail.js","sourceRoot":"","sources":["../../../../../ts/types/Interface/models/ISocialDetail.ts"],"names":[],"mappings":"","sourcesContent":["// socialDetail\nexport interface ISocialDetail {\n id?: number;\n priceBulletin: number;\n priceDsn: number;\n ras: boolean;\n freqCibt: number | null;\n idSociety: number;\n createdAt?: Date | null;\n updatedAt?: Date | null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ISocialDetail.js","sourceRoot":"","sources":["../../../../../ts/types/Interface/models/ISocialDetail.ts"],"names":[],"mappings":"","sourcesContent":["// socialDetail\nexport interface ISocialDetail {\n id?: number;\n priceBulletin: number;\n priceDsn: number;\n ras: boolean;\n freqCibt: number | null;\n idPaymentMethod: number;\n idSociety: number;\n createdAt?: Date | null;\n updatedAt?: Date | null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../ts/utils/payment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAe,qBAAqB,EAAiB,WAAW,
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../ts/utils/payment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAe,qBAAqB,EAAiB,WAAW,EAA0B,MAAM,UAAU,CAAC;AAK5H,UAAU,gBAAiB,SAAQ,QAAQ;IACzC,IAAI,EAAE,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;IAC7D,YAAY,EAAE,QAAQ,EAAE,CAAA;CACzB;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,0BAA0B,aAAc,QAAQ,EAAE,UAAS,CAAC,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC,EAAE,KAA2D,gBAAgB,EAoCrM,CAAC;AAkBF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,qBAAqB,WAAY,qBAAqB,KAAE,WAAW,EAuOxE,CAAC;AAEF,OAAO,EACL,0BAA0B,EAAE,qBAAqB,GAClD,CAAC"}
|
|
@@ -63,6 +63,7 @@ const calculateFees = (amount, goToClient, paymentDate) => {
|
|
|
63
63
|
* @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding
|
|
64
64
|
*/
|
|
65
65
|
const calculatePaymentsAuto = (params) => {
|
|
66
|
+
var _a, _b;
|
|
66
67
|
const { idTypeBrand, goToClient, isWithApplicationFees, firstExerciceNonExpresssEndDate, idPrestation, idLegalForm, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;
|
|
67
68
|
const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3 /* || dayjs().date() >= 15 */
|
|
68
69
|
? dayjs().add(2, 'month').startOf('month').toDate()
|
|
@@ -76,7 +77,7 @@ const calculatePaymentsAuto = (params) => {
|
|
|
76
77
|
throw new Error('Impossible de trouver la grille tarifaire correspondante');
|
|
77
78
|
const { applicationCost, priceWithTaxesIncluded } = priceGrid;
|
|
78
79
|
const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : (0, types_1.getTaxesIncludedAmount)(applicationCost, idVat)) * 12;
|
|
79
|
-
const
|
|
80
|
+
const applicationFeesAmountTTC = (0, prestation_1.getApplicationFeesAmount)(idLegalForm, idVat);
|
|
80
81
|
if ((prestationList === null || prestationList === void 0 ? void 0 : prestationList.isCatalog) || !(prestationList === null || prestationList === void 0 ? void 0 : prestationList.isComptable))
|
|
81
82
|
throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');
|
|
82
83
|
// if (!listRegulations?.length) throw new Error('List of regulations can not be empty');
|
|
@@ -96,6 +97,7 @@ const calculatePaymentsAuto = (params) => {
|
|
|
96
97
|
const payload = JSON.parse((_b = r.paymentsExpectation) === null || _b === void 0 ? void 0 : _b.payload);
|
|
97
98
|
if (+(payload === null || payload === void 0 ? void 0 : payload.applicationFee) > 0) {
|
|
98
99
|
isApplicationFeesAlreadyPaid = true;
|
|
100
|
+
acc += +(payload === null || payload === void 0 ? void 0 : payload.applicationFee);
|
|
99
101
|
}
|
|
100
102
|
if (+(payload === null || payload === void 0 ? void 0 : payload.accountingFee) > 0)
|
|
101
103
|
acc += +(payload === null || payload === void 0 ? void 0 : payload.accountingFee);
|
|
@@ -116,25 +118,42 @@ const calculatePaymentsAuto = (params) => {
|
|
|
116
118
|
//On ajoute un paiement initial correspondant à la somme des régulations
|
|
117
119
|
if (sumRegulations) {
|
|
118
120
|
listPayments.push({
|
|
119
|
-
amount: sumRegulations,
|
|
121
|
+
amount: isApplicationFeesAlreadyPaid ? sumRegulations - applicationFeesAmountTTC : sumRegulations,
|
|
120
122
|
isPaid: true,
|
|
121
123
|
datePayment: dayjs().toDate(),
|
|
122
124
|
idPrestation,
|
|
123
|
-
idPaymentMethod: types_1.PaymentMethod.DIRECT_DEBIT.id,
|
|
125
|
+
idPaymentMethod: (_b = (_a = listRegulations[0]) === null || _a === void 0 ? void 0 : _a.idPaymentMethod) !== null && _b !== void 0 ? _b : types_1.PaymentMethod.DIRECT_DEBIT.id,
|
|
124
126
|
closingDate: (listPartialExercicePrestationExpress === null || listPartialExercicePrestationExpress === void 0 ? void 0 : listPartialExercicePrestationExpress.length) ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
|
|
125
127
|
});
|
|
126
128
|
}
|
|
127
|
-
// Si les frais de dossiers sont facturés
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
// Si les frais de dossiers sont facturés ,
|
|
130
|
+
if (isWithApplicationFees) {
|
|
131
|
+
if (isApplicationFeesAlreadyPaid) {
|
|
132
|
+
//et qu'ils ont déjà été payés
|
|
133
|
+
// on ajoute un paiement sur le mois en cours
|
|
134
|
+
listPayments.push({
|
|
135
|
+
amount: applicationFeesAmountTTC,
|
|
136
|
+
isPaid: true,
|
|
137
|
+
datePayment: dayjs().toDate(),
|
|
138
|
+
idPrestation,
|
|
139
|
+
idPaymentMethod: types_1.PaymentMethod.DIRECT_DEBIT.id,
|
|
140
|
+
closingDate: (listPartialExercicePrestationExpress === null || listPartialExercicePrestationExpress === void 0 ? void 0 : listPartialExercicePrestationExpress.length) ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
|
|
141
|
+
comment: 'Frais de dossier',
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
//et qu'ils n'ont pas déjà été payés
|
|
146
|
+
// on ajoute un paiement sur la première mensualité non express
|
|
147
|
+
listPayments.push({
|
|
148
|
+
amount: applicationFeesAmountTTC,
|
|
149
|
+
isPaid: false,
|
|
150
|
+
datePayment: dayjs().startOf('month').add(1, 'month').toDate(),
|
|
151
|
+
idPrestation,
|
|
152
|
+
idPaymentMethod: types_1.PaymentMethod.DIRECT_DEBIT.id,
|
|
153
|
+
closingDate: (listPartialExercicePrestationExpress === null || listPartialExercicePrestationExpress === void 0 ? void 0 : listPartialExercicePrestationExpress.length) ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
|
|
154
|
+
comment: 'Frais de dossier',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
138
157
|
}
|
|
139
158
|
// =========================
|
|
140
159
|
// EXPRESS
|
|
@@ -196,7 +215,7 @@ const calculatePaymentsAuto = (params) => {
|
|
|
196
215
|
// }
|
|
197
216
|
// Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total
|
|
198
217
|
if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {
|
|
199
|
-
remainingAmount -=
|
|
218
|
+
remainingAmount -= applicationFeesAmountTTC;
|
|
200
219
|
}
|
|
201
220
|
let remainingAmountByExercicePrestation = remainingAmount;
|
|
202
221
|
// - frais d'application dès les second exo non express
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../ts/utils/payment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,oCAA+I;AAC/I,+BAA+B;AAE/B,6CAA4C;AAO5C;;;;;;;;;GASG;AACH,MAAM,0BAA0B,GAAG,CAAC,QAAoB,EAAE,QAAoE,CAAC,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,CAAC,EAAsB,EAAE;IACzM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,mBAAC,OAAA,MAAA,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,mBAAmB,0CAAE,eAAe,0CAAE,WAAW,mCAAI,KAAK,CAAA,EAAA,CAAC,CAAC;IAChH,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,uBAAC,OAAA,CAAC,CAAA,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,mBAAmB,0CAAE,eAAe,0CAAE,WAAW,CAAA,KAAI,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,mBAAmB,0CAAE,eAAe,0CAAE,QAAQ,CAAA,CAAA,EAAA,CAAC,CAAC;IAC3J,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,uBAAC,OAAA,CAAC,CAAA,MAAA,MAAA,EAAE,aAAF,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AAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAExD,YAAY,CAAC,IAAI,CAAC;YAChB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG;YACtC,WAAW,EAAE,WAAW;YACxB,YAAY;YACZ,eAAe,EAAE,qBAAa,CAAC,YAAY,CAAC,EAAE;YAC9C,WAAW,EAAE,eAAe;SAC7B,CAAC,CAAC;QACH,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;KAC5E;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAG4B,sDAAqB","sourcesContent":["'use strict';\n\nimport { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount, LegalFormTypeEnum } from '../types';\nimport * as dayjs from 'dayjs';\nimport { PartialExercicePrestationExpress } from '../types/Interface/api/payment/Util';\nimport { getPriceGrid } from './prestation';\n\ninterface PaymentsWithList extends IPayment {\n type: 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther',\n listPayments: IPayment[]\n}\n\n/**\n * A partir d'une liste de payment (avec include jusqu'à prestationList, \n * avec en attributs 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther')\n * permet de récupérer uniquement le premier paiement de chaque type \n * et les autres payments dans listPayments\n * avec possibilité de filtrer avec le tableau de filtres\n * @param payments \n * @param types \n * @returns \n */\nconst groupPaymentsByServiceType = (payments: IPayment[], types: ('isComptable' | 'isJuridique' | 'isSocial' | 'isOther')[] = ['isComptable', 'isJuridique', 'isSocial', 'isOther']): PaymentsWithList[] => {\n const prestaComptable = payments.filter((el) => el?.paymentsPrestations?.prestationsList?.isComptable ?? false);\n const prestaSocial = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isSocial);\n const prestaJuridique = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isJuridique);\n const prestaOther = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && !el?.paymentsPrestations?.prestationsList?.isJuridique && !el?.paymentsPrestations?.prestationsList?.isSocial);\n \n const societyPayment: PaymentsWithList[] = [];\n if (prestaComptable.length && types.includes('isComptable')) {\n societyPayment.push({\n ...prestaComptable[0], // Données de base\n type: 'isComptable',\n listPayments: prestaComptable,\n });\n }\n if (prestaSocial.length && types.includes('isSocial')) {\n societyPayment.push({\n ...prestaSocial[0], // Données de base\n type: 'isSocial',\n listPayments: prestaSocial,\n });\n }\n if (prestaJuridique.length && types.includes('isJuridique')) {\n societyPayment.push({\n ...prestaJuridique[0], // Données de base\n type: 'isJuridique',\n listPayments: prestaJuridique,\n });\n }\n if (prestaOther.length && types.includes('isOther')) {\n societyPayment.push({\n ...prestaOther[0], // Données de base\n type: 'isOther',\n listPayments: prestaOther,\n });\n }\n return societyPayment;\n};\n\nconst calculateFees = (amount: number, goToClient: Date, paymentDate: Date):number => {\n const yearlyPriceIncreasing = 1.0275;\n\n const oneYearLessIfIn3LastMonthsOfYear = dayjs(goToClient).month() >= 9 ? 1 : 0;\n\n if (dayjs(paymentDate).year() - dayjs().year() > 0) {\n const nbYearsMore = dayjs(paymentDate).year() - dayjs().year() - oneYearLessIfIn3LastMonthsOfYear;\n // on applique X fois l'augmentation\n // ex. : si on lance l'appel en 2024, et qu'on génére un paiement pour 2026, on applique 2 fois l'augmentation\n // soit amount * yearlyPriceIncreasing * yearlyPriceIncreasing\n // soit amount * yearlyPriceIncreasing ^ nbYearsMore\n amount = amount * Math.pow(yearlyPriceIncreasing, nbYearsMore);\n }\n return amount;\n};\n\n/**\n// * @param {number} firstPaymentAmount - amount of the first payment (first regulation of the customer)\n * @param {Date} firstExerciceNonExpresssEndDate - end date of the first exercice non express\n * @param {number} idPrestation - prestation id\n * @param {number} idLegalForm - legal form id of the society\n * @param {boolean} isWithApplicationFees - if the prestation has application fees to paid\n * @param {IPrestationList} prestationList - type of prestation (hidden: 0, isCatalog: 1, isComptable: 1)\n * @param {number} idVat - vat id of society linked\n * @param {number} yearlyAmountNonExpress - yearly amount of non express prestation (HT)\n * @param {number} nextYearlyAmountNonExpress - yearly amount of non express prestation for next years (HT)\n * @param {PartialExercicePrestationExpress[]} listPartialExercicePrestationExpress - list of exercicePrestation linked to idPrestation -> used to get express\n * @param {IRegulation[]} listRegulations - list of regulations linked to idPrestation (TTC)\n * @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding\n */\nconst calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {\n const { idTypeBrand, goToClient, isWithApplicationFees, firstExerciceNonExpresssEndDate, idPrestation, idLegalForm, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;\n const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3/* || dayjs().date() >= 15 */\n ? dayjs().add(2, 'month').startOf('month').toDate()\n : dayjs().add(1, 'month').startOf('month').toDate();\n\n // On récupère la grille tarifaire pour savoir si les tarifs sont HT ou TTC \n // et pour connaitre le montant du coût de l'app\n if (!prestationList.id) throw new Error('idPrestationList manquant');\n const priceGrid = getPriceGrid(idTypeBrand, prestationList.id);\n if (!priceGrid) throw new Error('Impossible de trouver la grille tarifaire correspondante');\n const { applicationCost, priceWithTaxesIncluded } = priceGrid;\n const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : getTaxesIncludedAmount(applicationCost, idVat)) * 12;\n const applicationFeesAmount = (idLegalForm === LegalFormTypeEnum.SCI) ? 150 : 50;\n\n if (prestationList?.isCatalog || !prestationList?.isComptable) throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');\n // if (!listRegulations?.length) throw new Error('List of regulations can not be empty');\n if (listPartialExercicePrestationExpress.length && listPartialExercicePrestationExpress?.some((ep: PartialExercicePrestationExpress) => !ep?.startDate)) throw new Error('Start date of some exercice are missing');\n if (!listRegulations?.every((r: IRegulation) => !!r?.amount || !!r?.amountUsed)) throw new Error('Amount and amountUsed are missing for regulations');\n\n const nbExoExpress = listPartialExercicePrestationExpress.length;\n const listPayments:PaymentAuto[] = [];\n\n // on récupère le/les premiers réglements effectués, non alloués\n let isApplicationFeesAlreadyPaid = false;\n const sumRegulations = listRegulations.reduce((acc: number, r:IRegulation) => {\n //Si la regulation est rattachée à un paymentExpectation, on récupère le détail\n // et on ne prend que les frais de dossier (applicationFee) + le montant de la compta (accountingFee)\n if (r.paymentsExpectation?.payload) {\n const payload = JSON.parse(r.paymentsExpectation?.payload);\n if (+payload?.applicationFee > 0) {\n isApplicationFeesAlreadyPaid = true;\n }\n if (+payload?.accountingFee > 0) acc += +payload?.accountingFee;\n return acc;\n } else {\n return acc + r.amount - r.amountUsed;\n }\n }, 0);\n let remainingAmount = -sumRegulations; //TTC\n let paymentDate = initializedPaymentDate;\n\n //On order les exercicePrestation par startDate ASC et id ASC\n listPartialExercicePrestationExpress.sort((a, b) => {\n const aStartDate = a?.startDate as Date;\n const bStartDate = b?.startDate as Date;\n return dayjs(aStartDate).diff(bStartDate);\n });\n\n //On ajoute un paiement initial correspondant à la somme des régulations\n if (sumRegulations) {\n listPayments.push({\n amount:sumRegulations, //TTC\n isPaid: true,\n datePayment: dayjs().toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n\n // Si les frais de dossiers sont facturés et qu'ils n'ont pas déjà été payés,\n // on ajoute un paiement sur la première mensualité non express\n if (isWithApplicationFees && !isApplicationFeesAlreadyPaid) {\n listPayments.push({\n amount: getTaxesIncludedAmount(applicationFeesAmount, idVat), //TTC\n isPaid: false,\n datePayment: dayjs().startOf('month').add(1, 'month').toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n \n // =========================\n // EXPRESS\n // =========================\n listPartialExercicePrestationExpress.forEach((exercicePrestation:PartialExercicePrestationExpress, indexEP: number) => {\n remainingAmount += !priceWithTaxesIncluded \n ? getTaxesIncludedAmount(exercicePrestation.totalAmount, idVat) \n : exercicePrestation.totalAmount; //TTC\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n if (remainingAmount <= 0) return;\n \n //express : on étale en countExpressMonthlyPayment (nb de mensualités)\n let remainingAmountByExercicePrestation = remainingAmount; //TTC\n let countExpressMonthlyPayment = exercicePrestation?.countExpressMonthlyPayment ?? 3; //TTC\n //Si un premier règlement est généré avec le montant des regulations, on le considère comme une mensualité (unioquement pour le premier express et la première mensualité)\n if (indexEP === 0 && sumRegulations > 0) countExpressMonthlyPayment -= 1;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countExpressMonthlyPayment; //TTC\n for (let index = 1; index <= countExpressMonthlyPayment; index++) {\n // On arrondis les 11 premières mensualités, mais on récupère le reste pour la dernière mensualité, pour éviter les centimes perdus en arrondis\n // et on applique le taux de tva de la société\n const amount = index < countExpressMonthlyPayment ? monthlyAmount : remainingAmountByExercicePrestation; //TTC\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exercicePrestation.endDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n remainingAmount = 0;\n });\n\n // =========================\n // NON EXPRESS\n // =========================\n // on lisse sur le nb de mois restants (avec au minimum 3 mensualités)\n // Si un seul exo express, alors on met les paiements de l'exo actuel en parallèle\n // sinon, ils sont à la suite des express\n if (nbExoExpress <= 1) paymentDate = initializedPaymentDate;\n let exerciceEndDate = dayjs(firstExerciceNonExpresssEndDate).toDate();\n\n let hasGeneratedWholeYear = false;\n let isFirstNonExpress = true;\n \n //On génère des paiements jusqu'à ce qu'un exercice soit entier (12 mois), non express\n while (!hasGeneratedWholeYear) {\n \n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n const exoAmount = isFirstNonExpress ? yearlyAmountNonExpress : nextYearlyAmountNonExpress;\n remainingAmount += priceWithTaxesIncluded ? exoAmount : getTaxesIncludedAmount(exoAmount, idVat);\n\n //TODO: CAS A TESTER : si sumRegulations couvre le premier exercice par exemple (cas rar mais à envisager)\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n // if (remainingAmount <= 0) {\n // continue;\n // }\n\n // Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total\n if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {\n remainingAmount -= getTaxesIncludedAmount(applicationFeesAmount, idVat);\n }\n\n let remainingAmountByExercicePrestation = remainingAmount;\n\n // - frais d'application dès les second exo non express\n if (!isFirstNonExpress) remainingAmountByExercicePrestation += applicationCostTotalTTC;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC\n\n if (monthlyAmount > 0) {\n for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {\n let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;\n \n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n amount = calculateFees(amount, goToClient, paymentDate);\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();\n }\n remainingAmount = 0;\n if (countMonthsBeforeExerciceEnd === 12) hasGeneratedWholeYear = true;\n isFirstNonExpress = false;\n }\n\n remainingAmount = 0;\n\n // =========================\n // JUSQU'EN DECEMBRE\n // =========================\n // On applique le taux de tva de la société, si besoin, selon la grille tarifaire\n remainingAmount += priceWithTaxesIncluded ? nextYearlyAmountNonExpress : getTaxesIncludedAmount(nextYearlyAmountNonExpress, idVat);\n\n let remainingAmountByExercicePrestation = remainingAmount;\n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n // - frais d'application dès les second exo non express\n remainingAmountByExercicePrestation += applicationCostTotalTTC;\n \n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;\n \n // Si aucun paiement généré, on stoppe là\n if (!listPayments.length) return [];\n\n while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11) {\n let amount = monthlyAmount;\n\n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n // - frais d'application dès les second exo non express\n amount = calculateFees(amount, goToClient, paymentDate);\n\n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n\n return listPayments;\n};\n\nexport {\n groupPaymentsByServiceType, calculatePaymentsAuto,\n};"]}
|
|
1
|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AM;QAAE,OAAO,EAAE,CAAC;IAEpC,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAChE,IAAI,MAAM,GAAG,aAAa,CAAC;QAE3B,iDAAiD;QACjD,yGAAyG;QACzG,uDAAuD;QACvD,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAExD,YAAY,CAAC,IAAI,CAAC;YAChB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG;YACtC,WAAW,EAAE,WAAW;YACxB,YAAY;YACZ,eAAe,EAAE,qBAAa,CAAC,YAAY,CAAC,EAAE;YAC9C,WAAW,EAAE,eAAe;SAC7B,CAAC,CAAC;QACH,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;KAC5E;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAG4B,sDAAqB","sourcesContent":["'use strict';\n\nimport { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount } from '../types';\nimport * as dayjs from 'dayjs';\nimport { PartialExercicePrestationExpress } from '../types/Interface/api/payment/Util';\nimport { getApplicationFeesAmount, getPriceGrid } from './prestation';\n\ninterface PaymentsWithList extends IPayment {\n type: 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther',\n listPayments: IPayment[]\n}\n\n/**\n * A partir d'une liste de payment (avec include jusqu'à prestationList, \n * avec en attributs 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther')\n * permet de récupérer uniquement le premier paiement de chaque type \n * et les autres payments dans listPayments\n * avec possibilité de filtrer avec le tableau de filtres\n * @param payments \n * @param types \n * @returns \n */\nconst groupPaymentsByServiceType = (payments: IPayment[], types: ('isComptable' | 'isJuridique' | 'isSocial' | 'isOther')[] = ['isComptable', 'isJuridique', 'isSocial', 'isOther']): PaymentsWithList[] => {\n const prestaComptable = payments.filter((el) => el?.paymentsPrestations?.prestationsList?.isComptable ?? false);\n const prestaSocial = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isSocial);\n const prestaJuridique = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isJuridique);\n const prestaOther = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && !el?.paymentsPrestations?.prestationsList?.isJuridique && !el?.paymentsPrestations?.prestationsList?.isSocial);\n \n const societyPayment: PaymentsWithList[] = [];\n if (prestaComptable.length && types.includes('isComptable')) {\n societyPayment.push({\n ...prestaComptable[0], // Données de base\n type: 'isComptable',\n listPayments: prestaComptable,\n });\n }\n if (prestaSocial.length && types.includes('isSocial')) {\n societyPayment.push({\n ...prestaSocial[0], // Données de base\n type: 'isSocial',\n listPayments: prestaSocial,\n });\n }\n if (prestaJuridique.length && types.includes('isJuridique')) {\n societyPayment.push({\n ...prestaJuridique[0], // Données de base\n type: 'isJuridique',\n listPayments: prestaJuridique,\n });\n }\n if (prestaOther.length && types.includes('isOther')) {\n societyPayment.push({\n ...prestaOther[0], // Données de base\n type: 'isOther',\n listPayments: prestaOther,\n });\n }\n return societyPayment;\n};\n\nconst calculateFees = (amount: number, goToClient: Date, paymentDate: Date):number => {\n const yearlyPriceIncreasing = 1.0275;\n\n const oneYearLessIfIn3LastMonthsOfYear = dayjs(goToClient).month() >= 9 ? 1 : 0;\n\n if (dayjs(paymentDate).year() - dayjs().year() > 0) {\n const nbYearsMore = dayjs(paymentDate).year() - dayjs().year() - oneYearLessIfIn3LastMonthsOfYear;\n // on applique X fois l'augmentation\n // ex. : si on lance l'appel en 2024, et qu'on génére un paiement pour 2026, on applique 2 fois l'augmentation\n // soit amount * yearlyPriceIncreasing * yearlyPriceIncreasing\n // soit amount * yearlyPriceIncreasing ^ nbYearsMore\n amount = amount * Math.pow(yearlyPriceIncreasing, nbYearsMore);\n }\n return amount;\n};\n\n/**\n// * @param {number} firstPaymentAmount - amount of the first payment (first regulation of the customer)\n * @param {Date} firstExerciceNonExpresssEndDate - end date of the first exercice non express\n * @param {number} idPrestation - prestation id\n * @param {number} idLegalForm - legal form id of the society\n * @param {boolean} isWithApplicationFees - if the prestation has application fees to paid\n * @param {IPrestationList} prestationList - type of prestation (hidden: 0, isCatalog: 1, isComptable: 1)\n * @param {number} idVat - vat id of society linked\n * @param {number} yearlyAmountNonExpress - yearly amount of non express prestation (HT)\n * @param {number} nextYearlyAmountNonExpress - yearly amount of non express prestation for next years (HT)\n * @param {PartialExercicePrestationExpress[]} listPartialExercicePrestationExpress - list of exercicePrestation linked to idPrestation -> used to get express\n * @param {IRegulation[]} listRegulations - list of regulations linked to idPrestation (TTC)\n * @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding\n */\nconst calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {\n const { idTypeBrand, goToClient, isWithApplicationFees, firstExerciceNonExpresssEndDate, idPrestation, idLegalForm, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;\n const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3/* || dayjs().date() >= 15 */\n ? dayjs().add(2, 'month').startOf('month').toDate()\n : dayjs().add(1, 'month').startOf('month').toDate();\n\n // On récupère la grille tarifaire pour savoir si les tarifs sont HT ou TTC \n // et pour connaitre le montant du coût de l'app\n if (!prestationList.id) throw new Error('idPrestationList manquant');\n const priceGrid = getPriceGrid(idTypeBrand, prestationList.id);\n if (!priceGrid) throw new Error('Impossible de trouver la grille tarifaire correspondante');\n const { applicationCost, priceWithTaxesIncluded } = priceGrid;\n const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : getTaxesIncludedAmount(applicationCost, idVat)) * 12;\n const applicationFeesAmountTTC = getApplicationFeesAmount(idLegalForm, idVat);\n\n if (prestationList?.isCatalog || !prestationList?.isComptable) throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');\n // if (!listRegulations?.length) throw new Error('List of regulations can not be empty');\n if (listPartialExercicePrestationExpress.length && listPartialExercicePrestationExpress?.some((ep: PartialExercicePrestationExpress) => !ep?.startDate)) throw new Error('Start date of some exercice are missing');\n if (!listRegulations?.every((r: IRegulation) => !!r?.amount || !!r?.amountUsed)) throw new Error('Amount and amountUsed are missing for regulations');\n\n const nbExoExpress = listPartialExercicePrestationExpress.length;\n const listPayments:PaymentAuto[] = [];\n\n // on récupère le/les premiers réglements effectués, non alloués\n let isApplicationFeesAlreadyPaid = false;\n const sumRegulations = listRegulations.reduce((acc: number, r:IRegulation) => {\n //Si la regulation est rattachée à un paymentExpectation, on récupère le détail\n // et on ne prend que les frais de dossier (applicationFee) + le montant de la compta (accountingFee)\n if (r.paymentsExpectation?.payload) {\n const payload = JSON.parse(r.paymentsExpectation?.payload);\n if (+payload?.applicationFee > 0) {\n isApplicationFeesAlreadyPaid = true;\n acc += +payload?.applicationFee;\n }\n if (+payload?.accountingFee > 0) acc += +payload?.accountingFee;\n return acc;\n } else {\n return acc + r.amount - r.amountUsed;\n }\n }, 0);\n let remainingAmount = -sumRegulations; //TTC\n let paymentDate = initializedPaymentDate;\n\n //On order les exercicePrestation par startDate ASC et id ASC\n listPartialExercicePrestationExpress.sort((a, b) => {\n const aStartDate = a?.startDate as Date;\n const bStartDate = b?.startDate as Date;\n return dayjs(aStartDate).diff(bStartDate);\n });\n\n //On ajoute un paiement initial correspondant à la somme des régulations\n if (sumRegulations) {\n listPayments.push({\n amount: isApplicationFeesAlreadyPaid ? sumRegulations - applicationFeesAmountTTC : sumRegulations, //TTC\n isPaid: true,\n datePayment: dayjs().toDate(),\n idPrestation,\n idPaymentMethod: listRegulations[0]?.idPaymentMethod ?? PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n\n // Si les frais de dossiers sont facturés ,\n if (isWithApplicationFees) {\n if (isApplicationFeesAlreadyPaid) {\n //et qu'ils ont déjà été payés\n // on ajoute un paiement sur le mois en cours\n listPayments.push({\n amount: applicationFeesAmountTTC, //TTC\n isPaid: true,\n datePayment: dayjs().toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n comment: 'Frais de dossier',\n });\n } else {\n //et qu'ils n'ont pas déjà été payés\n // on ajoute un paiement sur la première mensualité non express\n listPayments.push({\n amount: applicationFeesAmountTTC, //TTC\n isPaid: false,\n datePayment: dayjs().startOf('month').add(1, 'month').toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n comment: 'Frais de dossier',\n });\n }\n }\n \n // =========================\n // EXPRESS\n // =========================\n listPartialExercicePrestationExpress.forEach((exercicePrestation:PartialExercicePrestationExpress, indexEP: number) => {\n remainingAmount += !priceWithTaxesIncluded \n ? getTaxesIncludedAmount(exercicePrestation.totalAmount, idVat) \n : exercicePrestation.totalAmount; //TTC\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n if (remainingAmount <= 0) return;\n \n //express : on étale en countExpressMonthlyPayment (nb de mensualités)\n let remainingAmountByExercicePrestation = remainingAmount; //TTC\n let countExpressMonthlyPayment = exercicePrestation?.countExpressMonthlyPayment ?? 3; //TTC\n //Si un premier règlement est généré avec le montant des regulations, on le considère comme une mensualité (unioquement pour le premier express et la première mensualité)\n if (indexEP === 0 && sumRegulations > 0) countExpressMonthlyPayment -= 1;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countExpressMonthlyPayment; //TTC\n for (let index = 1; index <= countExpressMonthlyPayment; index++) {\n // On arrondis les 11 premières mensualités, mais on récupère le reste pour la dernière mensualité, pour éviter les centimes perdus en arrondis\n // et on applique le taux de tva de la société\n const amount = index < countExpressMonthlyPayment ? monthlyAmount : remainingAmountByExercicePrestation; //TTC\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exercicePrestation.endDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n remainingAmount = 0;\n });\n\n // =========================\n // NON EXPRESS\n // =========================\n // on lisse sur le nb de mois restants (avec au minimum 3 mensualités)\n // Si un seul exo express, alors on met les paiements de l'exo actuel en parallèle\n // sinon, ils sont à la suite des express\n if (nbExoExpress <= 1) paymentDate = initializedPaymentDate;\n let exerciceEndDate = dayjs(firstExerciceNonExpresssEndDate).toDate();\n\n let hasGeneratedWholeYear = false;\n let isFirstNonExpress = true;\n \n //On génère des paiements jusqu'à ce qu'un exercice soit entier (12 mois), non express\n while (!hasGeneratedWholeYear) {\n \n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n const exoAmount = isFirstNonExpress ? yearlyAmountNonExpress : nextYearlyAmountNonExpress;\n remainingAmount += priceWithTaxesIncluded ? exoAmount : getTaxesIncludedAmount(exoAmount, idVat);\n\n //TODO: CAS A TESTER : si sumRegulations couvre le premier exercice par exemple (cas rar mais à envisager)\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n // if (remainingAmount <= 0) {\n // continue;\n // }\n\n // Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total\n if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {\n remainingAmount -= applicationFeesAmountTTC;\n }\n\n let remainingAmountByExercicePrestation = remainingAmount;\n\n // - frais d'application dès les second exo non express\n if (!isFirstNonExpress) remainingAmountByExercicePrestation += applicationCostTotalTTC;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC\n\n if (monthlyAmount > 0) {\n for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {\n let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;\n \n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n amount = calculateFees(amount, goToClient, paymentDate);\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();\n }\n remainingAmount = 0;\n if (countMonthsBeforeExerciceEnd === 12) hasGeneratedWholeYear = true;\n isFirstNonExpress = false;\n }\n\n remainingAmount = 0;\n\n // =========================\n // JUSQU'EN DECEMBRE\n // =========================\n // On applique le taux de tva de la société, si besoin, selon la grille tarifaire\n remainingAmount += priceWithTaxesIncluded ? nextYearlyAmountNonExpress : getTaxesIncludedAmount(nextYearlyAmountNonExpress, idVat);\n\n let remainingAmountByExercicePrestation = remainingAmount;\n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n // - frais d'application dès les second exo non express\n remainingAmountByExercicePrestation += applicationCostTotalTTC;\n \n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;\n \n // Si aucun paiement généré, on stoppe là\n if (!listPayments.length) return [];\n\n while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11) {\n let amount = monthlyAmount;\n\n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n // - frais d'application dès les second exo non express\n amount = calculateFees(amount, goToClient, paymentDate);\n\n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n\n return listPayments;\n};\n\nexport {\n groupPaymentsByServiceType, calculatePaymentsAuto,\n};"]}
|
|
@@ -79,6 +79,13 @@ declare const calculatePrestationPriceWithPriceGrid: (idPrestationList: number,
|
|
|
79
79
|
monthNbr: number;
|
|
80
80
|
price: number;
|
|
81
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* From idLegalForm, get application fees amount (without taxes included if no idVat passed, or with taxes included calculated by given idVat)
|
|
84
|
+
* @param idLegalForm
|
|
85
|
+
* @param idVat
|
|
86
|
+
* @returns amount of application fees, without taxes included
|
|
87
|
+
*/
|
|
88
|
+
declare const getApplicationFeesAmount: (idLegalForm: number, idVat?: number) => number;
|
|
82
89
|
declare const calculatePrestationPrice: (idPrestationList: number, prestationList: IPrestationList, endDate: string, NbrMonth: number, turnover: number, rentsNumber: number, employeesNumber: number, associatesNumber: number, idTypeBrand: number, idVatRegime: number, pastBalanceSheet: boolean, optionsList: number[], totalPercentage: number, totalAmount: number, totalMonth: number, isWithApplicationFees: boolean, idTaxSystem: number, idLegalForm: number, isYearly?: boolean, isSubPrestation?: boolean, balanceSheetOffered?: number, exerciceList?: IExercice[]) => {
|
|
83
90
|
totalPrestation: number;
|
|
84
91
|
reduceMonth: number;
|
|
@@ -89,5 +96,5 @@ declare const calculatePrestationPrice: (idPrestationList: number, prestationLis
|
|
|
89
96
|
};
|
|
90
97
|
declare const getPrestationOptions: (idPrestationList: number) => PrestationOptionType[];
|
|
91
98
|
declare const isAbleToUpdatePrice: (idTypeBrand: number, idPrestationList: number, turnover: number, pastBalanceSheet: boolean) => boolean;
|
|
92
|
-
export { isOtherAccountingMissions, isOtherJuridicalMissions, isAdditionalPresta, isOtherSocialMission, isOnlyPrevi, isOnlySocial, isOnlyJuridic, isCreation, isFromStatutsExpress, isExpress, calculateScoringOfPrestation, calculatePrestationPrice, getPrestationOptions, isAbleToUpdatePrice, calculatePrestationPriceWithPriceGrid, };
|
|
99
|
+
export { isOtherAccountingMissions, isOtherJuridicalMissions, isAdditionalPresta, isOtherSocialMission, isOnlyPrevi, isOnlySocial, isOnlyJuridic, isCreation, isFromStatutsExpress, isExpress, calculateScoringOfPrestation, calculatePrestationPrice, getPrestationOptions, isAbleToUpdatePrice, calculatePrestationPriceWithPriceGrid, getApplicationFeesAmount, };
|
|
93
100
|
//# sourceMappingURL=prestation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prestation.d.ts","sourceRoot":"","sources":["../../../ts/utils/prestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"prestation.d.ts","sourceRoot":"","sources":["../../../ts/utils/prestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGnE,OAAO,EAAoB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gCAAgC,CAAC;AAexF,KAAK,SAA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
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculatePrestationPriceWithPriceGrid = exports.isAbleToUpdatePrice = exports.getPrestationOptions = exports.calculatePrestationPrice = exports.calculateScoringOfPrestation = exports.isExpress = exports.isFromStatutsExpress = exports.isCreation = exports.isOnlyJuridic = exports.isOnlySocial = exports.isOnlyPrevi = exports.isOtherSocialMission = exports.isAdditionalPresta = exports.isOtherJuridicalMissions = exports.isOtherAccountingMissions = exports.getPriceGrid = void 0;
|
|
3
|
+
exports.getApplicationFeesAmount = exports.calculatePrestationPriceWithPriceGrid = exports.isAbleToUpdatePrice = exports.getPrestationOptions = exports.calculatePrestationPrice = exports.calculateScoringOfPrestation = exports.isExpress = exports.isFromStatutsExpress = exports.isCreation = exports.isOnlyJuridic = exports.isOnlySocial = exports.isOnlyPrevi = exports.isOtherSocialMission = exports.isAdditionalPresta = exports.isOtherJuridicalMissions = exports.isOtherAccountingMissions = exports.getPriceGrid = void 0;
|
|
4
|
+
const utils_1 = require("./vat/utils");
|
|
4
5
|
const noLodash_1 = require("./noLodash");
|
|
5
6
|
const PrestationType_1 = require("../types/Enum/PrestationType");
|
|
6
7
|
const LegalForm_1 = require("../types/Enum/LegalForm");
|
|
@@ -78,7 +79,7 @@ const getPriceGrid = (idTypeBrand, idPrestationList) => {
|
|
|
78
79
|
return currentPriceGrid;
|
|
79
80
|
};
|
|
80
81
|
exports.getPriceGrid = getPriceGrid;
|
|
81
|
-
const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMonth, turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, isYearly, totalMonth, idTaxSystem, idLegalForm, exerciceNbr, balanceSheetOffered = 0) => {
|
|
82
|
+
const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMonth, /* Nbr de mois dans l'exercice */ turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, isYearly, /* Prestation annuel ou mensuel */ totalMonth, /* Nbr de moiis offer */ idTaxSystem, idLegalForm, exerciceNbr, balanceSheetOffered = 0) => {
|
|
82
83
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
83
84
|
let totalPrestation = 0;
|
|
84
85
|
let reduceMonth = 0;
|
|
@@ -102,6 +103,7 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
|
|
|
102
103
|
if (currentPriceGrid.taxSystem && idTaxSystem)
|
|
103
104
|
taxSystemPrice = (_f = (_e = currentPriceGrid.taxSystem) === null || _e === void 0 ? void 0 : _e.find(tax => tax.id === idTaxSystem)) === null || _f === void 0 ? void 0 : _f.price;
|
|
104
105
|
/* Gestion des montants */
|
|
106
|
+
/* Récupératioin des prix mensuels */
|
|
105
107
|
if (currentPriceGrid.turnoverMonthly && !isYearly)
|
|
106
108
|
monthlyPrice = (_h = (_g = currentPriceGrid.turnoverMonthly) === null || _g === void 0 ? void 0 : _g.find(turn => turnover < turn.turnoverValue)) === null || _h === void 0 ? void 0 : _h.price;
|
|
107
109
|
else if (currentPriceGrid.properties)
|
|
@@ -113,6 +115,7 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
|
|
|
113
115
|
else if (currentPriceGrid.employeeByLegalForm) {
|
|
114
116
|
monthlyPrice = (_p = (_o = currentPriceGrid.employeeByLegalForm) === null || _o === void 0 ? void 0 : _o.find(emp => emp.idLegalForm === idLegalForm)) === null || _p === void 0 ? void 0 : _p.price;
|
|
115
117
|
monthlyPrice = monthlyPrice ? monthlyPrice * employeesNumber : 0;
|
|
118
|
+
/* Récupération des prix annuels */
|
|
116
119
|
}
|
|
117
120
|
else if (currentPriceGrid.turnoverYearly && isYearly)
|
|
118
121
|
yearlyPrice = (_r = (_q = currentPriceGrid.turnoverYearly) === null || _q === void 0 ? void 0 : _q.find(turn => turnover < turn.turnoverValue)) === null || _r === void 0 ? void 0 : _r.price;
|
|
@@ -126,6 +129,7 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
|
|
|
126
129
|
yearlyPrice = (_z = (_y = currentPriceGrid.legalForm) === null || _y === void 0 ? void 0 : _y.find(form => form.idLegalForm === idLegalForm)) === null || _z === void 0 ? void 0 : _z.price;
|
|
127
130
|
else if (currentPriceGrid.exerciceNbr)
|
|
128
131
|
yearlyPrice = (_1 = (_0 = currentPriceGrid.exerciceNbr) === null || _0 === void 0 ? void 0 : _0.find(el => el.minimum <= exerciceNbr && exerciceNbr <= el.maximum)) === null || _1 === void 0 ? void 0 : _1.price;
|
|
132
|
+
/* Calcul du prix mensuel final */
|
|
129
133
|
finalMonthlyPrice = (monthlyPrice ? monthlyPrice : 0) + (vatRegimePrice ? vatRegimePrice : 0) + (taxSystemPrice ? taxSystemPrice : 0);
|
|
130
134
|
/* Gestion des mois */
|
|
131
135
|
let cloturedPast = false;
|
|
@@ -142,13 +146,16 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
|
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
}
|
|
149
|
+
/* Gestion des offres, mois offer */
|
|
145
150
|
if (totalMonth > 0) {
|
|
146
151
|
if (monthlyNbr && ((monthNbr - totalMonth) < (monthlyNbr === null || monthlyNbr === void 0 ? void 0 : monthlyNbr.minimum)))
|
|
147
152
|
canBeCreated = false;
|
|
148
153
|
monthNbr = monthNbr - totalMonth;
|
|
149
154
|
recalculateMonthly = true;
|
|
150
155
|
}
|
|
156
|
+
/* Calcul du nombre de mois soustraient */
|
|
151
157
|
reduceMonth = (monthNbr === NbrMonth - totalMonth ? totalMonth : 0);
|
|
158
|
+
/* Gestion des offres, bilan offer */
|
|
152
159
|
if (balanceSheetOffered > 0) {
|
|
153
160
|
yearlyPrice = undefined;
|
|
154
161
|
recalculateMonthly = false;
|
|
@@ -157,7 +164,7 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
|
|
|
157
164
|
/* Prix Final */
|
|
158
165
|
totalPrestation = (yearlyPrice ? yearlyPrice : finalMonthlyPrice * monthNbr);
|
|
159
166
|
}
|
|
160
|
-
return { totalPrestation, reduceMonth, canBeCreated, monthNbr: yearlyPrice ? 0 : recalculateMonthly ? NbrMonth : monthNbr, price: yearlyPrice ? yearlyPrice : recalculateMonthly ? (totalPrestation /
|
|
167
|
+
return { totalPrestation, reduceMonth, canBeCreated, monthNbr: yearlyPrice ? 0 : recalculateMonthly ? NbrMonth : monthNbr, price: yearlyPrice ? yearlyPrice : recalculateMonthly ? (totalPrestation / monthNbr) : (finalMonthlyPrice ? finalMonthlyPrice : 0) };
|
|
161
168
|
};
|
|
162
169
|
exports.calculatePrestationPriceWithPriceGrid = calculatePrestationPriceWithPriceGrid;
|
|
163
170
|
const calculatePrestationPriceWithPrestationList = (prestationList) => {
|
|
@@ -165,7 +172,24 @@ const calculatePrestationPriceWithPrestationList = (prestationList) => {
|
|
|
165
172
|
totalPrestation = (prestationList === null || prestationList === void 0 ? void 0 : prestationList.price) || 0;
|
|
166
173
|
return totalPrestation;
|
|
167
174
|
};
|
|
168
|
-
|
|
175
|
+
/**
|
|
176
|
+
* From idLegalForm, get application fees amount (without taxes included if no idVat passed, or with taxes included calculated by given idVat)
|
|
177
|
+
* @param idLegalForm
|
|
178
|
+
* @param idVat
|
|
179
|
+
* @returns amount of application fees, without taxes included
|
|
180
|
+
*/
|
|
181
|
+
const getApplicationFeesAmount = (idLegalForm, idVat) => {
|
|
182
|
+
let applicationFeesAmount = 50;
|
|
183
|
+
if (idLegalForm === LegalForm_1.LegalFormTypeEnum.SCI)
|
|
184
|
+
applicationFeesAmount = 150;
|
|
185
|
+
//Sans tva, on envoie le montant HT
|
|
186
|
+
if (!idVat)
|
|
187
|
+
return applicationFeesAmount;
|
|
188
|
+
//Avec tva, on envoie le montant TTC
|
|
189
|
+
return (0, utils_1.getTaxesIncludedAmount)(applicationFeesAmount, idVat);
|
|
190
|
+
};
|
|
191
|
+
exports.getApplicationFeesAmount = getApplicationFeesAmount;
|
|
192
|
+
const calculatePrestationPrice = (idPrestationList, prestationList, endDate, NbrMonth, /* Nbr de mois dans l'exercice */ turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, optionsList, totalPercentage, /* total pourcentage offer (%) */ totalAmount, /* total montant offer (€) */ totalMonth, /* total mois offer (mois) */ isWithApplicationFees, /* frais de dossier */ idTaxSystem, idLegalForm, isYearly = false, /* prestation annuel ou mensuel */ isSubPrestation = false, balanceSheetOffered = 0, exerciceList = []) => {
|
|
169
193
|
let totalPrestation = 0;
|
|
170
194
|
let reduceMonth = 0;
|
|
171
195
|
let canBeCreated = true;
|
|
@@ -213,10 +237,14 @@ const calculatePrestationPrice = (idPrestationList, prestationList, endDate, Nbr
|
|
|
213
237
|
if ([PrestationType_1.PrestationType.CREATION_SOCIETE].includes(idPrestationList) && !isSubPrestation)
|
|
214
238
|
totalPrestation += 50;
|
|
215
239
|
}
|
|
240
|
+
/* Gestion des offres */
|
|
241
|
+
/* Offre montant offer */
|
|
216
242
|
if (totalAmount > 0)
|
|
217
243
|
totalPrestation = totalPrestation - totalAmount;
|
|
244
|
+
/* Offre pourcentage offer */
|
|
218
245
|
if (totalPercentage > 0)
|
|
219
246
|
totalPrestation = totalPrestation - (totalPrestation * (totalPercentage / 100));
|
|
247
|
+
/* Gesstioin du prix minimum acceptable pour la prestation */
|
|
220
248
|
if (prestationList.minimumPrice && totalPrestation < prestationList.minimumPrice)
|
|
221
249
|
totalPrestation = prestationList.minimumPrice;
|
|
222
250
|
/* Gestion des options */
|
|
@@ -230,11 +258,10 @@ const calculatePrestationPrice = (idPrestationList, prestationList, endDate, Nbr
|
|
|
230
258
|
});
|
|
231
259
|
}
|
|
232
260
|
totalPrestation += (OptionTotalPrice ? OptionTotalPrice : 0);
|
|
261
|
+
/* Gestion des frais de dossier */
|
|
233
262
|
if (isWithApplicationFees) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
else
|
|
237
|
-
totalPrestation += 50;
|
|
263
|
+
const applicationFeesAmount = getApplicationFeesAmount(idLegalForm);
|
|
264
|
+
totalPrestation += applicationFeesAmount;
|
|
238
265
|
}
|
|
239
266
|
const calculDetail = `${monthNbr > 0 ? monthNbr + ' mois x ' + (Math.round(price * 100) / 100) + '€' : (Math.round(price * 100) / 100) + '€'} ${totalAmount > 0 ? '- ' + totalAmount + '€' : ''} ${totalPercentage > 0 ? '- ' + totalPercentage + '%' : ''} ${isWithApplicationFees ? '+ 50€' : ''}`;
|
|
240
267
|
return { totalPrestation, reduceMonth, canBeCreated, calculDetail, monthlyPrice: monthNbr > 0 ? (Math.round(price * 100) / 100) + '€/mois' : (Math.round(price * 100) / 100) + '€', price };
|