@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,126 @@
|
|
|
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.CampaigneGiftCodeEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const common_1 = require("@driveup/common");
|
|
15
|
+
const campaign_entity_1 = require("./campaign.entity");
|
|
16
|
+
const utils_1 = require("../../utils");
|
|
17
|
+
const staff_entity_1 = require("../staff/staff.entity");
|
|
18
|
+
const utils_2 = require("../../utils");
|
|
19
|
+
/**
|
|
20
|
+
* Campaign gift code entity representing promotional codes for campaigns.
|
|
21
|
+
* Extends TrackableEntity to track creation and update information.
|
|
22
|
+
*/
|
|
23
|
+
let CampaigneGiftCodeEntity = class CampaigneGiftCodeEntity extends utils_2.TrackableEntity {
|
|
24
|
+
/**
|
|
25
|
+
* The ID of the campaign this gift code belongs to
|
|
26
|
+
*/
|
|
27
|
+
campaignId;
|
|
28
|
+
/**
|
|
29
|
+
* Unique 8-character gift code
|
|
30
|
+
*/
|
|
31
|
+
code;
|
|
32
|
+
/**
|
|
33
|
+
* Profile type that can use this gift code (Company, Student, Agent)
|
|
34
|
+
*/
|
|
35
|
+
profile;
|
|
36
|
+
/**
|
|
37
|
+
* ID of the user who registered/used this gift code
|
|
38
|
+
*/
|
|
39
|
+
registredBy;
|
|
40
|
+
/**
|
|
41
|
+
* Timestamp when this gift code was registered/used
|
|
42
|
+
*/
|
|
43
|
+
registredOn;
|
|
44
|
+
/**
|
|
45
|
+
* The campaign associated with this gift code
|
|
46
|
+
*/
|
|
47
|
+
campaign;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new CampaigneGiftCodeEntity instance
|
|
50
|
+
* @param props - Partial properties to initialize the entity with
|
|
51
|
+
*/
|
|
52
|
+
constructor(props) {
|
|
53
|
+
super();
|
|
54
|
+
Object.assign(this, props);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Converts the entity to a GiftCode model instance
|
|
58
|
+
* @returns GiftCode model with basic gift code information
|
|
59
|
+
*/
|
|
60
|
+
toModel() {
|
|
61
|
+
return new common_1.GiftCode({
|
|
62
|
+
id: this.id,
|
|
63
|
+
code: this.code,
|
|
64
|
+
profile: this.profile
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns a summary representation of the gift code
|
|
69
|
+
* @returns GiftCode model instance (same as toModel())
|
|
70
|
+
*/
|
|
71
|
+
toSummary() {
|
|
72
|
+
return this.toModel();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves all tracked activities for this gift code
|
|
76
|
+
* Includes creation, registration timestamps and associated staff members
|
|
77
|
+
* @returns Array of Activity objects
|
|
78
|
+
*/
|
|
79
|
+
async getActivities() {
|
|
80
|
+
const activities = [];
|
|
81
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy, staff_entity_1.StaffEntity));
|
|
82
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
83
|
+
activities.push(await (0, utils_1.toActivity)(this.registredBy, common_1.ActivityType.registredBy));
|
|
84
|
+
activities.push(await (0, utils_1.toActivity)(this.registredOn, common_1.ActivityType.registredOn));
|
|
85
|
+
return activities;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.CampaigneGiftCodeEntity = CampaigneGiftCodeEntity;
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, typeorm_1.Column)(),
|
|
91
|
+
__metadata("design:type", Number)
|
|
92
|
+
], CampaigneGiftCodeEntity.prototype, "campaignId", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({
|
|
95
|
+
nullable: false,
|
|
96
|
+
unique: true,
|
|
97
|
+
length: 8
|
|
98
|
+
}),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], CampaigneGiftCodeEntity.prototype, "code", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, typeorm_1.Column)({
|
|
103
|
+
type: 'enum',
|
|
104
|
+
enum: common_1.ProfileType,
|
|
105
|
+
default: common_1.ProfileType.Company,
|
|
106
|
+
nullable: true,
|
|
107
|
+
}),
|
|
108
|
+
__metadata("design:type", String)
|
|
109
|
+
], CampaigneGiftCodeEntity.prototype, "profile", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
112
|
+
__metadata("design:type", Number)
|
|
113
|
+
], CampaigneGiftCodeEntity.prototype, "registredBy", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
116
|
+
__metadata("design:type", Date)
|
|
117
|
+
], CampaigneGiftCodeEntity.prototype, "registredOn", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, typeorm_1.ManyToMany)(() => campaign_entity_1.CampaigneEntity, campaign => campaign.giftCodes),
|
|
120
|
+
__metadata("design:type", campaign_entity_1.CampaigneEntity)
|
|
121
|
+
], CampaigneGiftCodeEntity.prototype, "campaign", void 0);
|
|
122
|
+
exports.CampaigneGiftCodeEntity = CampaigneGiftCodeEntity = __decorate([
|
|
123
|
+
(0, typeorm_1.Entity)('systemCampaigneGiftCodes'),
|
|
124
|
+
__metadata("design:paramtypes", [Object])
|
|
125
|
+
], CampaigneGiftCodeEntity);
|
|
126
|
+
//# sourceMappingURL=gifcode.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gifcode.entity.js","sourceRoot":"","sources":["../../../src/system/campaigne/gifcode.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAqD;AACrD,4CAA0F;AAC1F,uDAAoD;AACpD,uCAAyC;AACzC,wDAAoD;AACpD,uCAA8C;AAE9C;;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AAC;IACnB,CAAC;CACD,CAAA;AAzFY,0DAAuB;AAMnC;IADC,IAAA,gBAAM,GAAE;;2DACU;AAUnB;IALC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,CAAC;KACT,CAAC;;qDACW;AAWb;IANC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,oBAAW;QACjB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,QAAQ,EAAE,IAAI;KACd,CAAC;;wDACmB;AAMrB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;4DACtB;AAMpB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC7B,IAAI;4DAAC;AAMlB;IADC,IAAA,oBAAU,EAAC,GAAG,EAAE,CAAC,iCAAe,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;8BACxD,iCAAe;yDAAC;kCA7Cd,uBAAuB;IADnC,IAAA,gBAAM,EAAC,0BAA0B,CAAC;;GACtB,uBAAuB,CAyFnC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Language, WorkingHours, Activity, Country, Holiday } from '@driveup/common';
|
|
2
|
+
import { CompanyEntity } from '../../profile/company/company.entity';
|
|
3
|
+
import { CurrencyEntity } from '../currency/currency.entity';
|
|
4
|
+
import { UserEntity } from '../../user/user.entity';
|
|
5
|
+
import { ProductCountryEntity } from '../../catalog/product/country.entity';
|
|
6
|
+
import { AddonCountryEntity } from '../../catalog/addon/country.entity';
|
|
7
|
+
import { DrivingCategoryEntity } from '../driving/category.entity';
|
|
8
|
+
import { TrackableEntity } from '../../utils';
|
|
9
|
+
/**
|
|
10
|
+
* Represents a country in the system.
|
|
11
|
+
* Countries define regional settings including languages, currency, timezones,
|
|
12
|
+
* working hours, and holidays. Each country can have specific products, addons,
|
|
13
|
+
* and driving categories enabled. Activating/deactivating affects all users.
|
|
14
|
+
*
|
|
15
|
+
* @extends TrackableEntity
|
|
16
|
+
*/
|
|
17
|
+
export declare class CountryEntity extends TrackableEntity<Country> {
|
|
18
|
+
/**
|
|
19
|
+
* Reference to the country's official currency
|
|
20
|
+
*/
|
|
21
|
+
currencyId: number;
|
|
22
|
+
/**
|
|
23
|
+
* Country name (e.g., "Switzerland", "Germany")
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* URL to the country's flag image
|
|
28
|
+
*/
|
|
29
|
+
flagUrl: string;
|
|
30
|
+
/**
|
|
31
|
+
* Supported languages in the country
|
|
32
|
+
* @default [Language.De]
|
|
33
|
+
*/
|
|
34
|
+
languages: Language[];
|
|
35
|
+
/**
|
|
36
|
+
* ISO country code (e.g., "CH", "DE", "AT")
|
|
37
|
+
*/
|
|
38
|
+
code: string;
|
|
39
|
+
/**
|
|
40
|
+
* International dialing code (e.g., "+41", "+49")
|
|
41
|
+
*/
|
|
42
|
+
phoneCode: string;
|
|
43
|
+
/**
|
|
44
|
+
* List of timezones applicable to the country
|
|
45
|
+
*/
|
|
46
|
+
timezones: string[];
|
|
47
|
+
/**
|
|
48
|
+
* Standard working hours for the country
|
|
49
|
+
*/
|
|
50
|
+
workingHours: WorkingHours[];
|
|
51
|
+
/**
|
|
52
|
+
* List of public holidays for the country
|
|
53
|
+
*/
|
|
54
|
+
holidays: Holiday[];
|
|
55
|
+
/**
|
|
56
|
+
* Country active status
|
|
57
|
+
* Activating/Deactivating a country will affect existing customers.
|
|
58
|
+
* This action will block access for all users from this country.
|
|
59
|
+
*/
|
|
60
|
+
active: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* ID of the staff member who enabled this country
|
|
63
|
+
*/
|
|
64
|
+
enabledBy: number;
|
|
65
|
+
/**
|
|
66
|
+
* Date when the country was enabled
|
|
67
|
+
*/
|
|
68
|
+
enabledOn: Date;
|
|
69
|
+
/**
|
|
70
|
+
* ID of the staff member who disabled this country
|
|
71
|
+
*/
|
|
72
|
+
disabledBy: number;
|
|
73
|
+
/**
|
|
74
|
+
* Date when the country was disabled
|
|
75
|
+
*/
|
|
76
|
+
disabledOn: Date;
|
|
77
|
+
/**
|
|
78
|
+
* Reference to the country's currency
|
|
79
|
+
*/
|
|
80
|
+
currency: Promise<CurrencyEntity>;
|
|
81
|
+
/**
|
|
82
|
+
* Products available in this country
|
|
83
|
+
*/
|
|
84
|
+
products: Promise<ProductCountryEntity[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Addons available in this country
|
|
87
|
+
*/
|
|
88
|
+
addons: Promise<AddonCountryEntity[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Users registered in this country
|
|
91
|
+
*/
|
|
92
|
+
users: Promise<UserEntity[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Companies operating in this country
|
|
95
|
+
*/
|
|
96
|
+
companies: Promise<CompanyEntity[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Driving license categories available in this country
|
|
99
|
+
*/
|
|
100
|
+
drivingCategories: Promise<DrivingCategoryEntity[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new CountryEntity instance
|
|
103
|
+
* @param props - Partial properties to initialize the entity
|
|
104
|
+
*/
|
|
105
|
+
constructor(props?: Partial<CountryEntity>);
|
|
106
|
+
/**
|
|
107
|
+
* Converts the entity to a Country model instance with complete information
|
|
108
|
+
* @returns Country model with all country data
|
|
109
|
+
*/
|
|
110
|
+
toModel(): Country;
|
|
111
|
+
/**
|
|
112
|
+
* Converts the entity to a Country summary model with essential information
|
|
113
|
+
* @returns Country model with basic information for listings
|
|
114
|
+
*/
|
|
115
|
+
toSummary(): Country;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves activity history for this country
|
|
118
|
+
* @returns Promise resolving to array of Activity instances tracking creation, updates, and status changes
|
|
119
|
+
*/
|
|
120
|
+
getActivities(): Promise<Activity[]>;
|
|
121
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
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.CountryEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const common_1 = require("@driveup/common");
|
|
15
|
+
const company_entity_1 = require("../../profile/company/company.entity");
|
|
16
|
+
const currency_entity_1 = require("../currency/currency.entity");
|
|
17
|
+
const user_entity_1 = require("../../user/user.entity");
|
|
18
|
+
const country_entity_1 = require("../../catalog/product/country.entity");
|
|
19
|
+
const country_entity_2 = require("../../catalog/addon/country.entity");
|
|
20
|
+
const category_entity_1 = require("../driving/category.entity");
|
|
21
|
+
const staff_entity_1 = require("../staff/staff.entity");
|
|
22
|
+
const utils_1 = require("../../utils");
|
|
23
|
+
/**
|
|
24
|
+
* Represents a country in the system.
|
|
25
|
+
* Countries define regional settings including languages, currency, timezones,
|
|
26
|
+
* working hours, and holidays. Each country can have specific products, addons,
|
|
27
|
+
* and driving categories enabled. Activating/deactivating affects all users.
|
|
28
|
+
*
|
|
29
|
+
* @extends TrackableEntity
|
|
30
|
+
*/
|
|
31
|
+
let CountryEntity = class CountryEntity extends utils_1.TrackableEntity {
|
|
32
|
+
/**
|
|
33
|
+
* Reference to the country's official currency
|
|
34
|
+
*/
|
|
35
|
+
currencyId;
|
|
36
|
+
/**
|
|
37
|
+
* Country name (e.g., "Switzerland", "Germany")
|
|
38
|
+
*/
|
|
39
|
+
name;
|
|
40
|
+
/**
|
|
41
|
+
* URL to the country's flag image
|
|
42
|
+
*/
|
|
43
|
+
flagUrl;
|
|
44
|
+
/**
|
|
45
|
+
* Supported languages in the country
|
|
46
|
+
* @default [Language.De]
|
|
47
|
+
*/
|
|
48
|
+
languages;
|
|
49
|
+
/**
|
|
50
|
+
* ISO country code (e.g., "CH", "DE", "AT")
|
|
51
|
+
*/
|
|
52
|
+
code;
|
|
53
|
+
/**
|
|
54
|
+
* International dialing code (e.g., "+41", "+49")
|
|
55
|
+
*/
|
|
56
|
+
phoneCode;
|
|
57
|
+
/**
|
|
58
|
+
* List of timezones applicable to the country
|
|
59
|
+
*/
|
|
60
|
+
timezones;
|
|
61
|
+
/**
|
|
62
|
+
* Standard working hours for the country
|
|
63
|
+
*/
|
|
64
|
+
workingHours;
|
|
65
|
+
/**
|
|
66
|
+
* List of public holidays for the country
|
|
67
|
+
*/
|
|
68
|
+
holidays;
|
|
69
|
+
/**
|
|
70
|
+
* Country active status
|
|
71
|
+
* Activating/Deactivating a country will affect existing customers.
|
|
72
|
+
* This action will block access for all users from this country.
|
|
73
|
+
*/
|
|
74
|
+
active;
|
|
75
|
+
/**
|
|
76
|
+
* ID of the staff member who enabled this country
|
|
77
|
+
*/
|
|
78
|
+
enabledBy;
|
|
79
|
+
/**
|
|
80
|
+
* Date when the country was enabled
|
|
81
|
+
*/
|
|
82
|
+
enabledOn;
|
|
83
|
+
/**
|
|
84
|
+
* ID of the staff member who disabled this country
|
|
85
|
+
*/
|
|
86
|
+
disabledBy;
|
|
87
|
+
/**
|
|
88
|
+
* Date when the country was disabled
|
|
89
|
+
*/
|
|
90
|
+
disabledOn;
|
|
91
|
+
/**
|
|
92
|
+
* Reference to the country's currency
|
|
93
|
+
*/
|
|
94
|
+
currency;
|
|
95
|
+
/**
|
|
96
|
+
* Products available in this country
|
|
97
|
+
*/
|
|
98
|
+
products;
|
|
99
|
+
/**
|
|
100
|
+
* Addons available in this country
|
|
101
|
+
*/
|
|
102
|
+
addons;
|
|
103
|
+
/**
|
|
104
|
+
* Users registered in this country
|
|
105
|
+
*/
|
|
106
|
+
users;
|
|
107
|
+
/**
|
|
108
|
+
* Companies operating in this country
|
|
109
|
+
*/
|
|
110
|
+
companies;
|
|
111
|
+
/**
|
|
112
|
+
* Driving license categories available in this country
|
|
113
|
+
*/
|
|
114
|
+
drivingCategories;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a new CountryEntity instance
|
|
117
|
+
* @param props - Partial properties to initialize the entity
|
|
118
|
+
*/
|
|
119
|
+
constructor(props) {
|
|
120
|
+
super();
|
|
121
|
+
Object.assign(this, props);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Converts the entity to a Country model instance with complete information
|
|
125
|
+
* @returns Country model with all country data
|
|
126
|
+
*/
|
|
127
|
+
toModel() {
|
|
128
|
+
return new common_1.Country({
|
|
129
|
+
id: this.id,
|
|
130
|
+
name: this.name,
|
|
131
|
+
flagUrl: this.flagUrl,
|
|
132
|
+
code: this.code,
|
|
133
|
+
phoneCode: this.phoneCode,
|
|
134
|
+
languages: this.languages,
|
|
135
|
+
timezones: this.timezones,
|
|
136
|
+
workingHours: this.workingHours,
|
|
137
|
+
holidays: this.holidays,
|
|
138
|
+
active: this.active
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Converts the entity to a Country summary model with essential information
|
|
143
|
+
* @returns Country model with basic information for listings
|
|
144
|
+
*/
|
|
145
|
+
toSummary() {
|
|
146
|
+
return new common_1.Country({
|
|
147
|
+
id: this.id,
|
|
148
|
+
name: this.name,
|
|
149
|
+
flagUrl: this.flagUrl,
|
|
150
|
+
code: this.code,
|
|
151
|
+
phoneCode: this.phoneCode,
|
|
152
|
+
languages: this.languages,
|
|
153
|
+
active: this.active
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves activity history for this country
|
|
158
|
+
* @returns Promise resolving to array of Activity instances tracking creation, updates, and status changes
|
|
159
|
+
*/
|
|
160
|
+
async getActivities() {
|
|
161
|
+
const activities = [];
|
|
162
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy, staff_entity_1.StaffEntity));
|
|
163
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
164
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy, staff_entity_1.StaffEntity));
|
|
165
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
166
|
+
activities.push(await (0, utils_1.toActivity)(this.enabledBy, common_1.ActivityType.enabledBy, staff_entity_1.StaffEntity));
|
|
167
|
+
activities.push(await (0, utils_1.toActivity)(this.enabledOn, common_1.ActivityType.createdOn));
|
|
168
|
+
activities.push(await (0, utils_1.toActivity)(this.disabledBy, common_1.ActivityType.disabledBy, staff_entity_1.StaffEntity));
|
|
169
|
+
activities.push(await (0, utils_1.toActivity)(this.disabledOn, common_1.ActivityType.disabledOn));
|
|
170
|
+
return activities.filter(a => a);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
exports.CountryEntity = CountryEntity;
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, typeorm_1.Column)({
|
|
176
|
+
nullable: true,
|
|
177
|
+
default: null
|
|
178
|
+
}),
|
|
179
|
+
__metadata("design:type", Number)
|
|
180
|
+
], CountryEntity.prototype, "currencyId", void 0);
|
|
181
|
+
__decorate([
|
|
182
|
+
(0, typeorm_1.Column)(),
|
|
183
|
+
__metadata("design:type", String)
|
|
184
|
+
], CountryEntity.prototype, "name", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
(0, typeorm_1.Column)({
|
|
187
|
+
nullable: true,
|
|
188
|
+
default: null
|
|
189
|
+
}),
|
|
190
|
+
__metadata("design:type", String)
|
|
191
|
+
], CountryEntity.prototype, "flagUrl", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
(0, typeorm_1.Column)({
|
|
194
|
+
type: 'set',
|
|
195
|
+
enum: common_1.Language,
|
|
196
|
+
default: [common_1.Language.De],
|
|
197
|
+
nullable: false
|
|
198
|
+
}),
|
|
199
|
+
__metadata("design:type", Array)
|
|
200
|
+
], CountryEntity.prototype, "languages", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
|
203
|
+
__metadata("design:type", String)
|
|
204
|
+
], CountryEntity.prototype, "code", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
|
207
|
+
__metadata("design:type", String)
|
|
208
|
+
], CountryEntity.prototype, "phoneCode", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
(0, typeorm_1.Column)({
|
|
211
|
+
type: 'simple-json',
|
|
212
|
+
nullable: true,
|
|
213
|
+
default: null
|
|
214
|
+
}),
|
|
215
|
+
__metadata("design:type", Array)
|
|
216
|
+
], CountryEntity.prototype, "timezones", void 0);
|
|
217
|
+
__decorate([
|
|
218
|
+
(0, typeorm_1.Column)({
|
|
219
|
+
type: 'simple-json',
|
|
220
|
+
nullable: true,
|
|
221
|
+
default: null
|
|
222
|
+
}),
|
|
223
|
+
__metadata("design:type", Array)
|
|
224
|
+
], CountryEntity.prototype, "workingHours", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
(0, typeorm_1.Column)({
|
|
227
|
+
type: 'simple-json',
|
|
228
|
+
nullable: true,
|
|
229
|
+
default: null
|
|
230
|
+
}),
|
|
231
|
+
__metadata("design:type", Array)
|
|
232
|
+
], CountryEntity.prototype, "holidays", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
(0, typeorm_1.Column)({
|
|
235
|
+
nullable: false,
|
|
236
|
+
default: false
|
|
237
|
+
}),
|
|
238
|
+
__metadata("design:type", Boolean)
|
|
239
|
+
], CountryEntity.prototype, "active", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
242
|
+
__metadata("design:type", Number)
|
|
243
|
+
], CountryEntity.prototype, "enabledBy", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
246
|
+
__metadata("design:type", Date)
|
|
247
|
+
], CountryEntity.prototype, "enabledOn", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
250
|
+
__metadata("design:type", Number)
|
|
251
|
+
], CountryEntity.prototype, "disabledBy", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
254
|
+
__metadata("design:type", Date)
|
|
255
|
+
], CountryEntity.prototype, "disabledOn", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
(0, typeorm_1.ManyToOne)(() => currency_entity_1.CurrencyEntity, currency => currency.countries),
|
|
258
|
+
__metadata("design:type", Promise)
|
|
259
|
+
], CountryEntity.prototype, "currency", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
(0, typeorm_1.OneToMany)(() => country_entity_1.ProductCountryEntity, product => product.country),
|
|
262
|
+
__metadata("design:type", Promise)
|
|
263
|
+
], CountryEntity.prototype, "products", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
(0, typeorm_1.OneToMany)(() => country_entity_2.AddonCountryEntity, product => product.country),
|
|
266
|
+
__metadata("design:type", Promise)
|
|
267
|
+
], CountryEntity.prototype, "addons", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
(0, typeorm_1.OneToMany)(() => user_entity_1.UserEntity, user => user.country),
|
|
270
|
+
__metadata("design:type", Promise)
|
|
271
|
+
], CountryEntity.prototype, "users", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
(0, typeorm_1.OneToMany)(() => company_entity_1.CompanyEntity, compnay => compnay.country),
|
|
274
|
+
__metadata("design:type", Promise)
|
|
275
|
+
], CountryEntity.prototype, "companies", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
(0, typeorm_1.OneToMany)(() => category_entity_1.DrivingCategoryEntity, category => category.country),
|
|
278
|
+
__metadata("design:type", Promise)
|
|
279
|
+
], CountryEntity.prototype, "drivingCategories", void 0);
|
|
280
|
+
exports.CountryEntity = CountryEntity = __decorate([
|
|
281
|
+
(0, typeorm_1.Entity)('systemCountries'),
|
|
282
|
+
__metadata("design:paramtypes", [Object])
|
|
283
|
+
], CountryEntity);
|
|
284
|
+
//# sourceMappingURL=country.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country.entity.js","sourceRoot":"","sources":["../../../src/system/country/country.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,4CAAmG;AACnG,yEAAqE;AACrE,iEAA6D;AAC7D,wDAAoD;AACpD,yEAA4E;AAC5E,uEAAwE;AACxE,gEAAmE;AACnE,wDAAoD;AACpD,uCAA0D;AAE1D;;;;;;;GAOG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,uBAAwB;IAE1D;;OAEG;IAKH,UAAU,CAAS;IAEnB;;OAEG;IAEH,IAAI,CAAS;IAEb;;OAEG;IAKH,OAAO,CAAS;IAEhB;;;OAGG;IAOH,SAAS,CAAa;IAEtB;;OAEG;IAEH,IAAI,CAAS;IAEb;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAMH,SAAS,CAAW;IAEpB;;OAEG;IAMH,YAAY,CAAiB;IAE7B;;OAEG;IAMH,QAAQ,CAAY;IAEpB;;;;OAIG;IAKH,MAAM,CAAU;IAEhB;;OAEG;IAEH,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,OAAO,EAAE,IAAI,EAAE,CAAC;;iDACvB;AAMnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC9B,IAAI;iDAAC;AAMjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,gCAAc,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;;+CAC9B;AAMlC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAoB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;+CACxB;AAM1C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,mCAAkB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;6CAC1B;AAMtC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;4CACrB;AAM7B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;gDACvB;AAMpC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAqB,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;;wDACjB;wBArJxC,aAAa;IADzB,IAAA,gBAAM,EAAC,iBAAiB,CAAC;;GACb,aAAa,CAmNzB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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.CountryMetric = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const common_1 = require("@driveup/common");
|
|
15
|
+
const utils_1 = require("../../utils");
|
|
16
|
+
let CountryMetric = class CountryMetric {
|
|
17
|
+
id;
|
|
18
|
+
name;
|
|
19
|
+
company;
|
|
20
|
+
};
|
|
21
|
+
exports.CountryMetric = CountryMetric;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.ViewColumn)(),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], CountryMetric.prototype, "id", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.ViewColumn)(),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], CountryMetric.prototype, "name", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.ViewColumn)({
|
|
32
|
+
transformer: new utils_1.ColumnJsonMetricsTransformer()
|
|
33
|
+
}),
|
|
34
|
+
__metadata("design:type", Object)
|
|
35
|
+
], CountryMetric.prototype, "company", void 0);
|
|
36
|
+
exports.CountryMetric = CountryMetric = __decorate([
|
|
37
|
+
(0, typeorm_1.ViewEntity)({
|
|
38
|
+
name: 'vw_country_metrics',
|
|
39
|
+
expression: `
|
|
40
|
+
SELECT
|
|
41
|
+
c.id,
|
|
42
|
+
c.name,
|
|
43
|
+
JSON_OBJECT(
|
|
44
|
+
'total', subComp.totalCompanies,
|
|
45
|
+
'pending', subComp.totalPendingCompanies,
|
|
46
|
+
'active', subComp.totalActiveCompanies,
|
|
47
|
+
'suspended', subComp.totalSuspendedCompanies,
|
|
48
|
+
'disabled', subComp.totalBlockedCompanies,
|
|
49
|
+
'closed', subComp.totalClosedCompanies
|
|
50
|
+
) AS company
|
|
51
|
+
FROM countries c
|
|
52
|
+
LEFT JOIN (
|
|
53
|
+
SELECT
|
|
54
|
+
companies.id AS id,
|
|
55
|
+
COUNT(companies.id) AS totalCompanies,
|
|
56
|
+
SUM(IF(companies.status = '${common_1.AccountStatus.Pending}', 1, 0)) AS totalPendingCompanies,
|
|
57
|
+
SUM(IF(companies.status = '${common_1.AccountStatus.Active}', 1, 0)) AS totalActiveCompanies,
|
|
58
|
+
SUM(IF(companies.status = '${common_1.AccountStatus.Suspended}', 1, 0)) AS totalSuspendedCompanies,
|
|
59
|
+
SUM(IF(companies.status = '${common_1.AccountStatus.Blocked}', 1, 0)) AS totalBlockedCompanies,
|
|
60
|
+
SUM(IF(companies.status = '${common_1.AccountStatus.Closed}', 1, 0)) AS totalClosedCompanies
|
|
61
|
+
FROM companies
|
|
62
|
+
GROUP BY companies.id
|
|
63
|
+
) subComp ON subComp.id = c.id
|
|
64
|
+
GROUP BY c.id, c.name
|
|
65
|
+
`
|
|
66
|
+
})
|
|
67
|
+
], CountryMetric);
|
|
68
|
+
//# sourceMappingURL=country.metric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country.metric.js","sourceRoot":"","sources":["../../../src/system/country/country.metric.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiD;AACjD,4CAAgD;AAChD,uCAA2D;AAgCpD,IAAM,aAAa,GAAnB,MAAM,aAAa;IAEzB,EAAE,CAAS;IAGX,IAAI,CAAS;IAKb,OAAO,CAOL;CACF,CAAA;AAlBY,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;;8CAQA;wBAjBU,aAAa;IA9BzB,IAAA,oBAAU,EAAC;QACX,IAAI,EAAE,oBAAoB;QAC1B,UAAU,EAAE;;;;;;;;;;;;;;;;;iCAiBoB,sBAAa,CAAC,OAAO;iCACrB,sBAAa,CAAC,MAAM;iCACpB,sBAAa,CAAC,SAAS;iCACvB,sBAAa,CAAC,OAAO;iCACrB,sBAAa,CAAC,MAAM;;;;;KAKhD;KACJ,CAAC;GACW,aAAa,CAkBzB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CountryEntity } from '../country/country.entity';
|
|
2
|
+
import { Activity, Currency } from '@driveup/common';
|
|
3
|
+
import { TrackableEntity } from '../../utils';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a currency in the system.
|
|
6
|
+
* Currencies define monetary units used in different countries,
|
|
7
|
+
* including their symbols, abbreviations, and exchange rates relative to CHF.
|
|
8
|
+
*
|
|
9
|
+
* @extends TrackableEntity
|
|
10
|
+
*/
|
|
11
|
+
export declare class CurrencyEntity extends TrackableEntity<Currency> {
|
|
12
|
+
/**
|
|
13
|
+
* Full name of the currency (e.g., "Swiss Franc", "Euro")
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Currency abbreviation/code (e.g., "CHF", "EUR", "USD")
|
|
18
|
+
*/
|
|
19
|
+
abbr: string;
|
|
20
|
+
/**
|
|
21
|
+
* Currency symbol (e.g., "₣", "€", "$")
|
|
22
|
+
*/
|
|
23
|
+
symbol: string;
|
|
24
|
+
/**
|
|
25
|
+
* Exchange rate relative to Swiss Franc (CHF)
|
|
26
|
+
* Used for currency conversion calculations
|
|
27
|
+
* @default 0
|
|
28
|
+
*/
|
|
29
|
+
chRate: number;
|
|
30
|
+
/**
|
|
31
|
+
* Countries using this currency
|
|
32
|
+
*/
|
|
33
|
+
countries: Promise<CountryEntity[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new CurrencyEntity instance
|
|
36
|
+
* @param props - Partial properties to initialize the entity
|
|
37
|
+
*/
|
|
38
|
+
constructor(props?: Partial<CurrencyEntity>);
|
|
39
|
+
toModel(): Currency;
|
|
40
|
+
toSummary(): Currency;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves activity history for this currency
|
|
43
|
+
* @returns Promise resolving to array of Activity instances tracking creation and updates
|
|
44
|
+
*/
|
|
45
|
+
getActivities(): Promise<Activity[]>;
|
|
46
|
+
}
|