payservedb 5.3.8 → 5.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "5.3.8",
3
+ "version": "5.4.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -128,7 +128,12 @@ const handoverSchema = new mongoose.Schema({
128
128
  type: Number,
129
129
  min: 0
130
130
  },
131
- description: String
131
+ description: String,
132
+ invoiceId: {
133
+ type: mongoose.Schema.Types.ObjectId,
134
+ ref: 'Invoice',
135
+ default: null
136
+ }
132
137
  }],
133
138
  refundAmount: {
134
139
  type: Number,
@@ -105,36 +105,6 @@ const purchaseOrderSchema = new mongoose.Schema({
105
105
  type: Number,
106
106
  required: true
107
107
  },
108
-
109
- // Approvers Section
110
- approvers: [{
111
- approverId: {
112
- type: mongoose.Schema.Types.ObjectId,
113
- ref: 'User',
114
- required: true
115
- },
116
- approverName: {
117
- type: String,
118
- required: true
119
- },
120
- approverRole: {
121
- type: String,
122
- required: true
123
- },
124
- approvalStatus: {
125
- type: String,
126
- enum: ['pending', 'approved', 'rejected'],
127
- default: 'pending'
128
- },
129
- approvalDate: {
130
- type: Date
131
- },
132
- comments: {
133
- type: String,
134
- trim: true
135
- }
136
- }],
137
-
138
108
  // Document attachments
139
109
  attachments: [{
140
110
  name: {
@@ -153,22 +123,56 @@ const purchaseOrderSchema = new mongoose.Schema({
153
123
  type: Date,
154
124
  default: Date.now
155
125
  }
126
+ }],
127
+ approvalWorkflowId: {
128
+ type: mongoose.Schema.Types.ObjectId,
129
+ ref: 'ApprovalWorkflow',
130
+ required: true
131
+ },
132
+ approvalStatus: {
133
+ type: String,
134
+ enum: ['pending', 'in_progress', 'approved', 'rejected'],
135
+ default: 'pending',
136
+ index: true
137
+ },
138
+ currentStep: {
139
+ type: Number,
140
+ default: 1,
141
+ min: 1
142
+ },
143
+ approvals: [{
144
+ stepNumber: {
145
+ type: Number,
146
+ required: true
147
+ },
148
+ stepName: {
149
+ type: String,
150
+ required: true
151
+ },
152
+ approvers: [{
153
+ userId: {
154
+ type: mongoose.Schema.Types.ObjectId,
155
+ ref: 'User',
156
+ required: true
157
+ },
158
+ status: {
159
+ type: String,
160
+ enum: ['pending', 'approved', 'rejected'],
161
+ default: 'pending'
162
+ },
163
+ actionDate: {
164
+ type: Date
165
+ },
166
+ comments: {
167
+ type: String,
168
+ trim: true
169
+ }
170
+ }]
156
171
  }]
157
172
  }, {
158
173
  timestamps: true
159
174
  });
160
175
 
161
- // Virtual for tracking approval progress
162
- purchaseOrderSchema.virtual('approvalProgress').get(function () {
163
- if (!this.approvers || this.approvers.length === 0) return 0;
164
-
165
- const approvedCount = this.approvers.filter(
166
- approver => approver.approvalStatus === 'approved'
167
- ).length;
168
-
169
- return (approvedCount / this.approvers.length) * 100;
170
- });
171
-
172
176
  // Pre-save middleware to calculate totals
173
177
  purchaseOrderSchema.pre('save', function (next) {
174
178
  // Calculate subtotal
@@ -77,9 +77,53 @@ const rfqDetailsSchema = new mongoose.Schema({
77
77
  unitOfMeasure: { type: String, trim: true },
78
78
  specifications: { type: String, trim: true },
79
79
  }],
80
-
80
+ approvalWorkflowId: {
81
+ type: mongoose.Schema.Types.ObjectId,
82
+ ref: 'ApprovalWorkflow',
83
+ required: true
84
+ },
85
+ approvalStatus: {
86
+ type: String,
87
+ enum: ['pending', 'in_progress', 'approved', 'rejected'],
88
+ default: 'pending',
89
+ index: true
90
+ },
91
+ currentStep: {
92
+ type: Number,
93
+ default: 1,
94
+ min: 1
95
+ },
96
+ approvals: [{
97
+ stepNumber: {
98
+ type: Number,
99
+ required: true
100
+ },
101
+ stepName: {
102
+ type: String,
103
+ required: true
104
+ },
105
+ approvers: [{
106
+ userId: {
107
+ type: mongoose.Schema.Types.ObjectId,
108
+ ref: 'User',
109
+ required: true
110
+ },
111
+ status: {
112
+ type: String,
113
+ enum: ['pending', 'approved', 'rejected'],
114
+ default: 'pending'
115
+ },
116
+ actionDate: {
117
+ type: Date
118
+ },
119
+ comments: {
120
+ type: String,
121
+ trim: true
122
+ }
123
+ }]
124
+ }]
81
125
  }, {
82
- timestamps: true,
126
+ timestamps: true
83
127
  });
84
128
 
85
129
  const RFQDetails = mongoose.model('RFQDetails', rfqDetailsSchema);