tango-api-schema 2.6.47 → 2.6.48
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 +1 -1
- package/schema/invoice.model.js +156 -153
package/package.json
CHANGED
package/schema/invoice.model.js
CHANGED
|
@@ -1,154 +1,157 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const invoiceSchema = new mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
clientId: {
|
|
6
|
-
type:String
|
|
7
|
-
},
|
|
8
|
-
invoice: {
|
|
9
|
-
type:String,
|
|
10
|
-
},
|
|
11
|
-
invoiceIndex: {
|
|
12
|
-
type:String,
|
|
13
|
-
},
|
|
14
|
-
stores: {
|
|
15
|
-
type:Number
|
|
16
|
-
},
|
|
17
|
-
// For TINV (advance quarterly/half-yearly/yearly) invoices: the actual
|
|
18
|
-
// list of stores covered, captured at generation time, with each store's
|
|
19
|
-
// products and their working days.
|
|
20
|
-
storeDetails: [
|
|
21
|
-
{
|
|
22
|
-
storeId: { type: String },
|
|
23
|
-
storeName: { type: String },
|
|
24
|
-
products: [
|
|
25
|
-
{
|
|
26
|
-
productName: { type: String },
|
|
27
|
-
workingdays: { type: Number },
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
companyName:{
|
|
33
|
-
type:String,
|
|
34
|
-
},
|
|
35
|
-
monthOfbilling:{
|
|
36
|
-
type:String,
|
|
37
|
-
},
|
|
38
|
-
companyAddress:{
|
|
39
|
-
type:String,
|
|
40
|
-
},
|
|
41
|
-
PlaceOfSupply: {
|
|
42
|
-
type:String,
|
|
43
|
-
},
|
|
44
|
-
GSTNumber: {
|
|
45
|
-
type:String,
|
|
46
|
-
},
|
|
47
|
-
products:{
|
|
48
|
-
type:Array
|
|
49
|
-
},
|
|
50
|
-
tax:{
|
|
51
|
-
type:Array
|
|
52
|
-
},
|
|
53
|
-
amount:{
|
|
54
|
-
type:Number
|
|
55
|
-
},
|
|
56
|
-
totalAmount:{
|
|
57
|
-
type:Number
|
|
58
|
-
},
|
|
59
|
-
paymentMethod:{
|
|
60
|
-
type:String
|
|
61
|
-
},
|
|
62
|
-
status:{
|
|
63
|
-
type:String,
|
|
64
|
-
default:'pendingCsm',
|
|
65
|
-
enum:['pendingCsm','pendingFinance','pendingApproval','approved']
|
|
66
|
-
},
|
|
67
|
-
receivedAmount:{
|
|
68
|
-
type:Number
|
|
69
|
-
},
|
|
70
|
-
billingDate:{
|
|
71
|
-
type:Date
|
|
72
|
-
},
|
|
73
|
-
dueDate:{
|
|
74
|
-
type:Date
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
type:
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
type:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
type:
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
type:Date
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
type:
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
type:String
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
type:String
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
type:String
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
type:
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
type:Number
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
type:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
type:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const invoiceSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
clientId: {
|
|
6
|
+
type:String
|
|
7
|
+
},
|
|
8
|
+
invoice: {
|
|
9
|
+
type:String,
|
|
10
|
+
},
|
|
11
|
+
invoiceIndex: {
|
|
12
|
+
type:String,
|
|
13
|
+
},
|
|
14
|
+
stores: {
|
|
15
|
+
type:Number
|
|
16
|
+
},
|
|
17
|
+
// For TINV (advance quarterly/half-yearly/yearly) invoices: the actual
|
|
18
|
+
// list of stores covered, captured at generation time, with each store's
|
|
19
|
+
// products and their working days.
|
|
20
|
+
storeDetails: [
|
|
21
|
+
{
|
|
22
|
+
storeId: { type: String },
|
|
23
|
+
storeName: { type: String },
|
|
24
|
+
products: [
|
|
25
|
+
{
|
|
26
|
+
productName: { type: String },
|
|
27
|
+
workingdays: { type: Number },
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
companyName:{
|
|
33
|
+
type:String,
|
|
34
|
+
},
|
|
35
|
+
monthOfbilling:{
|
|
36
|
+
type:String,
|
|
37
|
+
},
|
|
38
|
+
companyAddress:{
|
|
39
|
+
type:String,
|
|
40
|
+
},
|
|
41
|
+
PlaceOfSupply: {
|
|
42
|
+
type:String,
|
|
43
|
+
},
|
|
44
|
+
GSTNumber: {
|
|
45
|
+
type:String,
|
|
46
|
+
},
|
|
47
|
+
products:{
|
|
48
|
+
type:Array
|
|
49
|
+
},
|
|
50
|
+
tax:{
|
|
51
|
+
type:Array
|
|
52
|
+
},
|
|
53
|
+
amount:{
|
|
54
|
+
type:Number
|
|
55
|
+
},
|
|
56
|
+
totalAmount:{
|
|
57
|
+
type:Number
|
|
58
|
+
},
|
|
59
|
+
paymentMethod:{
|
|
60
|
+
type:String
|
|
61
|
+
},
|
|
62
|
+
status:{
|
|
63
|
+
type:String,
|
|
64
|
+
default:'pendingCsm',
|
|
65
|
+
enum:['pendingCsm','pendingFinance','pendingApproval','approved']
|
|
66
|
+
},
|
|
67
|
+
receivedAmount:{
|
|
68
|
+
type:Number
|
|
69
|
+
},
|
|
70
|
+
billingDate:{
|
|
71
|
+
type:Date
|
|
72
|
+
},
|
|
73
|
+
dueDate:{
|
|
74
|
+
type:Date
|
|
75
|
+
},
|
|
76
|
+
paymentTerm:{
|
|
77
|
+
type:Number
|
|
78
|
+
},
|
|
79
|
+
paidDate:{
|
|
80
|
+
type:Date
|
|
81
|
+
},
|
|
82
|
+
paymentType: {
|
|
83
|
+
type:String,
|
|
84
|
+
enum: ['online','banktransfer']
|
|
85
|
+
},
|
|
86
|
+
paymentReferenceId: {
|
|
87
|
+
type:String
|
|
88
|
+
},
|
|
89
|
+
fromDate:{
|
|
90
|
+
type:Date
|
|
91
|
+
},
|
|
92
|
+
toDate:{
|
|
93
|
+
type:Date
|
|
94
|
+
},
|
|
95
|
+
currency: {
|
|
96
|
+
type:String
|
|
97
|
+
},
|
|
98
|
+
orderId: {
|
|
99
|
+
type:String
|
|
100
|
+
},
|
|
101
|
+
groupName: {
|
|
102
|
+
type:String
|
|
103
|
+
},
|
|
104
|
+
groupId: {
|
|
105
|
+
type:String
|
|
106
|
+
},
|
|
107
|
+
// Purchase order this invoice is mapped to (reduces the PO's remaining
|
|
108
|
+
// balance). Empty when the invoice isn't tied to a PO.
|
|
109
|
+
purchaseOrderNumber: {
|
|
110
|
+
type:String
|
|
111
|
+
},
|
|
112
|
+
discountAmount: {
|
|
113
|
+
type:Number
|
|
114
|
+
},
|
|
115
|
+
discountPercentage: {
|
|
116
|
+
type:Number
|
|
117
|
+
},
|
|
118
|
+
paymentStatus:{
|
|
119
|
+
type:String,
|
|
120
|
+
default:'unpaid',
|
|
121
|
+
// 'partial' = paidAmount > 0 && paidAmount < totalAmount.
|
|
122
|
+
// Server derives this in recordPayment so the value stays in sync.
|
|
123
|
+
enum: ['paid','unpaid','partial']
|
|
124
|
+
},
|
|
125
|
+
// Running total of all payments recorded against this invoice. Sum of
|
|
126
|
+
// paymentHistory[].amount; persisted for easy querying / display so
|
|
127
|
+
// the frontend doesn't need to re-sum every render.
|
|
128
|
+
paidAmount:{
|
|
129
|
+
type:Number,
|
|
130
|
+
default:0
|
|
131
|
+
},
|
|
132
|
+
// Append-only audit trail. Each entry is one payment received from
|
|
133
|
+
// the client. recordedAt is server-set; the rest comes from the form.
|
|
134
|
+
paymentHistory:[{
|
|
135
|
+
amount:{type:Number, required:true},
|
|
136
|
+
date:{type:Date, required:true},
|
|
137
|
+
method:{type:String, enum:['banktransfer','upi','cheque','card','cash','other']},
|
|
138
|
+
reference:{type:String},
|
|
139
|
+
notes:{type:String},
|
|
140
|
+
recordedBy:{type:String},
|
|
141
|
+
recordedAt:{type:Date, default:Date.now}
|
|
142
|
+
}],
|
|
143
|
+
advanceInvoice:{
|
|
144
|
+
type:Boolean,
|
|
145
|
+
default:false
|
|
146
|
+
},
|
|
147
|
+
tempIndex:{ type:Number },
|
|
148
|
+
advancePeriod:{ type:String },
|
|
149
|
+
advanceMonths:{ type:Number },
|
|
150
|
+
},{
|
|
151
|
+
strict: true,
|
|
152
|
+
versionKey: false,
|
|
153
|
+
timestamps: true,
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
|
|
154
157
|
export default mongoose.model('invoice', invoiceSchema);
|