@grapadigital/shared-schemas 1.0.119 → 1.0.121
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/schemas/commission.schema.d.ts +81 -0
- package/dist/schemas/commission.schema.js +120 -0
- package/dist/schemas/payment.schema.d.ts +1 -1
- package/dist/schemas/payment.schema.js +1 -2
- package/dist/schemas/sale.schema.d.ts +14 -6
- package/dist/schemas/sale.schema.js +67 -37
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/schemas/commission.schema.ts +96 -0
- package/src/schemas/payment.schema.ts +1 -1
- package/src/schemas/sale.schema.ts +69 -44
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -29,3 +29,4 @@ __exportStar(require("./schemas/sale.schema"), exports);
|
|
|
29
29
|
__exportStar(require("./schemas/invoice.schema"), exports);
|
|
30
30
|
__exportStar(require("./schemas/log.schema"), exports);
|
|
31
31
|
__exportStar(require("./schemas/project.schema"), exports);
|
|
32
|
+
__exportStar(require("./schemas/commission.schema"), exports);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/session" />
|
|
19
|
+
/// <reference types="mongoose/types/types" />
|
|
20
|
+
/// <reference types="mongoose/types/utility" />
|
|
21
|
+
/// <reference types="mongoose/types/validation" />
|
|
22
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
23
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
|
|
27
|
+
import { Sale } from './sale.schema';
|
|
28
|
+
export type CommissionDocument = HydratedDocument<Commission>;
|
|
29
|
+
export declare class CommissionRecipient {
|
|
30
|
+
name: string;
|
|
31
|
+
email: string;
|
|
32
|
+
team: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const CommissionRecipientSchema: MongooseSchema<CommissionRecipient, import("mongoose").Model<CommissionRecipient, any, any, any, import("mongoose").Document<unknown, any, CommissionRecipient, any, {}> & CommissionRecipient & {
|
|
35
|
+
_id: Types.ObjectId;
|
|
36
|
+
} & {
|
|
37
|
+
__v: number;
|
|
38
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CommissionRecipient, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CommissionRecipient>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<CommissionRecipient> & {
|
|
39
|
+
_id: Types.ObjectId;
|
|
40
|
+
} & {
|
|
41
|
+
__v: number;
|
|
42
|
+
}>;
|
|
43
|
+
export declare class Commission {
|
|
44
|
+
_id?: Types.ObjectId;
|
|
45
|
+
recipient: CommissionRecipient;
|
|
46
|
+
value: number;
|
|
47
|
+
percentage: number;
|
|
48
|
+
role: 'origination' | 'commercial' | 'planning' | 'curation';
|
|
49
|
+
status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed';
|
|
50
|
+
type: 'collaborator' | 'agency';
|
|
51
|
+
sale: Types.ObjectId | Sale;
|
|
52
|
+
paidAt?: Date;
|
|
53
|
+
approvedAt?: Date;
|
|
54
|
+
readyAt?: Date;
|
|
55
|
+
approvedBy?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
createdAt?: Date;
|
|
58
|
+
updatedAt?: Date;
|
|
59
|
+
}
|
|
60
|
+
export declare const CommissionSchema: MongooseSchema<Commission, import("mongoose").Model<Commission, any, any, any, import("mongoose").Document<unknown, any, Commission, any, {}> & Commission & Required<{
|
|
61
|
+
_id: Types.ObjectId;
|
|
62
|
+
}> & {
|
|
63
|
+
__v: number;
|
|
64
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Commission, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Commission>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Commission> & Required<{
|
|
65
|
+
_id: Types.ObjectId;
|
|
66
|
+
}> & {
|
|
67
|
+
__v: number;
|
|
68
|
+
}>;
|
|
69
|
+
export declare const CommissionModel: import("mongoose").Model<Commission, {}, {}, {}, import("mongoose").Document<unknown, {}, Commission, {}, import("mongoose").DefaultSchemaOptions> & Commission & Required<{
|
|
70
|
+
_id: Types.ObjectId;
|
|
71
|
+
}> & {
|
|
72
|
+
__v: number;
|
|
73
|
+
}, MongooseSchema<Commission, import("mongoose").Model<Commission, any, any, any, import("mongoose").Document<unknown, any, Commission, any, {}> & Commission & Required<{
|
|
74
|
+
_id: Types.ObjectId;
|
|
75
|
+
}> & {
|
|
76
|
+
__v: number;
|
|
77
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Commission, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Commission>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Commission> & Required<{
|
|
78
|
+
_id: Types.ObjectId;
|
|
79
|
+
}> & {
|
|
80
|
+
__v: number;
|
|
81
|
+
}>>;
|
|
@@ -0,0 +1,120 @@
|
|
|
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.CommissionModel = exports.CommissionSchema = exports.Commission = exports.CommissionRecipientSchema = exports.CommissionRecipient = void 0;
|
|
13
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const mongoose_2 = require("mongoose");
|
|
16
|
+
let CommissionRecipient = class CommissionRecipient {
|
|
17
|
+
};
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], CommissionRecipient.prototype, "name", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], CommissionRecipient.prototype, "email", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], CommissionRecipient.prototype, "team", void 0);
|
|
30
|
+
CommissionRecipient = __decorate([
|
|
31
|
+
(0, mongoose_1.Schema)({ _id: false })
|
|
32
|
+
], CommissionRecipient);
|
|
33
|
+
exports.CommissionRecipient = CommissionRecipient;
|
|
34
|
+
exports.CommissionRecipientSchema = mongoose_1.SchemaFactory.createForClass(CommissionRecipient);
|
|
35
|
+
let Commission = class Commission {
|
|
36
|
+
};
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, auto: true, required: false }),
|
|
39
|
+
__metadata("design:type", mongoose_2.Types.ObjectId)
|
|
40
|
+
], Commission.prototype, "_id", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, mongoose_1.Prop)({ type: exports.CommissionRecipientSchema, required: true }),
|
|
43
|
+
__metadata("design:type", CommissionRecipient)
|
|
44
|
+
], Commission.prototype, "recipient", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, mongoose_1.Prop)({ type: Number, required: true }),
|
|
47
|
+
__metadata("design:type", Number)
|
|
48
|
+
], Commission.prototype, "value", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, mongoose_1.Prop)({ type: Number, required: true, min: 0, max: 100 }),
|
|
51
|
+
__metadata("design:type", Number)
|
|
52
|
+
], Commission.prototype, "percentage", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, mongoose_1.Prop)({
|
|
55
|
+
type: String,
|
|
56
|
+
enum: ['origination', 'commercial', 'planning', 'curation'],
|
|
57
|
+
default: 'origination',
|
|
58
|
+
required: true,
|
|
59
|
+
}),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], Commission.prototype, "role", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, mongoose_1.Prop)({
|
|
64
|
+
type: String,
|
|
65
|
+
enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed'],
|
|
66
|
+
default: 'pending',
|
|
67
|
+
required: true,
|
|
68
|
+
}),
|
|
69
|
+
__metadata("design:type", String)
|
|
70
|
+
], Commission.prototype, "status", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, swagger_1.ApiProperty)({
|
|
73
|
+
enum: ['sale', 'recruitment', 'content', 'bonus'],
|
|
74
|
+
example: 'sale'
|
|
75
|
+
}),
|
|
76
|
+
(0, mongoose_1.Prop)({
|
|
77
|
+
type: String,
|
|
78
|
+
enum: ['collaborator', 'agency'],
|
|
79
|
+
required: true,
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], Commission.prototype, "type", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Sale', required: false }),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], Commission.prototype, "sale", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, mongoose_1.Prop)({ type: Date, required: false }),
|
|
89
|
+
__metadata("design:type", Date)
|
|
90
|
+
], Commission.prototype, "paidAt", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, mongoose_1.Prop)({ type: Date, required: false }),
|
|
93
|
+
__metadata("design:type", Date)
|
|
94
|
+
], Commission.prototype, "approvedAt", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, mongoose_1.Prop)({ type: Date, required: false }),
|
|
97
|
+
__metadata("design:type", Date)
|
|
98
|
+
], Commission.prototype, "readyAt", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, mongoose_1.Prop)({ type: String, required: false }),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], Commission.prototype, "approvedBy", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, mongoose_1.Prop)({ type: String, required: false }),
|
|
105
|
+
__metadata("design:type", String)
|
|
106
|
+
], Commission.prototype, "description", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, mongoose_1.Prop)({ type: Date, default: Date.now, required: false }),
|
|
109
|
+
__metadata("design:type", Date)
|
|
110
|
+
], Commission.prototype, "createdAt", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, mongoose_1.Prop)({ type: Date, default: Date.now, required: false }),
|
|
113
|
+
__metadata("design:type", Date)
|
|
114
|
+
], Commission.prototype, "updatedAt", void 0);
|
|
115
|
+
Commission = __decorate([
|
|
116
|
+
(0, mongoose_1.Schema)({ timestamps: true })
|
|
117
|
+
], Commission);
|
|
118
|
+
exports.Commission = Commission;
|
|
119
|
+
exports.CommissionSchema = mongoose_1.SchemaFactory.createForClass(Commission);
|
|
120
|
+
exports.CommissionModel = (0, mongoose_2.model)('Commission', exports.CommissionSchema);
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PaymentModel = exports.PaymentSchema = exports.Payment = exports.AttachmentSchema = exports.Attachment = exports.NoteSchema = exports.
|
|
12
|
+
exports.PaymentModel = exports.PaymentSchema = exports.Payment = exports.AttachmentSchema = exports.Attachment = exports.NoteSchema = exports.CanceledSchema = exports.Canceled = exports.PaidSchema = exports.Paid = exports.QueuedSchema = exports.Queued = exports.RequestedSchema = exports.Requested = exports.PendingSchema = exports.Pending = exports.ReviewSchema = exports.Review = void 0;
|
|
13
13
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
14
|
const swagger_1 = require("@nestjs/swagger");
|
|
15
15
|
const mongoose_2 = require("mongoose");
|
|
@@ -247,7 +247,6 @@ __decorate([
|
|
|
247
247
|
Note = __decorate([
|
|
248
248
|
(0, mongoose_1.Schema)({ _id: false })
|
|
249
249
|
], Note);
|
|
250
|
-
exports.Note = Note;
|
|
251
250
|
exports.NoteSchema = mongoose_1.SchemaFactory.createForClass(Note);
|
|
252
251
|
let Attachment = class Attachment {
|
|
253
252
|
};
|
|
@@ -26,9 +26,6 @@
|
|
|
26
26
|
import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
|
|
27
27
|
import { Profile } from './profile.schema';
|
|
28
28
|
import { Client } from './client.schema';
|
|
29
|
-
import { Action } from './action.schema';
|
|
30
|
-
import { Payment } from './payment.schema';
|
|
31
|
-
import { Invoice } from './invoice.schema';
|
|
32
29
|
export type SaleDocument = HydratedDocument<Sale>;
|
|
33
30
|
export declare class Screening {
|
|
34
31
|
subject: string;
|
|
@@ -41,6 +38,7 @@ export declare class Proposal {
|
|
|
41
38
|
businessUnit: 'enterprise' | 'artistic';
|
|
42
39
|
contact: string;
|
|
43
40
|
initialScope: string;
|
|
41
|
+
saleType: 'Inbound' | 'Outbound';
|
|
44
42
|
profile?: Types.ObjectId | Profile;
|
|
45
43
|
responsable: {
|
|
46
44
|
team: string;
|
|
@@ -94,6 +92,18 @@ declare class Note {
|
|
|
94
92
|
owner: string;
|
|
95
93
|
createdAt: Date;
|
|
96
94
|
}
|
|
95
|
+
export declare class CommissionParticipant {
|
|
96
|
+
email: string;
|
|
97
|
+
role: string;
|
|
98
|
+
percent: number;
|
|
99
|
+
value: number;
|
|
100
|
+
}
|
|
101
|
+
export declare class CommissionInfo {
|
|
102
|
+
marginPercent: number;
|
|
103
|
+
commissionPercent: number;
|
|
104
|
+
totalCommissionValue: number;
|
|
105
|
+
participants: CommissionParticipant[];
|
|
106
|
+
}
|
|
97
107
|
export declare class Sale {
|
|
98
108
|
_id?: Types.ObjectId;
|
|
99
109
|
title: string;
|
|
@@ -104,11 +114,9 @@ export declare class Sale {
|
|
|
104
114
|
formalization?: Formalization;
|
|
105
115
|
lost?: Lost;
|
|
106
116
|
notes?: Note[];
|
|
117
|
+
commission?: CommissionInfo;
|
|
107
118
|
tags?: string[];
|
|
108
119
|
profiles?: Types.ObjectId[] | Profile[];
|
|
109
|
-
invoices?: Types.ObjectId[] | Invoice[];
|
|
110
|
-
actions?: Types.ObjectId[] | Action[];
|
|
111
|
-
payments?: Types.ObjectId[] | Payment[];
|
|
112
120
|
closedAt?: Date;
|
|
113
121
|
createdAt?: Date;
|
|
114
122
|
updatedAt?: Date;
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaleModel = exports.SaleSchema = exports.Sale = exports.Lost = exports.Formalization = exports.Negotiation = exports.Proposal = exports.Screening = void 0;
|
|
12
|
+
exports.SaleModel = exports.SaleSchema = exports.Sale = exports.CommissionInfo = exports.CommissionParticipant = exports.Lost = exports.Formalization = exports.Negotiation = exports.Proposal = exports.Screening = void 0;
|
|
13
13
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
14
|
const mongoose_2 = require("mongoose");
|
|
15
15
|
let Screening = class Screening {
|
|
@@ -53,7 +53,19 @@ __decorate([
|
|
|
53
53
|
__metadata("design:type", String)
|
|
54
54
|
], Proposal.prototype, "initialScope", void 0);
|
|
55
55
|
__decorate([
|
|
56
|
-
(0, mongoose_1.Prop)({
|
|
56
|
+
(0, mongoose_1.Prop)({
|
|
57
|
+
type: String,
|
|
58
|
+
enum: ['Inbound', 'Outbound'],
|
|
59
|
+
required: true
|
|
60
|
+
}),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], Proposal.prototype, "saleType", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, mongoose_1.Prop)({
|
|
65
|
+
type: mongoose_2.Schema.Types.ObjectId,
|
|
66
|
+
ref: 'Profile',
|
|
67
|
+
required: false
|
|
68
|
+
}),
|
|
57
69
|
__metadata("design:type", Object)
|
|
58
70
|
], Proposal.prototype, "profile", void 0);
|
|
59
71
|
__decorate([
|
|
@@ -63,8 +75,8 @@ __decorate([
|
|
|
63
75
|
type: {
|
|
64
76
|
team: String,
|
|
65
77
|
name: String,
|
|
66
|
-
email: String
|
|
67
|
-
}
|
|
78
|
+
email: String
|
|
79
|
+
}
|
|
68
80
|
}),
|
|
69
81
|
__metadata("design:type", Object)
|
|
70
82
|
], Proposal.prototype, "responsable", void 0);
|
|
@@ -247,6 +259,50 @@ __decorate([
|
|
|
247
259
|
Note = __decorate([
|
|
248
260
|
(0, mongoose_1.Schema)({ _id: false })
|
|
249
261
|
], Note);
|
|
262
|
+
let CommissionParticipant = class CommissionParticipant {
|
|
263
|
+
};
|
|
264
|
+
__decorate([
|
|
265
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
266
|
+
__metadata("design:type", String)
|
|
267
|
+
], CommissionParticipant.prototype, "email", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
270
|
+
__metadata("design:type", String)
|
|
271
|
+
], CommissionParticipant.prototype, "role", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
274
|
+
__metadata("design:type", Number)
|
|
275
|
+
], CommissionParticipant.prototype, "percent", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
278
|
+
__metadata("design:type", Number)
|
|
279
|
+
], CommissionParticipant.prototype, "value", void 0);
|
|
280
|
+
CommissionParticipant = __decorate([
|
|
281
|
+
(0, mongoose_1.Schema)({ _id: false })
|
|
282
|
+
], CommissionParticipant);
|
|
283
|
+
exports.CommissionParticipant = CommissionParticipant;
|
|
284
|
+
let CommissionInfo = class CommissionInfo {
|
|
285
|
+
};
|
|
286
|
+
__decorate([
|
|
287
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
288
|
+
__metadata("design:type", Number)
|
|
289
|
+
], CommissionInfo.prototype, "marginPercent", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
292
|
+
__metadata("design:type", Number)
|
|
293
|
+
], CommissionInfo.prototype, "commissionPercent", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
296
|
+
__metadata("design:type", Number)
|
|
297
|
+
], CommissionInfo.prototype, "totalCommissionValue", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
(0, mongoose_1.Prop)({ type: [CommissionParticipant], required: true }),
|
|
300
|
+
__metadata("design:type", Array)
|
|
301
|
+
], CommissionInfo.prototype, "participants", void 0);
|
|
302
|
+
CommissionInfo = __decorate([
|
|
303
|
+
(0, mongoose_1.Schema)({ _id: false })
|
|
304
|
+
], CommissionInfo);
|
|
305
|
+
exports.CommissionInfo = CommissionInfo;
|
|
250
306
|
let Sale = class Sale {
|
|
251
307
|
};
|
|
252
308
|
__decorate([
|
|
@@ -267,7 +323,7 @@ __decorate([
|
|
|
267
323
|
'formalization',
|
|
268
324
|
'closed',
|
|
269
325
|
'lost'
|
|
270
|
-
]
|
|
326
|
+
]
|
|
271
327
|
}),
|
|
272
328
|
__metadata("design:type", String)
|
|
273
329
|
], Sale.prototype, "phase", void 0);
|
|
@@ -295,6 +351,10 @@ __decorate([
|
|
|
295
351
|
(0, mongoose_1.Prop)([{ type: Note, required: false }]),
|
|
296
352
|
__metadata("design:type", Array)
|
|
297
353
|
], Sale.prototype, "notes", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
(0, mongoose_1.Prop)({ type: CommissionInfo, required: false }),
|
|
356
|
+
__metadata("design:type", CommissionInfo)
|
|
357
|
+
], Sale.prototype, "commission", void 0);
|
|
298
358
|
__decorate([
|
|
299
359
|
(0, mongoose_1.Prop)({ type: [String], required: false, default: [] }),
|
|
300
360
|
__metadata("design:type", Array)
|
|
@@ -304,41 +364,11 @@ __decorate([
|
|
|
304
364
|
{
|
|
305
365
|
type: mongoose_2.Schema.Types.ObjectId,
|
|
306
366
|
ref: 'Profile',
|
|
307
|
-
required: false
|
|
308
|
-
}
|
|
367
|
+
required: false
|
|
368
|
+
}
|
|
309
369
|
]),
|
|
310
370
|
__metadata("design:type", Array)
|
|
311
371
|
], Sale.prototype, "profiles", void 0);
|
|
312
|
-
__decorate([
|
|
313
|
-
(0, mongoose_1.Prop)([
|
|
314
|
-
{
|
|
315
|
-
type: mongoose_2.Schema.Types.ObjectId,
|
|
316
|
-
ref: 'Invoice',
|
|
317
|
-
required: false,
|
|
318
|
-
},
|
|
319
|
-
]),
|
|
320
|
-
__metadata("design:type", Array)
|
|
321
|
-
], Sale.prototype, "invoices", void 0);
|
|
322
|
-
__decorate([
|
|
323
|
-
(0, mongoose_1.Prop)([
|
|
324
|
-
{
|
|
325
|
-
type: mongoose_2.Schema.Types.ObjectId,
|
|
326
|
-
ref: 'Action',
|
|
327
|
-
required: false,
|
|
328
|
-
},
|
|
329
|
-
]),
|
|
330
|
-
__metadata("design:type", Array)
|
|
331
|
-
], Sale.prototype, "actions", void 0);
|
|
332
|
-
__decorate([
|
|
333
|
-
(0, mongoose_1.Prop)([
|
|
334
|
-
{
|
|
335
|
-
type: mongoose_2.Schema.Types.ObjectId,
|
|
336
|
-
ref: 'Payment',
|
|
337
|
-
required: false,
|
|
338
|
-
},
|
|
339
|
-
]),
|
|
340
|
-
__metadata("design:type", Array)
|
|
341
|
-
], Sale.prototype, "payments", void 0);
|
|
342
372
|
__decorate([
|
|
343
373
|
(0, mongoose_1.Prop)({ required: false }),
|
|
344
374
|
__metadata("design:type", Date)
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
HydratedDocument,
|
|
6
|
+
Schema as MongooseSchema,
|
|
7
|
+
Types,
|
|
8
|
+
model as MongooseModel,
|
|
9
|
+
} from 'mongoose';
|
|
10
|
+
|
|
11
|
+
import { Sale } from './sale.schema';
|
|
12
|
+
|
|
13
|
+
export type CommissionDocument = HydratedDocument<Commission>;
|
|
14
|
+
|
|
15
|
+
@Schema({ _id: false })
|
|
16
|
+
export class CommissionRecipient {
|
|
17
|
+
@Prop({ type: String, required: true })
|
|
18
|
+
name: string;
|
|
19
|
+
|
|
20
|
+
@Prop({ type: String, required: true })
|
|
21
|
+
email: string;
|
|
22
|
+
|
|
23
|
+
@Prop({ type: String, required: true })
|
|
24
|
+
team: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const CommissionRecipientSchema = SchemaFactory.createForClass(CommissionRecipient);
|
|
28
|
+
|
|
29
|
+
@Schema({ timestamps: true })
|
|
30
|
+
export class Commission {
|
|
31
|
+
@Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
|
|
32
|
+
_id?: Types.ObjectId;
|
|
33
|
+
|
|
34
|
+
@Prop({ type: CommissionRecipientSchema, required: true })
|
|
35
|
+
recipient: CommissionRecipient;
|
|
36
|
+
|
|
37
|
+
@Prop({ type: Number, required: true })
|
|
38
|
+
value: number;
|
|
39
|
+
|
|
40
|
+
@Prop({ type: Number, required: true, min: 0, max: 100 })
|
|
41
|
+
percentage: number;
|
|
42
|
+
|
|
43
|
+
@Prop({
|
|
44
|
+
type: String,
|
|
45
|
+
enum: ['origination', 'commercial', 'planning', 'curation'],
|
|
46
|
+
default: 'origination',
|
|
47
|
+
required: true,
|
|
48
|
+
})
|
|
49
|
+
role: 'origination' | 'commercial' | 'planning' | 'curation';
|
|
50
|
+
|
|
51
|
+
@Prop({
|
|
52
|
+
type: String,
|
|
53
|
+
enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed'],
|
|
54
|
+
default: 'pending',
|
|
55
|
+
required: true,
|
|
56
|
+
})
|
|
57
|
+
status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed';
|
|
58
|
+
|
|
59
|
+
@ApiProperty({
|
|
60
|
+
enum: ['sale', 'recruitment', 'content', 'bonus'],
|
|
61
|
+
example: 'sale'
|
|
62
|
+
})
|
|
63
|
+
@Prop({
|
|
64
|
+
type: String,
|
|
65
|
+
enum: ['collaborator', 'agency'],
|
|
66
|
+
required: true,
|
|
67
|
+
})
|
|
68
|
+
type: 'collaborator' | 'agency';
|
|
69
|
+
|
|
70
|
+
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale', required: false })
|
|
71
|
+
sale: Types.ObjectId | Sale;
|
|
72
|
+
|
|
73
|
+
@Prop({ type: Date, required: false })
|
|
74
|
+
paidAt?: Date;
|
|
75
|
+
|
|
76
|
+
@Prop({ type: Date, required: false })
|
|
77
|
+
approvedAt?: Date;
|
|
78
|
+
|
|
79
|
+
@Prop({ type: Date, required: false })
|
|
80
|
+
readyAt?: Date;
|
|
81
|
+
|
|
82
|
+
@Prop({ type: String, required: false })
|
|
83
|
+
approvedBy?: string;
|
|
84
|
+
|
|
85
|
+
@Prop({ type: String, required: false })
|
|
86
|
+
description?: string;
|
|
87
|
+
|
|
88
|
+
@Prop({ type: Date, default: Date.now, required: false })
|
|
89
|
+
createdAt?: Date;
|
|
90
|
+
|
|
91
|
+
@Prop({ type: Date, default: Date.now, required: false })
|
|
92
|
+
updatedAt?: Date;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const CommissionSchema = SchemaFactory.createForClass(Commission);
|
|
96
|
+
export const CommissionModel = MongooseModel('Commission', CommissionSchema);
|
|
@@ -174,7 +174,7 @@ export class Canceled {
|
|
|
174
174
|
export const CanceledSchema = SchemaFactory.createForClass(Canceled);
|
|
175
175
|
|
|
176
176
|
@Schema({ _id: false })
|
|
177
|
-
|
|
177
|
+
class Note {
|
|
178
178
|
@ApiProperty({ example: 'Solicitar documento adicional' })
|
|
179
179
|
@Prop() text: string;
|
|
180
180
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
HydratedDocument,
|
|
4
|
+
Schema as MongooseSchema,
|
|
5
|
+
Types,
|
|
6
|
+
model as MongooseModel
|
|
7
|
+
} from 'mongoose';
|
|
3
8
|
import { Profile } from './profile.schema';
|
|
4
9
|
import { Client } from './client.schema';
|
|
5
|
-
import { Action } from './action.schema';
|
|
6
|
-
import { Payment } from './payment.schema';
|
|
7
|
-
import { Invoice } from './invoice.schema';
|
|
8
10
|
|
|
9
11
|
export type SaleDocument = HydratedDocument<Sale>;
|
|
10
12
|
|
|
@@ -22,8 +24,19 @@ export class Proposal {
|
|
|
22
24
|
@Prop({ required: true }) businessUnit: 'enterprise' | 'artistic';
|
|
23
25
|
@Prop({ required: true }) contact: string;
|
|
24
26
|
@Prop({ required: true }) initialScope: string;
|
|
25
|
-
|
|
26
|
-
@Prop({
|
|
27
|
+
|
|
28
|
+
@Prop({
|
|
29
|
+
type: String,
|
|
30
|
+
enum: ['Inbound', 'Outbound'],
|
|
31
|
+
required: true
|
|
32
|
+
})
|
|
33
|
+
saleType: 'Inbound' | 'Outbound';
|
|
34
|
+
|
|
35
|
+
@Prop({
|
|
36
|
+
type: MongooseSchema.Types.ObjectId,
|
|
37
|
+
ref: 'Profile',
|
|
38
|
+
required: false
|
|
39
|
+
})
|
|
27
40
|
profile?: Types.ObjectId | Profile;
|
|
28
41
|
|
|
29
42
|
@Prop({
|
|
@@ -32,8 +45,8 @@ export class Proposal {
|
|
|
32
45
|
type: {
|
|
33
46
|
team: String,
|
|
34
47
|
name: String,
|
|
35
|
-
email: String
|
|
36
|
-
}
|
|
48
|
+
email: String
|
|
49
|
+
}
|
|
37
50
|
})
|
|
38
51
|
responsable: {
|
|
39
52
|
team: string;
|
|
@@ -44,14 +57,27 @@ export class Proposal {
|
|
|
44
57
|
|
|
45
58
|
@Schema({ _id: false })
|
|
46
59
|
export class Negotiation {
|
|
47
|
-
@Prop({ required: true }) calculatorType:
|
|
60
|
+
@Prop({ required: true }) calculatorType:
|
|
61
|
+
| 'withPreDefinedBudget'
|
|
62
|
+
| 'withoutPreDefinedBudget'
|
|
63
|
+
| 'bourbon';
|
|
48
64
|
@Prop({ required: false }) childPermit?: boolean;
|
|
49
65
|
@Prop({ required: false }) childPermitValue?: number;
|
|
50
|
-
@Prop({ required: false }) childPermitMethod?:
|
|
66
|
+
@Prop({ required: false }) childPermitMethod?:
|
|
67
|
+
| 'direct'
|
|
68
|
+
| 'debit_note'
|
|
69
|
+
| 'client';
|
|
51
70
|
@Prop({ required: true }) influencerBroadcastValue: number;
|
|
52
|
-
@Prop({ required: true }) influencerBroadcastMethod:
|
|
71
|
+
@Prop({ required: true }) influencerBroadcastMethod:
|
|
72
|
+
| 'transfer'
|
|
73
|
+
| 'direct'
|
|
74
|
+
| 'debit_note'
|
|
75
|
+
| 'client';
|
|
53
76
|
@Prop({ required: true }) productionAndOthersValue: number;
|
|
54
|
-
@Prop({ required: true }) productionAndOthersMethod:
|
|
77
|
+
@Prop({ required: true }) productionAndOthersMethod:
|
|
78
|
+
| 'direct'
|
|
79
|
+
| 'debit_note'
|
|
80
|
+
| 'client';
|
|
55
81
|
@Prop({ required: true }) commissionRate: number;
|
|
56
82
|
@Prop({ required: true }) broadcastBonusRate: number;
|
|
57
83
|
@Prop({ required: true }) taxRate: number;
|
|
@@ -102,6 +128,24 @@ class Note {
|
|
|
102
128
|
@Prop({ required: true }) createdAt: Date;
|
|
103
129
|
}
|
|
104
130
|
|
|
131
|
+
@Schema({ _id: false })
|
|
132
|
+
export class CommissionParticipant {
|
|
133
|
+
@Prop({ required: true }) email: string;
|
|
134
|
+
@Prop({ required: true }) role: string;
|
|
135
|
+
@Prop({ required: true }) percent: number;
|
|
136
|
+
@Prop({ required: true }) value: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@Schema({ _id: false })
|
|
140
|
+
export class CommissionInfo {
|
|
141
|
+
@Prop({ required: true }) marginPercent: number;
|
|
142
|
+
@Prop({ required: true }) commissionPercent: number;
|
|
143
|
+
@Prop({ required: true }) totalCommissionValue: number;
|
|
144
|
+
|
|
145
|
+
@Prop({ type: [CommissionParticipant], required: true })
|
|
146
|
+
participants: CommissionParticipant[];
|
|
147
|
+
}
|
|
148
|
+
|
|
105
149
|
@Schema({ timestamps: true })
|
|
106
150
|
export class Sale {
|
|
107
151
|
@Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
|
|
@@ -118,9 +162,15 @@ export class Sale {
|
|
|
118
162
|
'formalization',
|
|
119
163
|
'closed',
|
|
120
164
|
'lost'
|
|
121
|
-
]
|
|
165
|
+
]
|
|
122
166
|
})
|
|
123
|
-
phase:
|
|
167
|
+
phase:
|
|
168
|
+
| 'screening'
|
|
169
|
+
| 'proposal'
|
|
170
|
+
| 'negotiation'
|
|
171
|
+
| 'formalization'
|
|
172
|
+
| 'closed'
|
|
173
|
+
| 'lost';
|
|
124
174
|
|
|
125
175
|
@Prop({ type: Screening }) screening?: Screening;
|
|
126
176
|
@Prop({ type: Proposal }) proposal?: Proposal;
|
|
@@ -131,6 +181,9 @@ export class Sale {
|
|
|
131
181
|
@Prop([{ type: Note, required: false }])
|
|
132
182
|
notes?: Note[];
|
|
133
183
|
|
|
184
|
+
@Prop({ type: CommissionInfo, required: false })
|
|
185
|
+
commission?: CommissionInfo;
|
|
186
|
+
|
|
134
187
|
@Prop({ type: [String], required: false, default: [] })
|
|
135
188
|
tags?: string[];
|
|
136
189
|
|
|
@@ -138,38 +191,11 @@ export class Sale {
|
|
|
138
191
|
{
|
|
139
192
|
type: MongooseSchema.Types.ObjectId,
|
|
140
193
|
ref: 'Profile',
|
|
141
|
-
required: false
|
|
142
|
-
}
|
|
194
|
+
required: false
|
|
195
|
+
}
|
|
143
196
|
])
|
|
144
197
|
profiles?: Types.ObjectId[] | Profile[];
|
|
145
198
|
|
|
146
|
-
@Prop([
|
|
147
|
-
{
|
|
148
|
-
type: MongooseSchema.Types.ObjectId,
|
|
149
|
-
ref: 'Invoice',
|
|
150
|
-
required: false,
|
|
151
|
-
},
|
|
152
|
-
])
|
|
153
|
-
invoices?: Types.ObjectId[] | Invoice[];
|
|
154
|
-
|
|
155
|
-
@Prop([
|
|
156
|
-
{
|
|
157
|
-
type: MongooseSchema.Types.ObjectId,
|
|
158
|
-
ref: 'Action',
|
|
159
|
-
required: false,
|
|
160
|
-
},
|
|
161
|
-
])
|
|
162
|
-
actions?: Types.ObjectId[] | Action[];
|
|
163
|
-
|
|
164
|
-
@Prop([
|
|
165
|
-
{
|
|
166
|
-
type: MongooseSchema.Types.ObjectId,
|
|
167
|
-
ref: 'Payment',
|
|
168
|
-
required: false,
|
|
169
|
-
},
|
|
170
|
-
])
|
|
171
|
-
payments?: Types.ObjectId[] | Payment[];
|
|
172
|
-
|
|
173
199
|
@Prop({ required: false })
|
|
174
200
|
closedAt?: Date;
|
|
175
201
|
|
|
@@ -182,4 +208,3 @@ export class Sale {
|
|
|
182
208
|
|
|
183
209
|
export const SaleSchema = SchemaFactory.createForClass(Sale);
|
|
184
210
|
export const SaleModel = MongooseModel('Sale', SaleSchema);
|
|
185
|
-
|