@silexpert/core 1.1.310 → 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.
Files changed (90) hide show
  1. package/dist/cjs/api/resources/Rating.d.ts +2 -7
  2. package/dist/cjs/api/resources/Rating.d.ts.map +1 -1
  3. package/dist/cjs/api/resources/Rating.js +5 -7
  4. package/dist/cjs/api/resources/Rating.js.map +1 -1
  5. package/dist/cjs/types/Enum/BalanceSheet.d.ts +21 -0
  6. package/dist/cjs/types/Enum/BalanceSheet.d.ts.map +1 -1
  7. package/dist/cjs/types/Enum/BalanceSheet.js +27 -1
  8. package/dist/cjs/types/Enum/BalanceSheet.js.map +1 -1
  9. package/dist/cjs/types/Enum/Contract.d.ts +2 -1
  10. package/dist/cjs/types/Enum/Contract.d.ts.map +1 -1
  11. package/dist/cjs/types/Enum/Contract.js +2 -0
  12. package/dist/cjs/types/Enum/Contract.js.map +1 -1
  13. package/dist/cjs/types/Enum/MailAuto.d.ts +3 -1
  14. package/dist/cjs/types/Enum/MailAuto.d.ts.map +1 -1
  15. package/dist/cjs/types/Enum/MailAuto.js +2 -0
  16. package/dist/cjs/types/Enum/MailAuto.js.map +1 -1
  17. package/dist/cjs/types/Enum/PriceGridClementine.js +1 -1
  18. package/dist/cjs/types/Enum/PriceGridClementine.js.map +1 -1
  19. package/dist/cjs/types/Enum/Supervision.d.ts +0 -2
  20. package/dist/cjs/types/Enum/Supervision.d.ts.map +1 -1
  21. package/dist/cjs/types/Enum/Supervision.js +12 -12
  22. package/dist/cjs/types/Enum/Supervision.js.map +1 -1
  23. package/dist/cjs/types/Interface/api/payment/Util.d.ts +1 -0
  24. package/dist/cjs/types/Interface/api/payment/Util.d.ts.map +1 -1
  25. package/dist/cjs/types/Interface/api/payment/Util.js.map +1 -1
  26. package/dist/cjs/types/Interface/api/supervision/Query.d.ts +4 -2
  27. package/dist/cjs/types/Interface/api/supervision/Query.d.ts.map +1 -1
  28. package/dist/cjs/types/Interface/api/supervision/Query.js +20 -8
  29. package/dist/cjs/types/Interface/api/supervision/Query.js.map +1 -1
  30. package/dist/cjs/types/Interface/models/ISocialDetail.d.ts +1 -0
  31. package/dist/cjs/types/Interface/models/ISocialDetail.d.ts.map +1 -1
  32. package/dist/cjs/types/Interface/models/ISocialDetail.js.map +1 -1
  33. package/dist/cjs/utils/payment.d.ts.map +1 -1
  34. package/dist/cjs/utils/payment.js +34 -15
  35. package/dist/cjs/utils/payment.js.map +1 -1
  36. package/dist/cjs/utils/prestation.d.ts +8 -1
  37. package/dist/cjs/utils/prestation.d.ts.map +1 -1
  38. package/dist/cjs/utils/prestation.js +35 -8
  39. package/dist/cjs/utils/prestation.js.map +1 -1
  40. package/dist/mjs/api/resources/Rating.d.ts +2 -7
  41. package/dist/mjs/api/resources/Rating.d.ts.map +1 -1
  42. package/dist/mjs/api/resources/Rating.js +5 -7
  43. package/dist/mjs/api/resources/Rating.js.map +1 -1
  44. package/dist/mjs/types/Enum/BalanceSheet.d.ts +21 -0
  45. package/dist/mjs/types/Enum/BalanceSheet.d.ts.map +1 -1
  46. package/dist/mjs/types/Enum/BalanceSheet.js +26 -0
  47. package/dist/mjs/types/Enum/BalanceSheet.js.map +1 -1
  48. package/dist/mjs/types/Enum/Contract.d.ts +2 -1
  49. package/dist/mjs/types/Enum/Contract.d.ts.map +1 -1
  50. package/dist/mjs/types/Enum/Contract.js +2 -0
  51. package/dist/mjs/types/Enum/Contract.js.map +1 -1
  52. package/dist/mjs/types/Enum/MailAuto.d.ts +3 -1
  53. package/dist/mjs/types/Enum/MailAuto.d.ts.map +1 -1
  54. package/dist/mjs/types/Enum/MailAuto.js +2 -0
  55. package/dist/mjs/types/Enum/MailAuto.js.map +1 -1
  56. package/dist/mjs/types/Enum/PriceGridClementine.js +1 -1
  57. package/dist/mjs/types/Enum/PriceGridClementine.js.map +1 -1
  58. package/dist/mjs/types/Enum/Supervision.d.ts +0 -2
  59. package/dist/mjs/types/Enum/Supervision.d.ts.map +1 -1
  60. package/dist/mjs/types/Enum/Supervision.js +12 -12
  61. package/dist/mjs/types/Enum/Supervision.js.map +1 -1
  62. package/dist/mjs/types/Interface/api/payment/Util.d.ts +1 -0
  63. package/dist/mjs/types/Interface/api/payment/Util.d.ts.map +1 -1
  64. package/dist/mjs/types/Interface/api/payment/Util.js.map +1 -1
  65. package/dist/mjs/types/Interface/api/supervision/Query.d.ts +4 -2
  66. package/dist/mjs/types/Interface/api/supervision/Query.d.ts.map +1 -1
  67. package/dist/mjs/types/Interface/api/supervision/Query.js +24 -10
  68. package/dist/mjs/types/Interface/api/supervision/Query.js.map +1 -1
  69. package/dist/mjs/types/Interface/models/ISocialDetail.d.ts +1 -0
  70. package/dist/mjs/types/Interface/models/ISocialDetail.d.ts.map +1 -1
  71. package/dist/mjs/types/Interface/models/ISocialDetail.js.map +1 -1
  72. package/dist/mjs/utils/payment.d.ts.map +1 -1
  73. package/dist/mjs/utils/payment.js +35 -17
  74. package/dist/mjs/utils/payment.js.map +1 -1
  75. package/dist/mjs/utils/prestation.d.ts +8 -1
  76. package/dist/mjs/utils/prestation.d.ts.map +1 -1
  77. package/dist/mjs/utils/prestation.js +34 -8
  78. package/dist/mjs/utils/prestation.js.map +1 -1
  79. package/package.json +1 -1
  80. package/ts/api/resources/Rating.ts +6 -8
  81. package/ts/types/Enum/BalanceSheet.ts +28 -1
  82. package/ts/types/Enum/Contract.ts +2 -0
  83. package/ts/types/Enum/MailAuto.ts +2 -0
  84. package/ts/types/Enum/PriceGridClementine.ts +1 -1
  85. package/ts/types/Enum/Supervision.ts +4 -4
  86. package/ts/types/Interface/api/payment/Util.ts +1 -0
  87. package/ts/types/Interface/api/supervision/Query.ts +17 -7
  88. package/ts/types/Interface/models/ISocialDetail.ts +1 -0
  89. package/ts/utils/payment.ts +34 -17
  90. package/ts/utils/prestation.ts +43 -15
