@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,148 @@
|
|
|
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.CompanyInvoiceItemEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const invoice_entity_1 = require("./invoice.entity");
|
|
15
|
+
const common_1 = require("@driveup/common");
|
|
16
|
+
const utils_1 = require("../../../../utils");
|
|
17
|
+
let CompanyInvoiceItemEntity = class CompanyInvoiceItemEntity extends utils_1.TrackableEntity {
|
|
18
|
+
invoiceId;
|
|
19
|
+
description;
|
|
20
|
+
price;
|
|
21
|
+
quantity;
|
|
22
|
+
vat;
|
|
23
|
+
vatAmount;
|
|
24
|
+
total;
|
|
25
|
+
/**
|
|
26
|
+
* Type of product the item refers to
|
|
27
|
+
*/
|
|
28
|
+
refProduct;
|
|
29
|
+
/**
|
|
30
|
+
* Reference ID to link item to other entities
|
|
31
|
+
*/
|
|
32
|
+
refId;
|
|
33
|
+
invoice;
|
|
34
|
+
constructor(props) {
|
|
35
|
+
super();
|
|
36
|
+
Object.assign(this, props);
|
|
37
|
+
}
|
|
38
|
+
toModel() {
|
|
39
|
+
return new common_1.InvoiceItem({
|
|
40
|
+
id: this.id,
|
|
41
|
+
description: this.description,
|
|
42
|
+
price: this.price,
|
|
43
|
+
quantity: this.quantity,
|
|
44
|
+
vat: this.vat,
|
|
45
|
+
vatAmount: this.vatAmount,
|
|
46
|
+
total: this.total,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
toSummary() {
|
|
50
|
+
return this.toModel();
|
|
51
|
+
}
|
|
52
|
+
async getActivities() {
|
|
53
|
+
const activities = [];
|
|
54
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
|
|
55
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
56
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
|
|
57
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
58
|
+
return activities.filter(a => a);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.CompanyInvoiceItemEntity = CompanyInvoiceItemEntity;
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.Column)(),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], CompanyInvoiceItemEntity.prototype, "invoiceId", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.Column)({
|
|
68
|
+
type: 'mediumtext',
|
|
69
|
+
nullable: true,
|
|
70
|
+
default: null
|
|
71
|
+
}),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], CompanyInvoiceItemEntity.prototype, "description", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({
|
|
76
|
+
type: 'decimal',
|
|
77
|
+
precision: 8,
|
|
78
|
+
scale: 2,
|
|
79
|
+
nullable: false,
|
|
80
|
+
default: 0
|
|
81
|
+
}),
|
|
82
|
+
__metadata("design:type", Number)
|
|
83
|
+
], CompanyInvoiceItemEntity.prototype, "price", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, typeorm_1.Column)({
|
|
86
|
+
type: 'decimal',
|
|
87
|
+
precision: 8,
|
|
88
|
+
scale: 2,
|
|
89
|
+
nullable: false,
|
|
90
|
+
default: 0
|
|
91
|
+
}),
|
|
92
|
+
__metadata("design:type", Number)
|
|
93
|
+
], CompanyInvoiceItemEntity.prototype, "quantity", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, typeorm_1.Column)({
|
|
96
|
+
type: 'decimal',
|
|
97
|
+
precision: 4,
|
|
98
|
+
scale: 2,
|
|
99
|
+
default: 0,
|
|
100
|
+
nullable: false
|
|
101
|
+
}),
|
|
102
|
+
__metadata("design:type", Number)
|
|
103
|
+
], CompanyInvoiceItemEntity.prototype, "vat", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, typeorm_1.Column)({
|
|
106
|
+
type: 'decimal',
|
|
107
|
+
precision: 4,
|
|
108
|
+
scale: 2,
|
|
109
|
+
default: 0,
|
|
110
|
+
nullable: false
|
|
111
|
+
}),
|
|
112
|
+
__metadata("design:type", Number)
|
|
113
|
+
], CompanyInvoiceItemEntity.prototype, "vatAmount", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, typeorm_1.Column)({
|
|
116
|
+
type: 'decimal',
|
|
117
|
+
precision: 8,
|
|
118
|
+
scale: 2,
|
|
119
|
+
nullable: false,
|
|
120
|
+
default: 0
|
|
121
|
+
}),
|
|
122
|
+
__metadata("design:type", Number)
|
|
123
|
+
], CompanyInvoiceItemEntity.prototype, "total", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, typeorm_1.Column)({
|
|
126
|
+
type: 'enum',
|
|
127
|
+
enum: common_1.ProductType,
|
|
128
|
+
default: common_1.ProductType.DrivingCar,
|
|
129
|
+
nullable: true,
|
|
130
|
+
}),
|
|
131
|
+
__metadata("design:type", String)
|
|
132
|
+
], CompanyInvoiceItemEntity.prototype, "refProduct", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
(0, typeorm_1.Column)({
|
|
135
|
+
nullable: true,
|
|
136
|
+
default: null
|
|
137
|
+
}),
|
|
138
|
+
__metadata("design:type", Number)
|
|
139
|
+
], CompanyInvoiceItemEntity.prototype, "refId", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
(0, typeorm_1.ManyToOne)(() => invoice_entity_1.CompanyInvoiceEntity, invoice => invoice.items),
|
|
142
|
+
__metadata("design:type", Promise)
|
|
143
|
+
], CompanyInvoiceItemEntity.prototype, "invoice", void 0);
|
|
144
|
+
exports.CompanyInvoiceItemEntity = CompanyInvoiceItemEntity = __decorate([
|
|
145
|
+
(0, typeorm_1.Entity)('companyInvoiceItems'),
|
|
146
|
+
__metadata("design:paramtypes", [Object])
|
|
147
|
+
], CompanyInvoiceItemEntity);
|
|
148
|
+
//# sourceMappingURL=item.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/invoice/item.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,qDAAwD;AACxD,4CAAmF;AACnF,6CAAgE;AAGzD,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,uBAA4B;IAGzE,SAAS,CAAS;IAOlB,WAAW,CAAS;IASpB,KAAK,CAAS;IASd,QAAQ,CAAS;IASjB,GAAG,CAAS;IASZ,SAAS,CAAS;IASlB,KAAK,CAAS;IAEd;;OAEG;IAOH,UAAU,CAAc;IAExB;;OAEG;IAKH,KAAK,CAAS;IAGd,OAAO,CAAgC;IAEvC,YAAY,KAAyC;QACpD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACN,OAAO,IAAI,oBAAW,CAAC;YACtB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,CAAC,CAAC;IACJ,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,aAAa;QAClB,MAAM,UAAU,GAAe,EAAE,CAAC;QAClC,UAAU,CAAC,IAAI,CAAC,MAAM,IAAA,kBAAU,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IAAI,EAAE,SAAS;QACf,SAAS,EAAE,CAAC;QACZ,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,KAAK;KACf,CAAC;;2DACgB;AASlB;IAPC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,CAAC;QACZ,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,CAAC;KACV,CAAC;;uDACY;AAWd;IANC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,oBAAW;QACjB,OAAO,EAAE,oBAAW,CAAC,UAAU;QAC/B,QAAQ,EAAE,IAAI;KACd,CAAC;;4DACsB;AASxB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;uDACY;AAGd;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAoB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;;yDACzB;mCA9E3B,wBAAwB;IADpC,IAAA,gBAAM,EAAC,qBAAqB,CAAC;;GACjB,wBAAwB,CA6GpC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Activity, PaymentMethod } from '@driveup/common';
|
|
2
|
+
import { CompanyEntity } from '../../company.entity';
|
|
3
|
+
import { CompanyBillTransactionEntity } from '../billing/transaction.entity';
|
|
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
|
+
toSummary(): PaymentMethod;
|
|
33
|
+
getFailedTransactions(): Promise<CompanyBillTransactionEntity[]>;
|
|
34
|
+
getActivities(): Promise<Activity[]>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method.entity.js","sourceRoot":"","sources":["../../../../../src/profile/company/finances/payment/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,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IAAI;KACb,CAAC;;4DACY;AAMd;IAJC,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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Activity, PaymentMethod } from '@driveup/common';
|
|
2
|
+
import { CompanyEntity } from '../../company.entity';
|
|
3
|
+
import { CompanyBillTransactionEntity } from '../billing/transaction.entity';
|
|
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
|
+
toSummary(): PaymentMethod;
|
|
33
|
+
getFailedTransactions(): Promise<CompanyBillTransactionEntity[]>;
|
|
34
|
+
getActivities(): Promise<Activity[]>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,y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,OAAO,EAAE,IAAI;KACb,CAAC;;4DACY;AAMd;IAJC,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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|