krsyer-server-monitor-pro 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/guestguru-api/.idea/guestguru-api.iml +9 -0
  2. package/guestguru-api/.idea/misc.xml +6 -0
  3. package/guestguru-api/.idea/modules.xml +8 -0
  4. package/guestguru-api/.idea/vcs.xml +6 -0
  5. package/guestguru-api/API_DESIGN_GUIDE.md +140 -0
  6. package/guestguru-api/API_DOCUMENTATION.md +504 -0
  7. package/guestguru-api/API_REQUIREMENTS_TENANTS.md +110 -0
  8. package/guestguru-api/AVAILABLE_TENANT_ENDPOINTS.md +137 -0
  9. package/guestguru-api/BACKEND_INSTRUCTIONS.md +77 -0
  10. package/guestguru-api/DINING_MODULE_INTEGRATION.md +175 -0
  11. package/guestguru-api/FRONTEND_FINANCE_MODULE.md +151 -0
  12. package/guestguru-api/README.md +93 -0
  13. package/guestguru-api/app.json +12 -0
  14. package/guestguru-api/database.sqlite +0 -0
  15. package/guestguru-api/eas.json +21 -0
  16. package/guestguru-api/ecosystem.config.js +19 -0
  17. package/guestguru-api/fix_db_schema.js +77 -0
  18. package/guestguru-api/list_columns.js +27 -0
  19. package/guestguru-api/package.json +34 -0
  20. package/guestguru-api/postman_backend_v2.json +1745 -0
  21. package/guestguru-api/postman_collection.json +477 -0
  22. package/guestguru-api/postman_environment.json +17 -0
  23. package/guestguru-api/public/icon.png +0 -0
  24. package/guestguru-api/public/icon_b64.txt +1 -0
  25. package/guestguru-api/readd_column.js +27 -0
  26. package/guestguru-api/server.js +263 -0
  27. package/guestguru-api/test_cashfree_connection.js +52 -0
  28. package/lib/controllers/cloudflareController.js +1 -1
  29. package/lib/controllers/dockerController.js +1 -1
  30. package/lib/controllers/networkController.js +1 -1
  31. package/lib/controllers/serverController.js +1 -1
  32. package/lib/ecosystem.config.js +1 -1
  33. package/lib/middleware/saasAuth.js +1 -0
  34. package/lib/routes/cloudflareRoutes.js +1 -1
  35. package/lib/routes/dockerRoutes.js +1 -1
  36. package/lib/routes/networkRoutes.js +1 -1
  37. package/lib/routes/serverRoutes.js +1 -1
  38. package/lib/server.js +1 -1
  39. package/lib/services/cashfreeService.js +1 -1
  40. package/license-portal/README.md +93 -0
  41. package/license-portal/ecosystem.config.js +16 -0
  42. package/license-portal/package.json +9 -5
  43. package/license-portal/server.js +73 -32
  44. package/license-portal/views/pricing.html +6 -4
  45. package/package.json +1 -1
