@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,122 @@
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.CompanyMetric = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const utils_1 = require("../../../utils");
15
+ const common_1 = require("@driveup/common");
16
+ let CompanyMetric = class CompanyMetric {
17
+ id;
18
+ name;
19
+ drivingTraining;
20
+ courseTraining;
21
+ billing;
22
+ };
23
+ exports.CompanyMetric = CompanyMetric;
24
+ __decorate([
25
+ (0, typeorm_1.ViewColumn)(),
26
+ __metadata("design:type", Number)
27
+ ], CompanyMetric.prototype, "id", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.ViewColumn)(),
30
+ __metadata("design:type", String)
31
+ ], CompanyMetric.prototype, "name", void 0);
32
+ __decorate([
33
+ (0, typeorm_1.ViewColumn)({
34
+ transformer: new utils_1.ColumnJsonMetricsTransformer()
35
+ }),
36
+ __metadata("design:type", Object)
37
+ ], CompanyMetric.prototype, "drivingTraining", void 0);
38
+ __decorate([
39
+ (0, typeorm_1.ViewColumn)({
40
+ transformer: new utils_1.ColumnJsonMetricsTransformer()
41
+ }),
42
+ __metadata("design:type", Object)
43
+ ], CompanyMetric.prototype, "courseTraining", void 0);
44
+ __decorate([
45
+ (0, typeorm_1.ViewColumn)({
46
+ transformer: new utils_1.ColumnJsonMetricsTransformer()
47
+ }),
48
+ __metadata("design:type", Object)
49
+ ], CompanyMetric.prototype, "billing", void 0);
50
+ exports.CompanyMetric = CompanyMetric = __decorate([
51
+ (0, typeorm_1.ViewEntity)({
52
+ name: 'vw_company_metrics',
53
+ expression: `
54
+ SELECT
55
+ companies.id,
56
+ companies.name,
57
+ c.name AS country,
58
+ subInst.users,
59
+ JSON_OBJECT(
60
+ 'active', subStdDrv.activeTrainings,
61
+ 'completed', subStdDrv.completedTrainings,
62
+ 'terminated', subStdDrv.terminatedTrainings,
63
+ 'total', subStdDrv.totalTrainings
64
+ ) AS drivingTraining,
65
+ JSON_OBJECT(
66
+ 'active', subStdCur.activeTrainings,
67
+ 'completed', subStdCur.completedTrainings,
68
+ 'terminated', subStdCur.terminatedTrainings,
69
+ 'total', subStdCur.totalTrainings
70
+ ) AS courseTraining,
71
+ JSON_OBJECT(
72
+ 'revenue', subBill.totalRevenue,
73
+ 'paid', subBill.totalPaid,
74
+ 'unpaid', subBill.totalUnpaid
75
+ ) AS billing
76
+ FROM companies
77
+ INNER JOIN countries c ON c.id = companies.countryId
78
+ LEFT JOIN (
79
+ SELECT i.companyId, COUNT(i.id) AS users
80
+ FROM instructors i
81
+ WHERE i.status = '${common_1.AccountStatus.Active}'
82
+ GROUP BY i.companyId
83
+ ) subInst ON subInst.companyId = companies.id
84
+ LEFT JOIN (
85
+ SELECT
86
+ i.companyId,
87
+ COUNT(sdt.id) AS totalTrainings,
88
+ SUM(IF(sdt.status = '${common_1.StatusType.Progress}', 1, 0)) AS activeTrainings,
89
+ SUM(IF(sdt.status = '${common_1.StatusType.Completed}', 1, 0)) AS completedTrainings,
90
+ SUM(IF(sdt.status = '${common_1.StatusType.Terminated}', 1, 0)) AS terminatedTrainings
91
+ FROM studentDrivingTrainings sdt
92
+ INNER JOIN instructors i ON i.id = sdt.instructorId
93
+ GROUP BY i.companyId
94
+ ) subStdDrv ON subStdDrv.companyId = companies.id
95
+ LEFT JOIN (
96
+ SELECT
97
+ cur.companyId,
98
+ COUNT(sct.id) AS totalTrainings,
99
+ SUM(IF(sct.status = '${common_1.StatusType.Progress}', 1, 0)) AS activeTrainings,
100
+ SUM(IF(sct.status = '${common_1.StatusType.Completed}', 1, 0)) AS completedTrainings,
101
+ SUM(IF(sct.status = '${common_1.StatusType.Terminated}', 1, 0)) AS terminatedTrainings
102
+ FROM studentCourseTrainings sct
103
+ INNER JOIN courses cur ON cur.companyId = sct.courseId
104
+ GROUP BY cur.companyId
105
+ ) subStdCur ON subStdCur.companyId = companies.id
106
+ LEFT JOIN (
107
+ SELECT
108
+ cb.companyId,
109
+ SUM(cb.paid) AS totalRevenue,
110
+ SUM(IF(cb.paid, cb.totalPrice, 0)) AS totalPaid,
111
+ SUM(IF(cb.paid, 0, cb.totalPrice)) AS totalUnpaid
112
+ FROM companyBills cb
113
+ GROUP BY cb.companyId
114
+ ) subBill ON subBill.companyId = companies.id
115
+ GROUP BY
116
+ companies.id,
117
+ companies.name,
118
+ country
119
+ `
120
+ })
121
+ ], CompanyMetric);
122
+ //# sourceMappingURL=company.metric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company.metric.js","sourceRoot":"","sources":["../../../../src/profile/company/metrics/company.metric.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiD;AACjD,0CAA8D;AAC9D,4CAA4D;AAwErD,IAAM,aAAa,GAAnB,MAAM,aAAa;IAEzB,EAAE,CAAS;IAGX,IAAI,CAAS;IAKb,eAAe,CAKb;IAKF,cAAc,CAKZ;IAKF,OAAO,CAIL;CACF,CAAA;AAnCY,sCAAa;AAEzB;IADC,IAAA,oBAAU,GAAE;;yCACF;AAGX;IADC,IAAA,oBAAU,GAAE;;2CACA;AAKb;IAHC,IAAA,oBAAU,EAAC;QACX,WAAW,EAAE,IAAI,oCAA4B,EAAE;KAC/C,CAAC;;sDAMA;AAKF;IAHC,IAAA,oBAAU,EAAC;QACX,WAAW,EAAE,IAAI,oCAA4B,EAAE;KAC/C,CAAC;;qDAMA;AAKF;IAHC,IAAA,oBAAU,EAAC;QACX,WAAW,EAAE,IAAI,oCAA4B,EAAE;KAC/C,CAAC;;8CAKA;wBAlCU,aAAa;IAtEzB,IAAA,oBAAU,EAAC;QACX,IAAI,EAAE,oBAAoB;QAC1B,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4BU,sBAAa,CAAC,MAAM;;;;;;;2BAOhB,mBAAU,CAAC,QAAQ;2BACnB,mBAAU,CAAC,SAAS;2BACpB,mBAAU,CAAC,UAAU;;;;;;;;;2BASrB,mBAAU,CAAC,QAAQ;2BACnB,mBAAU,CAAC,SAAS;2BACpB,mBAAU,CAAC,UAAU;;;;;;;;;;;;;;;;;;EAkB9C;KACD,CAAC;GACW,aAAa,CAmCzB"}
@@ -0,0 +1,93 @@
1
+ import { Activity, Addon, Metadata } from '@driveup/common';
2
+ import { CompanyProductEntity } from './product.entity';
3
+ import { AddonCountryEntity } from '../../../catalog/addon/country.entity';
4
+ import { CompanyBillItemEntity } from '../finances/billing/item.entity';
5
+ import { TrackableEntity } from '../../../utils';
6
+ export declare class CompanyProductAddonEntity extends TrackableEntity<Addon> {
7
+ /**
8
+ * Company product
9
+ */
10
+ productId: number;
11
+ /**
12
+ * Driveup addon
13
+ */
14
+ addonId: number;
15
+ /**
16
+ * Company customized addon price (B2B)
17
+ */
18
+ price: number;
19
+ /**
20
+ * Free benefits included in the addon for the company customers
21
+ */
22
+ freeBenefits: number;
23
+ /**
24
+ * Company customized product metadata
25
+ * Seeding default metadata from system product country metadata
26
+ * Company admin can manage those metadata
27
+ */
28
+ metadata: Metadata[];
29
+ /**
30
+ * Company product active
31
+ * Can be managed by company admin
32
+ * Usefull for temporary disabling without deleting the product subscription
33
+ */
34
+ active: boolean;
35
+ /**
36
+ * Company product blocked state
37
+ * Managed by driveup console
38
+ * Indicates if the product is blocked for the company due to non-payment or violations
39
+ * When product is blocked, all activities are also disabled
40
+ * and company can't use the product features
41
+ */
42
+ blocked: boolean;
43
+ /**
44
+ * Company product enabled state
45
+ * Managed by driveup console
46
+ * Indicates if the product is currently enabled for the company
47
+ * Used to quickly enable/disable the product for the company
48
+ * When product is disabled, all activities are also disabled
49
+ * and company can't use the product features
50
+ */
51
+ enabled: boolean;
52
+ /**
53
+ * Timestamp when this addon was enabled
54
+ */
55
+ enabledOn: Date;
56
+ /**
57
+ * ID of the user who enabled this addon
58
+ */
59
+ enabledBy: number;
60
+ /**
61
+ * Timestamp when this addon was disabled
62
+ */
63
+ disabledOn: Date;
64
+ /**
65
+ * ID of the user who disabled this addon
66
+ */
67
+ disabledBy: number;
68
+ /**
69
+ * Timestamp when this addon was blocked
70
+ */
71
+ blockedOn: Date;
72
+ /**
73
+ * ID of the user who blocked this addon
74
+ */
75
+ blockedBy: number;
76
+ /**
77
+ * Company relation
78
+ */
79
+ company: Promise<CompanyProductEntity>;
80
+ /**
81
+ * Driveup country addon relation
82
+ */
83
+ addon: Promise<AddonCountryEntity>;
84
+ /**
85
+ * Company bill items relation
86
+ */
87
+ billItems: Promise<CompanyBillItemEntity>;
88
+ constructor(props?: Partial<CompanyProductAddonEntity>);
89
+ toModel(): Promise<Addon>;
90
+ toSummary(): Promise<Addon>;
91
+ getMetadata(): Metadata<any>[];
92
+ getActivities(): Promise<Activity[]>;
93
+ }
@@ -0,0 +1,234 @@
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.CompanyProductAddonEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const staff_entity_1 = require("../../../system/staff/staff.entity");
16
+ const product_entity_1 = require("./product.entity");
17
+ const country_entity_1 = require("../../../catalog/addon/country.entity");
18
+ const item_entity_1 = require("../finances/billing/item.entity");
19
+ const utils_1 = require("../../../utils");
20
+ let CompanyProductAddonEntity = class CompanyProductAddonEntity extends utils_1.TrackableEntity {
21
+ /**
22
+ * Company product
23
+ */
24
+ productId;
25
+ /**
26
+ * Driveup addon
27
+ */
28
+ addonId;
29
+ /**
30
+ * Company customized addon price (B2B)
31
+ */
32
+ price;
33
+ /**
34
+ * Free benefits included in the addon for the company customers
35
+ */
36
+ freeBenefits;
37
+ /**
38
+ * Company customized product metadata
39
+ * Seeding default metadata from system product country metadata
40
+ * Company admin can manage those metadata
41
+ */
42
+ metadata;
43
+ /**
44
+ * Company product active
45
+ * Can be managed by company admin
46
+ * Usefull for temporary disabling without deleting the product subscription
47
+ */
48
+ active;
49
+ /**
50
+ * Company product blocked state
51
+ * Managed by driveup console
52
+ * Indicates if the product is blocked for the company due to non-payment or violations
53
+ * When product is blocked, all activities are also disabled
54
+ * and company can't use the product features
55
+ */
56
+ blocked;
57
+ /**
58
+ * Company product enabled state
59
+ * Managed by driveup console
60
+ * Indicates if the product is currently enabled for the company
61
+ * Used to quickly enable/disable the product for the company
62
+ * When product is disabled, all activities are also disabled
63
+ * and company can't use the product features
64
+ */
65
+ enabled;
66
+ /**
67
+ * Timestamp when this addon was enabled
68
+ */
69
+ enabledOn;
70
+ /**
71
+ * ID of the user who enabled this addon
72
+ */
73
+ enabledBy;
74
+ /**
75
+ * Timestamp when this addon was disabled
76
+ */
77
+ disabledOn;
78
+ /**
79
+ * ID of the user who disabled this addon
80
+ */
81
+ disabledBy;
82
+ /**
83
+ * Timestamp when this addon was blocked
84
+ */
85
+ blockedOn;
86
+ /**
87
+ * ID of the user who blocked this addon
88
+ */
89
+ blockedBy;
90
+ /**
91
+ * Company relation
92
+ */
93
+ company;
94
+ /**
95
+ * Driveup country addon relation
96
+ */
97
+ addon;
98
+ /**
99
+ * Company bill items relation
100
+ */
101
+ billItems;
102
+ constructor(props) {
103
+ super();
104
+ Object.assign(this, props);
105
+ }
106
+ async toModel() {
107
+ const addonCountry = await this.addon;
108
+ const addon = await addonCountry.toModel();
109
+ addon.id = this.id;
110
+ addon.price = this.price;
111
+ addon.active = this.active;
112
+ addon.blocked = this.blocked;
113
+ addon.enabled = this.enabled;
114
+ addon.freeBenefits = this.freeBenefits;
115
+ addon.metadata = this.getMetadata();
116
+ return addon;
117
+ }
118
+ async toSummary() {
119
+ return await this.toModel();
120
+ }
121
+ getMetadata() {
122
+ return this.metadata?.map(m => common_1.Metadata.toInstance(m));
123
+ }
124
+ async getActivities() {
125
+ const activities = [];
126
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
127
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
128
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
129
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
130
+ activities.push(await (0, utils_1.toActivity)(this.enabledBy, common_1.ActivityType.enabledBy, staff_entity_1.StaffEntity));
131
+ activities.push(await (0, utils_1.toActivity)(this.enabledOn, common_1.ActivityType.enabledOn));
132
+ activities.push(await (0, utils_1.toActivity)(this.disabledBy, common_1.ActivityType.disabledBy, staff_entity_1.StaffEntity));
133
+ activities.push(await (0, utils_1.toActivity)(this.disabledOn, common_1.ActivityType.disabledOn));
134
+ activities.push(await (0, utils_1.toActivity)(this.blockedBy, common_1.ActivityType.blockedBy, staff_entity_1.StaffEntity));
135
+ activities.push(await (0, utils_1.toActivity)(this.blockedOn, common_1.ActivityType.blockedOn));
136
+ return activities.filter(a => a);
137
+ }
138
+ };
139
+ exports.CompanyProductAddonEntity = CompanyProductAddonEntity;
140
+ __decorate([
141
+ (0, typeorm_1.Column)(),
142
+ __metadata("design:type", Number)
143
+ ], CompanyProductAddonEntity.prototype, "productId", void 0);
144
+ __decorate([
145
+ (0, typeorm_1.Column)(),
146
+ __metadata("design:type", Number)
147
+ ], CompanyProductAddonEntity.prototype, "addonId", void 0);
148
+ __decorate([
149
+ (0, typeorm_1.Column)({
150
+ type: 'decimal',
151
+ precision: 8,
152
+ scale: 2,
153
+ nullable: true,
154
+ default: null
155
+ }),
156
+ __metadata("design:type", Number)
157
+ ], CompanyProductAddonEntity.prototype, "price", void 0);
158
+ __decorate([
159
+ (0, typeorm_1.Column)({
160
+ nullable: true,
161
+ default: null
162
+ }),
163
+ __metadata("design:type", Number)
164
+ ], CompanyProductAddonEntity.prototype, "freeBenefits", void 0);
165
+ __decorate([
166
+ (0, typeorm_1.Column)({
167
+ type: 'simple-json',
168
+ nullable: true,
169
+ default: null
170
+ }),
171
+ __metadata("design:type", Array)
172
+ ], CompanyProductAddonEntity.prototype, "metadata", void 0);
173
+ __decorate([
174
+ (0, typeorm_1.Column)({
175
+ nullable: false,
176
+ default: false
177
+ }),
178
+ __metadata("design:type", Boolean)
179
+ ], CompanyProductAddonEntity.prototype, "active", void 0);
180
+ __decorate([
181
+ (0, typeorm_1.Column)({
182
+ nullable: false,
183
+ default: false
184
+ }),
185
+ __metadata("design:type", Boolean)
186
+ ], CompanyProductAddonEntity.prototype, "blocked", void 0);
187
+ __decorate([
188
+ (0, typeorm_1.Column)({
189
+ nullable: false,
190
+ default: true
191
+ }),
192
+ __metadata("design:type", Boolean)
193
+ ], CompanyProductAddonEntity.prototype, "enabled", void 0);
194
+ __decorate([
195
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
196
+ __metadata("design:type", Date)
197
+ ], CompanyProductAddonEntity.prototype, "enabledOn", void 0);
198
+ __decorate([
199
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
200
+ __metadata("design:type", Number)
201
+ ], CompanyProductAddonEntity.prototype, "enabledBy", void 0);
202
+ __decorate([
203
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
204
+ __metadata("design:type", Date)
205
+ ], CompanyProductAddonEntity.prototype, "disabledOn", void 0);
206
+ __decorate([
207
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
208
+ __metadata("design:type", Number)
209
+ ], CompanyProductAddonEntity.prototype, "disabledBy", void 0);
210
+ __decorate([
211
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
212
+ __metadata("design:type", Date)
213
+ ], CompanyProductAddonEntity.prototype, "blockedOn", void 0);
214
+ __decorate([
215
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
216
+ __metadata("design:type", Number)
217
+ ], CompanyProductAddonEntity.prototype, "blockedBy", void 0);
218
+ __decorate([
219
+ (0, typeorm_1.ManyToOne)(() => product_entity_1.CompanyProductEntity, product => product.addons),
220
+ __metadata("design:type", Promise)
221
+ ], CompanyProductAddonEntity.prototype, "company", void 0);
222
+ __decorate([
223
+ (0, typeorm_1.ManyToOne)(() => country_entity_1.AddonCountryEntity, product => product.companyProducts),
224
+ __metadata("design:type", Promise)
225
+ ], CompanyProductAddonEntity.prototype, "addon", void 0);
226
+ __decorate([
227
+ (0, typeorm_1.ManyToOne)(() => item_entity_1.CompanyBillItemEntity, billItem => billItem.addon),
228
+ __metadata("design:type", Promise)
229
+ ], CompanyProductAddonEntity.prototype, "billItems", void 0);
230
+ exports.CompanyProductAddonEntity = CompanyProductAddonEntity = __decorate([
231
+ (0, typeorm_1.Entity)('companyProductAddons'),
232
+ __metadata("design:paramtypes", [Object])
233
+ ], CompanyProductAddonEntity);
234
+ //# sourceMappingURL=addon.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addon.entity.js","sourceRoot":"","sources":["../../../../src/profile/company/product/addon.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,4CAA0E;AAC1E,qEAAiE;AACjE,qDAAwD;AACxD,0EAA2E;AAC3E,iEAAwE;AACxE,0CAA6D;AAGtD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,uBAAsB;IAEpE;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,OAAO,CAAS;IAEhB;;OAEG;IAQH,KAAK,CAAS;IAEd;;OAEG;IAKH,YAAY,CAAS;IAErB;;;;OAIG;IAMH,QAAQ,CAAa;IAErB;;;;OAIG;IAKH,MAAM,CAAU;IAEhB;;;;;;OAMG;IAKH,OAAO,CAAU;IAEjB;;;;;;;OAOG;IAKH,OAAO,CAAU;IAEjB;;OAEG;IAEH,SAAS,CAAO;IAEhB;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,UAAU,CAAO;IAEjB;;OAEG;IAEH,UAAU,CAAS;IAEnB;;OAEG;IAEH,SAAS,CAAO;IAEhB;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,OAAO,CAAgC;IAEvC;;OAEG;IAEH,KAAK,CAA8B;IAEnC;;OAEG;IAEH,SAAS,CAAiC;IAE1C,YAAY,KAA0C;QACrD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;QACtC,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,CAAC;QAC3C,KAAK,CAAC,EAAE,GAAG,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E,CAAC,mCAAqB,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;;4DACzB;oCAzI9B,yBAAyB;IADrC,IAAA,gBAAM,EAAC,sBAAsB,CAAC;;GAClB,yBAAyB,CAmLrC"}
@@ -0,0 +1,57 @@
1
+ import { Activity, Language, PricePlan } from '@driveup/common';
2
+ import { CompanyProductEntity } from './product.entity';
3
+ import { ProductPricePlanEntity } from '../../../catalog/product/priceplan.entity';
4
+ import { CompanyPaymentMethodEntity } from '../finances/payment/method.entity';
5
+ import { TrackableEntity } from '../../../utils';
6
+ export declare class CompanyProductPricePlanEntity extends TrackableEntity<PricePlan> {
7
+ /**
8
+ * Company product
9
+ */
10
+ productId: number;
11
+ /**
12
+ * Driveup country product plan
13
+ */
14
+ pricePlanId: number;
15
+ paymentMethodId: number;
16
+ /**
17
+ * Product price
18
+ * Can be managed by driveup console and customized per company
19
+ */
20
+ price: number;
21
+ /**
22
+ * Product start credit for company
23
+ * Readonly for company admin
24
+ * Can be managed by driveup console and customized per company
25
+ */
26
+ startCredit: number;
27
+ /**
28
+ * Product max free benefits for company
29
+ * Can be managed by driveup console and customized per company
30
+ */
31
+ freeBenefits: number;
32
+ /**
33
+ * Planned switch date to new price plan
34
+ */
35
+ switchDate: Date;
36
+ /**
37
+ * Company product relation
38
+ */
39
+ product: Promise<CompanyProductEntity>;
40
+ /**
41
+ * Driveup product country price plan
42
+ */
43
+ pricePlan: Promise<ProductPricePlanEntity>;
44
+ /**
45
+ * Current product price plan
46
+ */
47
+ currentPricePlan: Promise<CompanyProductEntity>;
48
+ /**
49
+ * Current product payment method
50
+ */
51
+ paymentMethod: Promise<CompanyPaymentMethodEntity>;
52
+ constructor(props?: Partial<CompanyProductPricePlanEntity>);
53
+ toModel(lang?: Language): Promise<PricePlan>;
54
+ toSummary(): Promise<PricePlan>;
55
+ buildFeatureUsages(usageMetadata: Record<string, any>): Promise<import("@driveup/common").Item<any>[]>;
56
+ getActivities(): Promise<Activity[]>;
57
+ }
@@ -0,0 +1,167 @@
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.CompanyProductPricePlanEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const product_entity_1 = require("./product.entity");
16
+ const priceplan_entity_1 = require("../../../catalog/product/priceplan.entity");
17
+ const method_entity_1 = require("../finances/payment/method.entity");
18
+ const utils_1 = require("../../../utils");
19
+ let CompanyProductPricePlanEntity = class CompanyProductPricePlanEntity extends utils_1.TrackableEntity {
20
+ /**
21
+ * Company product
22
+ */
23
+ productId;
24
+ /**
25
+ * Driveup country product plan
26
+ */
27
+ pricePlanId;
28
+ paymentMethodId;
29
+ /**
30
+ * Product price
31
+ * Can be managed by driveup console and customized per company
32
+ */
33
+ price;
34
+ /**
35
+ * Product start credit for company
36
+ * Readonly for company admin
37
+ * Can be managed by driveup console and customized per company
38
+ */
39
+ startCredit;
40
+ /**
41
+ * Product max free benefits for company
42
+ * Can be managed by driveup console and customized per company
43
+ */
44
+ freeBenefits;
45
+ /**
46
+ * Planned switch date to new price plan
47
+ */
48
+ switchDate;
49
+ /**
50
+ * Company product relation
51
+ */
52
+ product;
53
+ /**
54
+ * Driveup product country price plan
55
+ */
56
+ pricePlan;
57
+ /**
58
+ * Current product price plan
59
+ */
60
+ currentPricePlan;
61
+ /**
62
+ * Current product payment method
63
+ */
64
+ paymentMethod;
65
+ constructor(props) {
66
+ super();
67
+ Object.assign(this, props);
68
+ }
69
+ async toModel(lang) {
70
+ const countryPricePlan = await this.pricePlan;
71
+ const pricePlan = await countryPricePlan.toModel(lang);
72
+ pricePlan.id = this.id;
73
+ pricePlan.price = this.price;
74
+ pricePlan.startCredit = this.startCredit;
75
+ pricePlan.freeBenefits = this.freeBenefits;
76
+ pricePlan.switchDate = this.switchDate;
77
+ return pricePlan;
78
+ }
79
+ async toSummary() {
80
+ return await this.toModel();
81
+ }
82
+ async buildFeatureUsages(usageMetadata) {
83
+ const countryPricePlan = await this.pricePlan;
84
+ const driveupPricePlan = await countryPricePlan.pricePlan;
85
+ return driveupPricePlan.getFeatureUsages(usageMetadata);
86
+ }
87
+ async getActivities() {
88
+ const activities = [];
89
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
90
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
91
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
92
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
93
+ return activities.filter(a => a);
94
+ }
95
+ };
96
+ exports.CompanyProductPricePlanEntity = CompanyProductPricePlanEntity;
97
+ __decorate([
98
+ (0, typeorm_1.Column)(),
99
+ __metadata("design:type", Number)
100
+ ], CompanyProductPricePlanEntity.prototype, "productId", void 0);
101
+ __decorate([
102
+ (0, typeorm_1.Column)(),
103
+ __metadata("design:type", Number)
104
+ ], CompanyProductPricePlanEntity.prototype, "pricePlanId", void 0);
105
+ __decorate([
106
+ (0, typeorm_1.Column)({
107
+ nullable: true,
108
+ default: null
109
+ }),
110
+ __metadata("design:type", Number)
111
+ ], CompanyProductPricePlanEntity.prototype, "paymentMethodId", void 0);
112
+ __decorate([
113
+ (0, typeorm_1.Column)({
114
+ type: 'decimal',
115
+ precision: 8,
116
+ scale: 2,
117
+ nullable: false,
118
+ default: 0
119
+ }),
120
+ __metadata("design:type", Number)
121
+ ], CompanyProductPricePlanEntity.prototype, "price", void 0);
122
+ __decorate([
123
+ (0, typeorm_1.Column)({
124
+ type: 'decimal',
125
+ precision: 8,
126
+ scale: 2,
127
+ nullable: false,
128
+ default: 0
129
+ }),
130
+ __metadata("design:type", Number)
131
+ ], CompanyProductPricePlanEntity.prototype, "startCredit", void 0);
132
+ __decorate([
133
+ (0, typeorm_1.Column)({
134
+ nullable: true,
135
+ default: null
136
+ }),
137
+ __metadata("design:type", Number)
138
+ ], CompanyProductPricePlanEntity.prototype, "freeBenefits", void 0);
139
+ __decorate([
140
+ (0, typeorm_1.Column)({
141
+ nullable: true,
142
+ default: null
143
+ }),
144
+ __metadata("design:type", Date)
145
+ ], CompanyProductPricePlanEntity.prototype, "switchDate", void 0);
146
+ __decorate([
147
+ (0, typeorm_1.ManyToOne)(() => product_entity_1.CompanyProductEntity, product => product.pricePlans),
148
+ __metadata("design:type", Promise)
149
+ ], CompanyProductPricePlanEntity.prototype, "product", void 0);
150
+ __decorate([
151
+ (0, typeorm_1.ManyToOne)(() => priceplan_entity_1.ProductPricePlanEntity, product => product.companies),
152
+ __metadata("design:type", Promise)
153
+ ], CompanyProductPricePlanEntity.prototype, "pricePlan", void 0);
154
+ __decorate([
155
+ (0, typeorm_1.OneToOne)(() => product_entity_1.CompanyProductEntity, product => product.pricePlan),
156
+ __metadata("design:type", Promise)
157
+ ], CompanyProductPricePlanEntity.prototype, "currentPricePlan", void 0);
158
+ __decorate([
159
+ (0, typeorm_1.OneToOne)(() => method_entity_1.CompanyPaymentMethodEntity, method => method.productPaymentMethod),
160
+ (0, typeorm_1.JoinColumn)(),
161
+ __metadata("design:type", Promise)
162
+ ], CompanyProductPricePlanEntity.prototype, "paymentMethod", void 0);
163
+ exports.CompanyProductPricePlanEntity = CompanyProductPricePlanEntity = __decorate([
164
+ (0, typeorm_1.Entity)('companyProductPricePlans'),
165
+ __metadata("design:paramtypes", [Object])
166
+ ], CompanyProductPricePlanEntity);
167
+ //# sourceMappingURL=priceplan.entity.js.map