@driveup/schema 0.1.2 → 0.1.3
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/lib/catalog/addon/addon.entity.js +0 -56
- package/lib/catalog/addon/addon.entity.js.map +1 -1
- package/lib/catalog/addon/country.entity.js +0 -70
- package/lib/catalog/addon/country.entity.js.map +1 -1
- package/lib/catalog/priceplan/priceplan.entity.js +0 -59
- package/lib/catalog/priceplan/priceplan.entity.js.map +1 -1
- package/lib/catalog/product/country.entity.js +0 -64
- package/lib/catalog/product/country.entity.js.map +1 -1
- package/lib/catalog/product/priceplan.entity.js +0 -65
- package/lib/catalog/product/priceplan.entity.js.map +1 -1
- package/lib/catalog/product/product.entity.js +0 -56
- package/lib/catalog/product/product.entity.js.map +1 -1
- package/lib/catalog/program/program.entity.js +0 -59
- package/lib/catalog/program/program.entity.js.map +1 -1
- package/lib/catalog/seed/assets/asset.entity.js +0 -23
- package/lib/catalog/seed/assets/asset.entity.js.map +1 -1
- package/lib/catalog/seed/courses/course.entity.js +0 -38
- package/lib/catalog/seed/courses/course.entity.js.map +1 -1
- package/lib/catalog/seed/courses/lesson.entity.js +0 -36
- package/lib/catalog/seed/courses/lesson.entity.js.map +1 -1
- package/lib/catalog/seed/courses/topic.entity.js +0 -25
- package/lib/catalog/seed/courses/topic.entity.js.map +1 -1
- package/lib/catalog/seed/expense/category.entity.js +0 -16
- package/lib/catalog/seed/expense/category.entity.js.map +1 -1
- package/lib/profile/agent/agent.entity.js +0 -49
- package/lib/profile/agent/agent.entity.js.map +1 -1
- package/lib/profile/agent/payout.entity.js +0 -35
- package/lib/profile/agent/payout.entity.js.map +1 -1
- package/lib/profile/agent/promotion.entity.js +0 -46
- package/lib/profile/agent/promotion.entity.js.map +1 -1
- package/lib/profile/company/company.entity.js +0 -148
- package/lib/profile/company/company.entity.js.map +1 -1
- package/lib/profile/company/course/appointment.entity.js +0 -60
- package/lib/profile/company/course/appointment.entity.js.map +1 -1
- package/lib/profile/company/course/course.entity.js +0 -107
- package/lib/profile/company/course/course.entity.js.map +1 -1
- package/lib/profile/company/course/lesson.entity.js +0 -83
- package/lib/profile/company/course/lesson.entity.js.map +1 -1
- package/lib/profile/company/course/topic.entity.js +0 -35
- package/lib/profile/company/course/topic.entity.js.map +1 -1
- package/lib/profile/company/finances/billing/bill.entity.js +0 -105
- package/lib/profile/company/finances/billing/bill.entity.js.map +1 -1
- package/lib/profile/company/finances/billing/item.entity.js +0 -62
- package/lib/profile/company/finances/billing/item.entity.js.map +1 -1
- package/lib/profile/company/finances/billing/transaction.entity.js +0 -33
- package/lib/profile/company/finances/billing/transaction.entity.js.map +1 -1
- package/lib/profile/company/finances/expense/category.entity.js +0 -24
- package/lib/profile/company/finances/expense/category.entity.js.map +1 -1
- package/lib/profile/company/finances/expense/expense.entity.js +0 -31
- package/lib/profile/company/finances/expense/expense.entity.js.map +1 -1
- package/lib/profile/company/finances/handover/handover.entity.js +0 -27
- package/lib/profile/company/finances/handover/handover.entity.js.map +1 -1
- package/lib/profile/company/finances/invoice/invoice.entity.js +0 -45
- package/lib/profile/company/finances/invoice/invoice.entity.js.map +1 -1
- package/lib/profile/company/finances/invoice/item.entity.js +0 -16
- package/lib/profile/company/finances/invoice/item.entity.js.map +1 -1
- package/lib/profile/company/finances/payment/method.entity.js +0 -23
- package/lib/profile/company/finances/payment/method.entity.js.map +1 -1
- package/lib/profile/company/instructor/instructor.entity.js +0 -63
- package/lib/profile/company/instructor/instructor.entity.js.map +1 -1
- package/lib/profile/company/instructor/task.entity.js +0 -36
- package/lib/profile/company/instructor/task.entity.js.map +1 -1
- package/lib/profile/company/medical/examination.entity.js +0 -43
- package/lib/profile/company/medical/examination.entity.js.map +1 -1
- package/lib/profile/company/medical/product.entity.js +0 -84
- package/lib/profile/company/medical/product.entity.js.map +1 -1
- package/lib/profile/company/product/addon.entity.js +0 -81
- package/lib/profile/company/product/addon.entity.js.map +1 -1
- package/lib/profile/company/product/priceplan.entity.js +0 -45
- package/lib/profile/company/product/priceplan.entity.js.map +1 -1
- package/lib/profile/company/product/product.entity.js +0 -154
- package/lib/profile/company/product/product.entity.js.map +1 -1
- package/lib/profile/company/product/vehicle.entity.js +0 -37
- package/lib/profile/company/product/vehicle.entity.js.map +1 -1
- package/lib/profile/instructor/instructor.entity.js +0 -34
- package/lib/profile/instructor/instructor.entity.js.map +1 -1
- package/lib/profile/student/program/licence/licence.entity.js +0 -55
- package/lib/profile/student/program/licence/licence.entity.js.map +1 -1
- package/lib/profile/student/program/medical/certificate.entity.js +0 -72
- package/lib/profile/student/program/medical/certificate.entity.js.map +1 -1
- package/lib/profile/student/program/medical/examination.model.js +0 -53
- package/lib/profile/student/program/medical/examination.model.js.map +1 -1
- package/lib/profile/student/program/program.entity.js +0 -62
- package/lib/profile/student/program/program.entity.js.map +1 -1
- package/lib/profile/student/program/training/appointment.entity.js +0 -130
- package/lib/profile/student/program/training/appointment.entity.js.map +1 -1
- package/lib/profile/student/program/training/exam.entity.js +0 -31
- package/lib/profile/student/program/training/exam.entity.js.map +1 -1
- package/lib/profile/student/program/training/lesson.entity.js +0 -71
- package/lib/profile/student/program/training/lesson.entity.js.map +1 -1
- package/lib/profile/student/program/training/request.entity.js +0 -46
- package/lib/profile/student/program/training/request.entity.js.map +1 -1
- package/lib/profile/student/program/training/topic.entity.js +0 -54
- package/lib/profile/student/program/training/topic.entity.js.map +1 -1
- package/lib/profile/student/program/training/training.entity.js +0 -139
- package/lib/profile/student/program/training/training.entity.js.map +1 -1
- package/lib/profile/student/program/training/transaction.entity.js +0 -67
- package/lib/profile/student/program/training/transaction.entity.js.map +1 -1
- package/lib/profile/student/student.entity.js +0 -58
- package/lib/profile/student/student.entity.js.map +1 -1
- package/lib/system/campaigne/campaign.entity.js +0 -26
- package/lib/system/campaigne/campaign.entity.js.map +1 -1
- package/lib/system/campaigne/gifcode.entity.js +0 -24
- package/lib/system/campaigne/gifcode.entity.js.map +1 -1
- package/lib/system/country/country.entity.js +0 -83
- package/lib/system/country/country.entity.js.map +1 -1
- package/lib/system/currency/currency.entity.js +0 -22
- package/lib/system/currency/currency.entity.js.map +1 -1
- package/lib/system/driving/category.entity.js +0 -97
- package/lib/system/driving/category.entity.js.map +1 -1
- package/lib/system/driving/vehicle.entity.js +0 -21
- package/lib/system/driving/vehicle.entity.js.map +1 -1
- package/lib/system/event/business.entity.js +0 -43
- package/lib/system/event/business.entity.js.map +1 -1
- package/lib/system/event/log.entity.js +0 -26
- package/lib/system/event/log.entity.js.map +1 -1
- package/lib/system/policy/policy.entity.js +0 -46
- package/lib/system/policy/policy.entity.js.map +1 -1
- package/lib/system/staff/staff.entity.js +0 -35
- package/lib/system/staff/staff.entity.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/user/alert.entity.js +0 -55
- package/lib/user/alert.entity.js.map +1 -1
- package/lib/user/blocked.entity.js +0 -9
- package/lib/user/blocked.entity.js.map +1 -1
- package/lib/user/device.entity.js +0 -40
- package/lib/user/device.entity.js.map +1 -1
- package/lib/user/notification.entity.js +0 -58
- package/lib/user/notification.entity.js.map +1 -1
- package/lib/user/ticket.entity.js +0 -56
- package/lib/user/ticket.entity.js.map +1 -1
- package/lib/user/user.entity.js +0 -91
- package/lib/user/user.entity.js.map +1 -1
- package/lib/user/verification.entity.js +0 -30
- package/lib/user/verification.entity.js.map +1 -1
- package/lib/utils/trackable.entity.js +0 -31
- package/lib/utils/trackable.entity.js.map +1 -1
- package/package.json +9 -15
- package/lib/catalog/driving/category.entity.d.ts +0 -122
- package/lib/catalog/driving/category.entity.js +0 -217
- package/lib/catalog/driving/category.entity.js.map +0 -1
- package/lib/catalog/driving/vehicle.entity.d.ts +0 -49
- package/lib/catalog/driving/vehicle.entity.js +0 -97
- package/lib/catalog/driving/vehicle.entity.js.map +0 -1
- package/lib/profile/company/finances/peyment/method.entity.d.ts +0 -35
- package/lib/profile/company/finances/peyment/method.entity.js +0 -143
- package/lib/profile/company/finances/peyment/method.entity.js.map +0 -1
- package/lib/profile/company/finances/peyment-method/payment-method.d.ts +0 -34
- package/lib/profile/company/finances/peyment-method/payment-method.js +0 -118
- package/lib/profile/company/finances/peyment-method/payment-method.js.map +0 -1
- package/lib/profile/company/metrics/company.metric.d.ts +0 -21
- package/lib/profile/company/metrics/company.metric.js +0 -122
- package/lib/profile/company/metrics/company.metric.js.map +0 -1
- package/lib/system/campaign/campaign.entity.d.ts +0 -68
- package/lib/system/campaign/campaign.entity.js +0 -150
- package/lib/system/campaign/campaign.entity.js.map +0 -1
- package/lib/system/campaign/gifcode.entity.d.ts +0 -14
- package/lib/system/campaign/gifcode.entity.js +0 -77
- package/lib/system/campaign/gifcode.entity.js.map +0 -1
- package/lib/system/country/country.metric.d.ts +0 -12
- package/lib/system/country/country.metric.js +0 -68
- package/lib/system/country/country.metric.js.map +0 -1
|
@@ -1,143 +0,0 @@
|
|
|
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.CompanyPaymentMethodEntity = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
14
|
-
const common_1 = require("@driveup/common");
|
|
15
|
-
const company_entity_1 = require("../../company.entity");
|
|
16
|
-
const transaction_entity_1 = require("../billing/transaction.entity");
|
|
17
|
-
const priceplan_entity_1 = require("../../product/priceplan.entity");
|
|
18
|
-
const utils_1 = require("../../../../utils");
|
|
19
|
-
let CompanyPaymentMethodEntity = class CompanyPaymentMethodEntity extends utils_1.TrackableEntity {
|
|
20
|
-
companyId;
|
|
21
|
-
name;
|
|
22
|
-
/**
|
|
23
|
-
* When company adds a new payment method,
|
|
24
|
-
* all other payment methods become inactive
|
|
25
|
-
*/
|
|
26
|
-
active;
|
|
27
|
-
/**
|
|
28
|
-
* The provider's response when adding the payment method
|
|
29
|
-
*/
|
|
30
|
-
metadata;
|
|
31
|
-
methodId;
|
|
32
|
-
customerId;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the payment method is confirmed and ready to use
|
|
35
|
-
*/
|
|
36
|
-
confirmed;
|
|
37
|
-
company;
|
|
38
|
-
transactions;
|
|
39
|
-
/**
|
|
40
|
-
* Current assigned payment method
|
|
41
|
-
*/
|
|
42
|
-
productPaymentMethod;
|
|
43
|
-
constructor(props) {
|
|
44
|
-
super();
|
|
45
|
-
Object.assign(this, props);
|
|
46
|
-
}
|
|
47
|
-
toModel() {
|
|
48
|
-
return new common_1.PaymentMethod({
|
|
49
|
-
id: this.id,
|
|
50
|
-
name: this.name,
|
|
51
|
-
active: this.active,
|
|
52
|
-
methodId: this.methodId,
|
|
53
|
-
customerId: this.customerId,
|
|
54
|
-
confirmed: this.confirmed,
|
|
55
|
-
metadata: this.metadata,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
toSummary() {
|
|
59
|
-
return this.toModel();
|
|
60
|
-
}
|
|
61
|
-
async getFailedTransactions() {
|
|
62
|
-
return await transaction_entity_1.CompanyBillTransactionEntity
|
|
63
|
-
.createQueryBuilder('t')
|
|
64
|
-
.leftJoinAndSelect('t.bill', 'bill')
|
|
65
|
-
.where('t.paymentMethodId = :id', { id: this.id })
|
|
66
|
-
.andWhere('t.status = :status', { status: common_1.StatusType.Failed })
|
|
67
|
-
.andWhere('bill.status = :billStatus', { billStatus: common_1.BillStatus.Unpaid })
|
|
68
|
-
.getMany();
|
|
69
|
-
}
|
|
70
|
-
async getActivities() {
|
|
71
|
-
const activities = [];
|
|
72
|
-
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
|
|
73
|
-
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
74
|
-
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
|
|
75
|
-
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
76
|
-
return activities.filter(a => !a);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
exports.CompanyPaymentMethodEntity = CompanyPaymentMethodEntity;
|
|
80
|
-
__decorate([
|
|
81
|
-
(0, typeorm_1.Column)(),
|
|
82
|
-
__metadata("design:type", Number)
|
|
83
|
-
], CompanyPaymentMethodEntity.prototype, "companyId", void 0);
|
|
84
|
-
__decorate([
|
|
85
|
-
(0, typeorm_1.Column)({
|
|
86
|
-
nullable: true,
|
|
87
|
-
default: null
|
|
88
|
-
}),
|
|
89
|
-
__metadata("design:type", String)
|
|
90
|
-
], CompanyPaymentMethodEntity.prototype, "name", void 0);
|
|
91
|
-
__decorate([
|
|
92
|
-
(0, typeorm_1.Column)({
|
|
93
|
-
nullable: false,
|
|
94
|
-
default: true
|
|
95
|
-
}),
|
|
96
|
-
__metadata("design:type", Boolean)
|
|
97
|
-
], CompanyPaymentMethodEntity.prototype, "active", void 0);
|
|
98
|
-
__decorate([
|
|
99
|
-
(0, typeorm_1.Column)({
|
|
100
|
-
type: 'simple-json',
|
|
101
|
-
nullable: true,
|
|
102
|
-
default: null
|
|
103
|
-
}),
|
|
104
|
-
__metadata("design:type", Object)
|
|
105
|
-
], CompanyPaymentMethodEntity.prototype, "metadata", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
(0, typeorm_1.Column)({
|
|
108
|
-
nullable: true,
|
|
109
|
-
default: null
|
|
110
|
-
}),
|
|
111
|
-
__metadata("design:type", String)
|
|
112
|
-
], CompanyPaymentMethodEntity.prototype, "methodId", void 0);
|
|
113
|
-
__decorate([
|
|
114
|
-
(0, typeorm_1.Column)({
|
|
115
|
-
nullable: true,
|
|
116
|
-
default: null
|
|
117
|
-
}),
|
|
118
|
-
__metadata("design:type", String)
|
|
119
|
-
], CompanyPaymentMethodEntity.prototype, "customerId", void 0);
|
|
120
|
-
__decorate([
|
|
121
|
-
(0, typeorm_1.Column)({
|
|
122
|
-
nullable: false,
|
|
123
|
-
default: false
|
|
124
|
-
}),
|
|
125
|
-
__metadata("design:type", Boolean)
|
|
126
|
-
], CompanyPaymentMethodEntity.prototype, "confirmed", void 0);
|
|
127
|
-
__decorate([
|
|
128
|
-
(0, typeorm_1.ManyToOne)(() => company_entity_1.CompanyEntity, company => company.paymentMethods),
|
|
129
|
-
__metadata("design:type", Promise)
|
|
130
|
-
], CompanyPaymentMethodEntity.prototype, "company", void 0);
|
|
131
|
-
__decorate([
|
|
132
|
-
(0, typeorm_1.OneToMany)(() => transaction_entity_1.CompanyBillTransactionEntity, payment => payment.paymentMethod),
|
|
133
|
-
__metadata("design:type", Promise)
|
|
134
|
-
], CompanyPaymentMethodEntity.prototype, "transactions", void 0);
|
|
135
|
-
__decorate([
|
|
136
|
-
(0, typeorm_1.OneToOne)(() => priceplan_entity_1.CompanyProductPricePlanEntity, priceplan => priceplan.paymentMethod),
|
|
137
|
-
__metadata("design:type", Promise)
|
|
138
|
-
], CompanyPaymentMethodEntity.prototype, "productPaymentMethod", void 0);
|
|
139
|
-
exports.CompanyPaymentMethodEntity = CompanyPaymentMethodEntity = __decorate([
|
|
140
|
-
(0, typeorm_1.Entity)('companyPaymentMethods'),
|
|
141
|
-
__metadata("design:paramtypes", [Object])
|
|
142
|
-
], CompanyPaymentMethodEntity);
|
|
143
|
-
//# sourceMappingURL=method.entity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"method.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/peyment/method.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyE;AACzE,4CAAgG;AAChG,yDAAqD;AACrD,sEAA6E;AAC7E,qEAA+E;AAC/E,6CAAgE;AAGzD,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,uBAA8B;IAG7E,SAAS,CAAS;IAMlB,IAAI,CAAS;IAEb;;;OAGG;IAKH,MAAM,CAAU;IAEhB;;OAEG;IAMH,QAAQ,CAAM;IAMd,QAAQ,CAAS;IAMjB,UAAU,CAAS;IAEnB;;OAEG;IAKH,SAAS,CAAU;IAGnB,OAAO,CAAyB;IAGhC,YAAY,CAA0C;IAEtD;;OAEG;IAEH,oBAAoB,CAAyC;IAE7D,YAAY,KAA2C;QACtD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACN,OAAO,IAAI,sBAAa,CAAC;YACxB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACJ,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,qBAAqB;QAC1B,OAAO,MAAM,iDAA4B;aACvC,kBAAkB,CAAC,GAAG,CAAC;aACvB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC;aACnC,KAAK,CAAC,yBAAyB,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE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,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;4DACe;AAMjB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;8DACiB;AASnB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;KACd,CAAC;;6DACiB;AAGnB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC;;2DAClC;AAGhC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iDAA4B,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;;gEAC1B;AAMtD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,gDAA6B,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC;;wEACvB;qCA9DjD,0BAA0B;IADtC,IAAA,gBAAM,EAAC,uBAAuB,CAAC;;GACnB,0BAA0B,CAuGtC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { CompanyEntity } from '../../company.entity';
|
|
2
|
-
import { CompanyBillTransactionEntity } from '../billing/transaction.entity';
|
|
3
|
-
import { Activity, PaymentMethod } from '@driveup/common';
|
|
4
|
-
import { CompanyProductPricePlanEntity } from '../../product/priceplan.entity';
|
|
5
|
-
import { TrackableEntity } from '../../../../utils';
|
|
6
|
-
export declare class CompanyPaymentMethodEntity extends TrackableEntity<PaymentMethod> {
|
|
7
|
-
companyId: number;
|
|
8
|
-
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* When company adds a new payment method,
|
|
11
|
-
* all other payment methods become inactive
|
|
12
|
-
*/
|
|
13
|
-
active: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* The provider's response when adding the payment method
|
|
16
|
-
*/
|
|
17
|
-
metadata: any;
|
|
18
|
-
methodId: string;
|
|
19
|
-
customerId: string;
|
|
20
|
-
/**
|
|
21
|
-
* Whether the payment method is confirmed and ready to use
|
|
22
|
-
*/
|
|
23
|
-
confirmed: boolean;
|
|
24
|
-
company: Promise<CompanyEntity>;
|
|
25
|
-
transactions: Promise<CompanyBillTransactionEntity[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Current assigned payment method
|
|
28
|
-
*/
|
|
29
|
-
productPaymentMethod: Promise<CompanyProductPricePlanEntity>;
|
|
30
|
-
constructor(props?: Partial<CompanyPaymentMethodEntity>);
|
|
31
|
-
toModel(): PaymentMethod;
|
|
32
|
-
getFailedTransactions(): Promise<CompanyBillTransactionEntity[]>;
|
|
33
|
-
getActivities(): Promise<Activity[]>;
|
|
34
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
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.CompanyPaymentMethodEntity = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
14
|
-
const typeorm_2 = require("typeorm");
|
|
15
|
-
const company_entity_1 = require("../../company.entity");
|
|
16
|
-
const transaction_entity_1 = require("../billing/transaction.entity");
|
|
17
|
-
const common_1 = require("@driveup/common");
|
|
18
|
-
const priceplan_entity_1 = require("../../product/priceplan.entity");
|
|
19
|
-
const utils_1 = require("../../../../utils");
|
|
20
|
-
let CompanyPaymentMethodEntity = class CompanyPaymentMethodEntity extends utils_1.TrackableEntity {
|
|
21
|
-
constructor(props) {
|
|
22
|
-
super();
|
|
23
|
-
Object.assign(this, props);
|
|
24
|
-
}
|
|
25
|
-
toModel() {
|
|
26
|
-
return new common_1.PaymentMethod({
|
|
27
|
-
id: this.id,
|
|
28
|
-
name: this.name,
|
|
29
|
-
active: this.active,
|
|
30
|
-
methodId: this.methodId,
|
|
31
|
-
customerId: this.customerId,
|
|
32
|
-
confirmed: this.confirmed,
|
|
33
|
-
metadata: this.metadata,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async getFailedTransactions() {
|
|
37
|
-
return await transaction_entity_1.CompanyBillTransactionEntity
|
|
38
|
-
.createQueryBuilder('t')
|
|
39
|
-
.leftJoinAndSelect('t.bill', 'bill')
|
|
40
|
-
.where('t.paymentMethodId = :id', { id: this.id })
|
|
41
|
-
.andWhere('t.status = :status', { status: common_1.StatusType.Failed })
|
|
42
|
-
.andWhere('bill.status = :billStatus', { billStatus: common_1.BillStatus.Unpaid })
|
|
43
|
-
.getMany();
|
|
44
|
-
}
|
|
45
|
-
async getActivities() {
|
|
46
|
-
const activities = [];
|
|
47
|
-
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
|
|
48
|
-
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
49
|
-
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
|
|
50
|
-
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
51
|
-
return activities.filter(a => !a);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.CompanyPaymentMethodEntity = CompanyPaymentMethodEntity;
|
|
55
|
-
__decorate([
|
|
56
|
-
(0, typeorm_1.Column)(),
|
|
57
|
-
__metadata("design:type", Number)
|
|
58
|
-
], CompanyPaymentMethodEntity.prototype, "companyId", void 0);
|
|
59
|
-
__decorate([
|
|
60
|
-
(0, typeorm_1.Column)({
|
|
61
|
-
nullable: true,
|
|
62
|
-
default: null
|
|
63
|
-
}),
|
|
64
|
-
__metadata("design:type", String)
|
|
65
|
-
], CompanyPaymentMethodEntity.prototype, "name", void 0);
|
|
66
|
-
__decorate([
|
|
67
|
-
(0, typeorm_1.Column)({
|
|
68
|
-
nullable: false,
|
|
69
|
-
default: true
|
|
70
|
-
}),
|
|
71
|
-
__metadata("design:type", Boolean)
|
|
72
|
-
], CompanyPaymentMethodEntity.prototype, "active", void 0);
|
|
73
|
-
__decorate([
|
|
74
|
-
(0, typeorm_1.Column)({
|
|
75
|
-
type: 'simple-json',
|
|
76
|
-
nullable: true,
|
|
77
|
-
default: null
|
|
78
|
-
}),
|
|
79
|
-
__metadata("design:type", Object)
|
|
80
|
-
], CompanyPaymentMethodEntity.prototype, "metadata", void 0);
|
|
81
|
-
__decorate([
|
|
82
|
-
(0, typeorm_1.Column)({
|
|
83
|
-
nullable: true,
|
|
84
|
-
default: null
|
|
85
|
-
}),
|
|
86
|
-
__metadata("design:type", String)
|
|
87
|
-
], CompanyPaymentMethodEntity.prototype, "methodId", void 0);
|
|
88
|
-
__decorate([
|
|
89
|
-
(0, typeorm_1.Column)({
|
|
90
|
-
nullable: true,
|
|
91
|
-
default: null
|
|
92
|
-
}),
|
|
93
|
-
__metadata("design:type", String)
|
|
94
|
-
], CompanyPaymentMethodEntity.prototype, "customerId", void 0);
|
|
95
|
-
__decorate([
|
|
96
|
-
(0, typeorm_1.Column)({
|
|
97
|
-
nullable: false,
|
|
98
|
-
default: false
|
|
99
|
-
}),
|
|
100
|
-
__metadata("design:type", Boolean)
|
|
101
|
-
], CompanyPaymentMethodEntity.prototype, "confirmed", void 0);
|
|
102
|
-
__decorate([
|
|
103
|
-
(0, typeorm_2.ManyToOne)(() => company_entity_1.CompanyEntity, company => company.paymentMethods),
|
|
104
|
-
__metadata("design:type", Promise)
|
|
105
|
-
], CompanyPaymentMethodEntity.prototype, "company", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
(0, typeorm_2.OneToMany)(() => transaction_entity_1.CompanyBillTransactionEntity, payment => payment.paymentMethod),
|
|
108
|
-
__metadata("design:type", Promise)
|
|
109
|
-
], CompanyPaymentMethodEntity.prototype, "transactions", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
(0, typeorm_1.OneToOne)(() => priceplan_entity_1.CompanyProductPricePlanEntity, priceplan => priceplan.paymentMethod),
|
|
112
|
-
__metadata("design:type", Promise)
|
|
113
|
-
], CompanyPaymentMethodEntity.prototype, "productPaymentMethod", void 0);
|
|
114
|
-
exports.CompanyPaymentMethodEntity = CompanyPaymentMethodEntity = __decorate([
|
|
115
|
-
(0, typeorm_1.Entity)('companyPaymentMethods'),
|
|
116
|
-
__metadata("design:paramtypes", [Object])
|
|
117
|
-
], CompanyPaymentMethodEntity);
|
|
118
|
-
//# sourceMappingURL=payment-method.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment-method.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/peyment-method/payment-method.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAmD;AACnD,qCAA+C;AAC/C,yDAAqD;AACrD,sEAA6E;AAC7E,4CAAgG;AAChG,qEAA+E;AAC/E,6CAAgE;AAGzD,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,uBAA8B;IAgE7E,YAAY,KAA2C;QACtD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACN,OAAO,IAAI,sBAAa,CAAC;YACxB,EAAE,EAAE,IAAI,CAAC,EAAE;Y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|
2
|
-
id: number;
|
|
3
|
-
name: string;
|
|
4
|
-
drivingTraining: {
|
|
5
|
-
active: number;
|
|
6
|
-
completed: number;
|
|
7
|
-
terminated: number;
|
|
8
|
-
total: number;
|
|
9
|
-
};
|
|
10
|
-
courseTraining: {
|
|
11
|
-
active: number;
|
|
12
|
-
completed: number;
|
|
13
|
-
terminated: number;
|
|
14
|
-
total: number;
|
|
15
|
-
};
|
|
16
|
-
billing: {
|
|
17
|
-
revenue: number;
|
|
18
|
-
paid: number;
|
|
19
|
-
unpaid: number;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Activity, Campaigne, Content, IContent, Language } from '@driveup/common';
|
|
2
|
-
import { CampaignGiftCodeEntity } from './gifcode.entity';
|
|
3
|
-
import { ProductType } from '@driveup/common';
|
|
4
|
-
import { TrackableEntity } from '../../utils';
|
|
5
|
-
/**
|
|
6
|
-
* Represents a marketing campaign in the system.
|
|
7
|
-
* Campaigns offer promotional discounts through gift codes that users can redeem.
|
|
8
|
-
* Each campaign targets specific products and has an expiration date.
|
|
9
|
-
* Gift amounts are credited to the user's product wallet upon redemption.
|
|
10
|
-
*
|
|
11
|
-
* @extends TrackableEntity
|
|
12
|
-
*/
|
|
13
|
-
export declare class CampaignEntity extends TrackableEntity {
|
|
14
|
-
/**
|
|
15
|
-
* Product types this campaign applies to
|
|
16
|
-
* @default []
|
|
17
|
-
*/
|
|
18
|
-
products: ProductType[];
|
|
19
|
-
/**
|
|
20
|
-
* Localized content for the campaign (title, description, etc.)
|
|
21
|
-
*/
|
|
22
|
-
translations: IContent[];
|
|
23
|
-
/**
|
|
24
|
-
* URL to the campaign's promotional image
|
|
25
|
-
*/
|
|
26
|
-
imageUrl: string;
|
|
27
|
-
/**
|
|
28
|
-
* Campaign discount amount
|
|
29
|
-
* This amount will be stored on product credit
|
|
30
|
-
*/
|
|
31
|
-
giftAmount: number;
|
|
32
|
-
/**
|
|
33
|
-
* Campaign expiration date - after this date, codes cannot be redeemed
|
|
34
|
-
*/
|
|
35
|
-
exipryDate: Date;
|
|
36
|
-
/**
|
|
37
|
-
* Gift codes associated with this campaign
|
|
38
|
-
*/
|
|
39
|
-
giftCodes: Promise<CampaignGiftCodeEntity[]>;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a new CampaignEntity instance
|
|
42
|
-
* @param props - Partial properties to initialize the entity
|
|
43
|
-
*/
|
|
44
|
-
constructor(props?: Partial<CampaignEntity>);
|
|
45
|
-
/**
|
|
46
|
-
* Converts the entity to a Campaigne model instance
|
|
47
|
-
* @param lang - Optional language for translations
|
|
48
|
-
* @returns Campaigne model with localized content
|
|
49
|
-
*/
|
|
50
|
-
toModel(lang?: Language): Campaigne;
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves all gift codes for this campaign
|
|
53
|
-
* @returns Promise resolving to array of GiftCode models
|
|
54
|
-
*/
|
|
55
|
-
getCodes(): Promise<import("@driveup/common").GiftCode[]>;
|
|
56
|
-
/**
|
|
57
|
-
* Gets the localized translation for the campaign
|
|
58
|
-
* @param lang - Optional language code; defaults to current i18n context
|
|
59
|
-
* @returns Content instance with translated title and description
|
|
60
|
-
*/
|
|
61
|
-
getTranslation(lang?: Language): Content;
|
|
62
|
-
/**
|
|
63
|
-
* Gets all available translations for the campaign
|
|
64
|
-
* @returns Array of Content instances for all languages
|
|
65
|
-
*/
|
|
66
|
-
getTranslations(): Content[];
|
|
67
|
-
getActivities(): Promise<Activity[]>;
|
|
68
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
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.CampaignEntity = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
14
|
-
const common_1 = require("@driveup/common");
|
|
15
|
-
const gifcode_entity_1 = require("./gifcode.entity");
|
|
16
|
-
const common_2 = require("@driveup/common");
|
|
17
|
-
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
18
|
-
const utils_1 = require("../../utils");
|
|
19
|
-
const staff_entity_1 = require("../staff/staff.entity");
|
|
20
|
-
const utils_2 = require("../../utils");
|
|
21
|
-
/**
|
|
22
|
-
* Represents a marketing campaign in the system.
|
|
23
|
-
* Campaigns offer promotional discounts through gift codes that users can redeem.
|
|
24
|
-
* Each campaign targets specific products and has an expiration date.
|
|
25
|
-
* Gift amounts are credited to the user's product wallet upon redemption.
|
|
26
|
-
*
|
|
27
|
-
* @extends TrackableEntity
|
|
28
|
-
*/
|
|
29
|
-
let CampaignEntity = class CampaignEntity extends utils_2.TrackableEntity {
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new CampaignEntity instance
|
|
32
|
-
* @param props - Partial properties to initialize the entity
|
|
33
|
-
*/
|
|
34
|
-
constructor(props) {
|
|
35
|
-
super();
|
|
36
|
-
Object.assign(this, props);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Converts the entity to a Campaigne model instance
|
|
40
|
-
* @param lang - Optional language for translations
|
|
41
|
-
* @returns Campaigne model with localized content
|
|
42
|
-
*/
|
|
43
|
-
toModel(lang) {
|
|
44
|
-
const transaltion = this.getTranslation(lang);
|
|
45
|
-
return new common_1.Campaigne({
|
|
46
|
-
id: this.id,
|
|
47
|
-
title: transaltion.title,
|
|
48
|
-
description: transaltion.description,
|
|
49
|
-
giftAmount: this.giftAmount,
|
|
50
|
-
imageUrl: transaltion.imageUrl || this.imageUrl,
|
|
51
|
-
exipryDate: this.exipryDate,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Retrieves all gift codes for this campaign
|
|
56
|
-
* @returns Promise resolving to array of GiftCode models
|
|
57
|
-
*/
|
|
58
|
-
async getCodes() {
|
|
59
|
-
return await Promise.all((await this.giftCodes).map(async (codeEntity) => codeEntity.toModel()));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Gets the localized translation for the campaign
|
|
63
|
-
* @param lang - Optional language code; defaults to current i18n context
|
|
64
|
-
* @returns Content instance with translated title and description
|
|
65
|
-
*/
|
|
66
|
-
getTranslation(lang) {
|
|
67
|
-
const language = lang || nestjs_i18n_1.I18nContext.current()?.lang;
|
|
68
|
-
const translation = this.translations?.find(t => t.language === language);
|
|
69
|
-
return new common_1.Content({
|
|
70
|
-
title: translation?.title,
|
|
71
|
-
description: translation?.description,
|
|
72
|
-
content: translation?.content,
|
|
73
|
-
imageUrl: translation?.imageUrl,
|
|
74
|
-
link: translation?.link,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Gets all available translations for the campaign
|
|
79
|
-
* @returns Array of Content instances for all languages
|
|
80
|
-
*/
|
|
81
|
-
getTranslations() {
|
|
82
|
-
return this.translations?.map(t => new common_1.Content({
|
|
83
|
-
title: t.title,
|
|
84
|
-
description: t.description,
|
|
85
|
-
content: t.content,
|
|
86
|
-
imageUrl: t.imageUrl,
|
|
87
|
-
link: t.link,
|
|
88
|
-
language: t.language
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
async getActivities() {
|
|
92
|
-
const activities = [];
|
|
93
|
-
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy, staff_entity_1.StaffEntity));
|
|
94
|
-
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
95
|
-
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy, staff_entity_1.StaffEntity));
|
|
96
|
-
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
97
|
-
return activities.filter(a => !a);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
exports.CampaignEntity = CampaignEntity;
|
|
101
|
-
__decorate([
|
|
102
|
-
(0, typeorm_1.Column)({
|
|
103
|
-
type: 'set',
|
|
104
|
-
enum: common_2.ProductType,
|
|
105
|
-
default: [],
|
|
106
|
-
nullable: false
|
|
107
|
-
}),
|
|
108
|
-
__metadata("design:type", Array)
|
|
109
|
-
], CampaignEntity.prototype, "products", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
(0, typeorm_1.Column)({
|
|
112
|
-
type: 'simple-json',
|
|
113
|
-
nullable: true,
|
|
114
|
-
default: null
|
|
115
|
-
}),
|
|
116
|
-
__metadata("design:type", Array)
|
|
117
|
-
], CampaignEntity.prototype, "translations", void 0);
|
|
118
|
-
__decorate([
|
|
119
|
-
(0, typeorm_1.Column)({
|
|
120
|
-
nullable: true,
|
|
121
|
-
default: null
|
|
122
|
-
}),
|
|
123
|
-
__metadata("design:type", String)
|
|
124
|
-
], CampaignEntity.prototype, "imageUrl", void 0);
|
|
125
|
-
__decorate([
|
|
126
|
-
(0, typeorm_1.Column)({
|
|
127
|
-
type: 'decimal',
|
|
128
|
-
precision: 10,
|
|
129
|
-
scale: 2,
|
|
130
|
-
nullable: false,
|
|
131
|
-
default: 0
|
|
132
|
-
}),
|
|
133
|
-
__metadata("design:type", Number)
|
|
134
|
-
], CampaignEntity.prototype, "giftAmount", void 0);
|
|
135
|
-
__decorate([
|
|
136
|
-
(0, typeorm_1.Column)({
|
|
137
|
-
nullable: true,
|
|
138
|
-
default: null
|
|
139
|
-
}),
|
|
140
|
-
__metadata("design:type", Date)
|
|
141
|
-
], CampaignEntity.prototype, "exipryDate", void 0);
|
|
142
|
-
__decorate([
|
|
143
|
-
(0, typeorm_1.OneToMany)(() => gifcode_entity_1.CampaignGiftCodeEntity, giftCode => giftCode.campaign),
|
|
144
|
-
__metadata("design:type", Promise)
|
|
145
|
-
], CampaignEntity.prototype, "giftCodes", void 0);
|
|
146
|
-
exports.CampaignEntity = CampaignEntity = __decorate([
|
|
147
|
-
(0, typeorm_1.Entity)('systemCampaigns'),
|
|
148
|
-
__metadata("design:paramtypes", [Object])
|
|
149
|
-
], CampaignEntity);
|
|
150
|
-
//# sourceMappingURL=campaign.entity.js.map
|