๐Ÿ“š ERP Documentation Viewer

Beautiful, colorful documentation for your ERP system

Bank Account Deficit Controller Documentation

File: /controllers/bankAccountDeficitController.php

Purpose: Manages bank account deficit resolution and balance adjustments for financial reconciliation

Last Updated: December 20, 2024

Total Functions: 3

Lines of Code: ~329

---

๐Ÿ“‹ Overview

The Bank Account Deficit Controller is a specialized financial module that handles bank account deficit resolution and balance corrections. It provides:

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Primary Tables (Direct Operations)

Table NamePurposeKey Columns
**accountmovement**Account transaction logaccountmovementid, accountid, accountmovementamount, accountmovementtype, accountmovementdate, tablename, bankid
**bankaccount**Bank account master dataaccountid, accountbeginingbalance, accountname, bankid, userid, treeId
**accountmovementkind**Transaction type categoriesaccountmovementkindid, accountmovementkindname, accountmovementkindcomment
### Financial Integration Tables

Table NamePurposeKey Columns
**dailyentry**Journal entry headersdailyentryid, entryComment, entryDate
**dailyentrycreditor**Credit side of journal entriesdailyentrycreditorid, dailyentryid, accountstreeid, value
**dailyentrydebtor**Debit side of journal entriesdailyentrydebtoreid, dailyentryid, accountstreeid, value
**accountstree**Chart of accountsaccountstreeid, name, parentid, accounttype
### Reference Tables

Table NamePurposeKey Columns
**bank**Bank master databankid, bankname, bankcode
**youtubelink**Tutorial/help linksyoutubelinkid, title, url
**user**System usersuserid, username
---

๐Ÿ”‘ Key Functions

1. Default Action - Deficit Adjustment Form

Location: Line 117

Purpose: Display form for creating new deficit adjustments

Process Flow:

1. Load authentication and permission checks

2. Query all banks for dropdown selection

3. Load account movement kinds (transaction types)

4. Display deficit adjustment form via add.html template

Template Variables:

---

2. add() - Process Deficit Adjustment

Location: Line 222

Purpose: Execute deficit adjustment with complete accounting integration

Function Signature:

function add()

Process Flow:

