@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,202 @@
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.CompanyHandoverEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const company_entity_1 = require("../../company.entity");
16
+ const expense_entity_1 = require("../expense/expense.entity");
17
+ const transaction_entity_1 = require("../../../student/program/training/transaction.entity");
18
+ const instructor_entity_1 = require("../../instructor/instructor.entity");
19
+ const utils_1 = require("../../../../utils");
20
+ let CompanyHandoverEntity = class CompanyHandoverEntity extends utils_1.TrackableEntity {
21
+ companyId;
22
+ /**
23
+ * Manager who approved the handover
24
+ */
25
+ managerId;
26
+ /**
27
+ * Instructor who is receiving the handover
28
+ */
29
+ instructorId;
30
+ /**
31
+ * List of approved student transactions IDs
32
+ */
33
+ approvedPayments;
34
+ /**
35
+ * List of approved instructor expense IDs
36
+ */
37
+ approvedExpenses;
38
+ /**
39
+ * List of rejected instructor expense IDs
40
+ */
41
+ rejectedExpenses;
42
+ /********************* for history purpose /*********************/
43
+ totalApprovedPayments;
44
+ totalApprovedExpenses;
45
+ totalRejectedExpenses;
46
+ company;
47
+ instructor;
48
+ constructor(props) {
49
+ super();
50
+ Object.assign(this, props);
51
+ }
52
+ async toModel() {
53
+ const manager = await (await this.getManager())?.getInstructor();
54
+ const instructor = await (await this.getInstructor())?.getInstructor();
55
+ const approvedPayments = await this.getApprovedPayments();
56
+ const approvedExpenses = await this.getApprovedExpenses();
57
+ const rejectedExpenses = await this.getRejectedExpenses();
58
+ return new common_1.Handover({
59
+ id: this.id,
60
+ manager: await manager?.toSummary(),
61
+ instructor: await instructor?.toSummary(),
62
+ approvedPayments: approvedPayments?.map(t => t.toSummary()),
63
+ approvedExpenses: approvedExpenses?.map(t => t.toSummary()),
64
+ rejectedExpenses: rejectedExpenses?.map(t => t.toSummary()),
65
+ totalApprovedPayments: this.totalApprovedPayments,
66
+ totalApprovedExpenses: this.totalApprovedExpenses,
67
+ totalRejectedExpenses: this.totalRejectedExpenses,
68
+ });
69
+ }
70
+ async toSummary() {
71
+ const manager = await (await this.getManager())?.getInstructor();
72
+ const instructor = await (await this.getInstructor())?.getInstructor();
73
+ return new common_1.Handover({
74
+ id: this.id,
75
+ manager: await manager?.toSummary(),
76
+ instructor: await instructor?.toSummary(),
77
+ totalApprovedPayments: this.totalApprovedPayments,
78
+ totalApprovedExpenses: this.totalApprovedExpenses,
79
+ totalRejectedExpenses: this.totalRejectedExpenses,
80
+ });
81
+ }
82
+ async getApprovedPayments() {
83
+ if (!this.approvedPayments?.length) {
84
+ return [];
85
+ }
86
+ return await transaction_entity_1.StudentTrainingTransactionEntity.findBy({
87
+ id: (0, typeorm_1.In)(this.approvedPayments),
88
+ type: common_1.TransactionType.Payment
89
+ });
90
+ }
91
+ async getApprovedExpenses() {
92
+ if (!this.approvedExpenses?.length) {
93
+ return [];
94
+ }
95
+ return await expense_entity_1.CompanyExpenseEntity.findBy({
96
+ id: (0, typeorm_1.In)(this.approvedExpenses),
97
+ status: common_1.StatusType.Approved
98
+ });
99
+ }
100
+ async getRejectedExpenses() {
101
+ if (!this.rejectedExpenses?.length) {
102
+ return [];
103
+ }
104
+ return await expense_entity_1.CompanyExpenseEntity.findBy({
105
+ id: (0, typeorm_1.In)(this.rejectedExpenses),
106
+ status: common_1.StatusType.Rejected
107
+ });
108
+ }
109
+ async getManager() {
110
+ return await instructor_entity_1.CompanyInstructorEntity.findOneBy({
111
+ id: this.managerId
112
+ });
113
+ }
114
+ async getInstructor() {
115
+ return await instructor_entity_1.CompanyInstructorEntity.findOneBy({
116
+ id: this.instructorId
117
+ });
118
+ }
119
+ async getActivities() {
120
+ const activities = [];
121
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
122
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
123
+ return activities.filter(a => a);
124
+ }
125
+ };
126
+ exports.CompanyHandoverEntity = CompanyHandoverEntity;
127
+ __decorate([
128
+ (0, typeorm_1.Column)(),
129
+ __metadata("design:type", Number)
130
+ ], CompanyHandoverEntity.prototype, "companyId", void 0);
131
+ __decorate([
132
+ (0, typeorm_1.Column)(),
133
+ __metadata("design:type", Number)
134
+ ], CompanyHandoverEntity.prototype, "managerId", void 0);
135
+ __decorate([
136
+ (0, typeorm_1.Column)(),
137
+ __metadata("design:type", Number)
138
+ ], CompanyHandoverEntity.prototype, "instructorId", void 0);
139
+ __decorate([
140
+ (0, typeorm_1.Column)({
141
+ type: 'simple-json',
142
+ nullable: false
143
+ }),
144
+ __metadata("design:type", Array)
145
+ ], CompanyHandoverEntity.prototype, "approvedPayments", void 0);
146
+ __decorate([
147
+ (0, typeorm_1.Column)({
148
+ type: 'simple-json',
149
+ nullable: false
150
+ }),
151
+ __metadata("design:type", Array)
152
+ ], CompanyHandoverEntity.prototype, "approvedExpenses", void 0);
153
+ __decorate([
154
+ (0, typeorm_1.Column)({
155
+ type: 'simple-json',
156
+ nullable: false
157
+ }),
158
+ __metadata("design:type", Array)
159
+ ], CompanyHandoverEntity.prototype, "rejectedExpenses", void 0);
160
+ __decorate([
161
+ (0, typeorm_1.Column)({
162
+ type: 'decimal',
163
+ precision: 8,
164
+ scale: 2,
165
+ nullable: false,
166
+ default: 0
167
+ }),
168
+ __metadata("design:type", Number)
169
+ ], CompanyHandoverEntity.prototype, "totalApprovedPayments", void 0);
170
+ __decorate([
171
+ (0, typeorm_1.Column)({
172
+ type: 'decimal',
173
+ precision: 8,
174
+ scale: 2,
175
+ nullable: false,
176
+ default: 0
177
+ }),
178
+ __metadata("design:type", Number)
179
+ ], CompanyHandoverEntity.prototype, "totalApprovedExpenses", void 0);
180
+ __decorate([
181
+ (0, typeorm_1.Column)({
182
+ type: 'decimal',
183
+ precision: 8,
184
+ scale: 2,
185
+ nullable: false,
186
+ default: 0
187
+ }),
188
+ __metadata("design:type", Number)
189
+ ], CompanyHandoverEntity.prototype, "totalRejectedExpenses", void 0);
190
+ __decorate([
191
+ (0, typeorm_1.ManyToOne)(() => company_entity_1.CompanyEntity, company => company.handovers),
192
+ __metadata("design:type", Promise)
193
+ ], CompanyHandoverEntity.prototype, "company", void 0);
194
+ __decorate([
195
+ (0, typeorm_1.ManyToOne)(() => instructor_entity_1.CompanyInstructorEntity, instructor => instructor.companyHandovers),
196
+ __metadata("design:type", Promise)
197
+ ], CompanyHandoverEntity.prototype, "instructor", void 0);
198
+ exports.CompanyHandoverEntity = CompanyHandoverEntity = __decorate([
199
+ (0, typeorm_1.Entity)('companyHandovers'),
200
+ __metadata("design:paramtypes", [Object])
201
+ ], CompanyHandoverEntity);
202
+ //# sourceMappingURL=handover.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handover.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/handover/handover.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwD;AACxD,4CAAgG;AAChG,yDAAqD;AACrD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@@ -0,0 +1,65 @@
1
+ import { Invoice, StatusType, Activity } from '@driveup/common';
2
+ import { Address, Note, Tax, BankAccount } from '@driveup/common';
3
+ import { CompanyInvoiceItemEntity } from './item.entity';
4
+ import { CompanyEntity } from '../../company.entity';
5
+ import { StudentTrainingEntity } from '../../../student/program/training/training.entity';
6
+ import { StudentEntity } from '../../../student/student.entity';
7
+ import { StudentTrainingTransactionEntity } from '../../../student/program/training/transaction.entity';
8
+ import { TrackableEntity } from '../../../../utils';
9
+ export declare class CompanyInvoiceEntity extends TrackableEntity<Invoice> {
10
+ companyId: number;
11
+ trainingId: number;
12
+ status: StatusType;
13
+ number: number;
14
+ invoiceDate: Date;
15
+ dueDate: Date;
16
+ subtotalAmount: number;
17
+ totalVatAmount: number;
18
+ totalAmount: number;
19
+ /**
20
+ * Company address information at the time of invoice generation
21
+ */
22
+ companyAddress: Address;
23
+ companyPhone: string;
24
+ /**
25
+ * Company address information at the time of invoice generation
26
+ */
27
+ bankAccount: BankAccount;
28
+ /**
29
+ * Company tax ID at the time of invoice generation
30
+ */
31
+ companyTax: Tax;
32
+ note: Note;
33
+ generatedBy: number;
34
+ generatedOn: Date;
35
+ paidBy: number;
36
+ paidOn: Date;
37
+ canceledBy: number;
38
+ canceledOn: Date;
39
+ /**
40
+ * Company related to this invoice
41
+ */
42
+ company: Promise<CompanyEntity>;
43
+ /**
44
+ * Student training related to this invoice
45
+ */
46
+ training: Promise<StudentTrainingEntity>;
47
+ /**
48
+ * Items included in this invoice
49
+ */
50
+ items: Promise<CompanyInvoiceItemEntity[]>;
51
+ /**
52
+ * Transaction related to this invoice, if applicable
53
+ */
54
+ transaction: Promise<StudentTrainingTransactionEntity>;
55
+ constructor(props?: Partial<CompanyInvoiceEntity>);
56
+ toModel(): Invoice<import("@driveup/common").Training>;
57
+ toSummary(): Invoice<import("@driveup/common").Training>;
58
+ getStudentTransaction(): Promise<StudentTrainingTransactionEntity>;
59
+ getStudent(): Promise<StudentEntity>;
60
+ /**
61
+ * Get the total amount for the invoice, including items totals and VAT.
62
+ */
63
+ getTotalAmount(): Promise<number>;
64
+ getActivities(): Promise<Activity[]>;
65
+ }
@@ -0,0 +1,296 @@
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.CompanyInvoiceEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const common_2 = require("@driveup/common");
16
+ const item_entity_1 = require("./item.entity");
17
+ const company_entity_1 = require("../../company.entity");
18
+ const training_entity_1 = require("../../../student/program/training/training.entity");
19
+ const transaction_entity_1 = require("../../../student/program/training/transaction.entity");
20
+ const utils_1 = require("../../../../utils");
21
+ let CompanyInvoiceEntity = class CompanyInvoiceEntity extends utils_1.TrackableEntity {
22
+ companyId;
23
+ trainingId;
24
+ status;
25
+ number;
26
+ invoiceDate;
27
+ dueDate;
28
+ subtotalAmount;
29
+ totalVatAmount;
30
+ totalAmount;
31
+ /**
32
+ * Company address information at the time of invoice generation
33
+ */
34
+ companyAddress;
35
+ companyPhone;
36
+ /**
37
+ * Company address information at the time of invoice generation
38
+ */
39
+ bankAccount;
40
+ /**
41
+ * Company tax ID at the time of invoice generation
42
+ */
43
+ companyTax;
44
+ note;
45
+ generatedBy;
46
+ generatedOn;
47
+ paidBy;
48
+ paidOn;
49
+ canceledBy;
50
+ canceledOn;
51
+ /**
52
+ * Company related to this invoice
53
+ */
54
+ company;
55
+ /**
56
+ * Student training related to this invoice
57
+ */
58
+ training;
59
+ /**
60
+ * Items included in this invoice
61
+ */
62
+ items;
63
+ /**
64
+ * Transaction related to this invoice, if applicable
65
+ */
66
+ transaction;
67
+ constructor(props) {
68
+ super();
69
+ Object.assign(this, props);
70
+ }
71
+ toModel() {
72
+ return new common_1.Invoice({
73
+ id: this.id,
74
+ status: this.status,
75
+ number: this.number,
76
+ invoiceDate: this.invoiceDate,
77
+ dueDate: this.dueDate,
78
+ bankAccount: this.bankAccount ? common_2.BankAccount.toInstance(this.bankAccount) : null,
79
+ companyAddress: this.bankAccount ? common_2.Address.toInstance(this.companyAddress) : null,
80
+ companyTax: this.companyTax ? common_2.Tax.toInstance(this.companyTax) : null,
81
+ companyPhone: this.companyPhone,
82
+ subtotalAmount: this.subtotalAmount,
83
+ totalVatAmount: this.totalVatAmount,
84
+ totalAmount: this.totalAmount,
85
+ note: this.note ? common_2.Note.toInstance(this.note) : null,
86
+ });
87
+ }
88
+ toSummary() {
89
+ return new common_1.Invoice({
90
+ id: this.id,
91
+ status: this.status,
92
+ number: this.number,
93
+ invoiceDate: this.invoiceDate,
94
+ dueDate: this.dueDate,
95
+ totalAmount: this.totalAmount
96
+ });
97
+ }
98
+ async getStudentTransaction() {
99
+ return await transaction_entity_1.StudentTrainingTransactionEntity.findOneBy({
100
+ invoiceId: this.id
101
+ });
102
+ }
103
+ async getStudent() {
104
+ const training = await this.training;
105
+ return await training.getStudent();
106
+ }
107
+ /**
108
+ * Get the total amount for the invoice, including items totals and VAT.
109
+ */
110
+ async getTotalAmount() {
111
+ const items = await item_entity_1.CompanyInvoiceItemEntity.findBy({ invoiceId: this.id });
112
+ return items?.reduce((total, item) => {
113
+ const itemSubtotal = item.price * item.quantity;
114
+ const itemVat = item.vat ? itemSubtotal * (item.vat / 100) : 0;
115
+ return total + itemSubtotal + itemVat;
116
+ }, 0) || 0;
117
+ }
118
+ async getActivities() {
119
+ const activities = [];
120
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
121
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
122
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
123
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
124
+ activities.push(await (0, utils_1.toActivity)(this.generatedBy, common_1.ActivityType.generatedBy));
125
+ activities.push(await (0, utils_1.toActivity)(this.generatedOn, common_1.ActivityType.generatedOn));
126
+ activities.push(await (0, utils_1.toActivity)(this.paidBy, common_1.ActivityType.paidBy));
127
+ activities.push(await (0, utils_1.toActivity)(this.paidOn, common_1.ActivityType.paidOn));
128
+ activities.push(await (0, utils_1.toActivity)(this.canceledBy, common_1.ActivityType.canceledBy));
129
+ activities.push(await (0, utils_1.toActivity)(this.canceledOn, common_1.ActivityType.canceledOn));
130
+ return activities.filter(a => a);
131
+ }
132
+ };
133
+ exports.CompanyInvoiceEntity = CompanyInvoiceEntity;
134
+ __decorate([
135
+ (0, typeorm_1.Column)(),
136
+ __metadata("design:type", Number)
137
+ ], CompanyInvoiceEntity.prototype, "companyId", void 0);
138
+ __decorate([
139
+ (0, typeorm_1.Column)({
140
+ nullable: true,
141
+ default: null
142
+ }),
143
+ __metadata("design:type", Number)
144
+ ], CompanyInvoiceEntity.prototype, "trainingId", void 0);
145
+ __decorate([
146
+ (0, typeorm_1.Column)({
147
+ type: 'enum',
148
+ enum: [
149
+ common_1.StatusType.Draft,
150
+ common_1.StatusType.Generated,
151
+ common_1.StatusType.Paid,
152
+ common_1.StatusType.Failed,
153
+ common_1.StatusType.Overdate,
154
+ common_1.StatusType.Sent,
155
+ ],
156
+ default: common_1.StatusType.Draft,
157
+ nullable: false
158
+ }),
159
+ __metadata("design:type", String)
160
+ ], CompanyInvoiceEntity.prototype, "status", void 0);
161
+ __decorate([
162
+ (0, typeorm_1.Column)({
163
+ nullable: true,
164
+ default: null,
165
+ unique: true
166
+ }),
167
+ __metadata("design:type", Number)
168
+ ], CompanyInvoiceEntity.prototype, "number", void 0);
169
+ __decorate([
170
+ (0, typeorm_1.Column)({
171
+ nullable: true,
172
+ default: null
173
+ }),
174
+ __metadata("design:type", Date)
175
+ ], CompanyInvoiceEntity.prototype, "invoiceDate", void 0);
176
+ __decorate([
177
+ (0, typeorm_1.Column)({
178
+ nullable: true,
179
+ default: null
180
+ }),
181
+ __metadata("design:type", Date)
182
+ ], CompanyInvoiceEntity.prototype, "dueDate", void 0);
183
+ __decorate([
184
+ (0, typeorm_1.Column)({
185
+ type: 'decimal',
186
+ precision: 4,
187
+ scale: 2,
188
+ default: 0,
189
+ nullable: false
190
+ }),
191
+ __metadata("design:type", Number)
192
+ ], CompanyInvoiceEntity.prototype, "subtotalAmount", void 0);
193
+ __decorate([
194
+ (0, typeorm_1.Column)({
195
+ type: 'decimal',
196
+ precision: 4,
197
+ scale: 2,
198
+ default: 0,
199
+ nullable: false
200
+ }),
201
+ __metadata("design:type", Number)
202
+ ], CompanyInvoiceEntity.prototype, "totalVatAmount", void 0);
203
+ __decorate([
204
+ (0, typeorm_1.Column)({
205
+ type: 'decimal',
206
+ precision: 4,
207
+ scale: 2,
208
+ default: 0,
209
+ nullable: false
210
+ }),
211
+ __metadata("design:type", Number)
212
+ ], CompanyInvoiceEntity.prototype, "totalAmount", void 0);
213
+ __decorate([
214
+ (0, typeorm_1.Column)({
215
+ type: 'simple-json',
216
+ nullable: true,
217
+ default: null
218
+ }),
219
+ __metadata("design:type", common_2.Address)
220
+ ], CompanyInvoiceEntity.prototype, "companyAddress", void 0);
221
+ __decorate([
222
+ (0, typeorm_1.Column)({
223
+ nullable: true,
224
+ default: null
225
+ }),
226
+ __metadata("design:type", String)
227
+ ], CompanyInvoiceEntity.prototype, "companyPhone", void 0);
228
+ __decorate([
229
+ (0, typeorm_1.Column)({
230
+ type: 'simple-json',
231
+ nullable: true,
232
+ default: null
233
+ }),
234
+ __metadata("design:type", common_2.BankAccount)
235
+ ], CompanyInvoiceEntity.prototype, "bankAccount", void 0);
236
+ __decorate([
237
+ (0, typeorm_1.Column)({
238
+ type: 'simple-json',
239
+ nullable: true,
240
+ default: null
241
+ }),
242
+ __metadata("design:type", common_2.Tax)
243
+ ], CompanyInvoiceEntity.prototype, "companyTax", void 0);
244
+ __decorate([
245
+ (0, typeorm_1.Column)({
246
+ type: 'simple-json',
247
+ nullable: true,
248
+ default: null
249
+ }),
250
+ __metadata("design:type", common_2.Note)
251
+ ], CompanyInvoiceEntity.prototype, "note", void 0);
252
+ __decorate([
253
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
254
+ __metadata("design:type", Number)
255
+ ], CompanyInvoiceEntity.prototype, "generatedBy", void 0);
256
+ __decorate([
257
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
258
+ __metadata("design:type", Date)
259
+ ], CompanyInvoiceEntity.prototype, "generatedOn", void 0);
260
+ __decorate([
261
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
262
+ __metadata("design:type", Number)
263
+ ], CompanyInvoiceEntity.prototype, "paidBy", void 0);
264
+ __decorate([
265
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
266
+ __metadata("design:type", Date)
267
+ ], CompanyInvoiceEntity.prototype, "paidOn", void 0);
268
+ __decorate([
269
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
270
+ __metadata("design:type", Number)
271
+ ], CompanyInvoiceEntity.prototype, "canceledBy", void 0);
272
+ __decorate([
273
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
274
+ __metadata("design:type", Date)
275
+ ], CompanyInvoiceEntity.prototype, "canceledOn", void 0);
276
+ __decorate([
277
+ (0, typeorm_1.ManyToOne)(() => company_entity_1.CompanyEntity, company => company.invoices),
278
+ __metadata("design:type", Promise)
279
+ ], CompanyInvoiceEntity.prototype, "company", void 0);
280
+ __decorate([
281
+ (0, typeorm_1.ManyToOne)(() => training_entity_1.StudentTrainingEntity, training => training.invoices),
282
+ __metadata("design:type", Promise)
283
+ ], CompanyInvoiceEntity.prototype, "training", void 0);
284
+ __decorate([
285
+ (0, typeorm_1.OneToMany)(() => item_entity_1.CompanyInvoiceItemEntity, item => item.invoice),
286
+ __metadata("design:type", Promise)
287
+ ], CompanyInvoiceEntity.prototype, "items", void 0);
288
+ __decorate([
289
+ (0, typeorm_1.OneToOne)(() => transaction_entity_1.StudentTrainingTransactionEntity, transaction => transaction.invoice),
290
+ __metadata("design:type", Promise)
291
+ ], CompanyInvoiceEntity.prototype, "transaction", void 0);
292
+ exports.CompanyInvoiceEntity = CompanyInvoiceEntity = __decorate([
293
+ (0, typeorm_1.Entity)('companyInvoices'),
294
+ __metadata("design:paramtypes", [Object])
295
+ ], CompanyInvoiceEntity);
296
+ //# sourceMappingURL=invoice.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/invoice/invoice.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0E;AAC1E,4CAA8E;AAC9E,4CAAkE;AAClE,+CAAyD;AACzD,yDAAqD;AACrD,uFAA0F;AAE1F,6FAAwG;AACxG,6CAAgE;AAGzD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,uBAAwB;IAGjE,SAAS,CAAS;IAMlB,UAAU,CAAS;IAenB,MAAM,CAAa;IAOnB,MAAM,CAAS;IAMf,WAAW,CAAO;IAMlB,OAAO,CAAO;IASd,cAAc,CAAS;IASvB,cAAc,CAAS;IASvB,WAAW,CAAS;IAEpB;;OAEG;IAMH,cAAc,CAAU;IAMxB,YAAY,CAAS;IAErB;;OAEG;IAMH,WAAW,CAAc;IAEzB;;OAEG;IAMH,UAAU,CAAM;IAOhB,IAAI,CAAO;IAGX,WAAW,CAAS;IAGpB,WAAW,CAAO;IAGlB,MAAM,CAAS;IAGf,MAAM,CAAO;IAG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,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC9B,IAAI;wDAAC;AAMjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;;qDAC5B;AAMhC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAqB,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;;sDAC7B;AAMzC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,sCAAwB,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;mDACrB;AAM3C;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,qDAAgC,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;yDAC9B;+BA3J3C,oBAAoB;IADhC,IAAA,gBAAM,EAAC,iBAAiB,CAAC;;GACb,oBAAoB,CAoOhC"}
@@ -0,0 +1,25 @@
1
+ import { CompanyInvoiceEntity } from './invoice.entity';
2
+ import { Activity, InvoiceItem, ProductType } from '@driveup/common';
3
+ import { TrackableEntity } from '../../../../utils';
4
+ export declare class CompanyInvoiceItemEntity extends TrackableEntity<InvoiceItem> {
5
+ invoiceId: number;
6
+ description: string;
7
+ price: number;
8
+ quantity: number;
9
+ vat: number;
10
+ vatAmount: number;
11
+ total: number;
12
+ /**
13
+ * Type of product the item refers to
14
+ */
15
+ refProduct: ProductType;
16
+ /**
17
+ * Reference ID to link item to other entities
18
+ */
19
+ refId: number;
20
+ invoice: Promise<CompanyInvoiceEntity>;
21
+ constructor(props?: Partial<CompanyInvoiceItemEntity>);
22
+ toModel(): InvoiceItem;
23
+ toSummary(): InvoiceItem;
24
+ getActivities(): Promise<Activity[]>;
25
+ }