Income Documentation
Income Controller Documentation
File: /controllers/incomeController.php
Purpose: Manages income transactions, income types, and revenue tracking with cost center integration
Last Updated: December 19, 2024
Total Functions: 18
Lines of Code: 1,538
---
๐ Overview
The Income Controller manages all income and revenue transactions in the ERP system. It handles:
- โข Income transaction creation and management
- โข Income type categorization and hierarchy
- โข Cost center allocation and tracking
- โข Client-specific income recording
- โข Cash account integration with income posting
- โข Daily income reporting and analysis
- โข Income transaction modifications and deletions
- โข Multi-currency income support
- โข Project-based income tracking
- โข Integration with financial reporting systems
Primary Functions
- โ Create and manage income transactions
- โ Categorize income by type
- โ Allocate income to cost centers
- โ Track client-specific revenue
- โ Integrate with cash accounts
- โ Generate income reports
- โ Handle income modifications
- โ Support multi-project tracking
- โ Provide audit trails
- โ Support CRUD operations
Related Controllers
- โข expenseController.php - Expense management
- โข clientController.php - Client revenue tracking
- โข saveController.php - Cash account management
- โข FaidaController.php - Profit analysis
- โข balancereportController.php - Financial reporting
- โข sellbillController.php - Sales revenue integration
- โข costcenterController.php - Cost center management
---
๐๏ธ Database Tables
Primary Tables (Direct Operations)
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| `income` | Main income records | incomeid, incomeamount, incomedate, incometypeid, clientid, saveid, incomeDescription, projectid | |
| `incometype` | Income categorization | incometypeid, incometypename, incometypeparent, conditions | |
| `costcenterdetail` | Cost allocation | costcenterdetailid, costcenterid, incomeamount, incomeid, incomedate |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| `save` | Cash accounts | saveid, savename, savecurrentvalue, savecurrentvalueInMainCurrency | |
| `savedaily` | Daily cash movements | savedailyid, saveid, savedailyamount, savedailydate, savedailydescription | |
| `clientdebtchange` | Client balance changes | clientdebtchangeid, clientid, clientdebtchangeamount, clientdebtchangedate |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| `client` | Customer information | clientid, clientname, clientphone, clientdebt | |
| `costcenter` | Cost center master | costcenterid, costcentername, costcenterdescription | |
| `programsettings` | System configuration | id, currency_settings, decimal_places | |
| `usergroup` | User permissions | usergroupid, usergroupname, permissions |
๐ง Key Functions
Core CRUD Operations
add() (Lines 571-785)
Purpose: Creates new income transaction with cost center allocation
Parameters:
- โข
$_POST['incomeamount']- Income amount - โข
$_POST['incomedate']- Transaction date - โข
$_POST['incometypeid']- Income type category - โข
$_POST['clientid']- Client identifier - โข
$_POST['saveid']- Cash account - โข
$_POST['incomeDescription']- Description - โข
$_POST['projectid']- Project allocation - โข
$_POST['costcenterid'][]- Cost center assignments
Process Flow:
delete($incomeId) (Lines 998-1091)
Purpose: Deletes income transaction and reverses all related entries
Parameters: $incomeId - Income transaction ID
Reversal Process:
update() (Lines 1327-1355)
Purpose: Updates existing income transaction
Process: Deletes old transaction and creates new one with updated data
Query and Reporting Functions
showWithDate($from, $to, $projectid, $clientid, $saveid) (Lines 847-891)
Purpose: Retrieves income transactions by date range with optional filters
Parameters: Date range and optional filter criteria
Returns: Filtered income transaction list
showWithOneDate($condition, $date, $incomeTypeId, $clientid, $saveid) (Lines 892-930)
Purpose: Gets income transactions for specific date with conditions
Parameters: Date and filter conditions
Returns: Single-date income transactions
showWithDateAndType($from, $to, $incomeTypeId) (Lines 966-997)
Purpose: Filters income by date range and income type
Parameters: Date range and income type
Returns: Type-filtered income transactions
showwithsearch() (Lines 786-820)
Purpose: Provides search interface for income transactions
Features: Supports multiple search criteria and filters
Financial Integration Functions
getSaveValue($saveid) (Lines 1452-1466)
Purpose: Retrieves current cash account balance
Parameters: $saveid - Save account ID (optional)
Returns: Current balance or total of all accounts
getSaveValueAndPlus($savevaluechanged, $saveid) (Lines 1467-1486)
Purpose: Increases cash account balance
Parameters: Amount to add and save account ID
Process: Updates save balance and records daily transaction
getSaveValueAndMins($savevaluechanged, $saveid) (Lines 1487-1510)
Purpose: Decreases cash account balance
Parameters: Amount to subtract and save account ID
Process: Updates save balance and records daily transaction
Specialized Functions
getClients() (Lines 564-570)
Purpose: Loads active clients for dropdown selection
Returns: Array of client data
IncomeType() (Lines 545-555)
Purpose: Loads income type hierarchy for categorization
Returns: Tree structure of income types
tempdelete($incomeId) (Lines 1186-1270)
Purpose: Temporary deletion without permanent removal
Use case: For draft or pending income transactions
returndelete($incomeId) (Lines 1271-1326)
Purpose: Handles return-based income deletions
Use case: For refund or correction scenarios
---
๐ Business Logic Flow
Income Transaction Creation
User Input โ Validation โ Income Record Creation
โ
Cash Account Update โ Daily Transaction Log โ Cost Center Allocation
โ
Client Debt Adjustment โ Financial Report Update โ Completion
Income Categories and Cost Centers
Income Entry โ Type Selection โ Cost Center Allocation
โ
Amount Distribution โ Project Assignment โ Financial Posting
Cash Flow Integration
Income Transaction โ Save Account Selection โ Balance Update
โ
Daily Entry Creation โ Audit Trail โ Report Generation
---
โ ๏ธ Common Issues
Data Integrity Issues
1. Double posting: No locking mechanism to prevent duplicate transactions
2. Reverse calculations: Complex reversal logic may cause balance discrepancies
3. Cost center allocation: Total allocation validation needed
Performance Considerations
1. Complex queries: Multiple table joins for reporting
2. Date range searches: Large ranges may impact performance
3. Real-time balance updates: No caching of frequently accessed balances
Business Logic Warnings
1. Currency conversion: Multi-currency support may have rate conversion issues
2. Client debt tracking: Automatic debt adjustments need validation
3. Permission control: Access control implementation varies by function
---
๐ Dependencies
Required Files
- โข
../public/impOpreation.php- Core operations - โข
../public/include_dao.php- All DAO includes - โข
initiateStaticSessionCommingWithCurl.php- CURL session handling - โข
dailyentryfun.php- Daily transaction utilities
Database Dependencies
- โข Proper foreign key relationships between income, client, and save tables
- โข Cost center hierarchy for proper allocation
- โข User group permissions for access control
- โข Program settings for currency and decimal handling
External Dependencies
- โข Smarty templating engine for UI
- โข Multi-language support for internationalization
- โข CURL integration for external API calls
- โข YouTube integration for help videos
Financial Dependencies
- โข Integration with general ledger systems
- โข Cost accounting and allocation rules
- โข Multi-currency exchange rate handling
- โข Audit trail and compliance requirements
---
Income Management Notes:
- โข Income Types support hierarchical categorization for detailed reporting
- โข Cost Centers allow for detailed expense allocation and departmental tracking
- โข Save Integration provides real-time cash flow impact tracking
- โข Client Debt automatically adjusts customer balances for income transactions
- โข Daily Transactions maintain detailed audit trails for all cash movements
- โข Multi-Project support enables project-based revenue tracking and analysis