payservedb 1.4.4 → 1.4.6

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/index.js CHANGED
@@ -72,7 +72,8 @@ const models = {
72
72
  Settings:require('./src/models/settings'),
73
73
  Contract:require('./src/models/contract'),
74
74
  Levy:require('./src/models/levy'),
75
- LevyType:require('./src/models/levytype')
75
+ LevyType:require('./src/models/levytype'),
76
+ Invoice:require('./src/models/invoice')
76
77
  };
77
78
 
78
79
  // Function to get models dynamically from a specific database connection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,86 @@
1
+ const mongoose = require('mongoose');
2
+ const Schema = mongoose.Schema;
3
+
4
+ const InvoiceSchema = new Schema({
5
+ invoiceNumber: {
6
+ type: String,
7
+ required: true,
8
+ unique: true,
9
+ },
10
+ client: {
11
+ name: { type: String, required: true },
12
+ email: { type: String, required: true },
13
+ address: { type: String },
14
+ },
15
+ items: [
16
+ {
17
+ description: { type: String, required: true },
18
+ quantity: { type: Number, required: true },
19
+ unitPrice: { type: Number, required: true },
20
+ }
21
+ ],
22
+ subTotal: {
23
+ type: Number,
24
+ required: true,
25
+ default: 0,
26
+ },
27
+ tax: {
28
+ type: Number,
29
+ required: true,
30
+ default: 0,
31
+ },
32
+ totalAmount: {
33
+ type: Number,
34
+ required: true,
35
+ default: 0,
36
+ },
37
+ issueDate: {
38
+ type: Date,
39
+ required: true,
40
+ default: Date.now,
41
+ },
42
+ dueDate: {
43
+ type: Date,
44
+ required: true,
45
+ },
46
+ status: {
47
+ type: String,
48
+ enum: ['Pending', 'Paid', 'Cancelled', 'Overdue', 'Partially Paid'],
49
+ default: 'Pending',
50
+ },
51
+ penalty: {
52
+ isApplied: { type: Boolean, default: false },
53
+ penaltyAmount: { type: Number, default: 0 },
54
+ penaltyDate: { type: Date },
55
+ penaltyReason: { type: String },
56
+ },
57
+ whatFor: {
58
+ invoiceType: { type: String, required: true },
59
+ description: { type: String, required: true }
60
+ },
61
+ invoiceNote: {
62
+ type: String,
63
+ default: ''
64
+ },
65
+ paymentDetails: {
66
+ paymentStatus: {
67
+ type: String,
68
+ enum: ['Pending', 'Completed', 'Failed'],
69
+ default: 'Pending'
70
+ },
71
+ paymentMethod: {
72
+ type: String,
73
+ enum: ['Credit Card', 'Bank Transfer', 'PayPal', 'Cash'],
74
+ },
75
+ paymentDate: {
76
+ type: Date,
77
+ },
78
+ transactionId: {
79
+ type: String,
80
+ default: ''
81
+ }
82
+ }
83
+ });
84
+
85
+ const Invoice = mongoose.model('Invoice', InvoiceSchema);
86
+ module.exports = Invoice
@@ -6,14 +6,14 @@ const LevySchema = new mongoose.Schema({
6
6
  required: [true, 'Levy name is required'],
7
7
  trim: true,
8
8
  },
9
- amount: {
10
- type:Number,
11
- required: [true, 'amount is required'],
12
- },
13
- levyType: {
9
+ amount: {
14
10
  type: String,
11
+ required: [true, 'amount is required'],
12
+ },
13
+ levyType: {
14
+ type: mongoose.Schema.Types.ObjectId, // Update this to reference LevyType
15
+ ref: 'LevyType',
15
16
  required: [true, 'Levy type is required'],
16
- trim: true,
17
17
  },
18
18
  levyApplicant: {
19
19
  type: String,