Skip to content

Issue #1207 #1214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const summary = async (Model, req, res) => {
{
$match: {
removed: false,
created: { $gte: startDate.toDate(), $lte: endDate.toDate() },
createdAt: { $gte: startDate.toDate(), $lte: endDate.toDate() },
enabled: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ const update = async (req, res) => {
? 'partially'
: 'unpaid';

const updatedDate = new Date();
const updates = {
number: req.body.number,
date: req.body.date,
amount: req.body.amount,
paymentMode: req.body.paymentMode,
ref: req.body.ref,
description: req.body.description,
updated: updatedDate,
};

const result = await Model.findOneAndUpdate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const listAll = async (req, res) => {
const result = await Model.find({
removed: false,
isPrivate: false,
}).sort({ created: sort });
}).sort({ createdAt: sort });

if (result.length > 0) {
return res.status(200).json({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const listAll = async (Model, req, res) => {
result = await Model.find({
removed: false,
})
.sort({ created: sort })
.sort({ createdAt: sort })
.populate()
.exec();
} else {
result = await Model.find({
removed: false,
enabled: enabled,
})
.sort({ created: sort })
.sort({ createdAt: sort })
.populate()
.exec();
}
Expand Down
10 changes: 1 addition & 9 deletions backend/src/models/appModels/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@ const schema = new mongoose.Schema({
email: String,
createdBy: { type: mongoose.Schema.ObjectId, ref: 'Admin' },
assigned: { type: mongoose.Schema.ObjectId, ref: 'Admin' },
created: {
type: Date,
default: Date.now,
},
updated: {
type: Date,
default: Date.now,
},
});
}, {timestamps: true});

schema.plugin(require('mongoose-autopopulate'));

Expand Down
12 changes: 2 additions & 10 deletions backend/src/models/appModels/Invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,8 @@ const invoiceSchema = new mongoose.Schema({
default: true,
},
},
],
updated: {
type: Date,
default: Date.now,
},
created: {
type: Date,
default: Date.now,
},
});
]
}, { timestamps: true });

invoiceSchema.plugin(require('mongoose-autopopulate'));
module.exports = mongoose.model('Invoice', invoiceSchema);
10 changes: 1 addition & 9 deletions backend/src/models/appModels/Payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ const paymentSchema = new mongoose.Schema({
description: {
type: String,
},
updated: {
type: Date,
default: Date.now,
},
created: {
type: Date,
default: Date.now,
},
});
}, { timestamps: true });
paymentSchema.plugin(require('mongoose-autopopulate'));
module.exports = mongoose.model('Payment', paymentSchema);
6 changes: 1 addition & 5 deletions backend/src/models/appModels/PaymentMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ const paymentModeSchema = new mongoose.Schema({
type: Boolean,
default: false,
},
created: {
type: Date,
default: Date.now,
},
});
}, {timestamps: true});

module.exports = mongoose.model('PaymentMode', paymentModeSchema);
10 changes: 1 addition & 9 deletions backend/src/models/appModels/Quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,7 @@ const quoteSchema = new mongoose.Schema({
},
},
],
updated: {
type: Date,
default: Date.now,
},
created: {
type: Date,
default: Date.now,
},
});
}, {timestamps: true});

quoteSchema.plugin(require('mongoose-autopopulate'));
module.exports = mongoose.model('Quote', quoteSchema);
6 changes: 1 addition & 5 deletions backend/src/models/appModels/Taxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ const schema = new mongoose.Schema({
type: Boolean,
default: false,
},
created: {
type: Date,
default: Date.now,
},
});
}, {timestamps: true});

module.exports = mongoose.model('Taxes', schema);
6 changes: 1 addition & 5 deletions backend/src/models/coreModels/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ const adminSchema = new Schema({
type: String,
trim: true,
},
created: {
type: Date,
default: Date.now,
},
role: {
type: String,
default: 'owner',
enum: ['owner'],
},
});
}, {timestamps: true});

module.exports = mongoose.model('Admin', adminSchema);
2 changes: 1 addition & 1 deletion backend/src/models/coreModels/AdminPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const AdminPasswordSchema = new Schema({
type: [String],
default: [],
},
});
},{timestamps: true});

// AdminPasswordSchema.index({ user: 1 });
// generating a hash
Expand Down
6 changes: 1 addition & 5 deletions backend/src/models/coreModels/Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ const uploadSchema = new mongoose.Schema({
type: String,
required: true,
},
created: {
type: Date,
default: Date.now,
},
});
}, {timestamps: true});

module.exports = mongoose.model('Upload ', uploadSchema);
8 changes: 4 additions & 4 deletions frontend/src/components/UpdateForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ export default function UpdateForm({ config, formElements, withUpload = false })
expiredDate: dayjs(newValues['expiredDate']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
};
}
if (newValues.created) {
if (newValues.createdAt) {
newValues = {
...newValues,
created: dayjs(newValues['created']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
createdAt: dayjs(newValues['createdAt']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
};
}
if (newValues.updated) {
if (newValues.updatedAt) {
newValues = {
...newValues,
updated: dayjs(newValues['updated']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
updatedAt: dayjs(newValues['updatedAt']).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
};
}
form.resetFields();
Expand Down