1. Extract Form Data:

   $bankid = $_POST["ddlBank"];
   $accountid = $_POST["accountid"];
   $changetype = (int) $_POST["changetype"]; // 0=increase, 1=decrease
   $changeamount = $_POST["changeamount"];
   ```

2. **Load Current Account Balance**:
   ```php
   $account = $myBankaccountRecord->load($accountid);
   $balanceBefore = $account->accountbeginingbalance;
   ```

3. **Calculate New Balance Based on Operation Type**:
   - **Increase (changetype = 0)**: `$balanceAfter = $balanceBefore + $changeamount`
   - **Decrease (changetype = 1)**: `$balanceAfter = $balanceBefore - $changeamount`

4. **Create Account Movement Record**:
   ```php
   $myAccountmovement->accountmovementbefore = $balanceBefore;
   $myAccountmovement->accountmovementamount = $changeamount;
   $myAccountmovement->accountmovementafter = $balanceAfter;
   $myAccountmovement->tablename = "bankAccountDeficitController.php";
   ```

5. **Update Account Balance**:
   ```php
   $account->accountbeginingbalance = $balanceAfter;
   $myBankaccountRecord->update($account, $account->comment);
   ```

6. **Generate Journal Entries**:
   - **For Deficit Increase (Interest Income)**:
     - **Debit**: Bank Account (Asset)
     - **Credit**: Account #393 (Interest Income)
   - **For Deficit Decrease (Bank Charges)**:
     - **Debit**: Account #65 (Bank Expenses)  
     - **Credit**: Bank Account (Asset)

**Accounting Logic**:
php

if ($changetype == 1) { // Decrease - Bank charges

$dailyEntryDebtor->accountstreeid = 65; // Bank expenses

$dailyEntryCreditor->accountstreeid = $account->treeId; // Bank account

} elseif ($changetype == 0) { // Increase - Interest income

$dailyEntryDebtor->accountstreeid = $account->treeId; // Bank account

$dailyEntryCreditor->accountstreeid = 393; // Interest income

}

---

### 3. **show()** - Transaction History Display  
**Location**: Line 146  
**Purpose**: Display filtered deficit adjustment history with search capabilities

**Function Signature**:
php

// Parameters from $_REQUEST

$startDate = $_REQUEST['from'];

$endDate = $_REQUEST['to'];

$bankid = $_REQUEST['bankid'];

$accountid = $_REQUEST['accountid'];

$accountmovementkindid = $_REQUEST['accountmovementkindid'];

**Process Flow**:
1. **Build Dynamic Query String**:
   ```php
   $queryString = '';
   if (isset($bankid) && $bankid > 0) {
       $queryString .= ' AND accountmovement.bankid = ' . $bankid;
   }
   if (isset($accountid) && $accountid > 0) {
       $queryString .= ' AND accountmovement.accountid = ' . $accountid;
   }
   ```

2. **Apply Date Filters**:
   ```php
   if (isset($startDate) && !empty($startDate)) {
       $queryString .= ' AND DATE(accountmovement.accountmovementdate) >= "' . $startDate . '"';
   }
   if (isset($endDate) && !empty($endDate)) {
       $queryString .= ' AND DATE(accountmovement.accountmovementdate) <= "' . $endDate . '"';
   }
   ```

3. **Default to Today if No Filters**:
   ```php
   if ($queryString == '') {
       $queryString .= ' AND DATE(accountmovement.accountmovementdate) >= "' . $today . '"';
   }
   ```

4. **Filter by Controller Source**:
   ```php
   $queryString .= ' AND accountmovement.tablename = "bankAccountDeficitController.php"';
   ```

5. **Load and Display Results**:
   - Query movement data with extended information
   - Load reference data (banks, accounts, movement kinds)
   - Display via `show.html` template

---

### 4. **edit($id)** - Load Single Transaction
**Location**: Line 318  
**Purpose**: Load specific deficit adjustment record for display/editing

**Function Signature**:
php

function edit($id)

**Process Flow**:
php

$data = $myAccountmovementEx->loadMovementEX($id);

return $data;

**Used by**: `editprint` action for displaying printable transaction records

---

## ๐Ÿ”„ Workflows

### Workflow 1: Deficit Adjustment Process

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ START: Select Account & Amount โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 1. Load Current Account Balance โ”‚

โ”‚ - Query bankaccount table โ”‚

โ”‚ - Get current accountbeginingbalance โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 2. Determine Operation Type โ”‚

โ”‚ - changetype = 0: Increase (Interest) โ”‚

โ”‚ - changetype = 1: Decrease (Bank Charges) โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 3. Calculate New Balance โ”‚

โ”‚ - Increase: balanceAfter = balanceBefore + amount โ”‚

โ”‚ - Decrease: balanceAfter = balanceBefore - amount โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 4. Create Account Movement Record โ”‚

โ”‚ - Record before/after balances โ”‚

โ”‚ - Set transaction type and amount โ”‚

โ”‚ - Link to source controller โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 5. Update Account Balance โ”‚

โ”‚ - Update accountbeginingbalance โ”‚

โ”‚ - Set modification date and user โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 6. Generate Journal Entry โ”‚

โ”‚ - Create daily entry header โ”‚

โ”‚ - Add debit/credit entries โ”‚

โ”‚ - Link to appropriate expense/income accounts โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

### Workflow 2: Transaction History Viewing

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ START: Apply Search Filters โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 1. Build Query String โ”‚

โ”‚ - Add bank filter if specified โ”‚

โ”‚ - Add account filter if specified โ”‚

โ”‚ - Add date range filters โ”‚

โ”‚ - Add movement kind filter โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 2. Apply Controller Filter โ”‚

โ”‚ - Only show bankAccountDeficitController transactions โ”‚

โ”‚ - Order by transaction ID descending โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”‚

โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ”‚ 3. Query and Display Results โ”‚

โ”‚ - Load movement data with extended info โ”‚

โ”‚ - Include bank names, account names โ”‚

โ”‚ - Show before/after balances โ”‚

โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

## ๐ŸŒ URL Routes & Actions

| URL Parameter | Function Called | Description |
|---------------|----------------|-------------|
| `do=` (empty) | Default action | Display deficit adjustment form |
| `do=add` | `add()` | Process new deficit adjustment |
| `do=show` | Show transactions | Display filtered transaction history |
| `do=editprint` | `edit()` | Load single transaction for printing |
| `do=sucess` | - | Show success message |
| `do=error` | - | Show error message |

### Required Parameters by Action

**Add Deficit Adjustment** (`do=add`):
- `ddlBank` - Bank ID
- `accountid` - Account ID  
- `changetype` - Operation type (0=increase, 1=decrease)
- `changeamount` - Adjustment amount
- `accountmovementcomment` - Comment/description
- `accountmovementkindid` - Transaction type category

**Show Transactions** (`do=show`):
- `from` - Start date (YYYY-MM-DD) [optional]
- `to` - End date (YYYY-MM-DD) [optional]
- `bankid` - Bank filter [optional]
- `accountid` - Account filter [optional]
- `accountmovementkindid` - Movement kind filter [optional]

**Print Transaction** (`do=editprint`):
- `id` - Account movement ID

---

## ๐Ÿงฎ Calculation Methods

### Balance Calculation
php

// Current balance retrieval

$account = $myBankaccountRecord->load($accountid);

$balanceBefore = $account->accountbeginingbalance;

// New balance calculation

if ($changetype == 1) { // Decrease

$balanceAfter = $balanceBefore - $changeamount;

} elseif ($changetype == 0) { // Increase

$balanceAfter = $balanceBefore + $changeamount;

}

### Journal Entry Logic
php

// For decreases (bank charges)

if ($changetype == 1) {

$dailyEntryDebtor->accountstreeid = 65; // Bank expenses

$dailyEntryCreditor->accountstreeid = $account->treeId; // Bank account

}

// For increases (interest income)

elseif ($changetype == 0) {

$dailyEntryDebtor->accountstreeid = $account->treeId; // Bank account

$dailyEntryCreditor->accountstreeid = 393; // Interest income

}

---

## ๐Ÿ”’ Security & Permissions

### Authentication
- All actions require `include_once("../public/authentication.php")`
- Session-based user authentication required
- User ID tracked in all database modifications

### Transaction Safety
- Uses Transaction class for database consistency
- Rollback on any errors during processing
- Atomic operations ensure data integrity

### Input Validation
- Numeric casting: `(int) $_POST["changetype"]`
- Amount validation through form controls
- SQL injection prevented by DAO layer

---

## ๐Ÿงช Common Use Cases

### 1. Bank Charge Processing

Scenario: Bank charged $25 for monthly maintenance

### 2. Interest Income Recording

Scenario: Bank credited $150 interest income

### 3. Reconciliation Adjustments

Scenario: Bank statement shows different balance

---

## ๐Ÿ› Troubleshooting

### Common Issues

1. **Transaction Fails to Commit**
   - Check database connections
   - Verify account exists and is active
   - Ensure sufficient permissions

2. **Journal Entries Not Created**
   - Verify chart of accounts setup (accounts 65, 393)
   - Check dailyentry function availability
   - Confirm account tree ID exists

3. **Balance Calculation Errors**
   - Validate input amounts are numeric
   - Check for concurrent account modifications
   - Verify account balance before operation

### Debug Commands
sql

-- Check account movement history

SELECT * FROM accountmovement

WHERE tablename = 'bankAccountDeficitController.php'

ORDER BY accountmovementdate DESC;

-- Verify account balances

SELECT accountid, accountname, accountbeginingbalance

FROM bankaccount

WHERE conditions = 0;

-- Check journal entry creation

SELECT * FROM dailyentry

WHERE entryComment LIKE '%ุชุณูˆูŠู‡%'

ORDER BY entryDate DESC;

```

---

๐Ÿ“š Related Documentation

---

Documented By: AI Assistant

Review Status: โœ… Complete

Next Review: When major changes occur

โ†‘