Spaces:
Sleeping
Sleeping
Upload 10 files
Browse files- models/CustomerModel.js +8 -0
- models/IncomeModel.js +46 -0
- models/InvoiceModel.js +4 -0
- models/TenantModel.js +40 -0
models/CustomerModel.js
CHANGED
|
@@ -44,6 +44,14 @@ const customerSchema = new mongoose.Schema(
|
|
| 44 |
ref: "Invoice",
|
| 45 |
},
|
| 46 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
},
|
| 48 |
{
|
| 49 |
timestamps: true,
|
|
|
|
| 44 |
ref: "Invoice",
|
| 45 |
},
|
| 46 |
],
|
| 47 |
+
isDeleted: {
|
| 48 |
+
type: Boolean,
|
| 49 |
+
default: false,
|
| 50 |
+
},
|
| 51 |
+
deletedAt: {
|
| 52 |
+
type: Date,
|
| 53 |
+
default: null,
|
| 54 |
+
},
|
| 55 |
},
|
| 56 |
{
|
| 57 |
timestamps: true,
|
models/IncomeModel.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import mongoose from "mongoose";
|
| 2 |
+
|
| 3 |
+
const incomeSchema = new mongoose.Schema(
|
| 4 |
+
{
|
| 5 |
+
tenant: {
|
| 6 |
+
type: mongoose.Schema.Types.ObjectId,
|
| 7 |
+
ref: "Tenant",
|
| 8 |
+
required: true,
|
| 9 |
+
index: true,
|
| 10 |
+
},
|
| 11 |
+
title: {
|
| 12 |
+
type: String,
|
| 13 |
+
required: true,
|
| 14 |
+
},
|
| 15 |
+
category: {
|
| 16 |
+
type: String,
|
| 17 |
+
default: "general",
|
| 18 |
+
},
|
| 19 |
+
amount: {
|
| 20 |
+
type: Number,
|
| 21 |
+
required: true,
|
| 22 |
+
},
|
| 23 |
+
paymentMethod: {
|
| 24 |
+
type: String,
|
| 25 |
+
default: "cash",
|
| 26 |
+
},
|
| 27 |
+
notes: {
|
| 28 |
+
type: String,
|
| 29 |
+
default: "",
|
| 30 |
+
},
|
| 31 |
+
date: {
|
| 32 |
+
type: Date,
|
| 33 |
+
default: Date.now,
|
| 34 |
+
},
|
| 35 |
+
createdBy: {
|
| 36 |
+
type: mongoose.Schema.Types.ObjectId,
|
| 37 |
+
ref: "User",
|
| 38 |
+
default: null,
|
| 39 |
+
},
|
| 40 |
+
},
|
| 41 |
+
{ timestamps: true }
|
| 42 |
+
);
|
| 43 |
+
|
| 44 |
+
incomeSchema.index({ tenant: 1, date: -1 });
|
| 45 |
+
|
| 46 |
+
export default mongoose.model("Income", incomeSchema);
|
models/InvoiceModel.js
CHANGED
|
@@ -81,6 +81,10 @@ const invoiceSchema = new mongoose.Schema(
|
|
| 81 |
type: String,
|
| 82 |
default: "",
|
| 83 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
},
|
| 85 |
{ timestamps: true }
|
| 86 |
);
|
|
|
|
| 81 |
type: String,
|
| 82 |
default: "",
|
| 83 |
},
|
| 84 |
+
isDeleted: {
|
| 85 |
+
type: Boolean,
|
| 86 |
+
default: false,
|
| 87 |
+
},
|
| 88 |
},
|
| 89 |
{ timestamps: true }
|
| 90 |
);
|
models/TenantModel.js
CHANGED
|
@@ -55,6 +55,46 @@ const tenantSchema = new mongoose.Schema(
|
|
| 55 |
default: 5,
|
| 56 |
},
|
| 57 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
},
|
| 59 |
{ timestamps: true }
|
| 60 |
);
|
|
|
|
| 55 |
default: 5,
|
| 56 |
},
|
| 57 |
},
|
| 58 |
+
monthlyFeeAmount: {
|
| 59 |
+
type: Number,
|
| 60 |
+
default: 800,
|
| 61 |
+
},
|
| 62 |
+
monthlyFeeCurrency: {
|
| 63 |
+
type: String,
|
| 64 |
+
default: "EGP",
|
| 65 |
+
},
|
| 66 |
+
nextPaymentDueAt: {
|
| 67 |
+
type: Date,
|
| 68 |
+
},
|
| 69 |
+
lastPaymentAt: {
|
| 70 |
+
type: Date,
|
| 71 |
+
},
|
| 72 |
+
payments: [
|
| 73 |
+
{
|
| 74 |
+
amount: {
|
| 75 |
+
type: Number,
|
| 76 |
+
required: true,
|
| 77 |
+
},
|
| 78 |
+
date: {
|
| 79 |
+
type: Date,
|
| 80 |
+
required: true,
|
| 81 |
+
default: Date.now,
|
| 82 |
+
},
|
| 83 |
+
method: {
|
| 84 |
+
type: String,
|
| 85 |
+
default: "manual",
|
| 86 |
+
},
|
| 87 |
+
note: {
|
| 88 |
+
type: String,
|
| 89 |
+
default: "Monthly fee payment",
|
| 90 |
+
},
|
| 91 |
+
recordedBy: {
|
| 92 |
+
type: mongoose.Schema.Types.ObjectId,
|
| 93 |
+
ref: "User",
|
| 94 |
+
default: null,
|
| 95 |
+
},
|
| 96 |
+
},
|
| 97 |
+
],
|
| 98 |
},
|
| 99 |
{ timestamps: true }
|
| 100 |
);
|