Compare commits

..

2 Commits

3 changed files with 42 additions and 4 deletions

View File

@ -13,7 +13,6 @@ const paymentSchema = new Schema(
state: {
type: { type: String, required: true, default: 'draft' },
},
paymentDate: { type: Date, required: false },
postedAt: { type: Date, required: false },
authorisedAt: { type: Date, required: false },
declinedAt: { type: Date, required: false },

View File

@ -0,0 +1,41 @@
import mongoose from 'mongoose';
import { generateId } from '../../utils.js';
const { Schema } = mongoose;
const userSettingsSchema = new mongoose.Schema({
_reference: { type: String, default: () => generateId()() },
user: {
type: Schema.Types.ObjectId,
ref: 'user',
required: true,
unique: true,
},
defaults: {
viewMode: { type: Schema.Types.Mixed, default: () => ({}) },
filterSidebarVisibility: {
type: Schema.Types.Mixed,
default: () => ({}),
},
columnVisibility: { type: Schema.Types.Mixed, default: () => ({}) },
collapseState: { type: Schema.Types.Mixed, default: () => ({}) },
},
createdAt: {
type: Date,
required: true,
default: Date.now,
},
updatedAt: {
type: Date,
required: true,
default: Date.now,
},
});
userSettingsSchema.virtual('id').get(function () {
return this._id;
});
userSettingsSchema.set('toJSON', { virtuals: true });
export const userSettingsModel = mongoose.model('userSettings', userSettingsSchema);

View File

@ -13,7 +13,7 @@ import {
getModelStats,
getModelHistory,
checkStates,
searchObjects
searchObjects,
} from '../../database/database.js';
import { invoiceModel } from '../../database/schemas/finance/invoice.schema.js';
@ -131,7 +131,6 @@ export const editPaymentRouteHandler = async (req, res) => {
client: req.body.client,
invoice: req.body.invoice,
amount: req.body.amount,
paymentDate: req.body.paymentDate,
paymentMethod: req.body.paymentMethod,
notes: req.body.notes,
};
@ -206,7 +205,6 @@ export const newPaymentRouteHandler = async (req, res) => {
client: invoice.client?._id || req.body.client,
invoice: req.body.invoice,
amount: req.body.amount || 0,
paymentDate: req.body.paymentDate || new Date(),
paymentMethod: req.body.paymentMethod,
notes: req.body.notes,
};