Date: December 15, 2025 Feature: Custom activity forms for Finance Management and Resource Management modules
The activity form system has been enhanced to provide module-specific fields based on the parent module. Activities created under Finance Management (ID=6) and Resource Management (ID=5) modules now have tailored form fields relevant to their workflows.
File: frontend/src/components/AddActivityModal.tsx
The activity modal now:
- Detects the parent module by fetching component → sub-program → module hierarchy
- Shows conditional form sections based on module type
- Displays module-specific icons (💰 for Finance, 🏗️ for Resources)
- Stores module-specific data as JSON in the database
When creating an activity under Finance Management, users see:
- Transaction Type: Expense, Reimbursement, Advance Payment, Refund
- Expense Category: Operational, Program, Capital, Administrative
- Payment Method: Cash, Bank Transfer, Mobile Money, Check
- Approval Level Required: Department Head, Director, Board Approval
- Budget Line/Code: For tracking against specific budget lines
- Expected Amount: Estimated cost
- Vendor/Payee Name: Who will be paid
- Invoice Number: For reference
- Receipt Number: For verification
Note: Finance activities hide location fields (parish, ward, county) and beneficiary fields as they're not relevant to financial transactions.
When creating an activity under Resource Management, users see:
- Activity Type: Resource Allocation, Maintenance, Capacity Building, Equipment Request, Facility Booking
- Resource Category: Equipment, Vehicle, Facility, Tools, Materials
- Quantity Needed: Number of units required
- Duration of Use: How many days the resource is needed
- Maintenance Type: (if maintenance activity) Preventive, Corrective, Emergency
- Training Topic: (if capacity building) Subject of training
- Expected Participants: (if capacity building) Number of attendees
Conditional fields appear based on activity type selection (e.g., maintenance type only shows for maintenance activities).
Migration File: database/migrations/016_add_module_specific_data_to_activities.sql
Added module_specific_data JSON column to the activities table:
ALTER TABLE activities
ADD COLUMN module_specific_data JSON DEFAULT NULL
COMMENT 'JSON field for module-specific data (Finance, Resources, etc.)';Why JSON?
- Flexible: Each module can store different fields without schema changes
- Efficient: No need for separate junction tables for each module
- Queryable: MySQL JSON functions allow filtering and searching
- Scalable: Easy to add new modules with their own field requirements
File: backend/services/me.service.js
Updated createActivity() function to:
- Accept
module_specific_datafield in the payload - Store JSON data in the database
- Handle null values appropriately
// Frontend sends:
{
name: "Vehicle Maintenance",
description: "Quarterly maintenance",
module_specific_data: JSON.stringify({
activity_type: "maintenance",
resource_category: "vehicle",
maintenance_type: "preventive",
quantity_needed: "1",
duration_of_use: "2"
})
}
// Backend stores in activities.module_specific_datamysql -u root -p me_clickup_system < database/migrations/MANUAL_MODULE_SPECIFIC_MIGRATION.sqlcd backend
node run-module-specific-migration.js- Open MySQL Workbench
- Connect to your database
- File > Run SQL Script
- Select
MANUAL_MODULE_SPECIFIC_MIGRATION.sql - Click Run
- User opens activity modal for a component under Finance or Resource module
- Modal fetches module information:
- GET
/api/components/{componentId}→ getssub_program_id - GET
/api/sub-programs/{subProgramId}→ getsmodule_id - GET
/api/programs/{moduleId}→ gets module name
- GET
- Form adapts based on
module_id:module_id === 6→ Show Finance fieldsmodule_id === 5→ Show Resource fields- Other modules → Show standard fields
- On submit:
- Module-specific data is JSON stringified
- Sent as
module_specific_datafield - Backend stores in activities table
- Backend creates activity with all standard fields + module-specific JSON
{
"transaction_type": "expense",
"expense_category": "program",
"payment_method": "bank_transfer",
"budget_line": "BL-2025-001",
"vendor_payee": "ABC Supplies",
"invoice_number": "INV-12345",
"receipt_number": "RCP-67890",
"approval_level": "director",
"expected_amount": "50000.00"
}{
"activity_type": "maintenance",
"resource_category": "vehicle",
"resource_id": "15",
"quantity_needed": "1",
"duration_of_use": "7",
"maintenance_type": "preventive",
"training_topic": null,
"participants_count": null
}- Shows all standard fields (location, beneficiaries, duration, etc.)
- Generic activity icon (✓)
- Title: "Add New [Module Name] Activity"
- Finance icon (💰) in header
- Green highlighted "Finance Details" section
- Hides location fields (parish, ward, county)
- Hides beneficiary fields
- Shows transaction tracking fields
- Title: "Add New Finance Management Activity"
- Resource icon (🏗️) in header
- Blue highlighted "Resource Management Details" section
- Shows all standard location and beneficiary fields
- Conditional fields based on activity type selection
- Title: "Add New Resource Management Activity"
Potential additions for future releases:
- Activity Details View: Display module-specific data in activity details modal
- Activity Edit: Allow editing module-specific fields
- Filtering: Filter activities by module-specific criteria
- Reporting: Generate module-specific activity reports
- Validation: Add field validation rules (e.g., budget line format)
- Resource Dropdown: Link resource activities to actual resources from inventory
- Budget Validation: Check against available budget for finance activities
- Approval Workflows: Module-specific approval rules
database/migrations/016_add_module_specific_data_to_activities.sql(NEW)database/migrations/MANUAL_MODULE_SPECIFIC_MIGRATION.sql(NEW)backend/run-module-specific-migration.js(NEW)
frontend/src/components/AddActivityModal.tsx(UPDATED - completely rewritten)
backend/services/me.service.js(UPDATED - added module_specific_data field)
MODULE_SPECIFIC_ACTIVITY_FORMS.md(NEW - this file)
- Navigate to a sub-program under Finance Management (module ID = 6)
- Go to a component
- Click "New Activity"
- Verify Finance Details section appears with green background
- Fill in finance-specific fields
- Submit and check database for
module_specific_dataJSON
- Navigate to a sub-program under Resource Management (module ID = 5)
- Go to a component
- Click "New Activity"
- Verify Resource Management Details section appears with blue background
- Select "Maintenance" as activity type
- Verify "Maintenance Type" field appears conditionally
- Submit and check database
- Navigate to any other module (Health, Education, Agriculture, etc.)
- Go to a component
- Click "New Activity"
- Verify standard form without module-specific sections
- Verify no
module_specific_datais stored
- Check that the sub-program's
module_idis correctly set to 5 or 6 - Open browser console for any API errors
- Verify component → sub-program → module hierarchy is correct
- Ensure MySQL server is running
- Check database credentials in migration script
- Verify you're running against correct database (
me_clickup_system) - Column might already exist - check with
DESCRIBE activities;
- Check browser network tab for POST /api/activities payload
- Verify
module_specific_datais included in request - Check backend logs for any SQL errors
- Confirm migration was run successfully
For issues or questions:
- Check migration logs in console output
- Verify database column exists:
DESCRIBE activities; - Check browser console for frontend errors
- Review backend logs for API errors
- Ensure component/sub-program/module relationships are correct in database
Created: December 15, 2025 Version: 1.0 Modules Enhanced: Finance Management (ID: 6), Resource Management (ID: 5)