Spaces:
Running
Running
feat: implement core backend POS API with authentication, role-based access control, menu management, and order processing logic.
1e480b5 Download src/models/Expense.js from aliroohan179/face: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/models/Expense.js
- Command line
-
hf download hf://spaces/aliroohan179/face/src/models/Expense.js
-
curl -L -o Expense.js https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/models/Expense.js
1.27 kB
| const mongoose = require('mongoose'); | |
| const editLogEntrySchema = new mongoose.Schema( | |
| { | |
| user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }, | |
| timestamp: { type: Date, default: Date.now }, | |
| changes: { type: String, required: true }, // human-readable diff string | |
| }, | |
| { _id: false } | |
| ); | |
| const expenseSchema = new mongoose.Schema( | |
| { | |
| title: { type: String, required: true, trim: true }, // e.g. "Ali's Salary - July" | |
| category: { | |
| type: String, | |
| enum: ['Salary', 'Rent', 'Utilities', 'Raw Material', 'Maintenance', 'Misc'], | |
| required: true, | |
| }, | |
| amount: { type: Number, required: true, min: 0 }, | |
| date: { type: Date, required: true }, | |
| note: { type: String, default: '' }, | |
| // No receiptImage — receipts are generated on-demand from data | |
| recurring: { type: Boolean, default: false }, | |
| frequency: { type: String, enum: ['monthly', 'weekly', null], default: null }, | |
| createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }, | |
| editLog: { type: [editLogEntrySchema], default: [] }, | |
| }, | |
| { timestamps: true } | |
| ); | |
| expenseSchema.index({ date: -1 }); | |
| expenseSchema.index({ category: 1, date: -1 }); | |
| module.exports = mongoose.model('Expense', expenseSchema); | |