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