@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,95 @@
1
+ import { AccountStatus, Language, Activity, Agent, Person } from '@driveup/common';
2
+ import { BankAccount, Preference } from '@driveup/common';
3
+ import { UserEntity } from '../../user/user.entity';
4
+ import { AgentPayoutEntity } from './payout.entity';
5
+ import { AgentPromotionEntity } from './promotion.entity';
6
+ import { TrackableEntity } from '../../utils';
7
+ /**
8
+ * Represents an agent profile in the system.
9
+ * Agents are users who promote Driveup services and earn commissions
10
+ * through a unique promotion code. They can receive payouts based on
11
+ * their generated revenue.
12
+ *
13
+ * @extends TrackableEntity<Agent>
14
+ */
15
+ export declare class AgentEntity extends TrackableEntity<Agent> {
16
+ /**
17
+ * Reference to the user account
18
+ */
19
+ userId: number;
20
+ /**
21
+ * Account status of the agent profile
22
+ * @default AccountStatus.Pending
23
+ */
24
+ status: AccountStatus;
25
+ /**
26
+ * Agent's display name
27
+ */
28
+ name: string;
29
+ /**
30
+ * Preferred language for the agent interface
31
+ * @default Language.En
32
+ */
33
+ language: Language;
34
+ /**
35
+ * Unique promotion code for this agent
36
+ * Used by companies during onboarding to link to the agent
37
+ */
38
+ code: string;
39
+ /**
40
+ * Commission percentage earned on referred sales
41
+ * @default 50
42
+ */
43
+ percentage: number;
44
+ /**
45
+ * Bank account information for payouts
46
+ */
47
+ bankAccount: BankAccount;
48
+ /**
49
+ * Notification preferences stored as JSON
50
+ */
51
+ preferences: Preference[];
52
+ /**
53
+ * Agent user account
54
+ * User can have only one active agent profile
55
+ */
56
+ user: Promise<UserEntity>;
57
+ /**
58
+ * Agent promotions
59
+ */
60
+ promotions: Promise<AgentPromotionEntity[]>;
61
+ /**
62
+ * Promotion payouts
63
+ */
64
+ payouts: Promise<AgentPayoutEntity[]>;
65
+ /**
66
+ * Creates an instance of AgentEntity
67
+ * @param props - Partial properties to initialize the entity
68
+ */
69
+ constructor(props?: Partial<AgentEntity>);
70
+ /**
71
+ * Converts the entity to an Agent model instance
72
+ * @returns Agent model with basic information
73
+ */
74
+ toModel(): Promise<Agent>;
75
+ /**
76
+ * Converts the entity to an Agent model instance
77
+ * @returns Agent model with basic information
78
+ */
79
+ toSummary(): Promise<Agent>;
80
+ /**
81
+ * Converts the entity to a Person model
82
+ * @returns Promise resolving to Person model with basic contact information
83
+ */
84
+ toPerson(): Promise<Person>;
85
+ /**
86
+ * Retrieves notification preferences as typed Preference instances
87
+ * @returns Array of Preference objects or undefined if not set
88
+ */
89
+ getPreferences(): Preference<boolean>[];
90
+ /**
91
+ * Retrieves activity history for this agent
92
+ * @returns Promise resolving to array of Activity instances tracking creation and updates
93
+ */
94
+ getActivities(): Promise<Activity[]>;
95
+ }
@@ -0,0 +1,223 @@
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.AgentEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const common_2 = require("@driveup/common");
16
+ const user_entity_1 = require("../../user/user.entity");
17
+ const payout_entity_1 = require("./payout.entity");
18
+ const promotion_entity_1 = require("./promotion.entity");
19
+ const utils_1 = require("../../utils");
20
+ /**
21
+ * Represents an agent profile in the system.
22
+ * Agents are users who promote Driveup services and earn commissions
23
+ * through a unique promotion code. They can receive payouts based on
24
+ * their generated revenue.
25
+ *
26
+ * @extends TrackableEntity<Agent>
27
+ */
28
+ let AgentEntity = class AgentEntity extends utils_1.TrackableEntity {
29
+ /**
30
+ * Reference to the user account
31
+ */
32
+ userId;
33
+ /**
34
+ * Account status of the agent profile
35
+ * @default AccountStatus.Pending
36
+ */
37
+ status;
38
+ /**
39
+ * Agent's display name
40
+ */
41
+ name;
42
+ /**
43
+ * Preferred language for the agent interface
44
+ * @default Language.En
45
+ */
46
+ language;
47
+ /**
48
+ * Unique promotion code for this agent
49
+ * Used by companies during onboarding to link to the agent
50
+ */
51
+ code;
52
+ /**
53
+ * Commission percentage earned on referred sales
54
+ * @default 50
55
+ */
56
+ percentage;
57
+ /**
58
+ * Bank account information for payouts
59
+ */
60
+ bankAccount;
61
+ /**
62
+ * Notification preferences stored as JSON
63
+ */
64
+ preferences;
65
+ /**
66
+ * Agent user account
67
+ * User can have only one active agent profile
68
+ */
69
+ user;
70
+ /**
71
+ * Agent promotions
72
+ */
73
+ promotions;
74
+ /**
75
+ * Promotion payouts
76
+ */
77
+ payouts;
78
+ /**
79
+ * Creates an instance of AgentEntity
80
+ * @param props - Partial properties to initialize the entity
81
+ */
82
+ constructor(props) {
83
+ super();
84
+ Object.assign(this, props);
85
+ }
86
+ /**
87
+ * Converts the entity to an Agent model instance
88
+ * @returns Agent model with basic information
89
+ */
90
+ async toModel() {
91
+ const user = await this.user;
92
+ return new common_1.Agent({
93
+ id: this.id,
94
+ name: this.name || user.name,
95
+ imageUrl: user.imageUrl,
96
+ language: this.language || user.language,
97
+ code: this.code,
98
+ percentage: this.percentage,
99
+ status: this.status,
100
+ bankAccount: common_2.BankAccount.toInstance(this.bankAccount)
101
+ });
102
+ }
103
+ /**
104
+ * Converts the entity to an Agent model instance
105
+ * @returns Agent model with basic information
106
+ */
107
+ async toSummary() {
108
+ const user = await this.user;
109
+ return new common_1.Agent({
110
+ id: this.id,
111
+ name: this.name || user.name,
112
+ imageUrl: user.imageUrl,
113
+ language: this.language || user.language,
114
+ status: this.status
115
+ });
116
+ }
117
+ /**
118
+ * Converts the entity to a Person model
119
+ * @returns Promise resolving to Person model with basic contact information
120
+ */
121
+ async toPerson() {
122
+ const user = await this.user;
123
+ return new common_1.Person({
124
+ id: this.id,
125
+ name: this.name,
126
+ imageUrl: user.imageUrl,
127
+ phone: user.phone,
128
+ email: user.email
129
+ });
130
+ }
131
+ /**
132
+ * Retrieves notification preferences as typed Preference instances
133
+ * @returns Array of Preference objects or undefined if not set
134
+ */
135
+ getPreferences() {
136
+ if (!this.preferences)
137
+ return;
138
+ return this.preferences.map(common_2.Preference.toInstance);
139
+ }
140
+ /**
141
+ * Retrieves activity history for this agent
142
+ * @returns Promise resolving to array of Activity instances tracking creation and updates
143
+ */
144
+ async getActivities() {
145
+ const activities = [];
146
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
147
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
148
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
149
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
150
+ return activities.filter(a => a);
151
+ }
152
+ };
153
+ exports.AgentEntity = AgentEntity;
154
+ __decorate([
155
+ (0, typeorm_1.Column)(),
156
+ __metadata("design:type", Number)
157
+ ], AgentEntity.prototype, "userId", void 0);
158
+ __decorate([
159
+ (0, typeorm_1.Column)({
160
+ type: 'enum',
161
+ enum: common_1.AccountStatus,
162
+ default: common_1.AccountStatus.Pending,
163
+ nullable: false
164
+ }),
165
+ __metadata("design:type", String)
166
+ ], AgentEntity.prototype, "status", void 0);
167
+ __decorate([
168
+ (0, typeorm_1.Column)({
169
+ nullable: true,
170
+ default: null
171
+ }),
172
+ __metadata("design:type", String)
173
+ ], AgentEntity.prototype, "name", void 0);
174
+ __decorate([
175
+ (0, typeorm_1.Column)({
176
+ type: 'enum',
177
+ enum: common_1.Language,
178
+ default: common_1.Language.En,
179
+ nullable: true
180
+ }),
181
+ __metadata("design:type", String)
182
+ ], AgentEntity.prototype, "language", void 0);
183
+ __decorate([
184
+ (0, typeorm_1.Column)({ unique: true }),
185
+ __metadata("design:type", String)
186
+ ], AgentEntity.prototype, "code", void 0);
187
+ __decorate([
188
+ (0, typeorm_1.Column)({ default: 50 }),
189
+ __metadata("design:type", Number)
190
+ ], AgentEntity.prototype, "percentage", void 0);
191
+ __decorate([
192
+ (0, typeorm_1.Column)({
193
+ type: 'simple-json',
194
+ nullable: true,
195
+ default: null
196
+ }),
197
+ __metadata("design:type", common_2.BankAccount)
198
+ ], AgentEntity.prototype, "bankAccount", void 0);
199
+ __decorate([
200
+ (0, typeorm_1.Column)({
201
+ type: 'simple-json',
202
+ nullable: true,
203
+ default: null
204
+ }),
205
+ __metadata("design:type", Array)
206
+ ], AgentEntity.prototype, "preferences", void 0);
207
+ __decorate([
208
+ (0, typeorm_1.ManyToOne)(() => user_entity_1.UserEntity, user => user.agentProfiles),
209
+ __metadata("design:type", Promise)
210
+ ], AgentEntity.prototype, "user", void 0);
211
+ __decorate([
212
+ (0, typeorm_1.OneToMany)(() => promotion_entity_1.AgentPromotionEntity, promotion => promotion.agent),
213
+ __metadata("design:type", Promise)
214
+ ], AgentEntity.prototype, "promotions", void 0);
215
+ __decorate([
216
+ (0, typeorm_1.OneToMany)(() => payout_entity_1.AgentPayoutEntity, payout => payout.agent),
217
+ __metadata("design:type", Promise)
218
+ ], AgentEntity.prototype, "payouts", void 0);
219
+ exports.AgentEntity = AgentEntity = __decorate([
220
+ (0, typeorm_1.Entity)('agents'),
221
+ __metadata("design:paramtypes", [Object])
222
+ ], AgentEntity);
223
+ //# sourceMappingURL=agent.entity.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ACb,CAAC;;gDACwB;AAO1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;;yCAC/B;AAMzB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;;+CACxB;AAM5C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iCAAiB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;;4CACrB;sBA5F1B,WAAW;IADvB,IAAA,gBAAM,EAAC,QAAQ,CAAC;;GACJ,WAAW,CA4KvB"}
@@ -0,0 +1,70 @@
1
+ import { BankAccount, Payout } from '@driveup/common';
2
+ import { Activity, StatusType } from '@driveup/common';
3
+ import { AgentEntity } from './agent.entity';
4
+ import { AgentPromotionEntity } from './promotion.entity';
5
+ import { TrackableEntity } from '../../utils';
6
+ /**
7
+ * Represents a payout to an agent for their earned commissions.
8
+ * Payouts aggregate multiple promotions and track the payment status,
9
+ * amount, and bank account information.
10
+ *
11
+ * @extends TrackableEntity<Payout>
12
+ */
13
+ export declare class AgentPayoutEntity extends TrackableEntity<Payout> {
14
+ /**
15
+ * Reference to the agent receiving the payout
16
+ */
17
+ agentId: number;
18
+ /**
19
+ * Payment status (Pending, Paid, Failed)
20
+ * @default StatusType.Pending
21
+ */
22
+ status: StatusType;
23
+ /**
24
+ * Total payout amount in the agent's currency
25
+ * Precision: 8 digits, Scale: 2 decimal places
26
+ * @default 0
27
+ */
28
+ amount: number;
29
+ /**
30
+ * Bank account information where the payout was sent
31
+ */
32
+ bankAccount: BankAccount;
33
+ /**
34
+ * Timestamp when the payout was completed
35
+ */
36
+ paidOn: Date;
37
+ /**
38
+ * ID of the staff member who processed the payout
39
+ */
40
+ paidBy: number;
41
+ /**
42
+ * Agent receiving this payout
43
+ */
44
+ agent: Promise<AgentEntity>;
45
+ /**
46
+ * Promotions included in this payout
47
+ */
48
+ promotions: Promise<AgentPromotionEntity[]>;
49
+ /**
50
+ * Creates an instance of AgentPayoutEntity
51
+ * @param props - Partial properties to initialize the entity
52
+ */
53
+ constructor(props?: Partial<AgentPayoutEntity>);
54
+ /**
55
+ * Converts the entity to a Payout model instance
56
+ * @returns Payout model with status, amount, and bank account information
57
+ */
58
+ toModel(): Promise<Payout>;
59
+ /**
60
+ * Converts the entity to a Payout model instance
61
+ * @returns Payout model with status, amount, and bank account information
62
+ */
63
+ toSummary(): Promise<Payout>;
64
+ /**
65
+ * Retrieves all activity records for this payout
66
+ * Includes creation and payment actions
67
+ * @returns Array of Activity objects
68
+ */
69
+ getActivities(): Promise<Activity[]>;
70
+ }
@@ -0,0 +1,160 @@
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.AgentPayoutEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const common_2 = require("@driveup/common");
16
+ const staff_entity_1 = require("../../system/staff/staff.entity");
17
+ const agent_entity_1 = require("./agent.entity");
18
+ const promotion_entity_1 = require("./promotion.entity");
19
+ const utils_1 = require("../../utils");
20
+ /**
21
+ * Represents a payout to an agent for their earned commissions.
22
+ * Payouts aggregate multiple promotions and track the payment status,
23
+ * amount, and bank account information.
24
+ *
25
+ * @extends TrackableEntity<Payout>
26
+ */
27
+ let AgentPayoutEntity = class AgentPayoutEntity extends utils_1.TrackableEntity {
28
+ /**
29
+ * Reference to the agent receiving the payout
30
+ */
31
+ agentId;
32
+ /**
33
+ * Payment status (Pending, Paid, Failed)
34
+ * @default StatusType.Pending
35
+ */
36
+ status;
37
+ /**
38
+ * Total payout amount in the agent's currency
39
+ * Precision: 8 digits, Scale: 2 decimal places
40
+ * @default 0
41
+ */
42
+ amount;
43
+ /**
44
+ * Bank account information where the payout was sent
45
+ */
46
+ bankAccount;
47
+ /**
48
+ * Timestamp when the payout was completed
49
+ */
50
+ paidOn;
51
+ /**
52
+ * ID of the staff member who processed the payout
53
+ */
54
+ paidBy;
55
+ /**
56
+ * Agent receiving this payout
57
+ */
58
+ agent;
59
+ /**
60
+ * Promotions included in this payout
61
+ */
62
+ promotions;
63
+ /**
64
+ * Creates an instance of AgentPayoutEntity
65
+ * @param props - Partial properties to initialize the entity
66
+ */
67
+ constructor(props) {
68
+ super();
69
+ Object.assign(this, props);
70
+ }
71
+ /**
72
+ * Converts the entity to a Payout model instance
73
+ * @returns Payout model with status, amount, and bank account information
74
+ */
75
+ async toModel() {
76
+ return new common_1.Payout({
77
+ id: this.id,
78
+ status: this.status,
79
+ amount: this.amount,
80
+ bankAccount: common_1.BankAccount.toInstance(this.bankAccount)
81
+ });
82
+ }
83
+ /**
84
+ * Converts the entity to a Payout model instance
85
+ * @returns Payout model with status, amount, and bank account information
86
+ */
87
+ async toSummary() {
88
+ return await this.toModel();
89
+ }
90
+ /**
91
+ * Retrieves all activity records for this payout
92
+ * Includes creation and payment actions
93
+ * @returns Array of Activity objects
94
+ */
95
+ async getActivities() {
96
+ const activities = [];
97
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_2.ActivityType.createdBy, staff_entity_1.StaffEntity));
98
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_2.ActivityType.createdOn));
99
+ activities.push(await (0, utils_1.toActivity)(this.paidBy, common_2.ActivityType.paidBy, staff_entity_1.StaffEntity));
100
+ activities.push(await (0, utils_1.toActivity)(this.paidOn, common_2.ActivityType.paidOn));
101
+ return activities.filter(a => a);
102
+ }
103
+ };
104
+ exports.AgentPayoutEntity = AgentPayoutEntity;
105
+ __decorate([
106
+ (0, typeorm_1.Column)(),
107
+ __metadata("design:type", Number)
108
+ ], AgentPayoutEntity.prototype, "agentId", void 0);
109
+ __decorate([
110
+ (0, typeorm_1.Column)({
111
+ type: 'enum',
112
+ enum: [
113
+ common_2.StatusType.Pending,
114
+ common_2.StatusType.Paid,
115
+ common_2.StatusType.Failed
116
+ ],
117
+ default: common_2.StatusType.Pending,
118
+ nullable: false
119
+ }),
120
+ __metadata("design:type", String)
121
+ ], AgentPayoutEntity.prototype, "status", void 0);
122
+ __decorate([
123
+ (0, typeorm_1.Column)({
124
+ type: 'decimal',
125
+ precision: 8,
126
+ scale: 2,
127
+ default: 0,
128
+ nullable: false
129
+ }),
130
+ __metadata("design:type", Number)
131
+ ], AgentPayoutEntity.prototype, "amount", void 0);
132
+ __decorate([
133
+ (0, typeorm_1.Column)({
134
+ type: 'simple-json',
135
+ nullable: true,
136
+ default: null
137
+ }),
138
+ __metadata("design:type", common_1.BankAccount)
139
+ ], AgentPayoutEntity.prototype, "bankAccount", void 0);
140
+ __decorate([
141
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
142
+ __metadata("design:type", Date)
143
+ ], AgentPayoutEntity.prototype, "paidOn", void 0);
144
+ __decorate([
145
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
146
+ __metadata("design:type", Number)
147
+ ], AgentPayoutEntity.prototype, "paidBy", void 0);
148
+ __decorate([
149
+ (0, typeorm_1.ManyToOne)(() => agent_entity_1.AgentEntity, agent => agent.payouts),
150
+ __metadata("design:type", Promise)
151
+ ], AgentPayoutEntity.prototype, "agent", void 0);
152
+ __decorate([
153
+ (0, typeorm_1.OneToMany)(() => promotion_entity_1.AgentPromotionEntity, promotion => promotion.payout),
154
+ __metadata("design:type", Promise)
155
+ ], AgentPayoutEntity.prototype, "promotions", void 0);
156
+ exports.AgentPayoutEntity = AgentPayoutEntity = __decorate([
157
+ (0, typeorm_1.Entity)('agentPayouts'),
158
+ __metadata("design:paramtypes", [Object])
159
+ ], AgentPayoutEntity);
160
+ //# sourceMappingURL=payout.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payout.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/payout.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,4CAAsD;AACtD,4CAAqE;AACrE,kEAA8D;AAC9D,iDAA6C;AAC7C,yDAA0D;AAC1D,uCAA0D;AAE1D;;;;;;GAMG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,uBAAuB;IAE7D;;OAEG;IAEH,OAAO,CAAS;IAEhB;;;OAGG;IAWH,MAAM,CAAa;IAEnB;;;;OAIG;IAQH,MAAM,CAAS;IAEf;;OAEG;IAMH,WAAW,CAAc;IAEzB;;OAEG;IAEH,MAAM,CAAO;IAEb;;OAEG;IAEH,MAAM,CAAS;IAEf;;OAEG;IAEH,KAAK,CAAuB;IAE5B;;OAEG;IAEH,UAAU,CAAkC;IAE5C;;;OAGG;IACH,YAAY,KAAkC;QAC7C,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACZ,OAAO,IAAI,eAAM,CAAC;YACjB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,WAAW,EAAE,oBAAW,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC;SACrD,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,K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;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;8BACW,oBAAW;sDAAC;AAMzB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAClC,IAAI;iDAAC;AAMb;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;iDAC3B;AAMf;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,0BAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;;gDACzB;AAM5B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;;qDACzB;4BAtEhC,iBAAiB;IAD7B,IAAA,gBAAM,EAAC,cAAc,CAAC;;GACV,iBAAiB,CAmH7B"}
@@ -0,0 +1,82 @@
1
+ import { Activity, PayoutItem } from '@driveup/common';
2
+ import { AgentEntity } from './agent.entity';
3
+ import { AgentPayoutEntity } from './payout.entity';
4
+ import { CompanyEntity } from '../company/company.entity';
5
+ import { CompanyBillTransactionEntity } from '../company/finances/billing/transaction.entity';
6
+ import { TrackableEntity } from '../../utils';
7
+ /**
8
+ * Represents a promotion generated by an agent.
9
+ * Tracks the relationship between an agent, a referred company, and the
10
+ * resulting profit. Promotions can be included in payouts for commission distribution.
11
+ *
12
+ * @extends TrackableEntity<PayoutItem>
13
+ */
14
+ export declare class AgentPromotionEntity extends TrackableEntity<PayoutItem> {
15
+ /**
16
+ * Reference to the agent who generated this promotion
17
+ */
18
+ agentId: number;
19
+ /**
20
+ * Reference to the company that used the agent's promotion code
21
+ */
22
+ companyId: number;
23
+ /**
24
+ * Reference to the bill transaction associated with this promotion
25
+ */
26
+ transactionId: number;
27
+ /**
28
+ * Reference to the payout this promotion is included in
29
+ * Null if not yet paid out
30
+ */
31
+ payoutId: number;
32
+ /**
33
+ * The profit generated from this promotion
34
+ */
35
+ profit: number;
36
+ /**
37
+ * Start date of the promotion period
38
+ */
39
+ startDate: Date;
40
+ /**
41
+ * End date of the promotion period
42
+ */
43
+ endDate: Date;
44
+ /**
45
+ * Agent profile
46
+ */
47
+ agent: Promise<AgentEntity>;
48
+ /**
49
+ * Binded promotion for company (by promotion code in onboarding process)
50
+ */
51
+ company: Promise<CompanyEntity>;
52
+ /**
53
+ * Payout containing this promotion
54
+ * Payouts are generated periodically and contain set of selected promotions
55
+ */
56
+ payout: Promise<AgentPayoutEntity>;
57
+ /**
58
+ * Reference to company bill transaction created for this promotion profit
59
+ */
60
+ transaction: Promise<CompanyBillTransactionEntity>;
61
+ /**
62
+ * Creates an instance of AgentPromotionEntity
63
+ * @param props - Partial properties to initialize the entity
64
+ */
65
+ constructor(props?: Partial<AgentPromotionEntity>);
66
+ /**
67
+ * Converts the entity to a PayoutItem model instance
68
+ * @returns PayoutItem model with profit, period, and customer information
69
+ */
70
+ toModel(): Promise<PayoutItem>;
71
+ /**
72
+ * Converts the entity to a PayoutItem model instance
73
+ * @returns PayoutItem model with profit, period, and customer information
74
+ */
75
+ toSummary(): Promise<PayoutItem>;
76
+ /**
77
+ * Retrieves all activity records for this promotion
78
+ * Includes creation and update actions
79
+ * @returns Array of Activity objects
80
+ */
81
+ getActivities(): Promise<Activity[]>;
82
+ }