@@ -0,0 +1,110 @@
1
+ # API Requirements: Tenant Management Module
2
+
3
+ To make the `TenantsList` component dynamic and support full CRUD functionality along with current UI operations (filtering, searching, status updates), the following API endpoints and data structures are required.
4
+
5
+ ## 1. Data Models
6
+
7
+ ### **Tenant Object**
8
+ The core entity representing a tenant.
9
+
10
+ ```json
11
+ {
12
+ "id": "uuid",
13
+ "name": "string",
14
+ "email": "string",
15
+ "phone": "string",
16
+ "profileImage": "string (url)",
17
+ "roomNumber": "string",
18
+ "bedId": "string (optional)",
19
+ "joinDate": "ISO8601 Date String",
20
+ "status": "enum('Active', 'Due Payment', 'Moved Out')",
21
+ "outstandingBalance": "number",
22
+ "lastPaymentDate": "ISO8601 Date String"
23
+ }
24
+ ```
25
+
26
+ ## 2. API Endpoints
27
+
28
+ ### **A. Tenant Management (CRUD)**
29
+
30
+ #### 1. **Fetch Tenants List**
31
+ - **Endpoint**: `GET /api/tenants`
32
+ - **Description**: Retrieves a paginated list of tenants with support for filtering and searching.
33
+ - **Query Parameters**:
34
+ - `page`: Page number (default: 1)
35
+ - `limit`: Items per page (default: 10)
36
+ - `search`: Search term (matches name, roomNumber, or phone)
37
+ - `status`: Filter by status (`Active`, `Due Payment`, `Moved Out`, or `All`)
38
+ - **Response**:
39
+ ```json
40
+ {
41
+ "data": [ ...TenantObjects ],
42
+ "meta": {
43
+ "total": 50,
44
+ "page": 1,
45
+ "limit": 10
46
+ }
47
+ }
48
+ ```
49
+
50
+ #### 2. **Get Single Tenant Details**
51
+ - **Endpoint**: `GET /api/tenants/:id`
52
+ - **Description**: Fetches detailed information for a specific tenant (useful for a future detail view).
53
+
54
+ #### 3. **Add New Tenant**
55
+ - **Endpoint**: `POST /api/tenants`
56
+ - **Description**: Onboards a new tenant.
57
+ - **Body**:
58
+ ```json
59
+ {
60
+ "name": "John Doe",
61
+ "phone": "9876543210",
62
+ "roomNumber": "101",
63
+ "joinDate": "2023-01-01",
64
+ "initialPayment": 5000
65
+ }
66
+ ```
67
+
68
+ #### 4. **Update Tenant Details**
69
+ - **Endpoint**: `PUT /api/tenants/:id`
70
+ - **Description**: Updates tenant information (e.g., room change, phone number update).
71
+ - **Body**: (Partial Tenant Object)
72
+
73
+ #### 5. **Delete/Archive Tenant**
74
+ - **Endpoint**: `DELETE /api/tenants/:id`
75
+ - **Description**: Soft deletes a tenant or marks them as 'Archived'.
76
+
77
+ ### **B. Operational Actions**
78
+
79
+ #### 6. **Record Rent Payment (Collect Rent)**
80
+ - **Endpoint**: `POST /api/payments`
81
+ - **Description**: Triggered when the "Collect Rent" button is clicked. Records a payment and potentially updates the tenant's status from 'Due Payment' to 'Active'.
82
+ - **Body**:
83
+ ```json
84
+ {
85
+ "tenantId": "uuid",
86
+ "amount": 5000,
87
+ "type": "Rent",
88
+ "date": "2023-10-01"
89
+ }
90
+ ```
91
+
92
+ #### 7. **Move Out Tenant**
93
+ - **Endpoint**: `POST /api/tenants/:id/move-out`
94
+ - **Description**: Special action to mark a tenant as 'Moved Out' and free up the room/bed.
95
+ - **Body**:
96
+ ```json
97
+ {
98
+ "moveOutDate": "2023-10-15"
99
+ }
100
+ ```
101
+
102
+ ## 3. UI Integration Logic
103
+
104
+ - **Search Bar**: Debounce input and call `GET /api/tenants?search={query}`.
105
+ - **Filter Chips**: On click, call `GET /api/tenants?status={selectedStatus}`.
106
+ - **Infinite Scroll**: On reaching list end, increment `page` param and append results.
107
+ - **"Collect Rent" Button**:
108
+ 1. Opens a modal to confirm amount.
109
+ 2. Calls `POST /api/payments`.
110
+ 3. On success, local state update: remove "Due Payment" status and "Make Payment" button from that card.
@@ -0,0 +1,137 @@
1
+ # Available Tenant Endpoints
2
+
3
+ This document lists all currently implemented endpoints for Tenant Management, excluding the Create Tenant endpoint (which is already documented/fixed).
4
+
5
+ ## Base URL
6
+ `{{url}}/api/tenants`
7
+
8
+ ## Authentication
9
+ All endpoints require the following header:
10
+ - `x-access-token`: `{{admin_token}}`
11
+
12
+ ---
13
+
14
+ ## 1. Get All Tenants
15
+ Fetch a paginated list of tenants with optional search and filter.
16
+
17
+ - **Method**: `GET`
18
+ - **URL**: `/api/tenants`
19
+ - **Query Parameters**:
20
+ - `page`: (Optional) Page number (default: 1)
21
+ - `limit`: (Optional) Items per page (default: 10)
22
+ - `search`: (Optional) Filter by name or phone
23
+ - `status`: (Optional) Filter by status: `Active`, `Due Payment`, `Moved Out`, `All`
24
+ - **Response**:
25
+ ```json
26
+ {
27
+ "data": [
28
+ {
29
+ "id": "uuid",
30
+ "name": "John Doe",
31
+ "email": "john@example.com",
32
+ "phone": "9876543210",
33
+ "profileImage": "data:image/jpeg;base64,...",
34
+ "roomNumber": "101",
35
+ "status": "Active",
36
+ "outstandingBalance": 0
37
+ }
38
+ ],
39
+ "meta": {
40
+ "total": 50,
41
+ "page": 1,
42
+ "limit": 10
43
+ }
44
+ }
45
+ ```
46
+
47
+ ---
48
+
49
+ ## 2. Get Tenant Details
50
+ Fetch detailed information for a single tenant, including recent payments involved.
51
+
52
+ - **Method**: `GET`
53
+ - **URL**: `/api/tenants/:id`
54
+ - **Response**:
55
+ ```json
56
+ {
57
+ "id": "uuid",
58
+ "name": "John Doe",
59
+ "email": "john@example.com",
60
+ "phone": "9876543210",
61
+ "roomNumber": "101",
62
+ "profileImage": "data:image/jpeg;base64,...",
63
+ "documents": "data:application/pdf;base64,...",
64
+ "status": "Active",
65
+ "outstandingBalance": 5000,
66
+ "payments": [ ...last 5 payments... ]
67
+ }
68
+ ```
69
+
70
+ ---
71
+
72
+ ## 3. Update Tenant
73
+ Update tenant details such as phone, name, or swap rooms.
74
+
75
+ - **Method**: `PUT`
76
+ - **URL**: `/api/tenants/:id`
77
+ - **Body**: (Send specific fields to update)
78
+ ```json
79
+ {
80
+ "name": "John Updated",
81
+ "phone": "9999999999",
82
+ "roomNumber": "102", // Triggers room swap logic
83
+ "status": "Due Payment"
84
+ }
85
+ ```
86
+
87
+ ---
88
+
89
+ ## 4. Delete/Archive Tenant
90
+ Soft deletes the tenant and releases their room assignment.
91
+
92
+ - **Method**: `DELETE`
93
+ - **URL**: `/api/tenants/:id`
94
+ - **Response**:
95
+ ```json
96
+ {
97
+ "message": "Tenant archived/deleted successfully."
98
+ }
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 5. Move Out Tenant
104
+ Mark a tenant as moved out and free up the room.
105
+
106
+ - **Method**: `POST`
107
+ - **URL**: `/api/tenants/:id/move-out`
108
+ - **Response**:
109
+ ```json
110
+ {
111
+ "message": "Tenant moved out successfully."
112
+ }
113
+ ```
114
+
115
+ ---
116
+
117
+ ## 6. Collect Rent (Manual Payment)
118
+ Although technically under payment routes, this is crucial for tenant operations.
119
+
120
+ - **Method**: `POST`
121
+ - **URL**: `/api/payments`
122
+ - **Body**:
123
+ ```json
124
+ {
125
+ "tenantId": "uuid-of-tenant",
126
+ "amount": 5000,
127
+ "type": "monthly_rent", // optional
128
+ "date": "2023-12-16" // optional, defaults to now
129
+ }
130
+ ```
131
+ - **Response**:
132
+ ```json
133
+ {
134
+ "message": "Rent collected successfully.",
135
+ "payment": { ... }
136
+ }
137
+ ```
@@ -0,0 +1,77 @@
1
+ # Backend API Instructions for Admin Dashboard
2
+
3
+ To fully populate the Admin Dashboard in the GuestGuru application, the `GET /api/dashboard/admin` endpoint needs to return the following structure.
4
+
5
+ ## Endpoint: `GET /api/dashboard/admin`
6
+
7
+ **Current (Stubbed/Expected) Response:**
8
+ ```json
9
+ {
10
+ "totalRooms": 12,
11
+ "totalBeds": 45,
12
+ "availableBeds": 5,
13
+ "activeTenants": 40
14
+ }
15
+ ```
16
+
17
+ **Required Update:**
18
+ Please extend the response object to include `financials` and `recentActivity`.
19
+
20
+ ### 1. Financials Object
21
+ Provides data for the "Financial Overview" card.
22
+ - `financials.totalRevenue` (String/Number): Total revenue for the current month (e.g., "20,000").
23
+ - `financials.collected` (Number): Amount already collected (e.g., 15000).
24
+ - `financials.pending` (Number): Amount still pending (e.g., 5000).
25
+ - `financials.trend` (String): Trends string (e.g., "+12%").
26
+
27
+ ### 2. Recent Activity Array
28
+ Provides a list of recent events for the "Recent Activity" section.
29
+ - `recentActivity` (Array of Objects):
30
+ - `id` (String/Number): Unique identifier.
31
+ - `type` (String): One of `'payment'`, `'assignment'`, or `'maintenance'`.
32
+ - Determines the icon and color:
33
+ - `payment`: Green icon (money).
34
+ - `assignment`: Blue icon (key).
35
+ - `maintenance`: Orange icon (tools).
36
+ - `title` (String): Title of the activity (e.g., "Rent Received", "New Assignment").
37
+ - `time` (String): Relative time string (e.g., "2h ago").
38
+ - `description` (String): Brief description (e.g., "John Doe paid $500 for Room 203").
39
+
40
+ ### Example Full Response
41
+ ```json
42
+ {
43
+ "totalRooms": 12,
44
+ "totalBeds": 45,
45
+ "availableBeds": 5,
46
+ "activeTenants": 40,
47
+ "financials": {
48
+ "totalRevenue": "20,000",
49
+ "collected": 15000,
50
+ "pending": 5000,
51
+ "trend": "+12%"
52
+ },
53
+ "recentActivity": [
54
+ {
55
+ "id": 1,
56
+ "type": "payment",
57
+ "title": "Rent Received",
58
+ "time": "2h ago",
59
+ "description": "John Doe paid $500 for Room 203"
60
+ },
61
+ {
62
+ "id": 2,
63
+ "type": "assignment",
64
+ "title": "New Assignment",
65
+ "time": "5h ago",
66
+ "description": "Sarah Smith → Room 104"
67
+ },
68
+ {
69
+ "id": 3,
70
+ "type": "maintenance",
71
+ "title": "Maintenance",
72
+ "time": "1d ago",
73
+ "description": "Room 301: AC issue reported"
74
+ }
75
+ ]
76
+ }
77
+ ```
@@ -0,0 +1,175 @@
1
+ # Advanced Weekly Dining Timetable Module - Integration Guide
2
+
3
+ ## Overview
4
+ The Dining Module allows PG Owners to configure and display a weekly food menu (Monday to Sunday) for their tenants. It supports three main meals per day (Breakfast, Lunch, Dinner) with customizable timings, menu items, and optional special notes.
5
+
6
+ ---
7
+
8
+ ## 1. API Reference
9
+
10
+ ### Base URL: `/api/dining`
11
+
12
+ ### A. Get Weekly Menu
13
+ Fetches the full menu for the week. The backend guarantees a response of exactly 7 objects (Monday-Sunday), even if the owner hasn't configured some days yet (they will be returned with default empty values).
14
+
15
+ - **Endpoint**: `GET /api/dining`
16
+ - **Method**: `GET`
17
+ - **Headers**: `Authorization: Bearer <TOKEN>`
18
+ - **Access**: Owner, Admin, Tenant
19
+ - **Response**: `Array<DailyMenuObject>`
20
+
21
+ #### Response Example
22
+ ```json
23
+ [
24
+ {
25
+ "day": "Monday",
26
+ "breakfast": {
27
+ "items": ["Idli", "Sambar", "Chutney"],
28
+ "time": "07:30 - 09:30",
29
+ "enabled": true
30
+ },
31
+ "lunch": {
32
+ "items": ["Rice", "Dal", "Potato Fry"],
33
+ "time": "12:30 - 14:30",
34
+ "enabled": true
35
+ },
36
+ "dinner": {
37
+ "items": ["Chapati", "Paneer Butter Masala"],
38
+ "time": "19:30 - 21:30",
39
+ "enabled": true
40
+ },
41
+ "specialNote": "No Onion/Garlic"
42
+ },
43
+ {
44
+ "day": "Tuesday",
45
+ "breakfast": { "items": [], "time": "08:00 - 10:00", "enabled": true },
46
+ ... // Returns default structure if not set
47
+ },
48
+ ...
49
+ ]
50
+ ```
51
+
52
+ ### B. Update Menu (Bulk)
53
+ Allows the Owner to update the menu for one or multiple days at once.
54
+
55
+ - **Endpoint**: `POST /api/dining`
56
+ - **Method**: `POST`
57
+ - **Headers**: `Authorization: Bearer <TOKEN>`
58
+ - **Access**: Owner, Admin
59
+ - **Payload**: `Array<DailyMenuObject>`
60
+
61
+ #### Request Payload Example
62
+ ```json
63
+ [
64
+ {
65
+ "day": "Wednesday",
66
+ "breakfast": {
67
+ "items": ["Puri", "Bhaji"],
68
+ "time": "08:00 - 10:00",
69
+ "enabled": true
70
+ },
71
+ "lunch": {
72
+ "items": ["Veg Biryani", "Raita"],
73
+ "time": "13:00 - 14:30",
74
+ "enabled": true
75
+ },
76
+ "dinner": {
77
+ "items": ["Roti", "Dal Tadka"],
78
+ "time": "20:00 - 22:00",
79
+ "enabled": true
80
+ },
81
+ "specialNote": "Sweet included"
82
+ }
83
+ ]
84
+ ```
85
+ *Note: You only need to send the objects for the days you want to update. The backend uses the `day` field to identify the record.*
86
+
87
+ ---
88
+
89
+ ## 2. Frontend Implementation Guide (React)
90
+
91
+ ### A. Design Approach
92
+ We recommend two views:
93
+ 1. **Tabbed View (Mobile Friendly)**: Tabs for "Mon", "Tue", "Wed"... displaying that specific day's meals card.
94
+ 2. **Weekly Grid View (Desktop)**: A 7-column grid showing the entire week at a glance.
95
+
96
+ ### B. Data State
97
+ Store the menu in a Redux slice or local state.
98
+ ```javascript
99
+ const [weeklyMenu, setWeeklyMenu] = useState([]); // Array of 7 objects
100
+ const [activeDay, setActiveDay] = useState('Monday'); // For tab view
101
+ ```
102
+
103
+ ### C. Component Structure
104
+
105
+ #### `DiningDashboard.jsx` (Main Container)
106
+ - Fetches data on mount (`useEffect`).
107
+ - Renders `DayTabs` or `WeekGrid` based on screen size.
108
+ - Contains an "Edit Menu" button (Visible only to Owners).
109
+
110
+ #### `MealCard.jsx` (Dumb Component)
111
+ Displays a single meal section.
112
+ ```jsx
113
+ const MealCard = ({ title, data }) => (
114
+ <div className={`meal-card ${!data.enabled ? 'opacity-50' : ''}`}>
115
+ <div className="flex justify-between">
116
+ <h3 className="font-bold">{title}</h3>
117
+ <span className="text-sm text-gray-500">{data.time}</span>
118
+ </div>
119
+ <ul className="mt-2 list-disc pl-4">
120
+ {data.items.length > 0 ? (
121
+ data.items.map((item, idx) => <li key={idx}>{item}</li>)
122
+ ) : (
123
+ <li className="text-gray-400 italic">Not set</li>
124
+ )}
125
+ </ul>
126
+ </div>
127
+ );
128
+ ```
129
+
130
+ #### `EditMenuModal.jsx` (Form)
131
+ - **Fields needed per meal (Breakfast/Lunch/Dinner)**:
132
+ - **Items**: Tag Input (User types "Idli" + Enter -> adds to array).
133
+ - **Time**: Text Input (e.g., "08:00 - 09:00").
134
+ - **Enabled**: Toggle Switch (If off, grey out the section).
135
+ - **Special Note**: Text Area.
136
+ - **Structure**: Allow editing one day at a time to avoid a massive form.
137
+
138
+ ### D. Redux Slice (`diningSlice.js`)
139
+ ```javascript
140
+ import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
141
+ import axios from 'axios';
142
+
143
+ // Thunk to fetch
144
+ export const fetchWeeklyMenu = createAsyncThunk('dining/fetch', async () => {
145
+ const response = await axios.get('/api/dining');
146
+ return response.data;
147
+ });
148
+
149
+ // Thunk to update
150
+ export const updateDailyMenu = createAsyncThunk('dining/update', async (payload) => {
151
+ // Payload should be an array: [{ day: 'Monday', ... }]
152
+ const response = await axios.post('/api/dining', payload);
153
+ return response.data;
154
+ });
155
+
156
+ const diningSlice = createSlice({
157
+ name: 'dining',
158
+ initialState: { menu: [], loading: false },
159
+ extraReducers: (builder) => {
160
+ builder.addCase(fetchWeeklyMenu.fulfilled, (state, action) => {
161
+ state.menu = action.payload;
162
+ });
163
+ // Handle loading/error states...
164
+ }
165
+ });
166
+
167
+ export default diningSlice.reducer;
168
+ ```
169
+
170
+ ---
171
+
172
+ ## 3. Best Practices
173
+ 1. **Tag Input**: For entering food items (`["Idli", "Vada"]`), use a library like `react-tag-input` or simply listen for the `Enter` key in a text input to push to an array.
174
+ 2. **Validation**: Ensure time strings are reasonably formatted, though strict validation isn't enforced by backend.
175
+ 3. **Empty States**: The backend ensures a full week is returned, but visually handle `items: []` gracefully (e.g., show "No items listed").
@@ -0,0 +1,151 @@
1
+ # Frontend Finance Module Design & Implementation Guide
2
+
3
+ ## Overview
4
+ The Finance Module enables PG Owners to track their **Income** (from Rent Payments) and **Expenses** (Maintenance, Bills, etc.) to visualize **Profit & Loss** (P&L) on a monthly and yearly basis.
5
+
6
+ ## 1. API Integration
7
+
8
+ ### Base URL: `/api/finance`
9
+
10
+ #### A. Add Expense
11
+ - **Endpoint**: `POST /expenses`
12
+ - **Payload**:
13
+ ```json
14
+ {
15
+ "title": "Plumbing Repair",
16
+ "amount": 1500,
17
+ "category": "maintenance", // Options: maintenance, utility_bills, salary, groceries, marketing, other
18
+ "description": "Fixed leaking pipe in Room 101",
19
+ "date": "2024-12-18"
20
+ }
21
+ ```
22
+
23
+ #### B. Get Expenses List
24
+ - **Endpoint**: `GET /expenses`
25
+ - **Query Params**:
26
+ - `month`: 1-12 (Optional)
27
+ - `year`: 2024 (Optional)
28
+ - `search`: "plumbing" (Optional)
29
+
30
+ #### C. Get Financial Report (P&L)
31
+ - **Endpoint**: `GET /report`
32
+ - **Query Params**:
33
+ - `year`: YYYY (Required) - e.g., `2024`
34
+ - `month`: 1-12 (Optional) - If omitted, returns yearly breakdown.
35
+ - **Response (Monthly)**:
36
+ ```json
37
+ {
38
+ "period": "12/2024",
39
+ "stats": {
40
+ "income": 50000,
41
+ "expense": 12000,
42
+ "profit": 38000
43
+ },
44
+ "expenseBreakdown": [
45
+ { "category": "maintenance", "total": 2000 },
46
+ { "category": "utility_bills", "total": 10000 }
47
+ ]
48
+ }
49
+ ```
50
+ - **Response (Yearly)**:
51
+ ```json
52
+ {
53
+ "period": "Year 2024",
54
+ "overall": { "income": 600000, "expense": 120000, "profit": 480000 },
55
+ "monthlyBreakdown": [
56
+ { "month": 1, "monthName": "Jan", "income": 50000, "expense": 10000, "profit": 40000 },
57
+ ...
58
+ ]
59
+ }
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 2. UI Components & Design
65
+
66
+ ### A. Dashboard Cards (Summary)
67
+ Place these at the top of the **Finance/Reports** page.
68
+ - **Total Income**: Green Trend Icon + Value.
69
+ - **Total Expenses**: Red Trend Icon + Value.
70
+ - **Net Profit**: Blue/Purple Chart Icon + Value (highlighted).
71
+
72
+ ### B. Charts (Visual Analytics)
73
+ Use a library like `recharts` or `chart.js`.
74
+ 1. **Profit vs Loss (Yearly View)**:
75
+ - **Type**: Bar Chart (Sidebar or Stacked).
76
+ - **X-Axis**: Months (Jan, Feb...).
77
+ - **Bars**: Income (Green), Expense (Red).
78
+ 2. **Expense Breakdown (Monthly View)**:
79
+ - **Type**: Doughnut/Pie Chart.
80
+ - **Data**: Categories (Maintenance, Bills, etc.).
81
+
82
+ ### C. Expense Management Table
83
+ A searchable, paginated table to view history.
84
+ - **Columns**: Date, Title, Category (Badge), Amount, Actions (Delete).
85
+ - **Header Action**: "Add Expense" Button -> Opens Modal.
86
+
87
+ ### D. Add Expense Modal
88
+ - **Fields**:
89
+ - **Title**: Text Input.
90
+ - **Amount**: Number Input.
91
+ - **Category**: Dropdown (Maintenance, Bills, Salary, Groceries, Marketing, Other).
92
+ - **Date**: Date Picker (Default to Today).
93
+ - **Description**: Text Area.
94
+
95
+ ---
96
+
97
+ ## 3. Implementation Steps (React/Redux)
98
+
99
+ ### Step 1: Update Redux Slice (`financeSlice.js`)
100
+ Create a new slice to handle state.
101
+ ```javascript
102
+ const financeSlice = createSlice({
103
+ name: 'finance',
104
+ initialState: {
105
+ expenses: [],
106
+ report: null, // Stores P&L data
107
+ loading: false,
108
+ },
109
+ reducers: {},
110
+ extraReducers: (builder) => {
111
+ // Handle fetchExpenses, addExpense, fetchReport thunks
112
+ }
113
+ });
114
+ ```
115
+
116
+ ### Step 2: Create Components
117
+ 1. `FinanceDashboard.jsx`: Main container. Select Year/Month controls.
118
+ 2. `ExpenseForm.jsx`: Modal form.
119
+ 3. `PLLogic.js`: Utility to format data for charts.
120
+
121
+ ### Step 3: Aesthetic Guidelines
122
+ - **Colors**:
123
+ - Income: `#10B981` (Emerald-500)
124
+ - Expense: `#EF4444` (Red-500)
125
+ - Profit: `#6366F1` (Indigo-500)
126
+ - **Cards**: Glassmorphism effect or clean white cards with soft shadows (`shadow-lg`).
127
+ - **Typography**: Use `Inter` or `Outfit` fonts. Money values should be bold (`font-bold`).
128
+
129
+ ---
130
+
131
+ ## 4. Example Page Layout
132
+ ```
133
+ +-------------------------------------------------------+
134
+ | [Dashboard] [Rooms] [Tenants] [Finance (Active)] |
135
+ +-------------------------------------------------------+
136
+ | Year: [ 2024 v ] Month: [ December v ] |
137
+ +-------------------------------------------------------+
138
+ | [ Total Income ] [ Total Expenses ] [ Net Profit ] |
139
+ | [ $50,000 ] [ $12,000 ] [ $38,000 ] |
140
+ +-------------------------------------------------------+
141
+ | |
142
+ | [ Big Bar Chart: Income vs Expense ] |
143
+ | [ (Jan - Dec 2024 or Daily) ] |
144
+ | |
145
+ +-------------------------------------------------------+
146
+ | Recent Expenses [+ Add Expense Button] |
147
+ | --------------------------------------------------- |
148
+ | Date | Title | Category | Amount |
149
+ | 2024-12-18 | Pipe Repair | Maintenance | $1500 |
150
+ +-------------------------------------------------------+
151
+ ```