A sophisticated Frappe application designed for Gulf Energy Trading Company, featuring complete investor lifecycle management, multi-currency support, automated dividend processing, and intelligent project status automation.
- Multi-Currency Investment Tracking: Support for investments in different currencies with automatic conversion
- Smart Account Creation: Generates sequential investor accounts (I3001-I3999) with intelligent reuse logic
- Account Reuse System: Prevents duplicate accounts for same investor-project combinations
- Real-time Exchange Rates: Fetches current exchange rates from ERPNext Currency Exchange with manual override
- Project Integration: Links investments to specific projects for detailed tracking and reporting
- Automated Journal Entries: Creates and submits journal entries automatically upon investment submission
- Investor Closing Voucher: Comprehensive dividend processing system for bulk operations
- Automated Dividend Calculations: Smart calculation of eligible dividend amounts per investor
- Duplicate Prevention: Sophisticated system prevents processing same investors multiple times
- Processing History: Complete audit trail of all dividend distributions with detailed tracking
- Journal Entry Automation: Automatic creation of dividend distribution journal entries
- Bulk Processing: Handle multiple investors in single voucher with validation
- Intelligent Project Completion: Automatically marks projects as "Completed" when all investors processed
- Manual Override: "Force Complete Project" button for edge cases and special circumstances
- Status Validation: Checks for remaining unprocessed investors before project completion
- Audit Trail: Complete project status history with user comments and timestamps
- Reversion Logic: Automatically reverts project status on voucher cancellation
- Investment Entry β Creates investor account with reuse logic
- Multi-Project Support β Same investor can invest in multiple projects
- Dividend Processing β Bulk dividend distribution via Investor Closing Voucher
- Automated Accounting β Journal entries for both investments and dividends
- Project Completion β Automatic status updates when all investors processed
- Audit & Compliance β Complete processing history and comments
- Live Exchange Rate Fetching: Integrates with ERPNext's currency exchange system
- Manual Rate Override: Allows users to adjust exchange rates when needed
- Multi-Currency Display: Shows amounts in both invested currency and company base currency
- Real-time Conversion: Automatic calculation of converted amounts with visual feedback
- Sequential Account Numbering: I3001, I3002, I3003... format for investor accounts
- Clean Account Structure: Eliminates duplicate naming conventions
- Automated Journal Entries:
- Debits: Amount Received Account (Bank/Cash)
- Credits: Investor Account (Capital)
- Project Tagging: All journal entries tagged with associated projects
- Proper Dating: Uses investment date for all accounting entries
- Frappe Framework
- ERPNext (for currency exchange functionality)
- Python 3.8+
cd $PATH_TO_YOUR_BENCH
bench get-app https://github.com/your-repo/gulf_energy --branch main
bench install-app gulf_energy- Create Account Structure (if not exists):
# Run in Frappe console
exec(open('/path/to/setup_investor_accounts.py').read())- Migrate Database:
bench migrate-
Basic Information:
- Investor Name/Company
- Investment Date
- Country
- Invested Company
-
Financial Details:
- Invested Currency (auto-fetches exchange rate)
- Invested Amount
- Exchange Rate (editable)
- Company Currency (auto-filled)
- Converted Amount (auto-calculated)
-
Project & Account Selection:
- Invested Project (filtered by company)
- Amount Received Account (Bank/Cash accounts only)
-
Preview & Submit:
- Use "Preview Account Name" to see what will be created
- Submit to create investor account and journal entry
-
Create New Voucher:
- Select Company and Project
- Set Posting Date and Dividend Return Date
- Status automatically set to "Draft"
-
Fetch Project Investors:
- Click "Fetch Project Investors" button (appears when Company + Project selected)
- System automatically loads all investors for the project
- Excludes investors already processed in previous vouchers
- Shows duplicate prevention messages
-
Review and Process:
- Review investor list and dividend amounts
- Modify dividend percentages if needed
- Submit voucher to process dividends
-
Automated Operations on Submit:
- Creates dividend distribution journal entries
- Updates project status to "Completed" if all investors processed
- Adds audit comments to project
- Prevents duplicate processing
-
View Processing History:
- Click "View Processing History" button
- Shows all previous dividend distributions for the project
- Displays investor details, amounts, and dates
- Complete audit trail for compliance
-
Force Complete Project (for edge cases):
- Available in Actions menu for submitted vouchers
- Manually marks project as completed
- Includes confirmation dialog and audit trail
- Use when special circumstances require manual completion
The system intelligently handles account creation:
- New Investor + New Project: Creates new account (e.g., I3001 - Investor Name - Project)
- Same Investor + Same Project: Reuses existing account
- Same Investor + Different Project: Creates new account with project suffix
- Sequential Numbering: I3001, I3002, I3003... continues even with reuse
| Investor | Project | Account Number | Account Name | Display |
|---|---|---|---|---|
| DesignMelt | PROJ-001 | I3001 | DesignMelt | I3001 - DesignMelt - PROJ-001 |
| ABC Corp | PROJ-001 | I3002 | ABC Corp | I3002 - ABC Corp - PROJ-001 |
| DesignMelt | PROJ-002 | I3003 | DesignMelt | I3003 - DesignMelt - PROJ-002 |
| ABC Corp | PROJ-001 | I3002 | ABC Corp | I3002 - ABC Corp - PROJ-001 (Reused) |
Dr. Bank Account (Amount Received Account) XXX.XX
Cr. I30XX - Investor Name (Investor Account) XXX.XX
Description: "Investment by [Investor] - [Record ID] (Project: [Project Name])"
Date: Investment Date
Project: Associated Project (if selected)
Dr. I30XX - Investor Name (Investor Account) XXX.XX
Cr. Bank Account (Dividend Payment Account) XXX.XX
Description: "Dividend payment to [Investor] - [Voucher ID] (Project: [Project Name])"
Date: Dividend Return Date
Project: Associated Project
- Ensure Currency Exchange doctype has current rates
- System automatically fetches rates but allows manual override
- Exchange rates are fetched based on investment date
3000 - Equity (Group)
βββ 3110 - Investor Capital (Group)
βββ I30XX - Individual Investor Accounts (Ledger)
- Projects must be active and belong to the selected company
- Projects are automatically filtered based on company selection
- Completed and cancelled projects are excluded from selection
| Field | Type | Description | Auto-Filled |
|---|---|---|---|
| Investor Name/Company | Data | Name of investor | β |
| Invested Currency | Link | Investment currency | β |
| Invested Amount | Currency | Amount in invested currency | β |
| Exchange Rate | Float | Currency conversion rate | β (editable) |
| Company Currency | Data | Base currency | β |
| Invested Amount (Company Currency) | Currency | Converted amount | β |
| Invested Project | Link | Associated project | β |
| Project Name | Data | Project display name | β |
| Invested Company | Link | Receiving company | β |
| Country | Link | Investor's country | β |
| Amount Received Account | Link | Bank/Cash account | β |
| Investor Account | Link | Auto-created/reused account | β |
| Journal Entry | Link | Generated entry | β |
| Field | Type | Description | Auto-Filled |
|---|---|---|---|
| Series | Data | Naming series (ICV-YYYY-) | β |
| Company | Link | Processing company | β |
| Project | Link | Project for dividend processing | β |
| Project Name | Data | Project display name | β |
| Posting Date | Date | Voucher posting date | β |
| Dividend Return Date | Date | Dividend payment date | β |
| Status | Select | Draft/Submitted/Cancelled | β |
| Total Investors | Int | Number of investors | β |
| Total Investment | Currency | Sum of investments | β |
| Total Dividend Amount | Currency | Sum of dividends | β |
| Field | Type | Description | Auto-Filled |
|---|---|---|---|
| Investor Name | Link | Reference to investor | β |
| Investor ID | Data | Unique investor identifier | β |
| Investor Account | Link | Investor's account | β |
| Invested Amount | Currency | Original investment | β |
| Dividend % | Float | Dividend percentage | β |
| Eligible Dividend Amount | Currency | Calculated dividend | β |
| Dividend Return Date | Date | Payment date | β |
- Real-time Calculations: Automatic currency conversions and dividend calculations
- Smart Filtering: Context-aware dropdown filters for projects and accounts
- User Feedback: Visual indicators, notifications, and processing status updates
- Validation: Pre-submission checks, duplicate prevention, and data integrity
- Dynamic UI: Button visibility based on document state and field values
- Processing History: Interactive display of dividend distribution history
- Account Management: Sequential numbering with intelligent reuse logic
- Journal Entry Automation: Automated creation for investments and dividends
- Project Integration: Cross-module linking and status automation
- Duplicate Prevention: Sophisticated validation to prevent duplicate processing
- Error Handling: Comprehensive validation and error management
- Audit Trail: Complete transaction history with user tracking
find_existing_investor_account(): Account reuse logiccreate_investor_account(): Sequential account generationcreate_journal_entry(): Investment journal entry creationget_exchange_rate(): Currency rate fetching
fetch_project_investors(): Load unprocessed investorscreate_dividend_journal_entries(): Bulk dividend processingupdate_project_status(): Intelligent project completionforce_complete_project(): Manual project completion overrideget_investor_processing_history(): Audit trail retrieval
- Submittable DocTypes: Support draft/submitted workflow with cancellation
- Proper Indexing: Optimized for reporting, searches, and duplicate detection
- Audit Trail: Complete transaction history with timestamps and user tracking
- Data Integrity: Foreign key relationships and validation constraints
- Investor-wise Investment Summary: Complete investment history per investor
- Project-wise Investment Tracking: Total investments and dividends per project
- Currency-wise Investment Analysis: Multi-currency investment breakdowns
- Monthly/Yearly Investment Trends: Time-based investment patterns
- Dividend Distribution Reports: Complete dividend processing history
- Project Status Reports: Project completion tracking with investor counts
- Account Reuse Analytics: Statistics on account reuse and efficiency
- Complete Audit Trail: Every dividend distribution tracked with timestamps
- Investor-level Details: Individual investor processing history
- Voucher-level Summary: Bulk processing summaries with totals
- Project Completion Timeline: Track when projects were marked as completed
- User Activity Logs: Who processed what and when
- ERPNext Accounting: Full integration with chart of accounts and journal entries
- Project Management: Complete integration with ERPNext project module
- Currency Management: Uses ERPNext currency system with real-time rates
- Reporting: Compatible with ERPNext report builder and custom reports
- Dashboard Integration: Custom dashboards for investor and project analytics
- System Manager: Full access to all features including force complete project
- Accounts Manager: Investment and dividend processing capabilities
- Accounts User: Read-only access to investment and dividend records
- Project Manager: Can view project-related investment data
- Currency Validation: Ensures valid currency combinations and exchange rates
- Account Validation: Verifies account-company relationships and prevents orphaned accounts
- Project Validation: Confirms project-company alignment and active status
- Amount Validation: Prevents negative or zero investments and dividends
- Duplicate Prevention: Sophisticated checks prevent duplicate investor processing
- Date Validation: Ensures logical date sequences and prevents future dating
- Permission Checks: Validates user permissions for sensitive operations
- Create investor with same currency (exchange rate = 1)
- Create investor with different currency (auto exchange rate)
- Test manual exchange rate override
- Verify sequential account number generation
- Test account reuse for same investor-project combinations
- Test project assignment in journal entries
- Validate account filtering by company
- Test preview functionality
- Verify cancellation workflow
- Create Investor Closing Voucher and fetch investors
- Test duplicate prevention when fetching same project investors
- Verify dividend calculations and totals
- Test bulk dividend journal entry creation
- Validate processing history display
- Test project auto-completion when all investors processed
- Test force complete project functionality
- Verify voucher cancellation and project status reversion
- Multi-project investor account creation
- Cross-project dividend processing
- Project status automation with multiple vouchers
- Currency conversion accuracy across modules
- Permission-based access control
- Data integrity after cancellations and resubmissions
# Run all tests
bench run-tests gulf_energy
# Run specific test files
bench run-tests gulf_energy.tests.test_investor
bench run-tests gulf_energy.tests.test_investor_closing_voucher
# Run with coverage
bench run-tests gulf_energy --coverage- Large Dataset Handling: Test with 1000+ investors and 100+ projects
- Concurrent Processing: Multiple users processing dividends simultaneously
- Account Reuse Efficiency: Performance impact of account reuse logic
- Report Generation: Large-scale report performance and accuracy
You can install this app using the bench CLI:
cd $PATH_TO_YOUR_BENCH
bench get-app $URL_OF_THIS_REPO --branch develop
bench install-app gulf_energyThis app uses pre-commit for code formatting and linting. Please install pre-commit and enable it for this repository:
cd apps/gulf_energy
pre-commit installPre-commit is configured to use the following tools for checking and formatting your code:
- ruff
- eslint
- prettier
- pyupgrade
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
bench run-tests gulf_energy - Submit a pull request
- Follow PEP 8 for Python code
- Use ES6+ standards for JavaScript
- Document all new features
- Include unit tests for new functionality
This app can use GitHub Actions for CI. The following workflows are configured:
- CI: Installs this app and runs unit tests on every push to
developbranch - Linters: Runs Frappe Semgrep Rules and pip-audit on every pull request
- Deploy: Automated deployment to staging/production environments
- Documentation: Check the detailed guides in the
docs/folder - Issues: Report bugs and feature requests via GitHub Issues
- Community: Join the Frappe community forum for general discussions
- Exchange Rate Not Found: Ensure Currency Exchange records exist in ERPNext
- Account Creation Failed: Verify "3110 - Investor Capital" account exists
- Permission Errors: Check user roles and permissions for Account creation
- Duplicate Account Names: System now prevents duplicates with intelligent reuse
- "Fetch Project Investors" Button Missing: Ensure both Company and Project are selected
- Duplicate Processing Error: System prevents same investor being processed twice
- Project Not Found Error: Verify project exists and is active in the system
- Force Complete Project Not Working: Check if project name matches exactly
- Journal Entry Creation Failed: Verify account permissions and company settings
- Project Status Not Updating: Ensure project exists and user has Project permissions
- Processing History Empty: Check if any Investor Closing Vouchers have been submitted
- Clear Browser Cache:
Ctrl+F5or clear browser cache completely - Clear Frappe Cache:
bench clear-cacheon server - Check Error Logs: Review Frappe error logs for detailed error messages
- Verify Permissions: Ensure user has required roles and permissions
- Database Integrity: Run
bench migrateto ensure all database changes applied
- β Account Reuse System: Intelligent account reuse for same investor-project combinations
- β Investor Closing Voucher: Complete dividend processing workflow
- β Duplicate Prevention: Sophisticated validation prevents duplicate processing
- β Processing History: Complete audit trail with detailed tracking
- β Project Status Automation: Auto-completion when all investors processed
- β Manual Project Completion: Force complete project for edge cases
- β Enhanced Error Handling: Comprehensive validation and user feedback
- Investment Return Tracking: Track actual returns vs projected returns
- Advanced Dividend Calculations: Support for tiered dividend structures
- Bulk Import/Export: Excel-based bulk investor and dividend processing
- Mobile App Integration: Mobile access for investment tracking
- Advanced Analytics Dashboard: Real-time investment and dividend analytics
- API Endpoints: REST API for external system integration
- Investment Performance Metrics: ROI, IRR, and other performance indicators
- Automated Notifications: Email notifications for investors and stakeholders
- Multi-Company Consolidation: Cross-company investment reporting
- Investment Document Management: Document storage and tracking per investment
- v1.0.0 (Initial): Basic investor management module
- v1.1.0 (Q1 2025): Project integration and enhanced UI
- v1.2.0 (Q1 2025): Automated accounting and sequential numbering
- v1.3.0 (Q2 2025): Multi-currency support and exchange rate automation
- v2.0.0 (Q3 2025): Current - Complete dividend processing and project automation
- v2.1.0 (Q4 2025): Planned - Investment return tracking and advanced analytics
- v1.x to v2.0: Automatic migration with account reuse logic implementation
- Database Changes: New Investor Closing Voucher and Detail tables
- Field Additions: investor_id field added to child tables for duplicate prevention
- Method Updates: Enhanced server methods with improved error handling
MIT License
Copyright (c) 2025 Gulf Energy Trading Company
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
A Complete Solution for Investment Lifecycle Management
From initial investment tracking through dividend distribution to project completion - this system provides end-to-end automation with enterprise-grade reliability and audit capabilities.
Built with β€οΈ for Gulf Energy Trading Company
Powered by Frappe Framework & ERPNext