payservedb 4.5.1 → 4.5.2

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": "4.5.1",
3
+ "version": "4.5.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -56,7 +56,19 @@ const levyContractSchema = new mongoose.Schema({
56
56
  type: mongoose.Schema.Types.ObjectId,
57
57
  ref: 'Facility',
58
58
  required: true
59
- }
59
+ },
60
+ // New field to track edit history
61
+ editHistory: [
62
+ {
63
+ editedBy: {
64
+ type: mongoose.Schema.Types.ObjectId,
65
+ ref: 'User'
66
+ },
67
+ editedAt: { type: Date, default: Date.now },
68
+ reason: { type: String, required: true },
69
+ changes: { type: Object } // Store what fields were changed
70
+ }
71
+ ]
60
72
  }, {
61
73
  timestamps: true
62
74
  });
File without changes
File without changes
File without changes
@@ -0,0 +1,110 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const supplierSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true,
8
+ index: true
9
+ },
10
+ name: {
11
+ type: String,
12
+ required: true,
13
+ trim: true,
14
+ index: true
15
+ },
16
+ email: {
17
+ type: String,
18
+ required: true,
19
+ trim: true,
20
+ lowercase: true
21
+ },
22
+ phone: {
23
+ type: String,
24
+ required: true,
25
+ trim: true
26
+ },
27
+ address: {
28
+ street: String,
29
+ city: String,
30
+ state: String,
31
+ country: String,
32
+ postalCode: String
33
+ },
34
+ contactPerson: {
35
+ name: String,
36
+ email: String,
37
+ phone: String,
38
+ position: String
39
+ },
40
+ taxIdentificationNumber: {
41
+ type: String,
42
+ trim: true
43
+ },
44
+ supplierType: {
45
+ type: String,
46
+ enum: ['product', 'service', 'both'],
47
+ default: 'both'
48
+ },
49
+ preferredCurrency: {
50
+ type: String,
51
+ default: 'KES'
52
+ },
53
+ paymentTerms: {
54
+ type: String,
55
+ default: 'net30'
56
+ },
57
+ bankDetails: {
58
+ bankName: String,
59
+ accountName: String,
60
+ accountNumber: String,
61
+ branchCode: String,
62
+ swiftCode: String
63
+ },
64
+ documents: [{
65
+ name: String,
66
+ fileUrl: String,
67
+ fileType: String,
68
+ uploadDate: {
69
+ type: Date,
70
+ default: Date.now
71
+ }
72
+ }],
73
+ status: {
74
+ type: String,
75
+ enum: ['active', 'inactive', 'blacklisted'],
76
+ default: 'active',
77
+ index: true
78
+ },
79
+ rating: {
80
+ type: Number,
81
+ min: 0,
82
+ max: 5,
83
+ default: 0
84
+ },
85
+ categories: [{
86
+ type: mongoose.Schema.Types.ObjectId,
87
+ ref: 'SupplierCategory'
88
+ }],
89
+ notes: String,
90
+ purchaseHistory: [{
91
+ poNumber: String,
92
+ poDate: Date,
93
+ amount: Number,
94
+ currency: String,
95
+ status: {
96
+ type: String,
97
+ enum: ['pending', 'completed', 'cancelled'],
98
+ default: 'pending'
99
+ }
100
+ }]
101
+ }, {
102
+ timestamps: true
103
+ });
104
+
105
+ supplierSchema.index({ name: 1, status: 1 });
106
+ supplierSchema.index({ supplierType: 1 });
107
+
108
+ const Supplier = mongoose.model('Supplier', supplierSchema);
109
+
110
+ module.exports = Supplier;