@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,174 @@
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.AgentPromotionEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const agent_entity_1 = require("./agent.entity");
16
+ const payout_entity_1 = require("./payout.entity");
17
+ const company_entity_1 = require("../company/company.entity");
18
+ const transaction_entity_1 = require("../company/finances/billing/transaction.entity");
19
+ const utils_1 = require("../../utils");
20
+ /**
21
+ * Represents a promotion generated by an agent.
22
+ * Tracks the relationship between an agent, a referred company, and the
23
+ * resulting profit. Promotions can be included in payouts for commission distribution.
24
+ *
25
+ * @extends TrackableEntity<PayoutItem>
26
+ */
27
+ let AgentPromotionEntity = class AgentPromotionEntity extends utils_1.TrackableEntity {
28
+ /**
29
+ * Reference to the agent who generated this promotion
30
+ */
31
+ agentId;
32
+ /**
33
+ * Reference to the company that used the agent's promotion code
34
+ */
35
+ companyId;
36
+ /**
37
+ * Reference to the bill transaction associated with this promotion
38
+ */
39
+ transactionId;
40
+ /**
41
+ * Reference to the payout this promotion is included in
42
+ * Null if not yet paid out
43
+ */
44
+ payoutId;
45
+ /**
46
+ * The profit generated from this promotion
47
+ */
48
+ profit;
49
+ /**
50
+ * Start date of the promotion period
51
+ */
52
+ startDate;
53
+ /**
54
+ * End date of the promotion period
55
+ */
56
+ endDate;
57
+ /**
58
+ * Agent profile
59
+ */
60
+ agent;
61
+ /**
62
+ * Binded promotion for company (by promotion code in onboarding process)
63
+ */
64
+ company;
65
+ /**
66
+ * Payout containing this promotion
67
+ * Payouts are generated periodically and contain set of selected promotions
68
+ */
69
+ payout;
70
+ /**
71
+ * Reference to company bill transaction created for this promotion profit
72
+ */
73
+ transaction;
74
+ /**
75
+ * Creates an instance of AgentPromotionEntity
76
+ * @param props - Partial properties to initialize the entity
77
+ */
78
+ constructor(props) {
79
+ super();
80
+ Object.assign(this, props);
81
+ }
82
+ /**
83
+ * Converts the entity to a PayoutItem model instance
84
+ * @returns PayoutItem model with profit, period, and customer information
85
+ */
86
+ async toModel() {
87
+ return new common_1.PayoutItem({
88
+ id: this.id,
89
+ profit: this.profit,
90
+ period: new common_1.Period({
91
+ startDate: this.startDate,
92
+ endDate: this.endDate
93
+ }),
94
+ customer: (await this.company)?.toCustomer()
95
+ });
96
+ }
97
+ /**
98
+ * Converts the entity to a PayoutItem model instance
99
+ * @returns PayoutItem model with profit, period, and customer information
100
+ */
101
+ async toSummary() {
102
+ return await this.toModel();
103
+ }
104
+ /**
105
+ * Retrieves all activity records for this promotion
106
+ * Includes creation and update actions
107
+ * @returns Array of Activity objects
108
+ */
109
+ async getActivities() {
110
+ const activities = [];
111
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
112
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
113
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
114
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
115
+ return activities.filter(a => a);
116
+ }
117
+ };
118
+ exports.AgentPromotionEntity = AgentPromotionEntity;
119
+ __decorate([
120
+ (0, typeorm_1.Column)(),
121
+ __metadata("design:type", Number)
122
+ ], AgentPromotionEntity.prototype, "agentId", void 0);
123
+ __decorate([
124
+ (0, typeorm_1.Column)(),
125
+ __metadata("design:type", Number)
126
+ ], AgentPromotionEntity.prototype, "companyId", void 0);
127
+ __decorate([
128
+ (0, typeorm_1.Column)(),
129
+ __metadata("design:type", Number)
130
+ ], AgentPromotionEntity.prototype, "transactionId", void 0);
131
+ __decorate([
132
+ (0, typeorm_1.Column)({
133
+ nullable: true,
134
+ default: null
135
+ }),
136
+ __metadata("design:type", Number)
137
+ ], AgentPromotionEntity.prototype, "payoutId", void 0);
138
+ __decorate([
139
+ (0, typeorm_1.Column)({
140
+ nullable: false,
141
+ default: 0
142
+ }),
143
+ __metadata("design:type", Number)
144
+ ], AgentPromotionEntity.prototype, "profit", void 0);
145
+ __decorate([
146
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
147
+ __metadata("design:type", Date)
148
+ ], AgentPromotionEntity.prototype, "startDate", void 0);
149
+ __decorate([
150
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
151
+ __metadata("design:type", Date)
152
+ ], AgentPromotionEntity.prototype, "endDate", void 0);
153
+ __decorate([
154
+ (0, typeorm_1.ManyToOne)(() => agent_entity_1.AgentEntity, agent => agent.promotions),
155
+ __metadata("design:type", Promise)
156
+ ], AgentPromotionEntity.prototype, "agent", void 0);
157
+ __decorate([
158
+ (0, typeorm_1.ManyToOne)(() => company_entity_1.CompanyEntity, company => company.agentPromotions),
159
+ __metadata("design:type", Promise)
160
+ ], AgentPromotionEntity.prototype, "company", void 0);
161
+ __decorate([
162
+ (0, typeorm_1.ManyToOne)(() => payout_entity_1.AgentPayoutEntity, payout => payout.promotions),
163
+ __metadata("design:type", Promise)
164
+ ], AgentPromotionEntity.prototype, "payout", void 0);
165
+ __decorate([
166
+ (0, typeorm_1.OneToOne)(() => transaction_entity_1.CompanyBillTransactionEntity, transaction => transaction.agentPromotion),
167
+ (0, typeorm_1.JoinColumn)(),
168
+ __metadata("design:type", Promise)
169
+ ], AgentPromotionEntity.prototype, "transaction", void 0);
170
+ exports.AgentPromotionEntity = AgentPromotionEntity = __decorate([
171
+ (0, typeorm_1.Entity)('agentPromotions'),
172
+ __metadata("design:paramtypes", [Object])
173
+ ], AgentPromotionEntity);
174
+ //# sourceMappingURL=promotion.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/promotion.entity.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,234 @@
1
+ import { Company, AccountStatus, Language, Activity } from '@driveup/common';
2
+ import { WorkingHours, Holiday, Address, Preference } from '@driveup/common';
3
+ import { BankAccount, Tax, Link, Customer } from '@driveup/common';
4
+ import { CountryEntity } from '../../system/country/country.entity';
5
+ import { CompanyExpenseEntity } from './finances/expense/expense.entity';
6
+ import { CompanyExpenseCategoryEntity } from './finances/expense/category.entity';
7
+ import { CompanyHandoverEntity } from './finances/handover/handover.entity';
8
+ import { CompanyInvoiceEntity } from './finances/invoice/invoice.entity';
9
+ import { CompanyPaymentMethodEntity } from './finances/payment/method.entity';
10
+ import { CompanyBillEntity } from './finances/billing/bill.entity';
11
+ import { CompanyProductEntity } from './product/product.entity';
12
+ import { CompanyInstructorEntity } from './instructor/instructor.entity';
13
+ import { AgentPromotionEntity } from '../agent/promotion.entity';
14
+ import { TrackableEntity } from '../../utils';
15
+ /**
16
+ * Represents a driving school company in the system.
17
+ * Companies offer training products, manage instructors and students,
18
+ * handle billing, and maintain their own settings and preferences.
19
+ * Each company operates within a specific country and can have multiple locations.
20
+ *
21
+ * @extends TrackableEntity<Company>
22
+ */
23
+ export declare class CompanyEntity extends TrackableEntity<Company> {
24
+ /**
25
+ * Reference to the country this company operates in
26
+ */
27
+ countryId: number;
28
+ /**
29
+ * Unique identifier (UUID) for external references
30
+ * Auto-generated on creation
31
+ */
32
+ uid: string;
33
+ /**
34
+ * Account status of the company
35
+ * @default AccountStatus.Invited
36
+ */
37
+ status: AccountStatus;
38
+ /**
39
+ * Company name
40
+ */
41
+ name: string;
42
+ /**
43
+ * Company description for marketing purposes
44
+ */
45
+ description: string;
46
+ /**
47
+ * Primary language for company operations
48
+ * @default Language.De
49
+ */
50
+ language: Language;
51
+ /**
52
+ * Timezone for scheduling and appointments
53
+ * @default 'Europe/Zurich'
54
+ */
55
+ timezone: string;
56
+ /**
57
+ * URL to the company's logo image
58
+ */
59
+ logoUrl: string;
60
+ /**
61
+ * Promtion code from agent
62
+ */
63
+ promotionCode: string;
64
+ /**
65
+ * Company's physical address
66
+ */
67
+ address: Address;
68
+ /**
69
+ * Bank account information for payouts and payments
70
+ */
71
+ bankAccount: BankAccount;
72
+ /**
73
+ * Tax identification number
74
+ */
75
+ taxID: string;
76
+ /**
77
+ * Company operational locations
78
+ * Can have multiple training locations
79
+ */
80
+ locations: Address[];
81
+ /**
82
+ * Contact phone number
83
+ */
84
+ phone: string;
85
+ /**
86
+ * Contact email address
87
+ */
88
+ email: string;
89
+ /**
90
+ * Company website URL
91
+ */
92
+ homepage: string;
93
+ /**
94
+ * Social media and other related links
95
+ */
96
+ links: Link[];
97
+ /**
98
+ * Calculated field to optimize rating calculation
99
+ */
100
+ rating: number;
101
+ /**
102
+ * Company credit
103
+ * Global company wallet balance (can't be negative)
104
+ * Allow company to bay credit from PSP provider and use it for payments
105
+ * Can be used by payments if company product credit is not enough
106
+ */
107
+ credit: number;
108
+ /**
109
+ * Tax configuration for invoicing
110
+ */
111
+ tax: Tax;
112
+ /**
113
+ * Weekly working hours schedule
114
+ */
115
+ workingHours: WorkingHours[];
116
+ /**
117
+ * Company holidays and closure dates
118
+ */
119
+ holidays: Holiday[];
120
+ /**
121
+ * Company preferences and settings
122
+ */
123
+ preferences: Preference[];
124
+ /**
125
+ * ID of the staff member who closed this company
126
+ */
127
+ closedBy: number;
128
+ /**
129
+ * Timestamp when the company was closed
130
+ */
131
+ closedOn: Date;
132
+ /**
133
+ * Country relation
134
+ */
135
+ country: Promise<CountryEntity>;
136
+ /**
137
+ * Company products relation
138
+ */
139
+ products: Promise<CompanyProductEntity[]>;
140
+ /**
141
+ * Company bills relation
142
+ */
143
+ bills: Promise<CompanyBillEntity[]>;
144
+ /**
145
+ * Company payment methods relation
146
+ */
147
+ paymentMethods: Promise<CompanyPaymentMethodEntity[]>;
148
+ /**
149
+ * Company instructors relation
150
+ */
151
+ instructors: Promise<CompanyInstructorEntity[]>;
152
+ /**
153
+ * Company expenses relation
154
+ */
155
+ expenses: Promise<CompanyExpenseEntity[]>;
156
+ /**
157
+ * Company expense categories relation
158
+ */
159
+ expenseCategories: Promise<CompanyExpenseCategoryEntity[]>;
160
+ /**
161
+ * Handovers related to this company
162
+ */
163
+ handovers: Promise<CompanyHandoverEntity[]>;
164
+ /**
165
+ * Invoices related to this company
166
+ */
167
+ invoices: Promise<CompanyInvoiceEntity[]>;
168
+ /**
169
+ * Agent promotions related to this company
170
+ */
171
+ agentPromotions: Promise<AgentPromotionEntity[]>;
172
+ /**
173
+ * Creates a new CompanyEntity instance
174
+ * @param props - Partial properties to initialize the entity
175
+ */
176
+ constructor(props?: Partial<CompanyEntity>);
177
+ /**
178
+ * Converts the entity to a Company model instance with core information
179
+ * @returns Company model with essential company data
180
+ */
181
+ toModel(): Company;
182
+ /**
183
+ * Converts the entity to a Company summary model with minimal information
184
+ * @returns Company model with basic information for listings
185
+ */
186
+ toSummary(): Company;
187
+ /**
188
+ * Converts the entity to a Company model with all detailed information
189
+ * @returns Company model with complete information including address, bank account, tax, etc.
190
+ */
191
+ toModelWithDetails(): Company;
192
+ /**
193
+ * Converts the entity to a Customer model for invoicing purposes
194
+ * @returns Customer model with company information
195
+ */
196
+ toCustomer(): Customer;
197
+ /**
198
+ * Retrieves the owner of this company
199
+ * @returns Promise resolving to the CompanyInstructorEntity with Owner role
200
+ */
201
+ getOwner(): Promise<CompanyInstructorEntity>;
202
+ /**
203
+ * Retrieves all instructors associated with this company
204
+ * @param active - Optional flag to filter only active instructors
205
+ * @returns Promise resolving to array of CompanyInstructorEntity
206
+ */
207
+ getInstructors(active?: boolean): Promise<CompanyInstructorEntity[]>;
208
+ /**
209
+ * Retrieves all managers (owners and managers) associated with this company
210
+ * @param active - Optional flag to filter only active managers
211
+ * @returns Promise resolving to array of CompanyInstructorEntity with manager roles
212
+ */
213
+ getManagers(active?: boolean): Promise<CompanyInstructorEntity[]>;
214
+ /**
215
+ * Retrieves the active payment method for this company
216
+ * @returns Promise resolving to the active CompanyPaymentMethodEntity or null
217
+ */
218
+ getPaymentMethod(): Promise<CompanyPaymentMethodEntity>;
219
+ /**
220
+ * Calculates the total agent earnings from paid bills for this company
221
+ * @returns Promise resolving to the total agent profit amount
222
+ */
223
+ getAgentEarning(): Promise<number>;
224
+ /**
225
+ * Formats the company's full address as a single string
226
+ * @returns Formatted address string with location, address, and zip code
227
+ */
228
+ getFullAddress(): string;
229
+ /**
230
+ * Retrieves activity history for this company
231
+ * @returns Promise resolving to array of Activity instances tracking creation, updates, and closure
232
+ */
233
+ getActivities(): Promise<Activity[]>;
234
+ }