Bank Account Operations Controller Documentation
File: /controllers/bankAccountOpController.php
Purpose: Displays comprehensive bank account transaction history and operation monitoring
Last Updated: December 20, 2024
Total Functions: No custom functions (view-only controller)
Lines of Code: ~271
---
๐ Overview
The Bank Account Operations Controller is a specialized reporting and monitoring module that provides comprehensive views of all bank account activities across the system. It serves as a central hub for:
- โข Multi-controller transaction aggregation and display
- โข Bank account movement history with source identification
- โข Cross-reference linking to originating transactions
- โข Real-time account balance monitoring
- โข Filtered reporting by account, date range, and transaction type
- โข Integration with multiple transaction sources (deposits, withdrawals, transfers, etc.)
Primary Functions
- โ Aggregate transactions from multiple controllers
- โ Display comprehensive account movement history
- โ Link transactions to their source documents
- โ Show real-time account balances
- โ Filter by account, date range, and criteria
- โ Identify transaction sources and related parties
- โ Cross-reference with client and supplier data
- โ Provide audit trail for all account activities
Related Controllers
- โข depositcheckController.php - Check deposits
- โข checkwithdrawalController.php - Check withdrawals
- โข cashTransferController.php - Cash transfers
- โข datedCheckedController.php - Post-dated checks
- โข sellbillController.php - Sales transactions
- โข bankaccountController.php - Account management
---
๐๏ธ Database Tables
Primary Tables (Read Operations)
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **accountmovement** | All account transactions | accountmovementid, accountid, accountmovementamount, accountmovementtype, accountmovementdate, tablename, accountmovementmodelid | |
| **bankaccount** | Bank account master data | accountid, accountname, bankname, accountbeginingbalance |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **checkdeposit** | Check deposit transactions | checkdepositid, clientid, bankname, checkamount | |
| **checkwithdrawal** | Check withdrawal transactions | checkwithdrawalid, supplierid, checkamount | |
| **cashtransfer** | Cash transfer operations | cashtransferid, type, savename, amount | |
| **datedchecked** | Post-dated check management | datedcheckedid, clientNum, addType, done | |
| **sellbill** | Sales bill transactions | sellbillid, sellbillclientid, sellbilltotalpayed |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **client** | Customer information | clientid, clientname | |
| **supplier** | Supplier information | supplierid, suppliername | |
| **youtubelink** | Tutorial/help links | youtubelinkid, title, url |
๐ Key Functions & Actions
1. Default Action - Account Selection Interface
Location: Line 184
Purpose: Display account selection form for transaction viewing
Process Flow:
1. Load All Accounts with Bank Names:
$allAccounts = $myBankaccountEx->queryAllWithBankName();
$smarty->assign("allAccounts", $allAccounts);
```
2. **Setup Breadcrumb Navigation**:
```php
$breadcrumbObject->add('ุงุฏุงุฑุฉ ุงูุจููู><a href="bankaccountController.php?do=show">ุญุณุงุจุงุช ุงูุจููู</a> > ุงุถุงูุฉ ุญุณุงุจ', 'bankaccountController.php', 0);
```
3. **Display Selection Interface**: Uses `show.html` template for account selection
**Template Variables**:
- `$allAccounts` - All bank accounts with bank names for dropdown
- `$breadCrumb` - Navigation breadcrumb
---
### 2. **show** - Transaction History Display
**Location**: Line 201
**Purpose**: Display comprehensive transaction history for selected account with source identification
**Function Parameters**:
php
$accountId = filter_input(INPUT_POST, 'accountid'); // Target account
$from = filter_input(INPUT_POST, 'startDate'); // Date range start
$to = filter_input(INPUT_POST, 'endDate'); // Date range end
**Process Flow**:
#### **Step 1: Build Dynamic Query**
php
$query = '';
if ($accountId && $accountId != -1)
$query .= ' and accountmovement.accountid = ' . $accountId;
if ($from)
$query .= ' and date(accountmovement.accountmovementdate) >= "' . $from . '"';
if ($to)
$query .= ' and date(accountmovement.accountmovementdate) <= "' . $to . '"';
#### **Step 2: Load Movement Data**
php
$allMovements = $accountMovementExt->queryAllMovements2($query);
#### **Step 3: Source Transaction Identification and Enhancement**
For each movement record, identify source and enhance with related data:
**A. Check Deposits** (`depositcheckController.php`):
php
if ($movement->tablename == "depositcheckController.php") {
$depositData = $CheckdepositEX->loadEX($movement->accountmovementmodelid);
$movement->clientname = $depositData->clientname;
}
**B. Check Withdrawals** (`checkwithdrawalController.php`):
php
elseif ($movement->tablename == "checkwithdrawalController.php") {
$withdrawalData = $checkWithdrawalExtDAO->queryByIdExtwithsuplier($movement->accountmovementmodelid);
$movement->clientname = $withdrawalData->suppliername;
}
**C. Cash Transfers** (`cashTransferController.php`):
php
elseif ($movement->tablename == "cashTransferController.php") {
$transferData = $cashTransferExt->loadExt($movement->accountmovementmodelid);
if ($transferData->type == 1)
$movement->processname = "ุชุญููู ููุฏู ู ู ุจูู (" . $movement->bankname . ") ุฅูู ุฎุฒูุฉ (" . $transferData->savename . ")";
}
**D. Post-dated Checks** (`datedCheckedController.php`):
php
elseif ($movement->tablename == "datedCheckedController.php") {
$row = $datedCheckedDAO->load($movement->accountmovementmodelid);
if ($row->addType == 1) {
$supID = $row->clientNum;
$allSup = $supplierDAO->load($supID);
$clName = $allSup->suppliername;
} else {
$id1 = $row->clientNum;
$allClient = $clientDAO->load($id1);
$clName = $allClient->clientname;
}
$movement->clientname = $clName;
}
**E. Sales Bills** (`sellbillController.php`):
php
elseif ($movement->tablename == "sellbillController.php") {
$sellData = $mySellbillEx->loadExtWithClient($movement->accountmovementmodelid);
$movement->clientname = " " . $sellData->clientname . " / " . $movement->accountmovementmodelid . " ";
}
#### **Step 4: Display Enhanced Results**
php
$smarty->assign('allMovements', $allMovements);
// Load current account balance
$accountData = $myBankaccountRecord->load($accountId);
$smarty->assign('currentBalance', $accountData->accountbeginingbalance);
// Load support data
$youtubes = $youtubeLinkDAO->queryAll();
$smarty->assign("youtubes", $youtubes);
---
## ๐ Workflows
### Workflow 1: Account Transaction History Viewing
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ START: Select Account & Filters โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 1. Account Selection โ
โ - Choose from all available bank accounts โ
โ - Optionally set date range filters โ
โ - Submit search criteria โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 2. Build Query with Filters โ
โ - Add account ID filter (if specific account) โ
โ - Add date range filters (if specified) โ
โ - Apply to accountmovement table โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 3. Load Base Movement Data โ
โ - Query accountmovement table with filters โ
โ - Get basic transaction information โ
โ - Include amounts, dates, types โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 4. Enhance Each Transaction โ
โ FOR EACH movement: โ
โ โ โ
โ โโโ Identify source controller (tablename) โ
โ โ โ
โ โโโ Load related transaction details โ
โ โ โโ Check deposits โ client name โ
โ โ โโ Check withdrawals โ supplier name โ
โ โ โโ Cash transfers โ destination info โ
โ โ โโ Dated checks โ client/supplier โ
โ โ โโ Sales bills โ customer info โ
โ โ โ
โ โโโ Enhance movement object with details โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 5. Display Comprehensive Report โ
โ - Show enhanced transaction list โ
โ - Include source identification โ
โ - Display current account balance โ
โ - Provide links to source documents โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
---
## ๐ URL Routes & Actions
| URL Parameter | Action Description | Template Used |
|---------------|-------------------|---------------|
| `do=` (empty) | Show account selection form | `bankAccountOpview/show.html` |
| `do=show` | Display transaction history for selected account | `bankAccountOpview/show.html` |
### Required Parameters by Action
**Account Selection** (Default):
- No parameters required - displays selection form
**Transaction History** (`do=show`):
- `accountid` - Bank account ID (from POST, -1 for all accounts)
- `startDate` - Start date filter (YYYY-MM-DD format, optional)
- `endDate` - End date filter (YYYY-MM-DD format, optional)
---
## ๐ Transaction Source Integration
### Supported Transaction Sources
| Controller | Transaction Type | Data Enhancement | Key Information |
|------------|-----------------|------------------|-----------------|
| **depositcheckController.php** | Check deposits | Client name | Customer who deposited check |
| **checkwithdrawalController.php** | Check withdrawals | Supplier name | Supplier receiving payment |
| **cashTransferController.php** | Cash transfers | Transfer details | Source/destination information |
| **datedCheckedController.php** | Post-dated checks | Client/Supplier name | Based on addType flag |
| **sellbillController.php** | Sales transactions | Customer info | Customer and bill ID |
### Data Enhancement Logic
php
// Generic enhancement pattern
foreach ($allMovements as $movement) {
switch($movement->tablename) {
case "depositcheckController.php":
// Load deposit details and add client name
break;
case "checkwithdrawalController.php":
// Load withdrawal details and add supplier name
break;
case "cashTransferController.php":
// Load transfer details and enhance description
break;
// ... additional cases
}
}
---
## ๐งฎ Balance and Amount Display
### Current Balance Retrieval
php
// Get real-time account balance
$accountData = $myBankaccountRecord->load($accountId);
$currentBalance = $accountData->accountbeginingbalance;
$smarty->assign('currentBalance', $currentBalance);
### Transaction Amount Types
- **Positive Amounts**: Credits to account (deposits, transfers in)
- **Negative Amounts**: Debits from account (withdrawals, transfers out)
- **Movement Types**: Stored in `accountmovementtype` field
---
## ๐ Security & Permissions
### Authentication
- All actions require authentication: `include_once("../public/authentication.php")`
- Session-based user validation
- Account access may be user-restricted (implementation dependent)
### Data Access
- Read-only operations - no data modifications
- Cross-references multiple transaction sources safely
- Uses parameterized queries through DAO layer
### Input Validation
php
// Secure input filtering
$accountId = filter_input(INPUT_POST, 'accountid');
$from = filter_input(INPUT_POST, 'startDate');
$to = filter_input(INPUT_POST, 'endDate');
---
## ๐ฏ Use Cases & Benefits
### 1. **Account Reconciliation**
Scenario: Monthly bank statement reconciliation
- โข View all transactions for specific account and date range
- โข Cross-reference with bank statement entries
- โข Identify source of each transaction for verification
- โข Verify current system balance against statement
### 2. **Audit Trail Investigation**
Scenario: Investigating specific transaction
- โข Filter by date range when issue occurred
- โข Identify transaction source controller
- โข Follow link back to original document
- โข Verify transaction details and authorization
### 3. **Cash Flow Analysis**
Scenario: Analyzing account activity patterns
- โข View transaction history over time period
- โข Identify major deposits and withdrawals
- โข Analyze transaction frequency and amounts
- โข Track relationships with customers/suppliers
### 4. **Multi-Source Transaction Tracking**
Scenario: Understanding complete account picture
- โข See deposits from customer payments
- โข View withdrawals for supplier payments
- โข Track internal cash transfers
- โข Monitor automated transactions
---
## ๐ Display Features
### Enhanced Transaction Information
Each transaction shows:
- **Basic Data**: Date, amount, type, before/after balances
- **Source Controller**: Which module created the transaction
- **Related Party**: Customer or supplier name (when applicable)
- **Process Description**: Human-readable transaction description
- **Link Capability**: Potential linking to source documents
### Account Balance Display
- **Current Balance**: Real-time account balance
- **Transaction History**: Before/after amounts for each transaction
- **Balance Tracking**: Running balance calculations
### Filtering Capabilities
- **By Account**: Specific account or all accounts
- **By Date Range**: Flexible start/end date filtering
- **Combined Filters**: Account + date range combinations
---
## ๐ Troubleshooting
### Common Issues
1. **Missing Transaction Details**
```
Issue: Transaction shows without client/supplier name
Cause: Source data deleted or corrupted
Solution: Check source table integrity
```
2. **Incorrect Balance Display**
```
Issue: Current balance doesn't match transaction history
Cause: Balance calculation errors or missing transactions
Solution: Verify accountmovement completeness
```
3. **Source Document Not Found**
```
Issue: Cannot load related transaction details
Cause: Referenced record deleted or ID mismatch
Solution: Check foreign key integrity
```
### Debug Queries
sql
-- Check transaction source integrity
SELECT DISTINCT tablename, COUNT(*) as count
FROM accountmovement
GROUP BY tablename;
-- Verify account balance consistency
SELECT a.accountname, a.accountbeginingbalance,
SUM(CASE WHEN am.accountmovementtype = 0 THEN am.accountmovementamount ELSE -am.accountmovementamount END) as calculated
FROM bankaccount a
LEFT JOIN accountmovement am ON a.accountid = am.accountid
GROUP BY a.accountid;
-- Find orphaned transactions
SELECT * FROM accountmovement am
WHERE am.tablename = 'checkdepositController.php'
AND NOT EXISTS (SELECT 1 FROM checkdeposit cd WHERE cd.checkdepositid = am.accountmovementmodelid);
---
## ๐ง Potential Enhancements
### 1. **Export Functionality**
php
// Add CSV/Excel export capability
function exportTransactions($accountId, $startDate, $endDate) {
// Generate export file with enhanced transaction data
}
### 2. **Advanced Filtering**
php
// Add transaction type and amount range filters
$transactionType = filter_input(INPUT_POST, 'transactionType');
$minAmount = filter_input(INPUT_POST, 'minAmount');
$maxAmount = filter_input(INPUT_POST, 'maxAmount');
### 3. **Real-time Updates**
javascript
// Add AJAX refresh for real-time balance updates
setInterval(function() {
updateCurrentBalance(accountId);
}, 30000); // Update every 30 seconds
### 4. **Transaction Linking**
php
// Add direct links to source documents
function generateTransactionLink($tablename, $modelid) {
$linkMap = [
'sellbillController.php' => "sellbillController.php?do=editprint&id={$modelid}",
'depositcheckController.php' => "depositcheckController.php?do=edit&id={$modelid}"
// ... additional mappings
];
return isset($linkMap[$tablename]) ? $linkMap[$tablename] : '#';
}
```
---
๐ Related Documentation
- โข CLAUDE.md - PHP 8.2 migration guide
- โข bankaccountController.md - Account management
- โข sellbillController.md - Sales transaction integration
- โข Database Schema Documentation - Table relationships
- โข Transaction Processing Guide - Cross-controller transaction flow
---
Documented By: AI Assistant
Review Status: โ Complete
Next Review: When additional transaction sources are integrated