@duvdu-v1/duvdu 1.1.325 → 1.1.327
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/build/models/Ticket.model.js +5 -2
- package/build/models/all-contracts.model.d.ts +3 -1
- package/build/models/all-contracts.model.js +11 -5
- package/build/models/copyright-contract.model.js +1 -1
- package/build/models/copyrights-booking.model.js +1 -1
- package/build/models/copyrights.model.js +1 -1
- package/build/models/fundedTransactions.model.js +5 -2
- package/build/models/pages.model.d.ts +1 -0
- package/build/models/pages.model.js +1 -0
- package/build/models/portfolio-post.model.js +5 -2
- package/build/models/producer.model.js +5 -2
- package/build/models/producer_contracts.model.js +5 -2
- package/build/models/projectContract.model.js +5 -2
- package/build/models/rental-contracts.model.js +5 -2
- package/build/models/rental.model.js +5 -2
- package/build/models/report.model.js +5 -2
- package/build/models/teamProject.model.js +5 -2
- package/build/models/transactions.model.js +16 -2
- package/package.json +1 -1
|
@@ -25,10 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Ticket = void 0;
|
|
27
27
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
28
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
29
28
|
const model_names_1 = require("../types/model-names");
|
|
29
|
+
const generateTicketNumber = () => {
|
|
30
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
31
|
+
return `TKT${random}`;
|
|
32
|
+
};
|
|
30
33
|
const ticketSchema = new mongoose_1.default.Schema({
|
|
31
|
-
ticketNumber: { type: String, default:
|
|
34
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
32
35
|
userId: {
|
|
33
36
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
34
37
|
ref: model_names_1.MODELS.user,
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { Types } from 'mongoose';
|
|
26
26
|
import { Iuser } from '../types/User';
|
|
27
|
-
export declare const
|
|
27
|
+
export declare const generateContractTicketNumber: () => string;
|
|
28
|
+
export declare const generateContractReportTicketNumber: () => string;
|
|
28
29
|
export interface Icontract {
|
|
29
30
|
id: string;
|
|
30
31
|
customer: Types.ObjectId | Iuser;
|
|
@@ -34,6 +35,7 @@ export interface Icontract {
|
|
|
34
35
|
cycle: string;
|
|
35
36
|
coupons: Types.ObjectId[];
|
|
36
37
|
ticketNumber: string;
|
|
38
|
+
project: Types.ObjectId;
|
|
37
39
|
}
|
|
38
40
|
export declare const Contracts: import("mongoose").Model<Icontract, {}, {}, {}, import("mongoose").Document<unknown, {}, Icontract> & Icontract & {
|
|
39
41
|
_id: Types.ObjectId;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContractReports = exports.Contracts = exports.
|
|
3
|
+
exports.ContractReports = exports.Contracts = exports.generateContractReportTicketNumber = exports.generateContractTicketNumber = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
5
|
const model_names_1 = require("../types/model-names");
|
|
6
6
|
// Function to generate simple unique ticket number
|
|
7
|
-
const
|
|
7
|
+
const generateContractTicketNumber = () => {
|
|
8
8
|
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
9
|
-
return `
|
|
9
|
+
return `CON${random}`;
|
|
10
10
|
};
|
|
11
|
-
exports.
|
|
11
|
+
exports.generateContractTicketNumber = generateContractTicketNumber;
|
|
12
|
+
const generateContractReportTicketNumber = () => {
|
|
13
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
14
|
+
return `CRT${random}`;
|
|
15
|
+
};
|
|
16
|
+
exports.generateContractReportTicketNumber = generateContractReportTicketNumber;
|
|
12
17
|
exports.Contracts = (0, mongoose_1.model)(model_names_1.MODELS.allContracts, new mongoose_1.Schema({
|
|
13
18
|
customer: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
14
19
|
sp: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
@@ -17,9 +22,10 @@ exports.Contracts = (0, mongoose_1.model)(model_names_1.MODELS.allContracts, new
|
|
|
17
22
|
cycle: { type: String, default: null },
|
|
18
23
|
coupons: [{ type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.coupon }],
|
|
19
24
|
ticketNumber: { type: String, default: null },
|
|
25
|
+
project: { type: mongoose_1.Schema.Types.ObjectId },
|
|
20
26
|
}, { timestamps: true, collection: model_names_1.MODELS.allContracts }));
|
|
21
27
|
exports.ContractReports = (0, mongoose_1.model)(model_names_1.MODELS.contractReports, new mongoose_1.Schema({
|
|
22
|
-
ticketNumber: { type: String, default: exports.
|
|
28
|
+
ticketNumber: { type: String, default: exports.generateContractReportTicketNumber, unique: true },
|
|
23
29
|
reporter: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
24
30
|
contract: { type: mongoose_1.Schema.Types.ObjectId, refPath: 'ref' },
|
|
25
31
|
ref: String,
|
|
@@ -33,7 +33,7 @@ exports.CopyrightContracts = (0, mongoose_1.model)(model_names_1.MODELS.copyrigh
|
|
|
33
33
|
sp: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
34
34
|
project: { type: mongoose_1.Schema.Types.ObjectId, ref: 'rentals' },
|
|
35
35
|
details: { type: String, default: null },
|
|
36
|
-
ticketNumber: { type: String, default: all_contracts_model_1.
|
|
36
|
+
ticketNumber: { type: String, default: all_contracts_model_1.generateContractTicketNumber, unique: true, sparse: true },
|
|
37
37
|
attachments: [String],
|
|
38
38
|
location: { lat: Number, lng: Number },
|
|
39
39
|
address: { type: String, default: null },
|
|
@@ -11,7 +11,7 @@ exports.CopyrightsBooking = (0, mongoose_1.model)(model_names_1.MODELS.copyright
|
|
|
11
11
|
project: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user, required: true },
|
|
12
12
|
jobDetails: { type: String, default: null },
|
|
13
13
|
deadline: { type: Date, required: true },
|
|
14
|
-
ticketNumber: { type: String, default: all_contracts_model_1.
|
|
14
|
+
ticketNumber: { type: String, default: all_contracts_model_1.generateContractTicketNumber, unique: true, sparse: true },
|
|
15
15
|
totalPrice: { type: Number, required: true },
|
|
16
16
|
address: { type: String, default: null },
|
|
17
17
|
location: { lat: { type: String, required: true }, lng: { type: String, required: true } },
|
|
@@ -9,7 +9,7 @@ exports.CopyRights = (0, mongoose_1.model)(model_names_1.MODELS.copyrights, new
|
|
|
9
9
|
user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
10
10
|
category: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.category },
|
|
11
11
|
price: { type: Number, default: 0 },
|
|
12
|
-
ticketNumber: { type: String, default: all_contracts_model_1.
|
|
12
|
+
ticketNumber: { type: String, default: all_contracts_model_1.generateContractTicketNumber, unique: true, sparse: true },
|
|
13
13
|
duration: { value: Number, unit: String },
|
|
14
14
|
address: { type: String, default: null },
|
|
15
15
|
searchKeywords: [String],
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FundedTransaction = exports.FundedTransactionStatus = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
7
6
|
var FundedTransactionStatus;
|
|
8
7
|
(function (FundedTransactionStatus) {
|
|
@@ -10,6 +9,10 @@ var FundedTransactionStatus;
|
|
|
10
9
|
FundedTransactionStatus["SUCCESS"] = "success";
|
|
11
10
|
FundedTransactionStatus["FAILED"] = "failed";
|
|
12
11
|
})(FundedTransactionStatus || (exports.FundedTransactionStatus = FundedTransactionStatus = {}));
|
|
12
|
+
const generateFundedTransactionTicketNumber = () => {
|
|
13
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
14
|
+
return `FND${random}`;
|
|
15
|
+
};
|
|
13
16
|
exports.FundedTransaction = (0, mongoose_1.model)(model_names_1.MODELS.fundedTransaction, new mongoose_1.Schema({
|
|
14
17
|
user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
15
18
|
createdBy: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
@@ -18,5 +21,5 @@ exports.FundedTransaction = (0, mongoose_1.model)(model_names_1.MODELS.fundedTra
|
|
|
18
21
|
contract: { type: mongoose_1.Schema.Types.ObjectId },
|
|
19
22
|
status: { type: String, default: FundedTransactionStatus.PENDING },
|
|
20
23
|
withdrawMethod: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.withdrawMethod },
|
|
21
|
-
ticketNumber: { type: String, default:
|
|
24
|
+
ticketNumber: { type: String, default: generateFundedTransactionTicketNumber, unique: true, sparse: true },
|
|
22
25
|
}, { timestamps: true, collection: model_names_1.MODELS.fundedTransaction }));
|
|
@@ -6,6 +6,7 @@ const model_names_1 = require("../types/model-names");
|
|
|
6
6
|
exports.Pages = (0, mongoose_1.model)(model_names_1.MODELS.page, new mongoose_1.Schema({
|
|
7
7
|
title: { ar: { type: String, default: null }, en: { type: String, default: null } },
|
|
8
8
|
content: { ar: { type: String, default: null }, en: { type: String, default: null } },
|
|
9
|
+
slug: { type: String, unique: true, sparse: true },
|
|
9
10
|
}, {
|
|
10
11
|
timestamps: true,
|
|
11
12
|
collection: model_names_1.MODELS.page,
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProjectCycle = exports.InviteStatus = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
7
6
|
var InviteStatus;
|
|
8
7
|
(function (InviteStatus) {
|
|
@@ -10,9 +9,13 @@ var InviteStatus;
|
|
|
10
9
|
InviteStatus["rejected"] = "rejected";
|
|
11
10
|
InviteStatus["pending"] = "pending";
|
|
12
11
|
})(InviteStatus || (exports.InviteStatus = InviteStatus = {}));
|
|
12
|
+
const generateTicketNumber = () => {
|
|
13
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
14
|
+
return `PRT${random}`;
|
|
15
|
+
};
|
|
13
16
|
exports.ProjectCycle = (0, mongoose_1.model)(model_names_1.MODELS.portfolioPost, new mongoose_1.Schema({
|
|
14
17
|
user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
15
|
-
ticketNumber: { type: String, default:
|
|
18
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
16
19
|
category: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.category },
|
|
17
20
|
subCategory: {
|
|
18
21
|
ar: { type: String, default: null },
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Producer = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
6
|
+
const generateTicketNumber = () => {
|
|
7
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
8
|
+
return `PRD${random}`;
|
|
9
|
+
};
|
|
7
10
|
exports.Producer = (0, mongoose_1.model)(model_names_1.MODELS.producer, new mongoose_1.Schema({
|
|
8
11
|
user: {
|
|
9
12
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
10
13
|
ref: model_names_1.MODELS.user,
|
|
11
14
|
},
|
|
12
|
-
ticketNumber: { type: String, default:
|
|
15
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
13
16
|
category: {
|
|
14
17
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
15
18
|
ref: model_names_1.MODELS.category,
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProducerContract = exports.ContractStatus = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
7
6
|
var ContractStatus;
|
|
8
7
|
(function (ContractStatus) {
|
|
@@ -13,8 +12,12 @@ var ContractStatus;
|
|
|
13
12
|
ContractStatus["acceptedWithUpdate"] = "accepted with update";
|
|
14
13
|
ContractStatus["complaint"] = "complaint";
|
|
15
14
|
})(ContractStatus || (exports.ContractStatus = ContractStatus = {}));
|
|
15
|
+
const generateTicketNumber = () => {
|
|
16
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
17
|
+
return `PRC${random}`;
|
|
18
|
+
};
|
|
16
19
|
exports.ProducerContract = (0, mongoose_1.model)(model_names_1.MODELS.producerContract, new mongoose_1.Schema({
|
|
17
|
-
ticketNumber: { type: String, default:
|
|
20
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
18
21
|
producer: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
19
22
|
sp: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
20
23
|
user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProjectContract = exports.ProjectContractStatus = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const copyright_contract_model_1 = require("./copyright-contract.model");
|
|
7
6
|
const model_names_1 = require("../types/model-names");
|
|
8
7
|
var ProjectContractStatus;
|
|
@@ -17,9 +16,13 @@ var ProjectContractStatus;
|
|
|
17
16
|
ProjectContractStatus["rejected"] = "rejected";
|
|
18
17
|
ProjectContractStatus["complaint"] = "complaint";
|
|
19
18
|
})(ProjectContractStatus || (exports.ProjectContractStatus = ProjectContractStatus = {}));
|
|
19
|
+
const generateTicketNumber = () => {
|
|
20
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
21
|
+
return `PRJC${random}`;
|
|
22
|
+
};
|
|
20
23
|
exports.ProjectContract = (0, mongoose_1.model)(model_names_1.MODELS.projectContract, new mongoose_1.Schema({
|
|
21
24
|
sp: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
22
|
-
ticketNumber: { type: String, default:
|
|
25
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
23
26
|
customer: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
24
27
|
project: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.portfolioPost },
|
|
25
28
|
tools: [
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RentalContracts = exports.RentalContractStatus = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
7
6
|
var RentalContractStatus;
|
|
8
7
|
(function (RentalContractStatus) {
|
|
@@ -14,8 +13,12 @@ var RentalContractStatus;
|
|
|
14
13
|
RentalContractStatus["rejected"] = "rejected";
|
|
15
14
|
RentalContractStatus["complaint"] = "complaint";
|
|
16
15
|
})(RentalContractStatus || (exports.RentalContractStatus = RentalContractStatus = {}));
|
|
16
|
+
const generateTicketNumber = () => {
|
|
17
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
18
|
+
return `RNTC${random}`;
|
|
19
|
+
};
|
|
17
20
|
exports.RentalContracts = (0, mongoose_1.model)(model_names_1.MODELS.rentalContract, new mongoose_1.Schema({
|
|
18
|
-
ticketNumber: { type: String, default:
|
|
21
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
19
22
|
customer: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
20
23
|
sp: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
21
24
|
project: { type: mongoose_1.Schema.Types.ObjectId, ref: 'rentals' },
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Rentals = exports.RentalUnits = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
7
6
|
var RentalUnits;
|
|
8
7
|
(function (RentalUnits) {
|
|
@@ -12,9 +11,13 @@ var RentalUnits;
|
|
|
12
11
|
RentalUnits["months"] = "months";
|
|
13
12
|
RentalUnits["weeks"] = "weeks";
|
|
14
13
|
})(RentalUnits || (exports.RentalUnits = RentalUnits = {}));
|
|
14
|
+
const generateTicketNumber = () => {
|
|
15
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
16
|
+
return `RNT${random}`;
|
|
17
|
+
};
|
|
15
18
|
exports.Rentals = (0, mongoose_1.model)('rentals', new mongoose_1.Schema({
|
|
16
19
|
user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
17
|
-
ticketNumber: { type: String, default:
|
|
20
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
18
21
|
category: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.category },
|
|
19
22
|
subCategory: { ar: String, en: String, _id: String },
|
|
20
23
|
tags: [{ ar: String, en: String }],
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Report = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
6
|
+
const generateTicketNumber = () => {
|
|
7
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
8
|
+
return `RPT${random}`;
|
|
9
|
+
};
|
|
7
10
|
exports.Report = (0, mongoose_1.model)(model_names_1.MODELS.report, new mongoose_1.Schema({
|
|
8
|
-
ticketNumber: { type: String, default:
|
|
11
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
9
12
|
sourceUser: {
|
|
10
13
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
11
14
|
ref: model_names_1.MODELS.user,
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TeamProject = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const cycles_1 = require("../types/cycles");
|
|
7
6
|
const model_names_1 = require("../types/model-names");
|
|
7
|
+
const generateTicketNumber = () => {
|
|
8
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
9
|
+
return `TPT${random}`;
|
|
10
|
+
};
|
|
8
11
|
exports.TeamProject = (0, mongoose_1.model)(model_names_1.MODELS.teamProject, new mongoose_1.Schema({
|
|
9
12
|
user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
10
|
-
ticketNumber: { type: String, default:
|
|
13
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
11
14
|
cover: { type: String, default: null },
|
|
12
15
|
title: { type: String, default: null },
|
|
13
16
|
desc: { type: String, default: null },
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Transaction = exports.TransactionType = exports.TransactionStatus = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
-
const all_contracts_model_1 = require("./all-contracts.model");
|
|
6
5
|
const model_names_1 = require("../types/model-names");
|
|
7
6
|
var TransactionStatus;
|
|
8
7
|
(function (TransactionStatus) {
|
|
@@ -16,6 +15,10 @@ var TransactionType;
|
|
|
16
15
|
TransactionType["DEPOSIT"] = "deposit";
|
|
17
16
|
TransactionType["WITHDRAW"] = "withdraw";
|
|
18
17
|
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
|
18
|
+
const generateTicketNumber = () => {
|
|
19
|
+
const random = Math.floor(100000 + Math.random() * 900000); // 6-digit random number
|
|
20
|
+
return `TRN${random}`;
|
|
21
|
+
};
|
|
19
22
|
exports.Transaction = (0, mongoose_1.model)(model_names_1.MODELS.transaction, new mongoose_1.Schema({
|
|
20
23
|
currency: { type: String, default: 'EGP' },
|
|
21
24
|
amount: { type: Number, default: 0 },
|
|
@@ -30,5 +33,16 @@ exports.Transaction = (0, mongoose_1.model)(model_names_1.MODELS.transaction, ne
|
|
|
30
33
|
fundAttachment: { type: [String], default: [] },
|
|
31
34
|
fundingAmount: { type: Number, default: 0 },
|
|
32
35
|
fundedBy: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
33
|
-
ticketNumber: { type: String, default:
|
|
36
|
+
ticketNumber: { type: String, default: generateTicketNumber, unique: true, sparse: true },
|
|
37
|
+
}, {
|
|
38
|
+
timestamps: true,
|
|
39
|
+
collection: model_names_1.MODELS.transaction,
|
|
40
|
+
toJSON: {
|
|
41
|
+
transform: (doc, ret) => {
|
|
42
|
+
if (ret.fundAttachment) {
|
|
43
|
+
ret.fundAttachment = ret.fundAttachment.map((attachment) => `${process.env.BUCKET_HOST}/${attachment}`);
|
|
44
|
+
}
|
|
45
|
+
return ret;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
34
48
|
}));
|