@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,158 @@
|
|
|
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.CompanyBillTransactionEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const common_1 = require("@driveup/common");
|
|
15
|
+
const bill_entity_1 = require("./bill.entity");
|
|
16
|
+
const method_entity_1 = require("../payment/method.entity");
|
|
17
|
+
const promotion_entity_1 = require("../../../agent/promotion.entity");
|
|
18
|
+
const utils_1 = require("../../../../utils");
|
|
19
|
+
let CompanyBillTransactionEntity = class CompanyBillTransactionEntity extends utils_1.TrackableEntity {
|
|
20
|
+
billId;
|
|
21
|
+
paymentMethodId;
|
|
22
|
+
status;
|
|
23
|
+
amount;
|
|
24
|
+
provider;
|
|
25
|
+
/**
|
|
26
|
+
* Provider payment method id
|
|
27
|
+
*/
|
|
28
|
+
providerId;
|
|
29
|
+
providerResponse;
|
|
30
|
+
/**
|
|
31
|
+
* Payment confirmed by job task
|
|
32
|
+
*/
|
|
33
|
+
paidOn;
|
|
34
|
+
/**
|
|
35
|
+
* Payment failed on date
|
|
36
|
+
*/
|
|
37
|
+
failedOn;
|
|
38
|
+
/**
|
|
39
|
+
* Company bill associated with this transaction
|
|
40
|
+
*/
|
|
41
|
+
bill;
|
|
42
|
+
/**
|
|
43
|
+
* Payment method used for this transaction
|
|
44
|
+
*/
|
|
45
|
+
paymentMethod;
|
|
46
|
+
/**
|
|
47
|
+
* Agent promotion associated with this transaction
|
|
48
|
+
* The agent earns profit from this transaction based on his percentage
|
|
49
|
+
* The earning period is limited to the promotion start (company created date)
|
|
50
|
+
* and driveup promotion requirements (12 months)
|
|
51
|
+
*/
|
|
52
|
+
agentPromotion;
|
|
53
|
+
constructor(props) {
|
|
54
|
+
super();
|
|
55
|
+
Object.assign(this, props);
|
|
56
|
+
}
|
|
57
|
+
async toModel() {
|
|
58
|
+
return new common_1.BillTransaction({
|
|
59
|
+
id: this.id,
|
|
60
|
+
provider: this.provider,
|
|
61
|
+
status: this.status,
|
|
62
|
+
paymentMethod: (await this.paymentMethod).toModel(),
|
|
63
|
+
amount: this.amount,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
toSummary() {
|
|
67
|
+
return new common_1.BillTransaction({
|
|
68
|
+
id: this.id,
|
|
69
|
+
status: this.status,
|
|
70
|
+
amount: this.amount,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async getActivities() {
|
|
74
|
+
const activities = [];
|
|
75
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
76
|
+
activities.push(await (0, utils_1.toActivity)(this.paidOn, common_1.ActivityType.paidOn));
|
|
77
|
+
activities.push(await (0, utils_1.toActivity)(this.failedOn, common_1.ActivityType.failedOn));
|
|
78
|
+
return activities.filter(a => a);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.CompanyBillTransactionEntity = CompanyBillTransactionEntity;
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.Column)(),
|
|
84
|
+
__metadata("design:type", Number)
|
|
85
|
+
], CompanyBillTransactionEntity.prototype, "billId", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, typeorm_1.Column)(),
|
|
88
|
+
__metadata("design:type", Number)
|
|
89
|
+
], CompanyBillTransactionEntity.prototype, "paymentMethodId", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, typeorm_1.Column)({
|
|
92
|
+
type: 'enum',
|
|
93
|
+
enum: [
|
|
94
|
+
common_1.StatusType.Pending,
|
|
95
|
+
common_1.StatusType.Paid,
|
|
96
|
+
common_1.StatusType.Failed
|
|
97
|
+
],
|
|
98
|
+
default: common_1.StatusType.Pending,
|
|
99
|
+
nullable: true
|
|
100
|
+
}),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], CompanyBillTransactionEntity.prototype, "status", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, typeorm_1.Column)({
|
|
105
|
+
type: 'decimal',
|
|
106
|
+
precision: 12,
|
|
107
|
+
scale: 2,
|
|
108
|
+
nullable: false,
|
|
109
|
+
default: 0
|
|
110
|
+
}),
|
|
111
|
+
__metadata("design:type", Number)
|
|
112
|
+
], CompanyBillTransactionEntity.prototype, "amount", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, typeorm_1.Column)({
|
|
115
|
+
type: 'enum',
|
|
116
|
+
enum: common_1.PaymentProvider,
|
|
117
|
+
default: common_1.PaymentProvider.Stripe,
|
|
118
|
+
nullable: false
|
|
119
|
+
}),
|
|
120
|
+
__metadata("design:type", String)
|
|
121
|
+
], CompanyBillTransactionEntity.prototype, "provider", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, typeorm_1.Column)(),
|
|
124
|
+
__metadata("design:type", Number)
|
|
125
|
+
], CompanyBillTransactionEntity.prototype, "providerId", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, typeorm_1.Column)({
|
|
128
|
+
type: 'simple-json',
|
|
129
|
+
nullable: true,
|
|
130
|
+
default: null
|
|
131
|
+
}),
|
|
132
|
+
__metadata("design:type", Object)
|
|
133
|
+
], CompanyBillTransactionEntity.prototype, "providerResponse", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
136
|
+
__metadata("design:type", Date)
|
|
137
|
+
], CompanyBillTransactionEntity.prototype, "paidOn", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
140
|
+
__metadata("design:type", Date)
|
|
141
|
+
], CompanyBillTransactionEntity.prototype, "failedOn", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
(0, typeorm_1.ManyToOne)(() => bill_entity_1.CompanyBillEntity, bill => bill.transactions),
|
|
144
|
+
__metadata("design:type", Promise)
|
|
145
|
+
], CompanyBillTransactionEntity.prototype, "bill", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, typeorm_1.ManyToOne)(() => method_entity_1.CompanyPaymentMethodEntity, paymentMethod => paymentMethod.transactions),
|
|
148
|
+
__metadata("design:type", Promise)
|
|
149
|
+
], CompanyBillTransactionEntity.prototype, "paymentMethod", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, typeorm_1.OneToOne)(() => promotion_entity_1.AgentPromotionEntity, payout => payout.transaction),
|
|
152
|
+
__metadata("design:type", Promise)
|
|
153
|
+
], CompanyBillTransactionEntity.prototype, "agentPromotion", void 0);
|
|
154
|
+
exports.CompanyBillTransactionEntity = CompanyBillTransactionEntity = __decorate([
|
|
155
|
+
(0, typeorm_1.Entity)('companyBillTransactions'),
|
|
156
|
+
__metadata("design:paramtypes", [Object])
|
|
157
|
+
], CompanyBillTransactionEntity);
|
|
158
|
+
//# sourceMappingURL=transaction.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/billing/transaction.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA8D;AAC9D,4CAAuG;AAEvG,+CAAkD;AAClD,4DAAsE;AACtE,sEAAuE;AACvE,6CAAgE;AAGzD,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,uBAAgC;IAGjF,MAAM,CAAS;IAGf,eAAe,CAAS;IAYxB,MAAM,CAAa;IASnB,MAAM,CAAS;IAQf,QAAQ,CAAkB;IAE1B;;OAEG;IAEH,UAAU,CAAS;IAOnB,gBAAgB,CAAM;IAEtB;;OAEG;IAEH,MAAM,CAAO;IAEb;;OAEG;IAEH,QAAQ,CAAO;IAEf;;OAEG;IAEH,IAAI,CAA6B;IAEjC;;OAEG;IAEH,aAAa,CAAsC;IAEnD;;;;;O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uCAAoB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;;oEACxB;uCAjF/B,4BAA4B;IADxC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;;GACrB,4BAA4B,CAiHxC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Activity, Category } from '@driveup/common';
|
|
2
|
+
import { CompanyEntity } from '../../company.entity';
|
|
3
|
+
import { CompanyExpenseEntity } from './expense.entity';
|
|
4
|
+
import { TrackableEntity } from '../../../../utils';
|
|
5
|
+
/**
|
|
6
|
+
* Entity representing an expense category for company financial tracking.
|
|
7
|
+
* Each category organizes related expenses and provides visual identification through images.
|
|
8
|
+
* Categories can be sorted and are specific to individual companies.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CompanyExpenseCategoryEntity extends TrackableEntity<Category> {
|
|
11
|
+
/**
|
|
12
|
+
* Foreign key reference to the company that owns this expense category.
|
|
13
|
+
*/
|
|
14
|
+
companyId: number;
|
|
15
|
+
/**
|
|
16
|
+
* Display name for the expense category.
|
|
17
|
+
*/
|
|
18
|
+
title: string;
|
|
19
|
+
/**
|
|
20
|
+
* URL to the icon or image representing this category.
|
|
21
|
+
*/
|
|
22
|
+
imageUrl: string;
|
|
23
|
+
/**
|
|
24
|
+
* Sort order for displaying categories, defaults to 1.
|
|
25
|
+
*/
|
|
26
|
+
sort: number;
|
|
27
|
+
/**
|
|
28
|
+
* Many-to-one relationship with the owning company.
|
|
29
|
+
*/
|
|
30
|
+
company: Promise<CompanyEntity>;
|
|
31
|
+
/**
|
|
32
|
+
* One-to-many relationship with expenses belonging to this category.
|
|
33
|
+
*/
|
|
34
|
+
expenses: Promise<CompanyExpenseEntity[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new expense category instance.
|
|
37
|
+
* @param props - Partial properties to initialize the entity.
|
|
38
|
+
*/
|
|
39
|
+
constructor(props?: Partial<CompanyExpenseCategoryEntity>);
|
|
40
|
+
/**
|
|
41
|
+
* Converts the entity to a Category model object.
|
|
42
|
+
* @returns Category model with basic information.
|
|
43
|
+
*/
|
|
44
|
+
toModel(): Category;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a summary of the expense category.
|
|
47
|
+
* @returns Category model (same as toModel for this entity).
|
|
48
|
+
*/
|
|
49
|
+
toSummary(): Category;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves the activity history for this expense category.
|
|
52
|
+
* @returns Array of Activity objects showing creation and update information.
|
|
53
|
+
*/
|
|
54
|
+
getActivities(): Promise<Activity[]>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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.CompanyExpenseCategoryEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const common_1 = require("@driveup/common");
|
|
15
|
+
const company_entity_1 = require("../../company.entity");
|
|
16
|
+
const expense_entity_1 = require("./expense.entity");
|
|
17
|
+
const utils_1 = require("../../../../utils");
|
|
18
|
+
/**
|
|
19
|
+
* Entity representing an expense category for company financial tracking.
|
|
20
|
+
* Each category organizes related expenses and provides visual identification through images.
|
|
21
|
+
* Categories can be sorted and are specific to individual companies.
|
|
22
|
+
*/
|
|
23
|
+
let CompanyExpenseCategoryEntity = class CompanyExpenseCategoryEntity extends utils_1.TrackableEntity {
|
|
24
|
+
/**
|
|
25
|
+
* Foreign key reference to the company that owns this expense category.
|
|
26
|
+
*/
|
|
27
|
+
companyId;
|
|
28
|
+
/**
|
|
29
|
+
* Display name for the expense category.
|
|
30
|
+
*/
|
|
31
|
+
title;
|
|
32
|
+
/**
|
|
33
|
+
* URL to the icon or image representing this category.
|
|
34
|
+
*/
|
|
35
|
+
imageUrl;
|
|
36
|
+
/**
|
|
37
|
+
* Sort order for displaying categories, defaults to 1.
|
|
38
|
+
*/
|
|
39
|
+
sort;
|
|
40
|
+
/**
|
|
41
|
+
* Many-to-one relationship with the owning company.
|
|
42
|
+
*/
|
|
43
|
+
company;
|
|
44
|
+
/**
|
|
45
|
+
* One-to-many relationship with expenses belonging to this category.
|
|
46
|
+
*/
|
|
47
|
+
expenses;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new expense category instance.
|
|
50
|
+
* @param props - Partial properties to initialize the entity.
|
|
51
|
+
*/
|
|
52
|
+
constructor(props) {
|
|
53
|
+
super();
|
|
54
|
+
Object.assign(this, props);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Converts the entity to a Category model object.
|
|
58
|
+
* @returns Category model with basic information.
|
|
59
|
+
*/
|
|
60
|
+
toModel() {
|
|
61
|
+
return new common_1.Category({
|
|
62
|
+
id: this.id,
|
|
63
|
+
title: this.title,
|
|
64
|
+
imageUrl: this.imageUrl,
|
|
65
|
+
sort: this.sort
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns a summary of the expense category.
|
|
70
|
+
* @returns Category model (same as toModel for this entity).
|
|
71
|
+
*/
|
|
72
|
+
toSummary() {
|
|
73
|
+
return this.toModel();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves the activity history for this expense category.
|
|
77
|
+
* @returns Array of Activity objects showing creation and update information.
|
|
78
|
+
*/
|
|
79
|
+
async getActivities() {
|
|
80
|
+
const activities = [];
|
|
81
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
|
|
82
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
83
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
|
|
84
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
85
|
+
return activities.filter(a => a);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.CompanyExpenseCategoryEntity = CompanyExpenseCategoryEntity;
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, typeorm_1.Column)(),
|
|
91
|
+
__metadata("design:type", Number)
|
|
92
|
+
], CompanyExpenseCategoryEntity.prototype, "companyId", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.Column)(),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], CompanyExpenseCategoryEntity.prototype, "title", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, typeorm_1.Column)(),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], CompanyExpenseCategoryEntity.prototype, "imageUrl", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, typeorm_1.Column)({ default: 1 }),
|
|
103
|
+
__metadata("design:type", Number)
|
|
104
|
+
], CompanyExpenseCategoryEntity.prototype, "sort", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, typeorm_1.ManyToOne)(() => company_entity_1.CompanyEntity, company => company.expenseCategories),
|
|
107
|
+
__metadata("design:type", Promise)
|
|
108
|
+
], CompanyExpenseCategoryEntity.prototype, "company", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, typeorm_1.OneToMany)(() => expense_entity_1.CompanyExpenseEntity, expense => expense.category),
|
|
111
|
+
__metadata("design:type", Promise)
|
|
112
|
+
], CompanyExpenseCategoryEntity.prototype, "expenses", void 0);
|
|
113
|
+
exports.CompanyExpenseCategoryEntity = CompanyExpenseCategoryEntity = __decorate([
|
|
114
|
+
(0, typeorm_1.Entity)('companyExpenseCategories'),
|
|
115
|
+
__metadata("design:paramtypes", [Object])
|
|
116
|
+
], CompanyExpenseCategoryEntity);
|
|
117
|
+
//# sourceMappingURL=category.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/expense/category.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgE;AAChE,4CAAmE;AACnE,yDAAqD;AACrD,qDAAwD;AACxD,6CAAgE;AAEhE;;;;GAIG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,uBAAyB;IAE1E;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,KAAK,CAAS;IAEd;;OAEG;IAEH,QAAQ,CAAS;IAEjB;;OAEG;IAEH,IAAI,CAAS;IAEb;;OAEG;IAEH,OAAO,CAAyB;IAEhC;;OAEG;IAEH,QAAQ,CAAkC;IAE1C;;;OAGG;IACH,YAAY,KAA6C;QACxD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,OAAO,IAAI,iBAAQ,CAAC;YACnB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa;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from '../../company.entity';
|
|
3
|
+
import { CompanyExpenseCategoryEntity } from './category.entity';
|
|
4
|
+
import { TrackableEntity } from '../../../../utils';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a company expense record.
|
|
7
|
+
* Tracks expenses incurred by the company, categorized and requiring approval.
|
|
8
|
+
* Used for financial reporting and expense management.
|
|
9
|
+
*
|
|
10
|
+
* @extends TrackableEntity<Expense>
|
|
11
|
+
*/
|
|
12
|
+
export declare class CompanyExpenseEntity extends TrackableEntity<Expense> {
|
|
13
|
+
/**
|
|
14
|
+
* Reference to the company that incurred this expense
|
|
15
|
+
*/
|
|
16
|
+
companyId: number;
|
|
17
|
+
/**
|
|
18
|
+
* Reference to the expense category
|
|
19
|
+
* Null for uncategorized expenses
|
|
20
|
+
*/
|
|
21
|
+
categoryId: number;
|
|
22
|
+
/**
|
|
23
|
+
* Approval status of the expense
|
|
24
|
+
* @default StatusType.Pending
|
|
25
|
+
*/
|
|
26
|
+
status: StatusType;
|
|
27
|
+
/**
|
|
28
|
+
* Expense amount
|
|
29
|
+
* Precision: 8 digits, Scale: 2 decimal places
|
|
30
|
+
* @default 0
|
|
31
|
+
*/
|
|
32
|
+
amount: number;
|
|
33
|
+
/**
|
|
34
|
+
* Detailed description of the expense
|
|
35
|
+
*/
|
|
36
|
+
description: string;
|
|
37
|
+
receiptUrl: string;
|
|
38
|
+
approvedBy: number;
|
|
39
|
+
approvedOn: Date;
|
|
40
|
+
rejectedBy: number;
|
|
41
|
+
rejectedOn: Date;
|
|
42
|
+
company: Promise<CompanyEntity>;
|
|
43
|
+
category: Promise<CompanyExpenseCategoryEntity>;
|
|
44
|
+
constructor(props?: Partial<CompanyExpenseEntity>);
|
|
45
|
+
toModel(): Promise<Expense>;
|
|
46
|
+
toSummary(): Expense;
|
|
47
|
+
getActivities(): Promise<Activity[]>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
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.CompanyExpenseEntity = 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 category_entity_1 = require("./category.entity");
|
|
17
|
+
const utils_1 = require("../../../../utils");
|
|
18
|
+
/**
|
|
19
|
+
* Represents a company expense record.
|
|
20
|
+
* Tracks expenses incurred by the company, categorized and requiring approval.
|
|
21
|
+
* Used for financial reporting and expense management.
|
|
22
|
+
*
|
|
23
|
+
* @extends TrackableEntity<Expense>
|
|
24
|
+
*/
|
|
25
|
+
let CompanyExpenseEntity = class CompanyExpenseEntity extends utils_1.TrackableEntity {
|
|
26
|
+
/**
|
|
27
|
+
* Reference to the company that incurred this expense
|
|
28
|
+
*/
|
|
29
|
+
companyId;
|
|
30
|
+
/**
|
|
31
|
+
* Reference to the expense category
|
|
32
|
+
* Null for uncategorized expenses
|
|
33
|
+
*/
|
|
34
|
+
categoryId;
|
|
35
|
+
/**
|
|
36
|
+
* Approval status of the expense
|
|
37
|
+
* @default StatusType.Pending
|
|
38
|
+
*/
|
|
39
|
+
status;
|
|
40
|
+
/**
|
|
41
|
+
* Expense amount
|
|
42
|
+
* Precision: 8 digits, Scale: 2 decimal places
|
|
43
|
+
* @default 0
|
|
44
|
+
*/
|
|
45
|
+
amount;
|
|
46
|
+
/**
|
|
47
|
+
* Detailed description of the expense
|
|
48
|
+
*/
|
|
49
|
+
description;
|
|
50
|
+
receiptUrl;
|
|
51
|
+
approvedBy;
|
|
52
|
+
approvedOn;
|
|
53
|
+
rejectedBy;
|
|
54
|
+
rejectedOn;
|
|
55
|
+
company;
|
|
56
|
+
category;
|
|
57
|
+
constructor(props) {
|
|
58
|
+
super();
|
|
59
|
+
Object.assign(this, props);
|
|
60
|
+
}
|
|
61
|
+
async toModel() {
|
|
62
|
+
const category = await this.category;
|
|
63
|
+
return new common_1.Expense({
|
|
64
|
+
id: this.id,
|
|
65
|
+
category: category?.toModel(),
|
|
66
|
+
status: this.status,
|
|
67
|
+
amount: this.amount,
|
|
68
|
+
description: this.description,
|
|
69
|
+
receiptUrl: this.receiptUrl,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
toSummary() {
|
|
73
|
+
return new common_1.Expense({
|
|
74
|
+
id: this.id,
|
|
75
|
+
status: this.status,
|
|
76
|
+
amount: this.amount,
|
|
77
|
+
receiptUrl: this.receiptUrl,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async getActivities() {
|
|
81
|
+
const activities = [];
|
|
82
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
|
|
83
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
84
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
|
|
85
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
86
|
+
activities.push(await (0, utils_1.toActivity)(this.approvedBy, common_1.ActivityType.approvedBy));
|
|
87
|
+
activities.push(await (0, utils_1.toActivity)(this.approvedOn, common_1.ActivityType.approvedOn));
|
|
88
|
+
activities.push(await (0, utils_1.toActivity)(this.rejectedBy, common_1.ActivityType.rejectedBy));
|
|
89
|
+
activities.push(await (0, utils_1.toActivity)(this.rejectedOn, common_1.ActivityType.rejectedOn));
|
|
90
|
+
return activities.filter(a => a);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
exports.CompanyExpenseEntity = CompanyExpenseEntity;
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, typeorm_1.Column)(),
|
|
96
|
+
__metadata("design:type", Number)
|
|
97
|
+
], CompanyExpenseEntity.prototype, "companyId", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, typeorm_1.Column)({
|
|
100
|
+
nullable: true,
|
|
101
|
+
default: null
|
|
102
|
+
}),
|
|
103
|
+
__metadata("design:type", Number)
|
|
104
|
+
], CompanyExpenseEntity.prototype, "categoryId", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, typeorm_1.Column)({
|
|
107
|
+
type: 'enum',
|
|
108
|
+
enum: [
|
|
109
|
+
common_1.StatusType.Pending,
|
|
110
|
+
common_1.StatusType.Approved,
|
|
111
|
+
common_1.StatusType.Rejected
|
|
112
|
+
],
|
|
113
|
+
default: common_1.StatusType.Pending,
|
|
114
|
+
nullable: false
|
|
115
|
+
}),
|
|
116
|
+
__metadata("design:type", String)
|
|
117
|
+
], CompanyExpenseEntity.prototype, "status", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, typeorm_1.Column)({
|
|
120
|
+
type: 'decimal',
|
|
121
|
+
precision: 8,
|
|
122
|
+
scale: 2,
|
|
123
|
+
nullable: false,
|
|
124
|
+
default: 0
|
|
125
|
+
}),
|
|
126
|
+
__metadata("design:type", Number)
|
|
127
|
+
], CompanyExpenseEntity.prototype, "amount", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, typeorm_1.Column)({
|
|
130
|
+
type: 'mediumtext',
|
|
131
|
+
nullable: true,
|
|
132
|
+
default: null
|
|
133
|
+
}),
|
|
134
|
+
__metadata("design:type", String)
|
|
135
|
+
], CompanyExpenseEntity.prototype, "description", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
(0, typeorm_1.Column)({
|
|
138
|
+
nullable: true,
|
|
139
|
+
default: null
|
|
140
|
+
}),
|
|
141
|
+
__metadata("design:type", String)
|
|
142
|
+
], CompanyExpenseEntity.prototype, "receiptUrl", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
145
|
+
__metadata("design:type", Number)
|
|
146
|
+
], CompanyExpenseEntity.prototype, "approvedBy", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
149
|
+
__metadata("design:type", Date)
|
|
150
|
+
], CompanyExpenseEntity.prototype, "approvedOn", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
153
|
+
__metadata("design:type", Number)
|
|
154
|
+
], CompanyExpenseEntity.prototype, "rejectedBy", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
157
|
+
__metadata("design:type", Date)
|
|
158
|
+
], CompanyExpenseEntity.prototype, "rejectedOn", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
(0, typeorm_1.ManyToOne)(() => company_entity_1.CompanyEntity, company => company.expenses),
|
|
161
|
+
__metadata("design:type", Promise)
|
|
162
|
+
], CompanyExpenseEntity.prototype, "company", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
(0, typeorm_1.ManyToOne)(() => category_entity_1.CompanyExpenseCategoryEntity, category => category.expenses),
|
|
165
|
+
__metadata("design:type", Promise)
|
|
166
|
+
], CompanyExpenseEntity.prototype, "category", void 0);
|
|
167
|
+
exports.CompanyExpenseEntity = CompanyExpenseEntity = __decorate([
|
|
168
|
+
(0, typeorm_1.Entity)('companyExpenses'),
|
|
169
|
+
__metadata("design:paramtypes", [Object])
|
|
170
|
+
], CompanyExpenseEntity);
|
|
171
|
+
//# sourceMappingURL=expense.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expense.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/expense/expense.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,4CAA8E;AAC9E,yDAAqD;AACrD,uDAAiE;AACjE,6CAAgE;AAEhE;;;;;;GAMG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,uBAAwB;IAEjE;;OAEG;IAEH,SAAS,CAAS;IAElB;;;OAGG;IAKH,UAAU,CAAS;IAEnB;;;OAGG;IAWH,MAAM,CAAa;IAEnB;;;;OAIG;IAQH,MAAM,CAAS;IAEf;;OAEG;IAMH,WAAW,CAAS;IAMpB,UAAU,CAAS;IAGnB,UAAU,CAAS;IAGnB,UAAU,CAAO;IAGjB,UAAU,CAAS;IAGnB,UAAU,CAAO;IAGjB,OAAO,CAAyB;IAGhC,QAAQ,CAAwC;IAEhD,YAAY,KAAqC;QAChD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC;QACrC,OAAO,IAAI,gBAAO,CAAC;YAClB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE;YAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC,CAAA;IACH,CAAC;IAED,SAAS;QACR,OAAO,IAAI,gBAAO,CAAC;YAClB,EAAE,EAAE,IAAI,CAAC,EAAE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AAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;;qDAC5B;AAGhC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8CAA4B,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;;sDAC7B;+BAhFpC,oBAAoB;IADhC,IAAA,gBAAM,EAAC,iBAAiB,CAAC;;GACb,oBAAoB,CAwHhC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Activity, Handover } from '@driveup/common';
|
|
2
|
+
import { CompanyEntity } from '../../company.entity';
|
|
3
|
+
import { CompanyExpenseEntity } from '../expense/expense.entity';
|
|
4
|
+
import { StudentTrainingTransactionEntity } from '../../../student/program/training/transaction.entity';
|
|
5
|
+
import { CompanyInstructorEntity } from '../../instructor/instructor.entity';
|
|
6
|
+
import { TrackableEntity } from '../../../../utils';
|
|
7
|
+
export declare class CompanyHandoverEntity extends TrackableEntity<Handover> {
|
|
8
|
+
companyId: number;
|
|
9
|
+
/**
|
|
10
|
+
* Manager who approved the handover
|
|
11
|
+
*/
|
|
12
|
+
managerId: number;
|
|
13
|
+
/**
|
|
14
|
+
* Instructor who is receiving the handover
|
|
15
|
+
*/
|
|
16
|
+
instructorId: number;
|
|
17
|
+
/**
|
|
18
|
+
* List of approved student transactions IDs
|
|
19
|
+
*/
|
|
20
|
+
approvedPayments: number[];
|
|
21
|
+
/**
|
|
22
|
+
* List of approved instructor expense IDs
|
|
23
|
+
*/
|
|
24
|
+
approvedExpenses: number[];
|
|
25
|
+
/**
|
|
26
|
+
* List of rejected instructor expense IDs
|
|
27
|
+
*/
|
|
28
|
+
rejectedExpenses: number[];
|
|
29
|
+
/********************* for history purpose /*********************/
|
|
30
|
+
totalApprovedPayments: number;
|
|
31
|
+
totalApprovedExpenses: number;
|
|
32
|
+
totalRejectedExpenses: number;
|
|
33
|
+
company: Promise<CompanyEntity>;
|
|
34
|
+
instructor: Promise<CompanyInstructorEntity>;
|
|
35
|
+
constructor(props?: Partial<CompanyHandoverEntity>);
|
|
36
|
+
toModel(): Promise<Handover>;
|
|
37
|
+
toSummary(): Promise<Handover>;
|
|
38
|
+
getApprovedPayments(): Promise<StudentTrainingTransactionEntity[]>;
|
|
39
|
+
getApprovedExpenses(): Promise<CompanyExpenseEntity[]>;
|
|
40
|
+
getRejectedExpenses(): Promise<CompanyExpenseEntity[]>;
|
|
41
|
+
getManager(): Promise<CompanyInstructorEntity>;
|
|
42
|
+
getInstructor(): Promise<CompanyInstructorEntity>;
|
|
43
|
+
getActivities(): Promise<Activity[]>;
|
|
44
|
+
}
|