@driveup/schema 0.1.0

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 (246) hide show
  1. package/README.md +174 -0
  2. package/lib/catalog/addon/addon.entity.d.ts +109 -0
  3. package/lib/catalog/addon/addon.entity.js +260 -0
  4. package/lib/catalog/addon/addon.entity.js.map +1 -0
  5. package/lib/catalog/addon/country.entity.d.ts +112 -0
  6. package/lib/catalog/addon/country.entity.js +246 -0
  7. package/lib/catalog/addon/country.entity.js.map +1 -0
  8. package/lib/catalog/driving/category.entity.d.ts +122 -0
  9. package/lib/catalog/driving/category.entity.js +217 -0
  10. package/lib/catalog/driving/category.entity.js.map +1 -0
  11. package/lib/catalog/driving/vehicle.entity.d.ts +49 -0
  12. package/lib/catalog/driving/vehicle.entity.js +97 -0
  13. package/lib/catalog/driving/vehicle.entity.js.map +1 -0
  14. package/lib/catalog/priceplan/priceplan.entity.d.ts +123 -0
  15. package/lib/catalog/priceplan/priceplan.entity.js +288 -0
  16. package/lib/catalog/priceplan/priceplan.entity.js.map +1 -0
  17. package/lib/catalog/product/country.entity.d.ts +109 -0
  18. package/lib/catalog/product/country.entity.js +233 -0
  19. package/lib/catalog/product/country.entity.js.map +1 -0
  20. package/lib/catalog/product/priceplan.entity.d.ts +113 -0
  21. package/lib/catalog/product/priceplan.entity.js +251 -0
  22. package/lib/catalog/product/priceplan.entity.js.map +1 -0
  23. package/lib/catalog/product/product.entity.d.ts +104 -0
  24. package/lib/catalog/product/product.entity.js +262 -0
  25. package/lib/catalog/product/product.entity.js.map +1 -0
  26. package/lib/catalog/program/program.entity.d.ts +107 -0
  27. package/lib/catalog/program/program.entity.js +247 -0
  28. package/lib/catalog/program/program.entity.js.map +1 -0
  29. package/lib/catalog/seed/assets/asset.entity.d.ts +68 -0
  30. package/lib/catalog/seed/assets/asset.entity.js +163 -0
  31. package/lib/catalog/seed/assets/asset.entity.js.map +1 -0
  32. package/lib/catalog/seed/courses/course.entity.d.ts +98 -0
  33. package/lib/catalog/seed/courses/course.entity.js +216 -0
  34. package/lib/catalog/seed/courses/course.entity.js.map +1 -0
  35. package/lib/catalog/seed/courses/lesson.entity.d.ts +90 -0
  36. package/lib/catalog/seed/courses/lesson.entity.js +214 -0
  37. package/lib/catalog/seed/courses/lesson.entity.js.map +1 -0
  38. package/lib/catalog/seed/courses/topic.entity.d.ts +77 -0
  39. package/lib/catalog/seed/courses/topic.entity.js +185 -0
  40. package/lib/catalog/seed/courses/topic.entity.js.map +1 -0
  41. package/lib/catalog/seed/expense/category.entity.d.ts +61 -0
  42. package/lib/catalog/seed/expense/category.entity.js +153 -0
  43. package/lib/catalog/seed/expense/category.entity.js.map +1 -0
  44. package/lib/index.d.ts +67 -0
  45. package/lib/index.js +89 -0
  46. package/lib/index.js.map +1 -0
  47. package/lib/profile/agent/agent.entity.d.ts +95 -0
  48. package/lib/profile/agent/agent.entity.js +223 -0
  49. package/lib/profile/agent/agent.entity.js.map +1 -0
  50. package/lib/profile/agent/payout.entity.d.ts +70 -0
  51. package/lib/profile/agent/payout.entity.js +160 -0
  52. package/lib/profile/agent/payout.entity.js.map +1 -0
  53. package/lib/profile/agent/promotion.entity.d.ts +82 -0
  54. package/lib/profile/agent/promotion.entity.js +174 -0
  55. package/lib/profile/agent/promotion.entity.js.map +1 -0
  56. package/lib/profile/company/company.entity.d.ts +234 -0
  57. package/lib/profile/company/company.entity.js +558 -0
  58. package/lib/profile/company/company.entity.js.map +1 -0
  59. package/lib/profile/company/course/appointment.entity.d.ts +111 -0
  60. package/lib/profile/company/course/appointment.entity.js +240 -0
  61. package/lib/profile/company/course/appointment.entity.js.map +1 -0
  62. package/lib/profile/company/course/course.entity.d.ts +156 -0
  63. package/lib/profile/company/course/course.entity.js +365 -0
  64. package/lib/profile/company/course/course.entity.js.map +1 -0
  65. package/lib/profile/company/course/lesson.entity.d.ts +123 -0
  66. package/lib/profile/company/course/lesson.entity.js +288 -0
  67. package/lib/profile/company/course/lesson.entity.js.map +1 -0
  68. package/lib/profile/company/course/topic.entity.d.ts +55 -0
  69. package/lib/profile/company/course/topic.entity.js +147 -0
  70. package/lib/profile/company/course/topic.entity.js.map +1 -0
  71. package/lib/profile/company/finances/billing/bill.entity.d.ts +145 -0
  72. package/lib/profile/company/finances/billing/bill.entity.js +338 -0
  73. package/lib/profile/company/finances/billing/bill.entity.js.map +1 -0
  74. package/lib/profile/company/finances/billing/item.entity.d.ts +75 -0
  75. package/lib/profile/company/finances/billing/item.entity.js +219 -0
  76. package/lib/profile/company/finances/billing/item.entity.js.map +1 -0
  77. package/lib/profile/company/finances/billing/transaction.entity.d.ts +44 -0
  78. package/lib/profile/company/finances/billing/transaction.entity.js +158 -0
  79. package/lib/profile/company/finances/billing/transaction.entity.js.map +1 -0
  80. package/lib/profile/company/finances/expense/category.entity.d.ts +55 -0
  81. package/lib/profile/company/finances/expense/category.entity.js +117 -0
  82. package/lib/profile/company/finances/expense/category.entity.js.map +1 -0
  83. package/lib/profile/company/finances/expense/expense.entity.d.ts +48 -0
  84. package/lib/profile/company/finances/expense/expense.entity.js +171 -0
  85. package/lib/profile/company/finances/expense/expense.entity.js.map +1 -0
  86. package/lib/profile/company/finances/handover/handover.entity.d.ts +44 -0
  87. package/lib/profile/company/finances/handover/handover.entity.js +202 -0
  88. package/lib/profile/company/finances/handover/handover.entity.js.map +1 -0
  89. package/lib/profile/company/finances/invoice/invoice.entity.d.ts +65 -0
  90. package/lib/profile/company/finances/invoice/invoice.entity.js +296 -0
  91. package/lib/profile/company/finances/invoice/invoice.entity.js.map +1 -0
  92. package/lib/profile/company/finances/invoice/item.entity.d.ts +25 -0
  93. package/lib/profile/company/finances/invoice/item.entity.js +148 -0
  94. package/lib/profile/company/finances/invoice/item.entity.js.map +1 -0
  95. package/lib/profile/company/finances/payment/method.entity.d.ts +35 -0
  96. package/lib/profile/company/finances/payment/method.entity.js +143 -0
  97. package/lib/profile/company/finances/payment/method.entity.js.map +1 -0
  98. package/lib/profile/company/finances/peyment/method.entity.d.ts +35 -0
  99. package/lib/profile/company/finances/peyment/method.entity.js +143 -0
  100. package/lib/profile/company/finances/peyment/method.entity.js.map +1 -0
  101. package/lib/profile/company/finances/peyment-method/payment-method.d.ts +34 -0
  102. package/lib/profile/company/finances/peyment-method/payment-method.js +118 -0
  103. package/lib/profile/company/finances/peyment-method/payment-method.js.map +1 -0
  104. package/lib/profile/company/instructor/instructor.entity.d.ts +85 -0
  105. package/lib/profile/company/instructor/instructor.entity.js +254 -0
  106. package/lib/profile/company/instructor/instructor.entity.js.map +1 -0
  107. package/lib/profile/company/instructor/task.entity.d.ts +60 -0
  108. package/lib/profile/company/instructor/task.entity.js +133 -0
  109. package/lib/profile/company/instructor/task.entity.js.map +1 -0
  110. package/lib/profile/company/medical/examination.entity.d.ts +59 -0
  111. package/lib/profile/company/medical/examination.entity.js +175 -0
  112. package/lib/profile/company/medical/examination.entity.js.map +1 -0
  113. package/lib/profile/company/medical/product.entity.d.ts +99 -0
  114. package/lib/profile/company/medical/product.entity.js +270 -0
  115. package/lib/profile/company/medical/product.entity.js.map +1 -0
  116. package/lib/profile/company/metrics/company.metric.d.ts +21 -0
  117. package/lib/profile/company/metrics/company.metric.js +122 -0
  118. package/lib/profile/company/metrics/company.metric.js.map +1 -0
  119. package/lib/profile/company/product/addon.entity.d.ts +93 -0
  120. package/lib/profile/company/product/addon.entity.js +234 -0
  121. package/lib/profile/company/product/addon.entity.js.map +1 -0
  122. package/lib/profile/company/product/priceplan.entity.d.ts +57 -0
  123. package/lib/profile/company/product/priceplan.entity.js +167 -0
  124. package/lib/profile/company/product/priceplan.entity.js.map +1 -0
  125. package/lib/profile/company/product/product.entity.d.ts +171 -0
  126. package/lib/profile/company/product/product.entity.js +383 -0
  127. package/lib/profile/company/product/product.entity.js.map +1 -0
  128. package/lib/profile/company/product/vehicle.entity.d.ts +46 -0
  129. package/lib/profile/company/product/vehicle.entity.js +144 -0
  130. package/lib/profile/company/product/vehicle.entity.js.map +1 -0
  131. package/lib/profile/instructor/instructor.entity.d.ts +80 -0
  132. package/lib/profile/instructor/instructor.entity.js +186 -0
  133. package/lib/profile/instructor/instructor.entity.js.map +1 -0
  134. package/lib/profile/student/program/licence/licence.entity.d.ts +66 -0
  135. package/lib/profile/student/program/licence/licence.entity.js +187 -0
  136. package/lib/profile/student/program/licence/licence.entity.js.map +1 -0
  137. package/lib/profile/student/program/medical/certificate.entity.d.ts +84 -0
  138. package/lib/profile/student/program/medical/certificate.entity.js +244 -0
  139. package/lib/profile/student/program/medical/certificate.entity.js.map +1 -0
  140. package/lib/profile/student/program/medical/examination.model.d.ts +65 -0
  141. package/lib/profile/student/program/medical/examination.model.js +209 -0
  142. package/lib/profile/student/program/medical/examination.model.js.map +1 -0
  143. package/lib/profile/student/program/program.entity.d.ts +78 -0
  144. package/lib/profile/student/program/program.entity.js +225 -0
  145. package/lib/profile/student/program/program.entity.js.map +1 -0
  146. package/lib/profile/student/program/training/appointment.entity.d.ts +151 -0
  147. package/lib/profile/student/program/training/appointment.entity.js +441 -0
  148. package/lib/profile/student/program/training/appointment.entity.js.map +1 -0
  149. package/lib/profile/student/program/training/exam.entity.d.ts +41 -0
  150. package/lib/profile/student/program/training/exam.entity.js +141 -0
  151. package/lib/profile/student/program/training/exam.entity.js.map +1 -0
  152. package/lib/profile/student/program/training/lesson.entity.d.ts +84 -0
  153. package/lib/profile/student/program/training/lesson.entity.js +221 -0
  154. package/lib/profile/student/program/training/lesson.entity.js.map +1 -0
  155. package/lib/profile/student/program/training/request.entity.d.ts +56 -0
  156. package/lib/profile/student/program/training/request.entity.js +159 -0
  157. package/lib/profile/student/program/training/request.entity.js.map +1 -0
  158. package/lib/profile/student/program/training/topic.entity.d.ts +109 -0
  159. package/lib/profile/student/program/training/topic.entity.js +255 -0
  160. package/lib/profile/student/program/training/topic.entity.js.map +1 -0
  161. package/lib/profile/student/program/training/training.entity.d.ts +167 -0
  162. package/lib/profile/student/program/training/training.entity.js +501 -0
  163. package/lib/profile/student/program/training/training.entity.js.map +1 -0
  164. package/lib/profile/student/program/training/transaction.entity.d.ts +111 -0
  165. package/lib/profile/student/program/training/transaction.entity.js +266 -0
  166. package/lib/profile/student/program/training/transaction.entity.js.map +1 -0
  167. package/lib/profile/student/student.entity.d.ts +89 -0
  168. package/lib/profile/student/student.entity.js +183 -0
  169. package/lib/profile/student/student.entity.js.map +1 -0
  170. package/lib/system/campaign/campaign.entity.d.ts +68 -0
  171. package/lib/system/campaign/campaign.entity.js +150 -0
  172. package/lib/system/campaign/campaign.entity.js.map +1 -0
  173. package/lib/system/campaign/gifcode.entity.d.ts +14 -0
  174. package/lib/system/campaign/gifcode.entity.js +77 -0
  175. package/lib/system/campaign/gifcode.entity.js.map +1 -0
  176. package/lib/system/campaigne/campaign.entity.d.ts +69 -0
  177. package/lib/system/campaigne/campaign.entity.js +179 -0
  178. package/lib/system/campaigne/campaign.entity.js.map +1 -0
  179. package/lib/system/campaigne/gifcode.entity.d.ts +54 -0
  180. package/lib/system/campaigne/gifcode.entity.js +126 -0
  181. package/lib/system/campaigne/gifcode.entity.js.map +1 -0
  182. package/lib/system/country/country.entity.d.ts +121 -0
  183. package/lib/system/country/country.entity.js +284 -0
  184. package/lib/system/country/country.entity.js.map +1 -0
  185. package/lib/system/country/country.metric.d.ts +12 -0
  186. package/lib/system/country/country.metric.js +68 -0
  187. package/lib/system/country/country.metric.js.map +1 -0
  188. package/lib/system/currency/currency.entity.d.ts +46 -0
  189. package/lib/system/currency/currency.entity.js +112 -0
  190. package/lib/system/currency/currency.entity.js.map +1 -0
  191. package/lib/system/driving/category.entity.d.ts +146 -0
  192. package/lib/system/driving/category.entity.js +321 -0
  193. package/lib/system/driving/category.entity.js.map +1 -0
  194. package/lib/system/driving/vehicle.entity.d.ts +54 -0
  195. package/lib/system/driving/vehicle.entity.js +130 -0
  196. package/lib/system/driving/vehicle.entity.js.map +1 -0
  197. package/lib/system/event/business.entity.d.ts +75 -0
  198. package/lib/system/event/business.entity.js +170 -0
  199. package/lib/system/event/business.entity.js.map +1 -0
  200. package/lib/system/event/log.entity.d.ts +103 -0
  201. package/lib/system/event/log.entity.js +202 -0
  202. package/lib/system/event/log.entity.js.map +1 -0
  203. package/lib/system/policy/policy.entity.d.ts +90 -0
  204. package/lib/system/policy/policy.entity.js +226 -0
  205. package/lib/system/policy/policy.entity.js.map +1 -0
  206. package/lib/system/staff/staff.entity.d.ts +72 -0
  207. package/lib/system/staff/staff.entity.js +186 -0
  208. package/lib/system/staff/staff.entity.js.map +1 -0
  209. package/lib/tsconfig.tsbuildinfo +1 -0
  210. package/lib/user/alert.entity.d.ts +95 -0
  211. package/lib/user/alert.entity.js +223 -0
  212. package/lib/user/alert.entity.js.map +1 -0
  213. package/lib/user/blocked.entity.d.ts +42 -0
  214. package/lib/user/blocked.entity.js +83 -0
  215. package/lib/user/blocked.entity.js.map +1 -0
  216. package/lib/user/device.entity.d.ts +72 -0
  217. package/lib/user/device.entity.js +182 -0
  218. package/lib/user/device.entity.js.map +1 -0
  219. package/lib/user/notification.entity.d.ts +87 -0
  220. package/lib/user/notification.entity.js +219 -0
  221. package/lib/user/notification.entity.js.map +1 -0
  222. package/lib/user/ticket.entity.d.ts +85 -0
  223. package/lib/user/ticket.entity.js +231 -0
  224. package/lib/user/ticket.entity.js.map +1 -0
  225. package/lib/user/user.entity.d.ts +235 -0
  226. package/lib/user/user.entity.js +573 -0
  227. package/lib/user/user.entity.js.map +1 -0
  228. package/lib/user/verification.entity.d.ts +75 -0
  229. package/lib/user/verification.entity.js +142 -0
  230. package/lib/user/verification.entity.js.map +1 -0
  231. package/lib/utils/activity.helper.d.ts +26 -0
  232. package/lib/utils/activity.helper.js +39 -0
  233. package/lib/utils/activity.helper.js.map +1 -0
  234. package/lib/utils/index.d.ts +4 -0
  235. package/lib/utils/index.js +21 -0
  236. package/lib/utils/index.js.map +1 -0
  237. package/lib/utils/json-metrics.transform.d.ts +35 -0
  238. package/lib/utils/json-metrics.transform.js +83 -0
  239. package/lib/utils/json-metrics.transform.js.map +1 -0
  240. package/lib/utils/numeric.transform.d.ts +38 -0
  241. package/lib/utils/numeric.transform.js +74 -0
  242. package/lib/utils/numeric.transform.js.map +1 -0
  243. package/lib/utils/trackable.entity.d.ts +82 -0
  244. package/lib/utils/trackable.entity.js +100 -0
  245. package/lib/utils/trackable.entity.js.map +1 -0
  246. package/package.json +49 -0
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CompanyCourseLessonEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const course_entity_1 = require("./course.entity");
16
+ const topic_entity_1 = require("./topic.entity");
17
+ const appointment_entity_1 = require("./appointment.entity");
18
+ const instructor_entity_1 = require("../instructor/instructor.entity");
19
+ const lesson_entity_1 = require("../../student/program/training/lesson.entity");
20
+ const utils_1 = require("../../../utils");
21
+ /**
22
+ * Company Course Lesson Entity
23
+ *
24
+ * Represents course lesson which can be interpreted differently depending on course type:
25
+ *
26
+ * - Theory Courses: Lessons are classic lesson subdivisions within standard lessons
27
+ * - Driving Courses: Lessons represent driving learning phases
28
+ * (e.g., Basic Vehicle Control, Simple Traffic Situations, Complex Traffic Situations, Special Manoeuvres, Driving on Motorway, Safety & Eco Driving)
29
+ * and topics are the specific session topics within those phases
30
+ */
31
+ let CompanyCourseLessonEntity = class CompanyCourseLessonEntity extends utils_1.TrackableEntity {
32
+ /**
33
+ * Company course
34
+ */
35
+ courseId;
36
+ /**
37
+ * In-charge instructor for the course lesson
38
+ * Flexible lessons can have their own instructor
39
+ */
40
+ instructorId;
41
+ /****************** Content ******************/
42
+ /**
43
+ * Lesson number or sequence identifier
44
+ */
45
+ number;
46
+ /**
47
+ * Lesson title
48
+ */
49
+ title;
50
+ /**
51
+ * Lesson description
52
+ */
53
+ description;
54
+ /**
55
+ * Lesson header image (upcoming)
56
+ */
57
+ imageUrl;
58
+ /**
59
+ * Lesson gallery images (upcoming)
60
+ */
61
+ gallery;
62
+ /**
63
+ * Lesson sort order within the course
64
+ */
65
+ sort;
66
+ /****************** Calendar ******************/
67
+ /**
68
+ * Lesson start date
69
+ * Only used in fixed trainings
70
+ */
71
+ startDate;
72
+ /**
73
+ * Lesson end date
74
+ * Only used in fixed trainings
75
+ */
76
+ endDate;
77
+ /**
78
+ * Lesson duration in minutes
79
+ * Important for flexible courses
80
+ */
81
+ duration;
82
+ /**
83
+ * Location where the lesson takes place
84
+ */
85
+ location;
86
+ /***************** Tracks *****************/
87
+ /**
88
+ * Timestamp when the lesson was canceled
89
+ */
90
+ canceledOn;
91
+ /**
92
+ * ID of the user who canceled the lesson
93
+ */
94
+ canceledBy;
95
+ /**
96
+ * Course relation
97
+ */
98
+ course;
99
+ /**
100
+ * Lesson in-charge instructor
101
+ */
102
+ instructor;
103
+ /**
104
+ * Company lesson topics
105
+ */
106
+ topics;
107
+ /**
108
+ * Company lesson appointments
109
+ */
110
+ appointments;
111
+ /**
112
+ * Student training lessons based on this lesson
113
+ */
114
+ studentLessons;
115
+ /**
116
+ * Creates a new CompanyCourseLessonEntity instance
117
+ * @param props - Partial properties to initialize the entity with
118
+ */
119
+ constructor(props) {
120
+ super();
121
+ Object.assign(this, props);
122
+ }
123
+ /**
124
+ * Converts the entity to a Lesson model instance
125
+ * @returns Promise resolving to Lesson model with all lesson details including instructor, location, and gallery
126
+ */
127
+ async toModel() {
128
+ const instructor = this.instructorId ? await (await this.instructor).toModel() : null;
129
+ return common_1.Lesson.toInstance({
130
+ id: this.id,
131
+ instructor: instructor,
132
+ number: this.number,
133
+ title: this.title,
134
+ description: this.description,
135
+ imageUrl: this.imageUrl,
136
+ gallery: this.gallery ? this.gallery.map(common_1.Picture.toInstance) : null,
137
+ sort: this.sort,
138
+ startDate: this.startDate,
139
+ endDate: this.endDate,
140
+ duration: this.duration,
141
+ location: this.location ? common_1.Address.toInstance(this.location) : null
142
+ });
143
+ }
144
+ /**
145
+ * Returns a summary representation of the lesson with essential information
146
+ * @returns Lesson model with basic details (id, title, number, dates, duration)
147
+ */
148
+ toSummary() {
149
+ return common_1.Lesson.toInstance({
150
+ id: this.id,
151
+ title: this.title,
152
+ number: this.number,
153
+ startDate: this.startDate,
154
+ endDate: this.endDate,
155
+ duration: this.duration,
156
+ });
157
+ }
158
+ /**
159
+ * Retrieves all tracked activities for this lesson
160
+ * Includes creation, update, and cancellation timestamps with associated users
161
+ * @returns Promise resolving to array of Activity objects filtered to exclude null values
162
+ */
163
+ async getActivities() {
164
+ const activities = [];
165
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
166
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
167
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
168
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
169
+ activities.push(await (0, utils_1.toActivity)(this.canceledBy, common_1.ActivityType.canceledBy));
170
+ activities.push(await (0, utils_1.toActivity)(this.canceledOn, common_1.ActivityType.canceledOn));
171
+ return activities.filter(a => a);
172
+ }
173
+ };
174
+ exports.CompanyCourseLessonEntity = CompanyCourseLessonEntity;
175
+ __decorate([
176
+ (0, typeorm_1.Column)(),
177
+ __metadata("design:type", Number)
178
+ ], CompanyCourseLessonEntity.prototype, "courseId", void 0);
179
+ __decorate([
180
+ (0, typeorm_1.Column)({
181
+ nullable: true,
182
+ default: null
183
+ }),
184
+ __metadata("design:type", Number)
185
+ ], CompanyCourseLessonEntity.prototype, "instructorId", void 0);
186
+ __decorate([
187
+ (0, typeorm_1.Column)({
188
+ nullable: true,
189
+ default: null
190
+ }),
191
+ __metadata("design:type", Number)
192
+ ], CompanyCourseLessonEntity.prototype, "number", void 0);
193
+ __decorate([
194
+ (0, typeorm_1.Column)(),
195
+ __metadata("design:type", String)
196
+ ], CompanyCourseLessonEntity.prototype, "title", void 0);
197
+ __decorate([
198
+ (0, typeorm_1.Column)({
199
+ nullable: true,
200
+ default: null
201
+ }),
202
+ __metadata("design:type", String)
203
+ ], CompanyCourseLessonEntity.prototype, "description", void 0);
204
+ __decorate([
205
+ (0, typeorm_1.Column)({
206
+ nullable: true,
207
+ default: null
208
+ }),
209
+ __metadata("design:type", String)
210
+ ], CompanyCourseLessonEntity.prototype, "imageUrl", void 0);
211
+ __decorate([
212
+ (0, typeorm_1.Column)({
213
+ type: 'simple-json',
214
+ nullable: true,
215
+ default: null
216
+ }),
217
+ __metadata("design:type", Array)
218
+ ], CompanyCourseLessonEntity.prototype, "gallery", void 0);
219
+ __decorate([
220
+ (0, typeorm_1.Column)({
221
+ type: 'tinyint',
222
+ nullable: true,
223
+ default: null
224
+ }),
225
+ __metadata("design:type", Number)
226
+ ], CompanyCourseLessonEntity.prototype, "sort", void 0);
227
+ __decorate([
228
+ (0, typeorm_1.Column)({
229
+ nullable: true,
230
+ default: null
231
+ }),
232
+ __metadata("design:type", Date)
233
+ ], CompanyCourseLessonEntity.prototype, "startDate", void 0);
234
+ __decorate([
235
+ (0, typeorm_1.Column)({
236
+ nullable: true,
237
+ default: null
238
+ }),
239
+ __metadata("design:type", Date)
240
+ ], CompanyCourseLessonEntity.prototype, "endDate", void 0);
241
+ __decorate([
242
+ (0, typeorm_1.Column)({
243
+ nullable: true,
244
+ default: null
245
+ }),
246
+ __metadata("design:type", Number)
247
+ ], CompanyCourseLessonEntity.prototype, "duration", void 0);
248
+ __decorate([
249
+ (0, typeorm_1.Column)({
250
+ type: 'simple-json',
251
+ nullable: true,
252
+ default: null
253
+ }),
254
+ __metadata("design:type", common_1.Address)
255
+ ], CompanyCourseLessonEntity.prototype, "location", void 0);
256
+ __decorate([
257
+ (0, typeorm_1.Column)({ nullable: false, default: false }),
258
+ __metadata("design:type", Date)
259
+ ], CompanyCourseLessonEntity.prototype, "canceledOn", void 0);
260
+ __decorate([
261
+ (0, typeorm_1.Column)({ nullable: false, default: false }),
262
+ __metadata("design:type", Number)
263
+ ], CompanyCourseLessonEntity.prototype, "canceledBy", void 0);
264
+ __decorate([
265
+ (0, typeorm_1.ManyToOne)(() => course_entity_1.CompanyCourseEntity, product => product.lessons),
266
+ __metadata("design:type", Promise)
267
+ ], CompanyCourseLessonEntity.prototype, "course", void 0);
268
+ __decorate([
269
+ (0, typeorm_1.ManyToOne)(() => instructor_entity_1.CompanyInstructorEntity, instructor => instructor.companyCourseLessons),
270
+ __metadata("design:type", Promise)
271
+ ], CompanyCourseLessonEntity.prototype, "instructor", void 0);
272
+ __decorate([
273
+ (0, typeorm_1.OneToMany)(() => topic_entity_1.CompanyCourseTopicEntity, student => student.lesson),
274
+ __metadata("design:type", Promise)
275
+ ], CompanyCourseLessonEntity.prototype, "topics", void 0);
276
+ __decorate([
277
+ (0, typeorm_1.OneToMany)(() => appointment_entity_1.CompanyCourseAppointmentEntity, student => student.lesson),
278
+ __metadata("design:type", Promise)
279
+ ], CompanyCourseLessonEntity.prototype, "appointments", void 0);
280
+ __decorate([
281
+ (0, typeorm_1.OneToMany)(() => lesson_entity_1.StudentTrainingLessonEntity, student => student.lesson),
282
+ __metadata("design:type", Promise)
283
+ ], CompanyCourseLessonEntity.prototype, "studentLessons", void 0);
284
+ exports.CompanyCourseLessonEntity = CompanyCourseLessonEntity = __decorate([
285
+ (0, typeorm_1.Entity)('companyCourseLessons'),
286
+ __metadata("design:paramtypes", [Object])
287
+ ], CompanyCourseLessonEntity);
288
+ //# sourceMappingURL=lesson.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lesson.entity.js","sourceRoot":"","sources":["../../../../src/profile/company/course/lesson.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgE;AAChE,4CAAmF;AACnF,mDAAsD;AACtD,iDAA0D;AAC1D,6DAAsE;AACtE,uEAA0E;AAC1E,gFAA2F;AAC3F,0CAA6D;AAE7D;;;;;;;;;GASG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,uBAAuB;IAErE;;OAEG;IAEH,QAAQ,CAAS;IAEjB;;;OAGG;IAKH,YAAY,CAAS;IAErB,+CAA+C;IAE/C;;OAEG;IAKH,MAAM,CAAS;IAEf;;OAEG;IAEH,KAAK,CAAS;IAEd;;OAEG;IAKH,WAAW,CAAS;IAEpB;;OAEG;IAKH,QAAQ,CAAS;IAEjB;;OAEG;IAMH,OAAO,CAAY;IAEnB;;OAEG;IAMH,IAAI,CAAS;IAEb,gDAAgD;IAEhD;;;OAGG;IAKH,SAAS,CAAO;IAEhB;;;OAGG;IAKH,OAAO,CAAO;IAEd;;;OAGG;IAKH,QAAQ,CAAS;IAEjB;;OAEG;IAMH,QAAQ,CAAU;IAElB,4CAA4C;IAE5C;;OAEG;IAEH,UAAU,CAAO;IAEjB;;OAEG;IAEH,UAAU,CAAS;IAEnB;;OAEG;IAEH,MAAM,CAA+B;IAErC;;OAEG;IAEH,UAAU,CAAmC;IAE7C;;OAEG;IAEH,MAAM,CAAsC;IAE5C;;OAEG;IAEH,YAAY,CAA4C;IAExD;;OAEG;IAEH,cAAc,CAAyC;IAEvD;;;OAGG;IACH,YAAY,KAA0C;QACrD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC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,GAAG,EAAE,CAAC,uCAAwB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;yDACzB;AAM5C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,mDAA8B,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;+DACnB;AAMxD;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2CAA2B,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;iEACjB;oCA7J3C,yBAAyB;IADrC,IAAA,gBAAM,EAAC,sBAAsB,CAAC;;GAClB,yBAAyB,CA4NrC"}
@@ -0,0 +1,55 @@
1
+ import { Activity, Skill, Topic } from '@driveup/common';
2
+ import { CompanyCourseLessonEntity } from './lesson.entity';
3
+ import { StudentTrainingTopicEntity } from '../../student/program/training/topic.entity';
4
+ import { TrackableEntity } from '../../../utils';
5
+ /**
6
+ * Company Course Topic Entity
7
+ *
8
+ * Represents lesson parts (topics) which can be interpreted differently depending on course type:
9
+ *
10
+ * - Theory Courses: Topics are classic lesson subdivisions within standard lessons
11
+ * - Driving Courses: Lessons represent driving learning phases
12
+ * (e.g., Basic Vehicle Control, Simple Traffic Situations, Complex Traffic Situations, Special Manoeuvres, Driving on Motorway, Safety & Eco Driving)
13
+ * and topics are the specific session topics within those phases
14
+ */
15
+ export declare class CompanyCourseTopicEntity extends TrackableEntity<Topic> {
16
+ /**
17
+ * Reference to the lesson this topic belongs to
18
+ */
19
+ lessonId: number;
20
+ /**
21
+ * Title of the topic
22
+ */
23
+ title: string;
24
+ /**
25
+ * Detailed description of the topic content
26
+ */
27
+ description: string;
28
+ /**
29
+ * URL to the topic's representative image
30
+ */
31
+ imageUrl: string;
32
+ /**
33
+ * Sort order for displaying topics within a lesson
34
+ */
35
+ sort: number;
36
+ /**
37
+ * List of skills covered in this topic
38
+ */
39
+ skills: Skill[];
40
+ /**
41
+ * Reference to the parent lesson
42
+ */
43
+ lesson: Promise<CompanyCourseLessonEntity>;
44
+ /**
45
+ * Student training lesson topic relations
46
+ * Keep track to student training topics in case by update or delete the lexxon topic
47
+ * to handle the student topics accordingly
48
+ * Only trainings in progress can be uodated or deleted from student lessons
49
+ */
50
+ studentTopics: Promise<StudentTrainingTopicEntity[]>;
51
+ constructor(props?: Partial<CompanyCourseTopicEntity>);
52
+ toModel(): Topic;
53
+ toSummary(): Topic;
54
+ getActivities(): Promise<Activity[]>;
55
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CompanyCourseTopicEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const lesson_entity_1 = require("./lesson.entity");
16
+ const topic_entity_1 = require("../../student/program/training/topic.entity");
17
+ const utils_1 = require("../../../utils");
18
+ /**
19
+ * Company Course Topic Entity
20
+ *
21
+ * Represents lesson parts (topics) which can be interpreted differently depending on course type:
22
+ *
23
+ * - Theory Courses: Topics are classic lesson subdivisions within standard lessons
24
+ * - Driving Courses: Lessons represent driving learning phases
25
+ * (e.g., Basic Vehicle Control, Simple Traffic Situations, Complex Traffic Situations, Special Manoeuvres, Driving on Motorway, Safety & Eco Driving)
26
+ * and topics are the specific session topics within those phases
27
+ */
28
+ let CompanyCourseTopicEntity = class CompanyCourseTopicEntity extends utils_1.TrackableEntity {
29
+ /**
30
+ * Reference to the lesson this topic belongs to
31
+ */
32
+ lessonId;
33
+ /**
34
+ * Title of the topic
35
+ */
36
+ title;
37
+ /**
38
+ * Detailed description of the topic content
39
+ */
40
+ description;
41
+ /**
42
+ * URL to the topic's representative image
43
+ */
44
+ imageUrl;
45
+ /**
46
+ * Sort order for displaying topics within a lesson
47
+ */
48
+ sort;
49
+ /**
50
+ * List of skills covered in this topic
51
+ */
52
+ skills;
53
+ /**
54
+ * Reference to the parent lesson
55
+ */
56
+ lesson;
57
+ /**
58
+ * Student training lesson topic relations
59
+ * Keep track to student training topics in case by update or delete the lexxon topic
60
+ * to handle the student topics accordingly
61
+ * Only trainings in progress can be uodated or deleted from student lessons
62
+ */
63
+ studentTopics;
64
+ constructor(props) {
65
+ super();
66
+ Object.assign(this, props);
67
+ }
68
+ toModel() {
69
+ return new common_1.Topic({
70
+ id: this.id,
71
+ title: this.title,
72
+ description: this.description,
73
+ imageUrl: this.imageUrl,
74
+ skills: this.skills ? this.skills.map(common_1.Skill.toInstance) : null,
75
+ sort: this.sort
76
+ });
77
+ }
78
+ toSummary() {
79
+ return new common_1.Topic({
80
+ id: this.id,
81
+ title: this.title,
82
+ imageUrl: this.imageUrl,
83
+ sort: this.sort
84
+ });
85
+ }
86
+ async getActivities() {
87
+ const activities = [];
88
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
89
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
90
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
91
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
92
+ return activities.filter(a => a);
93
+ }
94
+ };
95
+ exports.CompanyCourseTopicEntity = CompanyCourseTopicEntity;
96
+ __decorate([
97
+ (0, typeorm_1.Column)(),
98
+ __metadata("design:type", Number)
99
+ ], CompanyCourseTopicEntity.prototype, "lessonId", void 0);
100
+ __decorate([
101
+ (0, typeorm_1.Column)(),
102
+ __metadata("design:type", String)
103
+ ], CompanyCourseTopicEntity.prototype, "title", void 0);
104
+ __decorate([
105
+ (0, typeorm_1.Column)({
106
+ type: 'mediumtext',
107
+ nullable: true,
108
+ default: null
109
+ }),
110
+ __metadata("design:type", String)
111
+ ], CompanyCourseTopicEntity.prototype, "description", void 0);
112
+ __decorate([
113
+ (0, typeorm_1.Column)({
114
+ nullable: true,
115
+ default: null
116
+ }),
117
+ __metadata("design:type", String)
118
+ ], CompanyCourseTopicEntity.prototype, "imageUrl", void 0);
119
+ __decorate([
120
+ (0, typeorm_1.Column)({
121
+ type: 'tinyint',
122
+ nullable: true,
123
+ default: null
124
+ }),
125
+ __metadata("design:type", Number)
126
+ ], CompanyCourseTopicEntity.prototype, "sort", void 0);
127
+ __decorate([
128
+ (0, typeorm_1.Column)({
129
+ type: 'json',
130
+ nullable: true,
131
+ default: null
132
+ }),
133
+ __metadata("design:type", Array)
134
+ ], CompanyCourseTopicEntity.prototype, "skills", void 0);
135
+ __decorate([
136
+ (0, typeorm_1.ManyToOne)(() => lesson_entity_1.CompanyCourseLessonEntity, lesson => lesson.topics),
137
+ __metadata("design:type", Promise)
138
+ ], CompanyCourseTopicEntity.prototype, "lesson", void 0);
139
+ __decorate([
140
+ (0, typeorm_1.OneToMany)(() => topic_entity_1.StudentTrainingTopicEntity, topic => topic.topic),
141
+ __metadata("design:type", Promise)
142
+ ], CompanyCourseTopicEntity.prototype, "studentTopics", void 0);
143
+ exports.CompanyCourseTopicEntity = CompanyCourseTopicEntity = __decorate([
144
+ (0, typeorm_1.Entity)('companyCourseTopics'),
145
+ __metadata("design:paramtypes", [Object])
146
+ ], CompanyCourseTopicEntity);
147
+ //# sourceMappingURL=topic.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topic.entity.js","sourceRoot":"","sources":["../../../../src/profile/company/course/topic.entity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wDACzB;AAS3C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,yCAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;;+DACb;mCAlEzC,wBAAwB;IADpC,IAAA,gBAAM,EAAC,qBAAqB,CAAC;;GACjB,wBAAwB,CAqGpC"}
@@ -0,0 +1,145 @@
1
+ import { BillStatus, Bill, Activity } from '@driveup/common';
2
+ import { CompanyEntity } from '../../company.entity';
3
+ import { CompanyBillTransactionEntity } from './transaction.entity';
4
+ import { CompanyBillItemEntity } from './item.entity';
5
+ import { TrackableEntity } from '../../../../utils';
6
+ /**
7
+ * Entity representing a company's billing statement for a specific period.
8
+ *
9
+ * @extends TrackableEntity<Bill>
10
+ */
11
+ export declare class CompanyBillEntity extends TrackableEntity<Bill> {
12
+ /**
13
+ * The ID of the company this bill belongs to
14
+ */
15
+ companyId: number;
16
+ /**
17
+ * Current status of the bill
18
+ * @type {BillStatus}
19
+ * @default BillStatus.Open
20
+ */
21
+ status: BillStatus;
22
+ /**
23
+ * Billing period start date
24
+ */
25
+ startDate: Date;
26
+ /**
27
+ * Billing period end date
28
+ */
29
+ endDate: Date;
30
+ /**
31
+ * - Total price of all items before promotion code discount, and taxes (excluded the free benefits)
32
+ *
33
+ * - If billItem.freeBenefit = true, then that item's price is not included in this subTotalPrice
34
+ */
35
+ subtotalPrice: number;
36
+ /**
37
+ * - Total price of all items after all discounts (from agent promotion code) and taxes
38
+ *
39
+ * - Steps:
40
+ * As default the totalPrice is equal to subTotalPrice, then we apply the following changes:
41
+ *
42
+ * - 1. get available amount from the credit, and store this in creditAmount.
43
+ * this.creditAmount = company.credit >= this.subTotalPrice ? this.subTotalPrice : company.credit
44
+ * // TODO: reduce company.credit by this.creditAmount
45
+ *
46
+ * - 2. reduce the totalPrice by creditAmount.
47
+ * this.totalPrice = this.subTotalPrice - this.creditAmount
48
+ *
49
+ * - 4. calculate agent payout amount.
50
+ * this.agentAmount = (this.totalPrice * agentCode.agentPercentage) / 100
51
+ *
52
+ * - 6. calculate taxAmount.
53
+ * this.taxAmount = (this.totalPrice * product.vat) / 100
54
+ *
55
+ * - 7. increase totalPrice by taxAmount.
56
+ * this.totalPrice = this.totalPrice + this.taxAmount
57
+ *
58
+ * - 8. if the amount is more than 0, go to stripe and submit the payment
59
+ */
60
+ totalPrice: number;
61
+ /**
62
+ * The total tax amount for this bill
63
+ */
64
+ taxAmount: number;
65
+ /**
66
+ * The amount that was taken from company's credit balance for this bill
67
+ */
68
+ creditAmount: number;
69
+ /**
70
+ * The product balance after this bill is calculated before sending the payment to the provider
71
+ * @type {number}
72
+ * @default 0
73
+ */
74
+ productBalance: number;
75
+ /**
76
+ * Total number of trainings that were covered by free benefits
77
+ * @type {number | null}
78
+ * @default null
79
+ */
80
+ freeBenefitItems: number;
81
+ /**
82
+ * Total amount of the trainings that was covered by free benefits
83
+ * @type {number | null}
84
+ * @default null
85
+ */
86
+ freeBenefitAmount: number;
87
+ /**
88
+ * Total amount that was reducted from credit or was covered by free benefits
89
+ * @type {number | null}
90
+ * @default null
91
+ */
92
+ fromCreditOrFreeBenefits: number;
93
+ /**
94
+ * The amount that goes to the agent for this bill
95
+ *
96
+ * - This number is updated after bill's payment is confirmed (25% of totalPrice goes to agent)
97
+ * @type {number}
98
+ * @default 0
99
+ */
100
+ agentProfit: number;
101
+ /**
102
+ * The company this bill belongs to
103
+ */
104
+ company: Promise<CompanyEntity>;
105
+ /**
106
+ * Line items included in this bill
107
+ */
108
+ items: Promise<CompanyBillItemEntity[]>;
109
+ /**
110
+ * Payment transactions associated with this bill
111
+ */
112
+ transactions: Promise<CompanyBillTransactionEntity[]>;
113
+ /**
114
+ * Creates a new CompanyBillEntity instance
115
+ * @param {Partial<CompanyBillEntity>} [props] - Optional initial properties
116
+ */
117
+ constructor(props?: Partial<CompanyBillEntity>);
118
+ /**
119
+ * Converts the entity to a Bill model
120
+ * @returns {Bill} The Bill model representation
121
+ */
122
+ toModel(): Bill;
123
+ /**
124
+ * Converts the entity to a Bill model
125
+ * @returns {Bill} The Bill model representation
126
+ */
127
+ toSummary(): Bill;
128
+ /**
129
+ * Calculates the subtotal price by summing all non-free-benefit items
130
+ * @returns {Promise<number>} The subtotal price
131
+ */
132
+ getSubtotalPrice(): Promise<number>;
133
+ /**
134
+ * Calculates the total tax amount for all non-free-benefit items
135
+ * Tax is calculated on the price after credit is applied
136
+ * @returns {Promise<number>} The total tax amount
137
+ */
138
+ getTotalTaxAmount(): Promise<number>;
139
+ /**
140
+ * Retrieves activity log entries for this bill
141
+ * Includes creation and update timestamps and user information
142
+ * @returns {Promise<Activity[]>} Array of activity entries (filtered to remove null values)
143
+ */
144
+ getActivities(): Promise<Activity[]>;
145
+ }