@@ -5,13 +5,15 @@ export declare class QueryPaginatedBalanceSheetSupervision extends RequiredQuery
5
5
  state?: number | null;
6
6
  balanceSheetState?: number[];
7
7
  bankCollectingState?: number[];
8
- closingTime?: number | null;
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,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAK5B,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;IAMxB,cAAc,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAKhC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAKxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAElC"}
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"}
@@ -17,14 +17,16 @@ export class QueryPaginatedBalanceSheetSupervision extends RequiredQueryPaginate
17
17
  state;
18
18
  balanceSheetState;
19
19
  bankCollectingState;
20
- closingTime;
20
+ typeBrand;
21
+ totalRange;
21
22
  month;
22
23
  endDate;
23
24
  year;
24
25
  isBack;
25
- displayArchive;
26
26
  userSelected;
27
27
  expertSelected;
28
+ orderBy;
29
+ descending;
28
30
  }
29
31
  __decorate([
30
32
  ApiPropertyOptional(),
@@ -56,12 +58,18 @@ __decorate([
56
58
  IsArray(),
57
59
  __metadata("design:type", Array)
58
60
  ], QueryPaginatedBalanceSheetSupervision.prototype, "bankCollectingState", void 0);
61
+ __decorate([
62
+ ApiPropertyOptional(),
63
+ IsOptional(),
64
+ IsArray(),
65
+ __metadata("design:type", Array)
66
+ ], QueryPaginatedBalanceSheetSupervision.prototype, "typeBrand", void 0);
59
67
  __decorate([
60
68
  ApiPropertyOptional(),
61
69
  IsOptional(),
62
70
  IsInt(),
63
71
  __metadata("design:type", Object)
64
- ], QueryPaginatedBalanceSheetSupervision.prototype, "closingTime", void 0);
72
+ ], QueryPaginatedBalanceSheetSupervision.prototype, "totalRange", void 0);
65
73
  __decorate([
66
74
  ApiPropertyOptional(),
67
75
  IsOptional(),
@@ -87,13 +95,6 @@ __decorate([
87
95
  ToBoolean(),
88
96
  __metadata("design:type", Object)
89
97
  ], QueryPaginatedBalanceSheetSupervision.prototype, "isBack", void 0);
90
- __decorate([
91
- ApiPropertyOptional(),
92
- IsOptional(),
93
- IsBoolean(),
94
- ToBoolean(),
95
- __metadata("design:type", Object)
96
- ], QueryPaginatedBalanceSheetSupervision.prototype, "displayArchive", void 0);
97
98
  __decorate([
98
99
  ApiPropertyOptional(),
99
100
  IsOptional(),
@@ -106,4 +107,17 @@ __decorate([
106
107
  IsInt(),
107
108
  __metadata("design:type", Object)
108
109
  ], QueryPaginatedBalanceSheetSupervision.prototype, "expertSelected", void 0);
110
+ __decorate([
111
+ ApiPropertyOptional(),
112
+ IsOptional(),
113
+ IsString(),
114
+ __metadata("design:type", Object)
115
+ ], QueryPaginatedBalanceSheetSupervision.prototype, "orderBy", void 0);
116
+ __decorate([
117
+ ApiPropertyOptional(),
118
+ IsOptional(),
119
+ IsBoolean(),
120
+ ToBoolean(),
121
+ __metadata("design:type", Object)
122
+ ], QueryPaginatedBalanceSheetSupervision.prototype, "descending", void 0);
109
123
  //# sourceMappingURL=Query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Query.js","sourceRoot":"","sources":["../../../../../../ts/types/Interface/api/supervision/Query.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,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;;qEACc;AAE1B;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,SAAS,EAAE;IACX,SAAS,EAAE;;6EACsB;AAElC;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,OAAO,EAAE;;2EACgB;AAE1B;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,KAAK,EAAE;;6EACyB","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 @IsInt()\n closingTime?: 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 @IsBoolean()\n @ToBoolean()\n displayArchive?: 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}"]}
1
+ {"version":3,"file":"Query.js","sourceRoot":"","sources":["../../../../../../ts/types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;AAExB;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,KAAK,EAAE;;sEACkB;AAE1B;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,KAAK,EAAE;;mEACe;AAEvB;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,SAAS,EAAE;IACX,SAAS,EAAE;;qEACc;AAE1B;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,OAAO,EAAE;;2EACgB;AAE1B;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,KAAK,EAAE;;6EACyB;AAEjC;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,QAAQ,EAAE;;sEACe;AAE1B;IAAC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,SAAS,EAAE;IACX,SAAS,EAAE;;yEACkB","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}"]}
@@ -4,6 +4,7 @@ export interface ISocialDetail {
4
4
  priceDsn: number;
5
5
  ras: boolean;
6
6
  freqCibt: number | null;
7
+ idPaymentMethod: number;
7
8
  idSociety: number;
8
9
  createdAt?: Date | null;
9
10
  updatedAt?: Date | null;
@@ -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,EAA6C,MAAM,UAAU,CAAC;AAK/I,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,EAsNxE,CAAC;AAEF,OAAO,EACL,0BAA0B,EAAE,qBAAqB,GAClD,CAAC"}
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"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
- import { PaymentMethod, getTaxesIncludedAmount, LegalFormTypeEnum } from '../types';
2
+ import { PaymentMethod, getTaxesIncludedAmount } from '../types';
3
3
  import * as dayjs from 'dayjs';
4
- import { getPriceGrid } from './prestation';
4
+ import { getApplicationFeesAmount, getPriceGrid } from './prestation';
5
5
  /**
6
6
  * A partir d'une liste de payment (avec include jusqu'à prestationList,
7
7
  * avec en attributs 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther')
@@ -89,7 +89,7 @@ const calculatePaymentsAuto = (params) => {
89
89
  throw new Error('Impossible de trouver la grille tarifaire correspondante');
90
90
  const { applicationCost, priceWithTaxesIncluded } = priceGrid;
91
91
  const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : getTaxesIncludedAmount(applicationCost, idVat)) * 12;
92
- const applicationFeesAmount = (idLegalForm === LegalFormTypeEnum.SCI) ? 150 : 50;
92
+ const applicationFeesAmountTTC = getApplicationFeesAmount(idLegalForm, idVat);
93
93
  if (prestationList?.isCatalog || !prestationList?.isComptable)
94
94
  throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');
95
95
  // if (!listRegulations?.length) throw new Error('List of regulations can not be empty');
@@ -108,6 +108,7 @@ const calculatePaymentsAuto = (params) => {
108
108
  const payload = JSON.parse(r.paymentsExpectation?.payload);
109
109
  if (+payload?.applicationFee > 0) {
110
110
  isApplicationFeesAlreadyPaid = true;
111
+ acc += +payload?.applicationFee;
111
112
  }
112
113
  if (+payload?.accountingFee > 0)
113
114
  acc += +payload?.accountingFee;
@@ -128,25 +129,42 @@ const calculatePaymentsAuto = (params) => {
128
129
  //On ajoute un paiement initial correspondant à la somme des régulations
129
130
  if (sumRegulations) {
130
131
  listPayments.push({
131
- amount: sumRegulations,
132
+ amount: isApplicationFeesAlreadyPaid ? sumRegulations - applicationFeesAmountTTC : sumRegulations,
132
133
  isPaid: true,
133
134
  datePayment: dayjs().toDate(),
134
135
  idPrestation,
135
- idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,
136
+ idPaymentMethod: listRegulations[0]?.idPaymentMethod ?? PaymentMethod.DIRECT_DEBIT.id,
136
137
  closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
137
138
  });
138
139
  }
139
- // Si les frais de dossiers sont facturés et qu'ils n'ont pas déjà été payés,
140
- // on ajoute un paiement sur la première mensualité non express
141
- if (isWithApplicationFees && !isApplicationFeesAlreadyPaid) {
142
- listPayments.push({
143
- amount: getTaxesIncludedAmount(applicationFeesAmount, idVat),
144
- isPaid: false,
145
- datePayment: dayjs().startOf('month').add(1, 'month').toDate(),
146
- idPrestation,
147
- idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,
148
- closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
149
- });
140
+ // Si les frais de dossiers sont facturés ,
141
+ if (isWithApplicationFees) {
142
+ if (isApplicationFeesAlreadyPaid) {
143
+ //et qu'ils ont déjà été payés
144
+ // on ajoute un paiement sur le mois en cours
145
+ listPayments.push({
146
+ amount: applicationFeesAmountTTC,
147
+ isPaid: true,
148
+ datePayment: dayjs().toDate(),
149
+ idPrestation,
150
+ idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,
151
+ closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
152
+ comment: 'Frais de dossier',
153
+ });
154
+ }
155
+ else {
156
+ //et qu'ils n'ont pas déjà été payés
157
+ // on ajoute un paiement sur la première mensualité non express
158
+ listPayments.push({
159
+ amount: applicationFeesAmountTTC,
160
+ isPaid: false,
161
+ datePayment: dayjs().startOf('month').add(1, 'month').toDate(),
162
+ idPrestation,
163
+ idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,
164
+ closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,
165
+ comment: 'Frais de dossier',
166
+ });
167
+ }
150
168
  }
151
169
  // =========================
152
170
  // EXPRESS
@@ -207,7 +225,7 @@ const calculatePaymentsAuto = (params) => {
207
225
  // }
208
226
  // Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total
209
227
  if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {
210
- remainingAmount -= getTaxesIncludedAmount(applicationFeesAmount, idVat);
228
+ remainingAmount -= applicationFeesAmountTTC;
211
229
  }
212
230
  let remainingAmountByExercicePrestation = remainingAmount;
213
231
  // - 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,OAAO,EAAgD,aAAa,EAAe,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,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,MAAM,CAAC,GAAG,GAAG;YACtC,WAAW,EAAE,WAAW;YACxB,YAAY;YACZ,eAAe,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE;YAC9C,WAAW,EAAE,eAAe;SAC7B,CAAC,CAAC;QACH,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;KAC5E;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EACL,0BAA0B,EAAE,qBAAqB,GAClD,CAAC","sourcesContent":["'use strict';\n\nimport { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount, LegalFormTypeEnum } from '../types';\nimport * as dayjs from 'dayjs';\nimport { PartialExercicePrestationExpress } from '../types/Interface/api/payment/Util';\nimport { getPriceGrid } from './prestation';\n\ninterface PaymentsWithList extends IPayment {\n type: 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther',\n listPayments: IPayment[]\n}\n\n/**\n * A partir d'une liste de payment (avec include jusqu'à prestationList, \n * avec en attributs 'isComptable' | 'isJuridique' | 'isSocial' | 'isOther')\n * permet de récupérer uniquement le premier paiement de chaque type \n * et les autres payments dans listPayments\n * avec possibilité de filtrer avec le tableau de filtres\n * @param payments \n * @param types \n * @returns \n */\nconst groupPaymentsByServiceType = (payments: IPayment[], types: ('isComptable' | 'isJuridique' | 'isSocial' | 'isOther')[] = ['isComptable', 'isJuridique', 'isSocial', 'isOther']): PaymentsWithList[] => {\n const prestaComptable = payments.filter((el) => el?.paymentsPrestations?.prestationsList?.isComptable ?? false);\n const prestaSocial = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isSocial);\n const prestaJuridique = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && el?.paymentsPrestations?.prestationsList?.isJuridique);\n const prestaOther = payments.filter((el) => !el?.paymentsPrestations?.prestationsList?.isComptable && !el?.paymentsPrestations?.prestationsList?.isJuridique && !el?.paymentsPrestations?.prestationsList?.isSocial);\n \n const societyPayment: PaymentsWithList[] = [];\n if (prestaComptable.length && types.includes('isComptable')) {\n societyPayment.push({\n ...prestaComptable[0], // Données de base\n type: 'isComptable',\n listPayments: prestaComptable,\n });\n }\n if (prestaSocial.length && types.includes('isSocial')) {\n societyPayment.push({\n ...prestaSocial[0], // Données de base\n type: 'isSocial',\n listPayments: prestaSocial,\n });\n }\n if (prestaJuridique.length && types.includes('isJuridique')) {\n societyPayment.push({\n ...prestaJuridique[0], // Données de base\n type: 'isJuridique',\n listPayments: prestaJuridique,\n });\n }\n if (prestaOther.length && types.includes('isOther')) {\n societyPayment.push({\n ...prestaOther[0], // Données de base\n type: 'isOther',\n listPayments: prestaOther,\n });\n }\n return societyPayment;\n};\n\nconst calculateFees = (amount: number, goToClient: Date, paymentDate: Date):number => {\n const yearlyPriceIncreasing = 1.0275;\n\n const oneYearLessIfIn3LastMonthsOfYear = dayjs(goToClient).month() >= 9 ? 1 : 0;\n\n if (dayjs(paymentDate).year() - dayjs().year() > 0) {\n const nbYearsMore = dayjs(paymentDate).year() - dayjs().year() - oneYearLessIfIn3LastMonthsOfYear;\n // on applique X fois l'augmentation\n // ex. : si on lance l'appel en 2024, et qu'on génére un paiement pour 2026, on applique 2 fois l'augmentation\n // soit amount * yearlyPriceIncreasing * yearlyPriceIncreasing\n // soit amount * yearlyPriceIncreasing ^ nbYearsMore\n amount = amount * Math.pow(yearlyPriceIncreasing, nbYearsMore);\n }\n return amount;\n};\n\n/**\n// * @param {number} firstPaymentAmount - amount of the first payment (first regulation of the customer)\n * @param {Date} firstExerciceNonExpresssEndDate - end date of the first exercice non express\n * @param {number} idPrestation - prestation id\n * @param {number} idLegalForm - legal form id of the society\n * @param {boolean} isWithApplicationFees - if the prestation has application fees to paid\n * @param {IPrestationList} prestationList - type of prestation (hidden: 0, isCatalog: 1, isComptable: 1)\n * @param {number} idVat - vat id of society linked\n * @param {number} yearlyAmountNonExpress - yearly amount of non express prestation (HT)\n * @param {number} nextYearlyAmountNonExpress - yearly amount of non express prestation for next years (HT)\n * @param {PartialExercicePrestationExpress[]} listPartialExercicePrestationExpress - list of exercicePrestation linked to idPrestation -> used to get express\n * @param {IRegulation[]} listRegulations - list of regulations linked to idPrestation (TTC)\n * @returns { IPayment[] } list of payment to create for billing auto, after each presta go to onBoarding\n */\nconst calculatePaymentsAuto = (params: ParamsForPaymentsAuto):PaymentAuto[] => {\n const { idTypeBrand, goToClient, isWithApplicationFees, firstExerciceNonExpresssEndDate, idPrestation, idLegalForm, prestationList, idVat, yearlyAmountNonExpress, nextYearlyAmountNonExpress, listPartialExercicePrestationExpress, listRegulations } = params;\n const initializedPaymentDate = dayjs().endOf('month').diff(dayjs(), 'day') < 3/* || dayjs().date() >= 15 */\n ? dayjs().add(2, 'month').startOf('month').toDate()\n : dayjs().add(1, 'month').startOf('month').toDate();\n\n // On récupère la grille tarifaire pour savoir si les tarifs sont HT ou TTC \n // et pour connaitre le montant du coût de l'app\n if (!prestationList.id) throw new Error('idPrestationList manquant');\n const priceGrid = getPriceGrid(idTypeBrand, prestationList.id);\n if (!priceGrid) throw new Error('Impossible de trouver la grille tarifaire correspondante');\n const { applicationCost, priceWithTaxesIncluded } = priceGrid;\n const applicationCostTotalTTC = (priceWithTaxesIncluded ? applicationCost : getTaxesIncludedAmount(applicationCost, idVat)) * 12;\n const applicationFeesAmount = (idLegalForm === LegalFormTypeEnum.SCI) ? 150 : 50;\n\n if (prestationList?.isCatalog || !prestationList?.isComptable) throw new Error('Ce type de prestation ne correspond pas aux conditions attendues.');\n // if (!listRegulations?.length) throw new Error('List of regulations can not be empty');\n if (listPartialExercicePrestationExpress.length && listPartialExercicePrestationExpress?.some((ep: PartialExercicePrestationExpress) => !ep?.startDate)) throw new Error('Start date of some exercice are missing');\n if (!listRegulations?.every((r: IRegulation) => !!r?.amount || !!r?.amountUsed)) throw new Error('Amount and amountUsed are missing for regulations');\n\n const nbExoExpress = listPartialExercicePrestationExpress.length;\n const listPayments:PaymentAuto[] = [];\n\n // on récupère le/les premiers réglements effectués, non alloués\n let isApplicationFeesAlreadyPaid = false;\n const sumRegulations = listRegulations.reduce((acc: number, r:IRegulation) => {\n //Si la regulation est rattachée à un paymentExpectation, on récupère le détail\n // et on ne prend que les frais de dossier (applicationFee) + le montant de la compta (accountingFee)\n if (r.paymentsExpectation?.payload) {\n const payload = JSON.parse(r.paymentsExpectation?.payload);\n if (+payload?.applicationFee > 0) {\n isApplicationFeesAlreadyPaid = true;\n }\n if (+payload?.accountingFee > 0) acc += +payload?.accountingFee;\n return acc;\n } else {\n return acc + r.amount - r.amountUsed;\n }\n }, 0);\n let remainingAmount = -sumRegulations; //TTC\n let paymentDate = initializedPaymentDate;\n\n //On order les exercicePrestation par startDate ASC et id ASC\n listPartialExercicePrestationExpress.sort((a, b) => {\n const aStartDate = a?.startDate as Date;\n const bStartDate = b?.startDate as Date;\n return dayjs(aStartDate).diff(bStartDate);\n });\n\n //On ajoute un paiement initial correspondant à la somme des régulations\n if (sumRegulations) {\n listPayments.push({\n amount:sumRegulations, //TTC\n isPaid: true,\n datePayment: dayjs().toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n\n // Si les frais de dossiers sont facturés et qu'ils n'ont pas déjà été payés,\n // on ajoute un paiement sur la première mensualité non express\n if (isWithApplicationFees && !isApplicationFeesAlreadyPaid) {\n listPayments.push({\n amount: getTaxesIncludedAmount(applicationFeesAmount, idVat), //TTC\n isPaid: false,\n datePayment: dayjs().startOf('month').add(1, 'month').toDate(),\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: listPartialExercicePrestationExpress?.length ? listPartialExercicePrestationExpress[0].endDate : firstExerciceNonExpresssEndDate,\n });\n }\n \n // =========================\n // EXPRESS\n // =========================\n listPartialExercicePrestationExpress.forEach((exercicePrestation:PartialExercicePrestationExpress, indexEP: number) => {\n remainingAmount += !priceWithTaxesIncluded \n ? getTaxesIncludedAmount(exercicePrestation.totalAmount, idVat) \n : exercicePrestation.totalAmount; //TTC\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n if (remainingAmount <= 0) return;\n \n //express : on étale en countExpressMonthlyPayment (nb de mensualités)\n let remainingAmountByExercicePrestation = remainingAmount; //TTC\n let countExpressMonthlyPayment = exercicePrestation?.countExpressMonthlyPayment ?? 3; //TTC\n //Si un premier règlement est généré avec le montant des regulations, on le considère comme une mensualité (unioquement pour le premier express et la première mensualité)\n if (indexEP === 0 && sumRegulations > 0) countExpressMonthlyPayment -= 1;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countExpressMonthlyPayment; //TTC\n for (let index = 1; index <= countExpressMonthlyPayment; index++) {\n // On arrondis les 11 premières mensualités, mais on récupère le reste pour la dernière mensualité, pour éviter les centimes perdus en arrondis\n // et on applique le taux de tva de la société\n const amount = index < countExpressMonthlyPayment ? monthlyAmount : remainingAmountByExercicePrestation; //TTC\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exercicePrestation.endDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n remainingAmount = 0;\n });\n\n // =========================\n // NON EXPRESS\n // =========================\n // on lisse sur le nb de mois restants (avec au minimum 3 mensualités)\n // Si un seul exo express, alors on met les paiements de l'exo actuel en parallèle\n // sinon, ils sont à la suite des express\n if (nbExoExpress <= 1) paymentDate = initializedPaymentDate;\n let exerciceEndDate = dayjs(firstExerciceNonExpresssEndDate).toDate();\n\n let hasGeneratedWholeYear = false;\n let isFirstNonExpress = true;\n \n //On génère des paiements jusqu'à ce qu'un exercice soit entier (12 mois), non express\n while (!hasGeneratedWholeYear) {\n \n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n const exoAmount = isFirstNonExpress ? yearlyAmountNonExpress : nextYearlyAmountNonExpress;\n remainingAmount += priceWithTaxesIncluded ? exoAmount : getTaxesIncludedAmount(exoAmount, idVat);\n\n //TODO: CAS A TESTER : si sumRegulations couvre le premier exercice par exemple (cas rar mais à envisager)\n //Si le premier règlement couvre le coût de cet exercicePrestation, on passe au suivant\n // if (remainingAmount <= 0) {\n // continue;\n // }\n\n // Si on a ajouté une ligne pour les applications fees, alors on les déduit du montant total\n if (isFirstNonExpress && isWithApplicationFees && !isApplicationFeesAlreadyPaid) {\n remainingAmount -= getTaxesIncludedAmount(applicationFeesAmount, idVat);\n }\n\n let remainingAmountByExercicePrestation = remainingAmount;\n\n // - frais d'application dès les second exo non express\n if (!isFirstNonExpress) remainingAmountByExercicePrestation += applicationCostTotalTTC;\n\n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd; //TTC\n\n if (monthlyAmount > 0) {\n for (let index = 1; index <= countMonthsBeforeExerciceEnd; index++) {\n let amount = index < countMonthsBeforeExerciceEnd ? monthlyAmount : remainingAmountByExercicePrestation;\n \n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n amount = calculateFees(amount, goToClient, paymentDate);\n \n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n remainingAmountByExercicePrestation -= monthlyAmount; \n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n exerciceEndDate = dayjs(exerciceEndDate).startOf('month').add(1, 'year').endOf('month').toDate();\n }\n remainingAmount = 0;\n if (countMonthsBeforeExerciceEnd === 12) hasGeneratedWholeYear = true;\n isFirstNonExpress = false;\n }\n\n remainingAmount = 0;\n\n // =========================\n // JUSQU'EN DECEMBRE\n // =========================\n // On applique le taux de tva de la société, si besoin, selon la grille tarifaire\n remainingAmount += priceWithTaxesIncluded ? nextYearlyAmountNonExpress : getTaxesIncludedAmount(nextYearlyAmountNonExpress, idVat);\n\n let remainingAmountByExercicePrestation = remainingAmount;\n //On compte le nb de mois restants entre la date à laquelle le paiement va être créé et la date de fin d'exercice\n let countMonthsBeforeExerciceEnd = Math.ceil(dayjs(exerciceEndDate).diff(paymentDate, 'months', true));\n if (countMonthsBeforeExerciceEnd < 3) countMonthsBeforeExerciceEnd = 3;\n\n // - frais d'application dès les second exo non express\n remainingAmountByExercicePrestation += applicationCostTotalTTC;\n \n const monthlyAmount = remainingAmountByExercicePrestation / countMonthsBeforeExerciceEnd;\n \n // Si aucun paiement généré, on stoppe là\n if (!listPayments.length) return [];\n\n while (dayjs(listPayments.slice(-1)[0].datePayment).month() < 11) {\n let amount = monthlyAmount;\n\n // Si besoin, on applique les frais nécessaires :\n // - 2,75% d'augmentation chaque année, sauf si souscriptiuon dans les 3 derniers mois de l'année civile)\n // - frais d'application dès les second exo non express\n amount = calculateFees(amount, goToClient, paymentDate);\n\n listPayments.push({\n amount: Math.round(100 * amount) / 100,\n datePayment: paymentDate,\n idPrestation,\n idPaymentMethod: PaymentMethod.DIRECT_DEBIT.id,\n closingDate: exerciceEndDate,\n });\n paymentDate = dayjs(paymentDate).add(1, 'month').startOf('month').toDate();\n }\n\n return listPayments;\n};\n\nexport {\n groupPaymentsByServiceType, calculatePaymentsAuto,\n};"]}
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../ts/utils/payment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AA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G,CAAC,CAAC;IAEvE,uDAAuD;IACvD,mCAAmC,IAAI,uBAAuB,CAAC;IAE/D,MAAM,aAAa,GAAG,mCAAmC,GAAG,4BAA4B,CAAC;IAEzF,yCAAyC;IACzC,IAAI,CAAC,YAAY,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEpC,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAChE,IAAI,MAAM,GAAG,aAAa,CAAC;QAE3B,iDAAiD;QACjD,yGAAyG;QACzG,uDAAuD;QACvD,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAExD,YAAY,CAAC,IAAI,CAAC;YAChB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG;YACtC,WAAW,EAAE,WAAW;YACxB,YAAY;YACZ,eAAe,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE;YAC9C,WAAW,EAAE,eAAe;SAC7B,CAAC,CAAC;QACH,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;KAC5E;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EACL,0BAA0B,EAAE,qBAAqB,GAClD,CAAC","sourcesContent":["'use strict';\n\nimport { IPayment, IRegulation, ParamsForPaymentsAuto, PaymentMethod, PaymentAuto, getTaxesIncludedAmount } 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;AAEnE,OAAO,EAAoB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gCAAgC,CAAC;AAexF,KAAK,SAAS,GAAG;IACf,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,sBAAsB,EAAE,OAAO,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACx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MAAM,WACf,MAAM,YACL,MAAM,YACN,MAAM,eACH,MAAM,mBACF,MAAM,oBACL,MAAM,eACX,MAAM,eACN,MAAM,oBACD,OAAO,YACf,OAAO,cACL,MAAM,eACL,MAAM,eACN,MAAM,eACN,MAAM,wBACE,MAAM;qBAEV,MAAM;iBACV,MAAM;kBACL,OAAO;cACX,MAAM;WACT,MAAM;CA0Ed,CAAC;AAUF,QAAA,MAAM,wBAAwB,qBACV,MAAM,kBACR,eAAe,WACtB,MAAM,YACL,MAAM,YACN,MAAM,eACH,MAAM,mBACF,MAAM,oBACL,MAAM,eACX,MAAM,eACN,MAAM,oBACD,OAAO,eACZ,MAAM,EAAE,mBACJ,MAAM,eACV,MAAM,cACP,MAAM,yBACK,OAAO,eACjB,MAAM,eACN,MAAM,aACT,OAAO,oBACA,OAAO,wBACH,MAAM,iBACb,SAAS,EAAE;qBAER,MAAM;iBACV,MAAM;kBACL,OAAO;kBACP,MAAM;kBACN,MAAM;WACb,MAAM;CAuFd,CAAC;AAEF,QAAA,MAAM,oBAAoB,qBAAsB,MAAM,KAAG,oBAAoB,EAG5E,CAAC;AAEF,QAAA,MAAM,mBAAmB,gBAAiB,MAAM,oBAAoB,MAAM,YAAY,MAAM,oBAAoB,OAAO,KAAG,OAgBzH,CAAC;AAEF,OAAO,EACL,yBAAyB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,qCAAqC,GAC/T,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;AAE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E,oBAAoB,EAAE,mBAAmB,EAAE,qCAAqC,EAAE,wBAAwB,GACzV,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { getTaxesIncludedAmount } from './vat/utils';
1
2
  import { intersection } from './noLodash';
2
3
  import { PrestationDetail, PrestationType } from '../types/Enum/PrestationType';
3
4
  import { LegalFormTypeEnum } from '../types/Enum/LegalForm';
@@ -63,7 +64,7 @@ export const getPriceGrid = (idTypeBrand, idPrestationList) => {
63
64
  currentPriceGrid = currentBrandPriceGrid?.price.find((price) => price.idPrestationList.includes(idPrestationList));
64
65
  return currentPriceGrid;
65
66
  };
66
- const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMonth, turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, isYearly, totalMonth, idTaxSystem, idLegalForm, exerciceNbr, balanceSheetOffered = 0) => {
67
+ 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) => {
67
68
  let totalPrestation = 0;
68
69
  let reduceMonth = 0;
69
70
  let monthNbr = NbrMonth;
@@ -86,6 +87,7 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
86
87
  if (currentPriceGrid.taxSystem && idTaxSystem)
87
88
  taxSystemPrice = currentPriceGrid.taxSystem?.find(tax => tax.id === idTaxSystem)?.price;
88
89
  /* Gestion des montants */
90
+ /* Récupératioin des prix mensuels */
89
91
  if (currentPriceGrid.turnoverMonthly && !isYearly)
90
92
  monthlyPrice = currentPriceGrid.turnoverMonthly?.find(turn => turnover < turn.turnoverValue)?.price;
91
93
  else if (currentPriceGrid.properties)
@@ -97,6 +99,7 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
97
99
  else if (currentPriceGrid.employeeByLegalForm) {
98
100
  monthlyPrice = currentPriceGrid.employeeByLegalForm?.find(emp => emp.idLegalForm === idLegalForm)?.price;
99
101
  monthlyPrice = monthlyPrice ? monthlyPrice * employeesNumber : 0;
102
+ /* Récupération des prix annuels */
100
103
  }
101
104
  else if (currentPriceGrid.turnoverYearly && isYearly)
102
105
  yearlyPrice = currentPriceGrid.turnoverYearly?.find(turn => turnover < turn.turnoverValue)?.price;
@@ -110,6 +113,7 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
110
113
  yearlyPrice = currentPriceGrid.legalForm?.find(form => form.idLegalForm === idLegalForm)?.price;
111
114
  else if (currentPriceGrid.exerciceNbr)
112
115
  yearlyPrice = currentPriceGrid.exerciceNbr?.find(el => el.minimum <= exerciceNbr && exerciceNbr <= el.maximum)?.price;
116
+ /* Calcul du prix mensuel final */
113
117
  finalMonthlyPrice = (monthlyPrice ? monthlyPrice : 0) + (vatRegimePrice ? vatRegimePrice : 0) + (taxSystemPrice ? taxSystemPrice : 0);
114
118
  /* Gestion des mois */
115
119
  let cloturedPast = false;
@@ -126,13 +130,16 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
126
130
  }
127
131
  }
128
132
  }
133
+ /* Gestion des offres, mois offer */
129
134
  if (totalMonth > 0) {
130
135
  if (monthlyNbr && ((monthNbr - totalMonth) < monthlyNbr?.minimum))
131
136
  canBeCreated = false;
132
137
  monthNbr = monthNbr - totalMonth;
133
138
  recalculateMonthly = true;
134
139
  }
140
+ /* Calcul du nombre de mois soustraient */
135
141
  reduceMonth = (monthNbr === NbrMonth - totalMonth ? totalMonth : 0);
142
+ /* Gestion des offres, bilan offer */
136
143
  if (balanceSheetOffered > 0) {
137
144
  yearlyPrice = undefined;
138
145
  recalculateMonthly = false;
@@ -141,14 +148,30 @@ const calculatePrestationPriceWithPriceGrid = (idPrestationList, endDate, NbrMon
141
148
  /* Prix Final */
142
149
  totalPrestation = (yearlyPrice ? yearlyPrice : finalMonthlyPrice * monthNbr);
143
150
  }
144
- return { totalPrestation, reduceMonth, canBeCreated, monthNbr: yearlyPrice ? 0 : recalculateMonthly ? NbrMonth : monthNbr, price: yearlyPrice ? yearlyPrice : recalculateMonthly ? (totalPrestation / NbrMonth) : (finalMonthlyPrice ? finalMonthlyPrice : 0) };
151
+ return { totalPrestation, reduceMonth, canBeCreated, monthNbr: yearlyPrice ? 0 : recalculateMonthly ? NbrMonth : monthNbr, price: yearlyPrice ? yearlyPrice : recalculateMonthly ? (totalPrestation / monthNbr) : (finalMonthlyPrice ? finalMonthlyPrice : 0) };
145
152
  };
146
153
  const calculatePrestationPriceWithPrestationList = (prestationList) => {
147
154
  let totalPrestation = 0;
148
155
  totalPrestation = prestationList?.price || 0;
149
156
  return totalPrestation;
150
157
  };
151
- const calculatePrestationPrice = (idPrestationList, prestationList, endDate, NbrMonth, turnover, rentsNumber, employeesNumber, associatesNumber, idTypeBrand, idVatRegime, pastBalanceSheet, optionsList, totalPercentage, totalAmount, totalMonth, isWithApplicationFees, idTaxSystem, idLegalForm, isYearly = false, isSubPrestation = false, balanceSheetOffered = 0, exerciceList = []) => {
158
+ /**
159
+ * From idLegalForm, get application fees amount (without taxes included if no idVat passed, or with taxes included calculated by given idVat)
160
+ * @param idLegalForm
161
+ * @param idVat
162
+ * @returns amount of application fees, without taxes included
163
+ */
164
+ const getApplicationFeesAmount = (idLegalForm, idVat) => {
165
+ let applicationFeesAmount = 50;
166
+ if (idLegalForm === LegalFormTypeEnum.SCI)
167
+ applicationFeesAmount = 150;
168
+ //Sans tva, on envoie le montant HT
169
+ if (!idVat)
170
+ return applicationFeesAmount;
171
+ //Avec tva, on envoie le montant TTC
172
+ return getTaxesIncludedAmount(applicationFeesAmount, idVat);
173
+ };
174
+ 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 = []) => {
152
175
  let totalPrestation = 0;
153
176
  let reduceMonth = 0;
154
177
  let canBeCreated = true;
@@ -196,10 +219,14 @@ const calculatePrestationPrice = (idPrestationList, prestationList, endDate, Nbr
196
219
  if ([PrestationType.CREATION_SOCIETE].includes(idPrestationList) && !isSubPrestation)
197
220
  totalPrestation += 50;
198
221
  }
222
+ /* Gestion des offres */
223
+ /* Offre montant offer */
199
224
  if (totalAmount > 0)
200
225
  totalPrestation = totalPrestation - totalAmount;
226
+ /* Offre pourcentage offer */
201
227
  if (totalPercentage > 0)
202
228
  totalPrestation = totalPrestation - (totalPrestation * (totalPercentage / 100));
229
+ /* Gesstioin du prix minimum acceptable pour la prestation */
203
230
  if (prestationList.minimumPrice && totalPrestation < prestationList.minimumPrice)
204
231
  totalPrestation = prestationList.minimumPrice;
205
232
  /* Gestion des options */
@@ -212,11 +239,10 @@ const calculatePrestationPrice = (idPrestationList, prestationList, endDate, Nbr
212
239
  });
213
240
  }
214
241
  totalPrestation += (OptionTotalPrice ? OptionTotalPrice : 0);
242
+ /* Gestion des frais de dossier */
215
243
  if (isWithApplicationFees) {
216
- if (idLegalForm === LegalFormTypeEnum.SCI)
217
- totalPrestation += 150;
218
- else
219
- totalPrestation += 50;
244
+ const applicationFeesAmount = getApplicationFeesAmount(idLegalForm);
245
+ totalPrestation += applicationFeesAmount;
220
246
  }
221
247
  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€' : ''}`;
222
248
  return { totalPrestation, reduceMonth, canBeCreated, calculDetail, monthlyPrice: monthNbr > 0 ? (Math.round(price * 100) / 100) + '€/mois' : (Math.round(price * 100) / 100) + '€', price };
@@ -246,5 +272,5 @@ const isAbleToUpdatePrice = (idTypeBrand, idPrestationList, turnover, pastBalanc
246
272
  }
247
273
  return false;
248
274
  };
249
- export { isOtherAccountingMissions, isOtherJuridicalMissions, isAdditionalPresta, isOtherSocialMission, isOnlyPrevi, isOnlySocial, isOnlyJuridic, isCreation, isFromStatutsExpress, isExpress, calculateScoringOfPrestation, calculatePrestationPrice, getPrestationOptions, isAbleToUpdatePrice, calculatePrestationPriceWithPriceGrid, };
275
+ export { isOtherAccountingMissions, isOtherJuridicalMissions, isAdditionalPresta, isOtherSocialMission, isOnlyPrevi, isOnlySocial, isOnlyJuridic, isCreation, isFromStatutsExpress, isExpress, calculateScoringOfPrestation, calculatePrestationPrice, getPrestationOptions, isAbleToUpdatePrice, calculatePrestationPriceWithPriceGrid, getApplicationFeesAmount, };
250
276
  //# sourceMappingURL=prestation.js.map