25 lines
879 B
JavaScript
25 lines
879 B
JavaScript
const { UserTypes, PaymentMethod } = require("../helpers/constants");
|
|
|
|
const mongoose = require("mongoose"),
|
|
Schema = mongoose.Schema;
|
|
|
|
const schema = new Schema({
|
|
invoice: { type: Schema.Types.ObjectId, ref: 'Invoice', required: true },
|
|
client: { type: Schema.Types.ObjectId, ref: UserTypes.CLIENT, required: true },
|
|
amount: { type: String, required: true },
|
|
amountDue: { type: String, required: false },
|
|
paymentMethod: {
|
|
type: String,
|
|
enum: Object.values(PaymentMethod),
|
|
message: "{VALUE} for invoice 'paymentMethod' is not supported",
|
|
},
|
|
paymentDate: { type: Date, required: true },
|
|
createdBy: { type: Schema.Types.ObjectId, ref: 'User', required: false },
|
|
updatedBy: { type: Schema.Types.ObjectId, ref: 'User', required: false }
|
|
}, {
|
|
collection: 'log_payments',
|
|
timestamps: true
|
|
});
|
|
|
|
module.exports = mongoose.model("LogPayment", schema);
|