@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,558 @@
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.CompanyEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const common_2 = require("@driveup/common");
16
+ const common_3 = require("@driveup/common");
17
+ const country_entity_1 = require("../../system/country/country.entity");
18
+ const expense_entity_1 = require("./finances/expense/expense.entity");
19
+ const category_entity_1 = require("./finances/expense/category.entity");
20
+ const handover_entity_1 = require("./finances/handover/handover.entity");
21
+ const invoice_entity_1 = require("./finances/invoice/invoice.entity");
22
+ const method_entity_1 = require("./finances/payment/method.entity");
23
+ const bill_entity_1 = require("./finances/billing/bill.entity");
24
+ const product_entity_1 = require("./product/product.entity");
25
+ const instructor_entity_1 = require("./instructor/instructor.entity");
26
+ const promotion_entity_1 = require("../agent/promotion.entity");
27
+ const utils_1 = require("../../utils");
28
+ /**
29
+ * Represents a driving school company in the system.
30
+ * Companies offer training products, manage instructors and students,
31
+ * handle billing, and maintain their own settings and preferences.
32
+ * Each company operates within a specific country and can have multiple locations.
33
+ *
34
+ * @extends TrackableEntity<Company>
35
+ */
36
+ let CompanyEntity = class CompanyEntity extends utils_1.TrackableEntity {
37
+ /**
38
+ * Reference to the country this company operates in
39
+ */
40
+ countryId;
41
+ /**
42
+ * Unique identifier (UUID) for external references
43
+ * Auto-generated on creation
44
+ */
45
+ uid;
46
+ /**
47
+ * Account status of the company
48
+ * @default AccountStatus.Invited
49
+ */
50
+ status;
51
+ /**
52
+ * Company name
53
+ */
54
+ name;
55
+ /**
56
+ * Company description for marketing purposes
57
+ */
58
+ description;
59
+ /**
60
+ * Primary language for company operations
61
+ * @default Language.De
62
+ */
63
+ language;
64
+ /**
65
+ * Timezone for scheduling and appointments
66
+ * @default 'Europe/Zurich'
67
+ */
68
+ timezone;
69
+ /**
70
+ * URL to the company's logo image
71
+ */
72
+ logoUrl;
73
+ /**
74
+ * Promtion code from agent
75
+ */
76
+ promotionCode;
77
+ /**
78
+ * Company's physical address
79
+ */
80
+ address;
81
+ /**
82
+ * Bank account information for payouts and payments
83
+ */
84
+ bankAccount;
85
+ /**
86
+ * Tax identification number
87
+ */
88
+ taxID;
89
+ /**
90
+ * Company operational locations
91
+ * Can have multiple training locations
92
+ */
93
+ locations;
94
+ /**
95
+ * Contact phone number
96
+ */
97
+ phone;
98
+ /**
99
+ * Contact email address
100
+ */
101
+ email;
102
+ /**
103
+ * Company website URL
104
+ */
105
+ homepage;
106
+ /**
107
+ * Social media and other related links
108
+ */
109
+ links;
110
+ /**
111
+ * Calculated field to optimize rating calculation
112
+ */
113
+ rating;
114
+ /**
115
+ * Company credit
116
+ * Global company wallet balance (can't be negative)
117
+ * Allow company to bay credit from PSP provider and use it for payments
118
+ * Can be used by payments if company product credit is not enough
119
+ */
120
+ credit;
121
+ /**
122
+ * Tax configuration for invoicing
123
+ */
124
+ tax;
125
+ /**
126
+ * Weekly working hours schedule
127
+ */
128
+ workingHours;
129
+ /**
130
+ * Company holidays and closure dates
131
+ */
132
+ holidays;
133
+ /**
134
+ * Company preferences and settings
135
+ */
136
+ preferences;
137
+ /**
138
+ * ID of the staff member who closed this company
139
+ */
140
+ closedBy;
141
+ /**
142
+ * Timestamp when the company was closed
143
+ */
144
+ closedOn;
145
+ /**
146
+ * Country relation
147
+ */
148
+ country;
149
+ /**
150
+ * Company products relation
151
+ */
152
+ products;
153
+ /**
154
+ * Company bills relation
155
+ */
156
+ bills;
157
+ /**
158
+ * Company payment methods relation
159
+ */
160
+ paymentMethods;
161
+ /**
162
+ * Company instructors relation
163
+ */
164
+ instructors;
165
+ /**
166
+ * Company expenses relation
167
+ */
168
+ expenses;
169
+ /**
170
+ * Company expense categories relation
171
+ */
172
+ expenseCategories;
173
+ /**
174
+ * Handovers related to this company
175
+ */
176
+ handovers;
177
+ /**
178
+ * Invoices related to this company
179
+ */
180
+ invoices;
181
+ /**
182
+ * Agent promotions related to this company
183
+ */
184
+ agentPromotions;
185
+ /**
186
+ * Creates a new CompanyEntity instance
187
+ * @param props - Partial properties to initialize the entity
188
+ */
189
+ constructor(props) {
190
+ super();
191
+ Object.assign(this, props);
192
+ }
193
+ /**
194
+ * Converts the entity to a Company model instance with core information
195
+ * @returns Company model with essential company data
196
+ */
197
+ toModel() {
198
+ return new common_1.Company({
199
+ id: this.id,
200
+ uid: this.uid,
201
+ status: this.status,
202
+ name: this.name,
203
+ description: this.description,
204
+ logoUrl: this.logoUrl,
205
+ language: this.language,
206
+ timezone: this.timezone,
207
+ phone: this.phone,
208
+ credit: this.credit,
209
+ });
210
+ }
211
+ /**
212
+ * Converts the entity to a Company summary model with minimal information
213
+ * @returns Company model with basic information for listings
214
+ */
215
+ toSummary() {
216
+ return new common_1.Company({
217
+ id: this.id,
218
+ status: this.status,
219
+ name: this.name,
220
+ logoUrl: this.logoUrl,
221
+ phone: this.phone,
222
+ credit: this.credit,
223
+ });
224
+ }
225
+ /**
226
+ * Converts the entity to a Company model with all detailed information
227
+ * @returns Company model with complete information including address, bank account, tax, etc.
228
+ */
229
+ toModelWithDetails() {
230
+ const company = this.toModel();
231
+ company.address = common_2.Address.toInstance(this.address);
232
+ company.bankAccount = common_3.BankAccount.toInstance(this.bankAccount);
233
+ company.tax = common_3.Tax.toInstance(this.tax);
234
+ company.email = this.email;
235
+ company.homepage = this.homepage;
236
+ company.rating = this.rating;
237
+ company.links = this.links;
238
+ company.workingHours = this.workingHours?.map(common_2.WorkingHours.toInstance);
239
+ company.holidays = this.holidays?.map(common_2.Holiday.toInstance);
240
+ company.locations = this.locations?.map(common_2.Address.toInstance);
241
+ company.preferences = this.preferences?.map(common_2.Preference.toInstance);
242
+ return company;
243
+ }
244
+ /**
245
+ * Converts the entity to a Customer model for invoicing purposes
246
+ * @returns Customer model with company information
247
+ */
248
+ toCustomer() {
249
+ return new common_3.Customer({
250
+ id: this.id,
251
+ name: this.name,
252
+ imageUrl: this.logoUrl,
253
+ address: common_2.Address.toInstance(this.address),
254
+ phone: this.phone,
255
+ email: this.email,
256
+ });
257
+ }
258
+ /**
259
+ * Retrieves the owner of this company
260
+ * @returns Promise resolving to the CompanyInstructorEntity with Owner role
261
+ */
262
+ async getOwner() {
263
+ return await instructor_entity_1.CompanyInstructorEntity.findOneBy({
264
+ companyId: this.id,
265
+ role: common_1.CompanyRole.Owner
266
+ });
267
+ }
268
+ /**
269
+ * Retrieves all instructors associated with this company
270
+ * @param active - Optional flag to filter only active instructors
271
+ * @returns Promise resolving to array of CompanyInstructorEntity
272
+ */
273
+ async getInstructors(active) {
274
+ const instructors = (await this.instructors) || [];
275
+ return active ? instructors.filter(i => i.status === common_1.AccountStatus.Active) : instructors;
276
+ }
277
+ /**
278
+ * Retrieves all managers (owners and managers) associated with this company
279
+ * @param active - Optional flag to filter only active managers
280
+ * @returns Promise resolving to array of CompanyInstructorEntity with manager roles
281
+ */
282
+ async getManagers(active) {
283
+ const instructors = await this.getInstructors(active);
284
+ const managerRoles = [common_1.CompanyRole.Owner, common_1.CompanyRole.Manager];
285
+ return instructors?.filter(i => managerRoles.includes(i.role));
286
+ }
287
+ /**
288
+ * Retrieves the active payment method for this company
289
+ * @returns Promise resolving to the active CompanyPaymentMethodEntity or null
290
+ */
291
+ async getPaymentMethod() {
292
+ return await method_entity_1.CompanyPaymentMethodEntity.findOneBy({
293
+ companyId: this.id,
294
+ active: true
295
+ });
296
+ }
297
+ /**
298
+ * Calculates the total agent earnings from paid bills for this company
299
+ * @returns Promise resolving to the total agent profit amount
300
+ */
301
+ async getAgentEarning() {
302
+ return await bill_entity_1.CompanyBillEntity.sum('agentProfit', {
303
+ companyId: this.id,
304
+ status: common_3.BillStatus.Paid
305
+ });
306
+ }
307
+ /**
308
+ * Formats the company's full address as a single string
309
+ * @returns Formatted address string with location, address, and zip code
310
+ */
311
+ getFullAddress() {
312
+ const address = this.address?.address || '';
313
+ const location = this.address?.place || '';
314
+ const zipCode = this.address?.zipCode || '';
315
+ return `${location}, ${address} - ${zipCode}`.trim();
316
+ }
317
+ /**
318
+ * Retrieves activity history for this company
319
+ * @returns Promise resolving to array of Activity instances tracking creation, updates, and closure
320
+ */
321
+ async getActivities() {
322
+ const activities = [];
323
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
324
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
325
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
326
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
327
+ activities.push(await (0, utils_1.toActivity)(this.closedBy, common_1.ActivityType.closedBy));
328
+ activities.push(await (0, utils_1.toActivity)(this.closedOn, common_1.ActivityType.closedOn));
329
+ return activities.filter(a => a);
330
+ }
331
+ };
332
+ exports.CompanyEntity = CompanyEntity;
333
+ __decorate([
334
+ (0, typeorm_1.Column)(),
335
+ __metadata("design:type", Number)
336
+ ], CompanyEntity.prototype, "countryId", void 0);
337
+ __decorate([
338
+ (0, typeorm_1.Column)({ unique: true }),
339
+ (0, typeorm_1.Generated)('uuid'),
340
+ __metadata("design:type", String)
341
+ ], CompanyEntity.prototype, "uid", void 0);
342
+ __decorate([
343
+ (0, typeorm_1.Column)({
344
+ type: 'enum',
345
+ enum: common_1.AccountStatus,
346
+ default: common_1.AccountStatus.Invited,
347
+ nullable: false
348
+ }),
349
+ __metadata("design:type", String)
350
+ ], CompanyEntity.prototype, "status", void 0);
351
+ __decorate([
352
+ (0, typeorm_1.Column)({
353
+ nullable: true,
354
+ default: null
355
+ }),
356
+ __metadata("design:type", String)
357
+ ], CompanyEntity.prototype, "name", void 0);
358
+ __decorate([
359
+ (0, typeorm_1.Column)({
360
+ nullable: true,
361
+ default: null
362
+ }),
363
+ __metadata("design:type", String)
364
+ ], CompanyEntity.prototype, "description", void 0);
365
+ __decorate([
366
+ (0, typeorm_1.Column)({
367
+ type: 'enum',
368
+ enum: common_1.Language,
369
+ default: common_1.Language.De,
370
+ nullable: true
371
+ }),
372
+ __metadata("design:type", String)
373
+ ], CompanyEntity.prototype, "language", void 0);
374
+ __decorate([
375
+ (0, typeorm_1.Column)({
376
+ nullable: true,
377
+ default: 'Europe/Zurich'
378
+ }),
379
+ __metadata("design:type", String)
380
+ ], CompanyEntity.prototype, "timezone", void 0);
381
+ __decorate([
382
+ (0, typeorm_1.Column)({
383
+ nullable: true,
384
+ default: null
385
+ }),
386
+ __metadata("design:type", String)
387
+ ], CompanyEntity.prototype, "logoUrl", void 0);
388
+ __decorate([
389
+ (0, typeorm_1.Column)({
390
+ nullable: true,
391
+ default: null
392
+ }),
393
+ __metadata("design:type", String)
394
+ ], CompanyEntity.prototype, "promotionCode", void 0);
395
+ __decorate([
396
+ (0, typeorm_1.Column)({
397
+ type: 'simple-json',
398
+ nullable: true,
399
+ default: null
400
+ }),
401
+ __metadata("design:type", common_2.Address)
402
+ ], CompanyEntity.prototype, "address", void 0);
403
+ __decorate([
404
+ (0, typeorm_1.Column)({
405
+ type: 'simple-json',
406
+ nullable: true,
407
+ default: null
408
+ }),
409
+ __metadata("design:type", common_3.BankAccount)
410
+ ], CompanyEntity.prototype, "bankAccount", void 0);
411
+ __decorate([
412
+ (0, typeorm_1.Column)({
413
+ nullable: true,
414
+ default: null
415
+ }),
416
+ __metadata("design:type", String)
417
+ ], CompanyEntity.prototype, "taxID", void 0);
418
+ __decorate([
419
+ (0, typeorm_1.Column)({
420
+ type: 'simple-json',
421
+ nullable: true,
422
+ default: null
423
+ }),
424
+ __metadata("design:type", Array)
425
+ ], CompanyEntity.prototype, "locations", void 0);
426
+ __decorate([
427
+ (0, typeorm_1.Column)({
428
+ nullable: true,
429
+ default: null
430
+ }),
431
+ __metadata("design:type", String)
432
+ ], CompanyEntity.prototype, "phone", void 0);
433
+ __decorate([
434
+ (0, typeorm_1.Column)({
435
+ nullable: true,
436
+ default: null
437
+ }),
438
+ __metadata("design:type", String)
439
+ ], CompanyEntity.prototype, "email", void 0);
440
+ __decorate([
441
+ (0, typeorm_1.Column)({
442
+ nullable: true,
443
+ default: null
444
+ }),
445
+ __metadata("design:type", String)
446
+ ], CompanyEntity.prototype, "homepage", void 0);
447
+ __decorate([
448
+ (0, typeorm_1.Column)({
449
+ type: 'simple-json',
450
+ nullable: true,
451
+ default: null
452
+ }),
453
+ __metadata("design:type", Array)
454
+ ], CompanyEntity.prototype, "links", void 0);
455
+ __decorate([
456
+ (0, typeorm_1.Column)({
457
+ nullable: true,
458
+ default: null,
459
+ type: 'decimal',
460
+ precision: 1
461
+ }),
462
+ __metadata("design:type", Number)
463
+ ], CompanyEntity.prototype, "rating", void 0);
464
+ __decorate([
465
+ (0, typeorm_1.Column)({
466
+ type: 'decimal',
467
+ precision: 10,
468
+ scale: 2,
469
+ nullable: false,
470
+ default: 0
471
+ }),
472
+ __metadata("design:type", Number)
473
+ ], CompanyEntity.prototype, "credit", void 0);
474
+ __decorate([
475
+ (0, typeorm_1.Column)({
476
+ type: 'simple-json',
477
+ nullable: true,
478
+ default: null
479
+ }),
480
+ __metadata("design:type", common_3.Tax)
481
+ ], CompanyEntity.prototype, "tax", void 0);
482
+ __decorate([
483
+ (0, typeorm_1.Column)({
484
+ type: 'simple-json',
485
+ nullable: true,
486
+ default: null
487
+ }),
488
+ __metadata("design:type", Array)
489
+ ], CompanyEntity.prototype, "workingHours", void 0);
490
+ __decorate([
491
+ (0, typeorm_1.Column)({
492
+ type: 'simple-json',
493
+ nullable: true,
494
+ default: null
495
+ }),
496
+ __metadata("design:type", Array)
497
+ ], CompanyEntity.prototype, "holidays", void 0);
498
+ __decorate([
499
+ (0, typeorm_1.Column)({
500
+ type: 'simple-json',
501
+ nullable: true,
502
+ default: null
503
+ }),
504
+ __metadata("design:type", Array)
505
+ ], CompanyEntity.prototype, "preferences", void 0);
506
+ __decorate([
507
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
508
+ __metadata("design:type", Number)
509
+ ], CompanyEntity.prototype, "closedBy", void 0);
510
+ __decorate([
511
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
512
+ __metadata("design:type", Date)
513
+ ], CompanyEntity.prototype, "closedOn", void 0);
514
+ __decorate([
515
+ (0, typeorm_1.ManyToOne)(() => country_entity_1.CountryEntity, country => country.companies),
516
+ __metadata("design:type", Promise)
517
+ ], CompanyEntity.prototype, "country", void 0);
518
+ __decorate([
519
+ (0, typeorm_1.OneToMany)(() => product_entity_1.CompanyProductEntity, product => product.company),
520
+ __metadata("design:type", Promise)
521
+ ], CompanyEntity.prototype, "products", void 0);
522
+ __decorate([
523
+ (0, typeorm_1.OneToMany)(() => bill_entity_1.CompanyBillEntity, bill => bill.company),
524
+ __metadata("design:type", Promise)
525
+ ], CompanyEntity.prototype, "bills", void 0);
526
+ __decorate([
527
+ (0, typeorm_1.OneToMany)(() => method_entity_1.CompanyPaymentMethodEntity, method => method.company),
528
+ __metadata("design:type", Promise)
529
+ ], CompanyEntity.prototype, "paymentMethods", void 0);
530
+ __decorate([
531
+ (0, typeorm_1.OneToMany)(() => instructor_entity_1.CompanyInstructorEntity, instructor => instructor.company),
532
+ __metadata("design:type", Promise)
533
+ ], CompanyEntity.prototype, "instructors", void 0);
534
+ __decorate([
535
+ (0, typeorm_1.OneToMany)(() => expense_entity_1.CompanyExpenseEntity, expense => expense.company),
536
+ __metadata("design:type", Promise)
537
+ ], CompanyEntity.prototype, "expenses", void 0);
538
+ __decorate([
539
+ (0, typeorm_1.OneToMany)(() => category_entity_1.CompanyExpenseCategoryEntity, expenseCategory => expenseCategory.company),
540
+ __metadata("design:type", Promise)
541
+ ], CompanyEntity.prototype, "expenseCategories", void 0);
542
+ __decorate([
543
+ (0, typeorm_1.OneToMany)(() => handover_entity_1.CompanyHandoverEntity, handover => handover.company),
544
+ __metadata("design:type", Promise)
545
+ ], CompanyEntity.prototype, "handovers", void 0);
546
+ __decorate([
547
+ (0, typeorm_1.OneToMany)(() => invoice_entity_1.CompanyInvoiceEntity, invoice => invoice.company),
548
+ __metadata("design:type", Promise)
549
+ ], CompanyEntity.prototype, "invoices", void 0);
550
+ __decorate([
551
+ (0, typeorm_1.OneToMany)(() => promotion_entity_1.AgentPromotionEntity, promotion => promotion.company),
552
+ __metadata("design:type", Promise)
553
+ ], CompanyEntity.prototype, "agentPromotions", void 0);
554
+ exports.CompanyEntity = CompanyEntity = __decorate([
555
+ (0, typeorm_1.Entity)('companies'),
556
+ __metadata("design:paramtypes", [Object])
557
+ ], CompanyEntity);
558
+ //# sourceMappingURL=company.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company.entity.js","sourceRoot":"","sources":["../../../src/profile/company/company.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0E;AAC1E,4CAAwG;AACxG,4CAA6E;AAC7E,4CAA+E;AAC/E,wEAAoE;AACpE,sEAAyE;AACzE,wEAAkF;AAClF,yEAA4E;AAC5E,sEAAyE;AACzE,oEAA8E;AAC9E,gEAAmE;AACnE,6DAAgE;AAChE,sEAAyE;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C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;;sDACrB;wBA3SrC,aAAa;IADzB,IAAA,gBAAM,EAAC,WAAW,CAAC;;GACP,aAAa,CA0czB"}
@@ -0,0 +1,111 @@
1
+ import { Activity, RecurringAppointment, WeekDay } from '@driveup/common';
2
+ import { IDateUpdate, IDateAssignment, IDateDuration } from '@driveup/common';
3
+ import { CompanyCourseLessonEntity } from './lesson.entity';
4
+ import { StudentTrainingAppointmentEntity } from '../../student/program/training/appointment.entity';
5
+ import { CompanyInstructorEntity } from '../instructor/instructor.entity';
6
+ import { TrackableEntity } from '../../../utils';
7
+ /**
8
+ * Represents a series of training appointment offers managed by the company.
9
+ *
10
+ * This entity defines appointment templates that serve as available time slots
11
+ * for student training sessions. Companies manage these appointments to organize
12
+ * their course training schedules, which students can then book.
13
+ *
14
+ * Supports both single and recurring appointments with flexible scheduling options
15
+ * including:
16
+ * - Weekly repetitions on specific weekdays
17
+ * - Custom date ranges for recurring appointments
18
+ * - Exception handling for skipped dates
19
+ * - Per-date overrides for time, instructor, and duration
20
+ *
21
+ * @remarks
22
+ * This is a company-managed entity that creates the foundation for student
23
+ * training bookings. Each appointment definition can generate multiple actual
24
+ * student appointments based on its repetition settings.
25
+ *
26
+ * @see {@link CompanyCourseLessonEntity} for the associated course lesson
27
+ * @see {@link StudentTrainingEntity} for student bookings
28
+ */
29
+ export declare class CompanyCourseAppointmentEntity extends TrackableEntity<RecurringAppointment> {
30
+ /**
31
+ * Company course lesson
32
+ */
33
+ lessonId: number;
34
+ /**
35
+ * In-charge instructor for the appointment
36
+ * For driving courses, can be empty
37
+ */
38
+ instructorId: number;
39
+ /**
40
+ * Represents the lesson start date for single appointments by student trainings.
41
+ * @remarks By recurring appoitmnets this field represents start of sierie
42
+ */
43
+ startDate: Date;
44
+ /**
45
+ * Represents the lesson end date for single appointments by student trainings.
46
+ * @remarks By recurring appoitmnets this field represents end of sierie (repeat until this date)
47
+ */
48
+ endDate: Date;
49
+ /**
50
+ * Duration of the appointment in minutes
51
+ * By fix courses this value is inherited from lesson
52
+ */
53
+ duration: number;
54
+ /**
55
+ * Indicates if the appointment is recurring
56
+ */
57
+ repetition: boolean;
58
+ /**
59
+ * Weekdays on which the appointment recurs
60
+ */
61
+ weekdays: WeekDay[];
62
+ /**
63
+ * Skipped dates for this recurring appointment
64
+ */
65
+ skippedDates: Date[];
66
+ /**
67
+ * Changed dates for this recurring appointment
68
+ */
69
+ updates: IDateUpdate[];
70
+ /**
71
+ * Different instructors for specific dates
72
+ */
73
+ instructors: IDateAssignment[];
74
+ /**
75
+ * Different durations for specific dates
76
+ */
77
+ durations: IDateDuration[];
78
+ /**
79
+ * Course lesson
80
+ */
81
+ lesson: Promise<CompanyCourseLessonEntity>;
82
+ /**
83
+ * Company instructor relation
84
+ */
85
+ instructor: Promise<CompanyInstructorEntity>;
86
+ /**
87
+ * Student training appointments relation
88
+ */
89
+ studentAppointments: Promise<StudentTrainingAppointmentEntity[]>;
90
+ /**
91
+ * Creates a new CompanyCourseAppointmentEntity instance
92
+ * @param props - Partial properties to initialize the entity with
93
+ */
94
+ constructor(props?: Partial<CompanyCourseAppointmentEntity>);
95
+ /**
96
+ * Converts the entity to a RecurringAppointment model instance
97
+ * @returns Promise resolving to RecurringAppointment model with lesson, instructor, and scheduling details
98
+ */
99
+ toModel(): Promise<RecurringAppointment<any>>;
100
+ /**
101
+ * Returns a summary representation of the appointment
102
+ * @returns Promise resolving to RecurringAppointment model (same as toModel())
103
+ */
104
+ toSummary(): Promise<RecurringAppointment<any>>;
105
+ /**
106
+ * Retrieves all tracked activities for this appointment
107
+ * Includes creation and update timestamps and associated users
108
+ * @returns Promise resolving to array of Activity objects filtered to exclude null values
109
+ */
110
+ getActivities(): Promise<Activity[]>;
111
+ }