Overview
Donations are time-bound fundraising campaigns created by pastors for their churches. Each donation campaign has specific goals, bank details, contact information, and tracks individual contributions from members.Donation Schema
The donation data model captures all aspects of a fundraising campaign:See the complete schema in
donationsmodel.js:3-88Donation Status
Donation campaigns can be in one of three states:on - Active Campaign
on - Active Campaign
- Campaign is currently accepting donations
- Members can view and contribute to the campaign
- Within the start and end date window
- Default status for new campaigns
off - Paused Campaign
off - Paused Campaign
- Campaign is temporarily disabled
- Donations are not being accepted
- Can be reactivated by pastor
- Used for temporary holds or maintenance
completed - Finished Campaign
completed - Finished Campaign
- Campaign has reached its goal or end date
- No longer accepting donations
- Final state, typically not reversible
- Historical record maintained
Only pastors can change the donation status. Members can only view campaigns with status “on”.
Campaign Timeline
Start Date
The campaign start date determines when donations can begin:See validation in
donationsmodel.js:23-32End Date
The campaign end date has dual validation:See validation in
donationsmodel.js:33-42- Must be after the start date
- Must be in the future
Both date validations ensure campaigns are properly scheduled and prevent invalid date ranges.
Bank Details
Each donation campaign includes banking information for receiving funds:See schema in
donationsmodel.js:47-54- accountName - Name on the bank account
- accountNumber - Bank account number for deposits
- bankName - Name of the banking institution
Support Contact
Donation-specific contact information for donor inquiries:See schema in
donationsmodel.js:55-66- Separate from church contact - Allows campaign-specific support
- Email validation - Ensures proper email format
- Automatic lowercase - Normalizes email addresses
Donation Metrics
Metrics track the financial goals and progress of the campaign:See schema in
donationsmodel.js:67-74Target Amount
The fundraising goal for the campaign:- Required field
- Set by pastor during campaign creation
- Used to calculate progress percentage
- Campaign may be marked “completed” when reached
Minimum Amount
The minimum donation accepted per transaction:- Required field
- Enforced during donation processing
- Prevents micro-transactions
- Can vary by campaign type
Total Gotten
Running total of all verified donations:- Defaults to 0
- Updated when donations are verified
- Sum of all
donatedamounts in thedonatorsarray - Only counts payments where
paymentVerified: true
Donators Tracking
The system tracks individual contributions in thedonators array:
See schema in
donationsmodel.js:75-85Donator Record Structure
user - Donor Reference
user - Donor Reference
- ObjectId reference to User document
- Optional (allows anonymous donations)
- Links donation to member profile
- Used for donation history
donated - Contribution Amount
donated - Contribution Amount
- Numeric value of the donation
- Currency assumed from church settings
- Must meet or exceed
minAmount - Included in
totalGottenwhen verified
transactionId - Payment Reference
transactionId - Payment Reference
- Unique identifier from payment processor
- Used for reconciliation
- Required for payment verification
- String format for flexibility
paymentVerified - Verification Status
paymentVerified - Verification Status
- Boolean flag for payment confirmation
- Defaults to
false - Set to
trueafter payment verification - Only verified payments count toward
totalGotten
Multiple Donations
Users can donate multiple times to the same campaign:Each donation creates a new entry in the donators array, even if from the same user. This maintains a complete transaction history.
Relationships
Donation → Church
- Many-to-one relationship
- Required reference
- Each donation belongs to exactly one church
- Churches can have multiple donation campaigns
Donation → Users (Donators)
- Many-to-many relationship through embedded documents
- Optional references (supports anonymous donations)
- Tracks individual contributions with metadata
Common Operations
Creating a Donation Campaign
Only users with the
pastor role can create donation campaigns.- Church ID
- Campaign name
- Status (“on”, “off”, or “completed”)
- Start and end dates (both in the future)
- Description
- Bank details (account name, number, bank name)
- Support contact (phone and email)
- Metrics (target amount, minimum amount)
Making a Donation
Members can contribute to active campaigns:- Verify campaign status is “on”
- Check amount meets
minAmountrequirement - Process payment through payment gateway
- Create donator record with transaction ID
- Mark
paymentVerified: falseinitially - Verify payment asynchronously
- Update to
paymentVerified: true - Increment
totalGotten
Updating Campaign Status
Pastors can change the campaign status:- on → off: Pause campaign temporarily
- off → on: Resume accepting donations
- on/off → completed: Mark campaign as finished
Validation Rules
| Field | Validation |
|---|---|
church | Required, must be valid Church ObjectId |
donationName | Required |
donationStatus | Required, enum: “on”, “off”, “completed” |
startDate | Required, must be in the future |
endDate | Required, must be after startDate and in the future |
donationDescription | Required |
bankDetails.* | All fields required |
donationSupportContact.phone | Required |
donationSupportContact.email | Required, must match email pattern |
donationMetrics.targetAmount | Required, numeric |
donationMetrics.minAmount | Required, numeric |
donationMetrics.totalGotten | Defaults to 0 |
donators[].user | Optional ObjectId |
donators[].paymentVerified | Defaults to false |
Best Practices
- Verify payments before updating totals - Only count verified donations in
totalGotten - Validate date ranges - Ensure start date < end date and both are in the future
- Enforce minimum amounts - Check donation amount ≥
minAmountbefore processing - Store transaction IDs - Always capture payment processor transaction IDs
- Separate contact info - Use campaign-specific contacts for better donor support
- Handle anonymous donations - Allow
userfield to be null for privacy - Track verification status - Use
paymentVerifiedflag for reconciliation