Bank Documentation
Bank Controller Documentation
File: /controllers/bankController.php
Purpose: Manages bank master data and bank institution information
Last Updated: December 19, 2024
Total Functions: 8
Lines of Code: 519
---
๐ Overview
The Bank Controller manages bank institution master data in the ERP system. It handles:
- โข Bank institution creation and management
- โข Bank information and details maintenance
- โข Bank status management (active/inactive)
- โข Bank deletion with safety checks
- โข Integration with bank account management
- โข Chart of accounts integration for bank accounts
- โข Multi-language support for bank operations
- โข API support for external integrations
- โข Bulk operations on multiple banks
- โข Bank listing and search functionality
Primary Functions
- โ Create new bank institutions
- โ Manage bank information and details
- โ Handle bank status (active/inactive/deleted)
- โ Delete banks with relationship validation
- โ Edit and update bank information
- โ Bulk operations (hide/show/delete multiple banks)
- โ Integration with chart of accounts
- โ API support for CURL operations
- โ Multi-language interface support
- โ Bank listing with ordering
Related Controllers
- โข bankaccountController.php - Bank account management
- โข accountstree.php - Chart of accounts integration
- โข saveController.php - Cash management
- โข dailyentry.php - Bank transaction entries
- โข expensesController.php - Bank expense payments
---
๐๏ธ Database Tables
Primary Tables (Direct Operations)
| Table Name | Purpose | Key Columns |
|---|---|---|
| **bank** | Bank institutions master | bankid, bankname, bankdate, conditions, userid, webApiId |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **bankaccount** | Bank accounts | bankaccount.bankid references bank.bankid | |
| **accountstree** | Chart of accounts | Auto-created bank account elements | |
| **accountmovement** | Bank account movements | Bank transaction history |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **user** | User management | bank.userid references user.userid | |
| **youtubelink** | Help videos | Training and help materials |
๐ง Key Functions
1. Main Display (Default Action)
Purpose: Display bank creation form
Line: 96
Process Flow:
UI Elements:
- โข Bank name input field
- โข Bank details text area
- โข API ID field for external integration
2. add()
Purpose: Create new bank institution
Line: 311
Parameters (via $_POST):
- โข
bankname- Bank institution name - โข
bankdetails- Additional bank details/description - โข
webApiId- External API integration ID
Process Flow:
Default Values Set:
$myBank->bankdate = date("Y-m-d"); // Current date
$myBank->conditions = 0; // Active status
$myBank->userid = $_SESSION["userid"]; // Current user
3. show()
Purpose: Display bank listing
Line: 333
Features:
- โข Ordered bank listing
- โข Status-based filtering
- โข Integration with YouTube help links
Process Flow:
4. delete($bankId)
Purpose: Permanently delete bank with safety validation
Line: 343
Safety Checks:
1. Validates bank ID exists
2. Checks for related bank accounts
3. Only deletes if no dependent records
Process Flow:
Return Codes:
- โข 0: Success - Bank deleted
- โข 1: Cannot delete - Has related bank accounts
- โข 2: Error - Database or validation error
Critical Safety Logic:
$bankaccountData = $myBankaccountRecord->queryByBankid($bankId);
if (count($bankaccountData) <= 0) {
// Safe to delete
$myBankRecord->delete($bankId);
delTreeElement($rowDelData->bankname); // Remove from chart of accounts
} else {
// Cannot delete - has dependent bank accounts
$bankdeleteValid = 1;
}
5. deletetemp($bankId)
Purpose: Soft delete (hide) bank institution
Line: 377
Process:
- โข Sets
conditions = 1(hidden status) - โข Preserves all data and relationships
- โข Can be reversed with returndelete()
6. returndelete($bankId)
Purpose: Restore soft-deleted (hidden) bank institution
Line: 405
Process:
- โข Sets
conditions = 0(active status) - โข Makes bank visible again in listings
7. edit()
Purpose: Load bank data for editing
Line: 433
Returns: Bank record object for editing form
8. update()
Purpose: Update existing bank institution
Line: 445
Parameters (via $_POST):
- โข
bankname- Updated bank name - โข
bankdetails- Updated bank details - โข
conditions- Status (0=active, 1=hidden) - โข
bankid- Bank ID to update - โข
bankdate- Bank creation/update date
Process: Updates bank record with new information
9. executeOperation()
Purpose: Perform bulk operations on multiple banks
Line: 470
Supported Operations:
- โข Operation 1: Bulk soft delete (hide multiple banks)
- โข Operation 2: Bulk restore (show multiple banks)
- โข Operation 3: Bulk permanent delete (with safety checks)
Process Flow:
---
๐ Business Logic Flow
Bank Creation Workflow
Bank Deletion Safety Logic
Status Management
Banks have three states:
- โข Active (conditions = 0): Visible and usable
- โข Hidden (conditions = 1): Hidden but data preserved
- โข Deleted: Permanently removed (only if no dependencies)
---
โ ๏ธ Common Issues
1. Cannot Delete Bank with Accounts
Issue: Attempting to delete bank that has bank accounts
Error Message: "ูุง ูู ูู ุญุฐู ูุฐุง ุงูุจูู ุงูุง ุจุนุฏ ุญุฐู ูู ุงูุจูุงูุงุช ุงูู ุฑุชุจุทู ุจู"
Solution: Delete all bank accounts first, then delete the bank
2. Chart of Accounts Sync Issues
Issue: Bank name changes not reflected in chart of accounts
Note: Current implementation doesn't sync bank name updates to chart of accounts
Recommendation: Add chart of accounts update in update() function
3. API Integration Conflicts
Issue: webApiId conflicts for external integrations
Prevention: Validate unique webApiId values
4. Bulk Operation Partial Failures
Issue: Some banks in bulk operation succeed, others fail
Handling: System provides detailed results for each bank operation
---
๐ Dependencies
Required Files
- โข
../public/impOpreation.php- Core operations - โข
../public/authentication.php- Security - โข
../public/include_dao.php- Database layer - โข
dailyentryfun.php- Journal entry utilities - โข
initiateStaticSessionCommingWithCurl.php- API session - โข
../library/breadcrumb.php- Navigation breadcrumbs
Critical DAOs
- โข
BankDAO- Bank master data operations - โข
BankaccountDAO- Bank account relationship checks - โข
AccountstreeDAO- Chart of accounts integration
JavaScript Integration
- โข Form validation (customValidation flag)
- โข Bulk operations interface (customBank flag)
- โข Checkbox selection for bulk operations (customCheck flag)
---
๐ฏ Bank Institution Management
Bank Master Data Structure
Standard Bank Types
Common bank institutions include:
- โข Commercial banks
- โข Central banks
- โข Investment banks
- โข Credit unions
- โข Online banks
- โข International banks
---
๐ฒ Best Practices
1. Bank Creation
- โข Use descriptive, standardized bank names
- โข Include relevant details for identification
- โข Set appropriate API IDs for external integration
2. Status Management
- โข Use soft delete (hide) for temporary deactivation
- โข Only use permanent delete when absolutely necessary
- โข Always check dependencies before deletion
3. Bulk Operations
- โข Review selected items before bulk operations
- โข Monitor operation results for partial failures
- โข Use bulk operations for efficiency with large datasets
4. Integration Management
- โข Coordinate bank changes with bank account teams
- โข Ensure chart of accounts consistency
- โข Validate API integrations after changes
---
๐ API Support
CURL Integration
The controller supports API operations via CURL posts:
if (isset($_POST['curlpost']) && $_POST['curlpost'] == 1) {
// API response format
$data = array(
'status' => 1, // 1=success, 2=error
'message' => 'ุชู
ุช ุงูุนู
ููู ุจูุฌุงุญ',
'message_en' => 'Success'
);
echo json_encode($data);
}
API Actions Supported:
- โข Add bank institution
- โข Update bank institution
- โข Delete bank institution
- โข Bulk operations
External API Integration
- โข
webApiIdfield supports external system integration - โข Enables synchronization with external banking systems
- โข Facilitates data exchange with third-party applications
---
๐ Relationship Dependencies
Parent-Child Relationships
Bank (Parent)
โโโ Bank Accounts (Children)
โโโ Account Movements (Grandchildren)
โโโ Journal Entries (Great-grandchildren)
Deletion Cascade Rules:
- โข Cannot delete bank if bank accounts exist
- โข Must delete in reverse dependency order
- โข Chart of accounts elements cleaned up automatically
---
Critical Note: This controller manages bank institution master data only. Actual bank account management, transactions, and balances are handled by separate controllers (bankaccountController, etc.). Changes to bank institutions should be coordinated with bank account operations to maintain data integrity.