payservedb 8.9.6 → 8.9.8
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 +1 -0
- package/package.json +1 -1
- package/src/models/invoice_edit_log.js +82 -0
package/index.js
CHANGED
|
@@ -95,6 +95,7 @@ const models = {
|
|
|
95
95
|
LevyType: require("./src/models/levytype"),
|
|
96
96
|
LevyContract: require("./src/models/levycontract"),
|
|
97
97
|
Invoice: require("./src/models/invoice"),
|
|
98
|
+
InvoiceEditLog: require("./src/models/invoice_edit_log"),
|
|
98
99
|
CombinedInvoice: require("./src/models/combined_invoice"),
|
|
99
100
|
InvoiceGeneration: require("./src/models/invoice_generation_approval"),
|
|
100
101
|
ShortUrl: require("./src/models/short_urls"),
|
package/package.json
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const invoiceEditLogSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
// Invoice reference
|
|
6
|
+
invoiceId: {
|
|
7
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
invoiceNumber: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
invoiceType: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// Unit & Customer context
|
|
20
|
+
unit: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
customerName: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
// Who edited
|
|
30
|
+
editedBy: {
|
|
31
|
+
userId: {
|
|
32
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
33
|
+
ref: "User",
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
name: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// What was changed
|
|
43
|
+
changes: [
|
|
44
|
+
{
|
|
45
|
+
field: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true,
|
|
48
|
+
enum: [
|
|
49
|
+
"amount",
|
|
50
|
+
"balanceBroughtForward",
|
|
51
|
+
"totalBalance",
|
|
52
|
+
"customer",
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
previousValue: {
|
|
56
|
+
type: mongoose.Schema.Types.Mixed,
|
|
57
|
+
required: true,
|
|
58
|
+
},
|
|
59
|
+
newValue: {
|
|
60
|
+
type: mongoose.Schema.Types.Mixed,
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
description: {
|
|
64
|
+
type: String,
|
|
65
|
+
required: true,
|
|
66
|
+
// e.g. "Amount updated from KES 5,000 to KES 6,000"
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
timestamps: true, // gives you createdAt as your date & time
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
invoiceEditLogSchema.index({ invoiceId: 1 });
|
|
77
|
+
invoiceEditLogSchema.index({ invoiceNumber: 1 });
|
|
78
|
+
invoiceEditLogSchema.index({ "editedBy.userId": 1 });
|
|
79
|
+
|
|
80
|
+
const InvoiceEditLog = mongoose.model("InvoiceEditLog", invoiceEditLogSchema);
|
|
81
|
+
|
|
82
|
+
module.exports = InvoiceEditLog;
|