EmployeePersonal Documentation
Employee Personal Controller Documentation
File: /controllers/employeePersonalController.php
Purpose: Manages employee financial transactions, loans, advances, deductions, and rewards
Last Updated: December 19, 2024
Total Functions: 13
Lines of Code: ~1285
---
๐ Overview
The Employee Personal Controller is the core component for managing all employee financial transactions beyond basic salary. It handles:
- โข Employee advance payments (ุณูู)
- โข Loan disbursements and repayments
- โข Employee withdrawals and deductions
- โข Bonus and reward payments
- โข Penalty and fine processing
- โข Integration with payroll and accounting systems
- โข Cost center allocation for employee expenses
- โข Multi-payment method support (cash, bank, check)
- โข Real-time employee debt tracking
- โข Automated salary processing capabilities
Primary Functions
- โ Process employee advance payments
- โ Manage loan disbursements and repayments
- โ Handle employee withdrawals and deductions
- โ Process bonuses and rewards
- โ Apply penalties and fines
- โ Track employee debt balances
- โ Generate accounting entries for all transactions
- โ Support multiple payment methods
- โ Cost center allocation
- โ Print transaction receipts
- โ Automated salary processing
- โ Branch-based transaction filtering
Related Controllers
- โข employeeController.php - Employee management
- โข salaryReportController.php - Salary processing
- โข EmployeeAttendanceController.php - Attendance tracking
- โข dailyentry.php - Accounting entries
- โข saveController.php - Cash/bank management
- โข accountstree.php - Chart of accounts
- โข costcenterController.php - Cost center management
- โข bankController.php - Bank account management
---
๐๏ธ Database Tables
Primary Tables (Direct Operations)
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| `employeepersonnel` | Employee financial transactions | `employeeid`, `employeepersonneltype`, `employeepersonnelvalue`, `empdeptbefor`, `empdeptafter` | |
| `employee` | Employee debt tracking | `employeeId`, `empdept`, `employeeName` | |
| `save` | Cash accounts for payments | `saveid`, `savename`, `savevalue`, `treeId` | |
| `savedaily` | Daily cash movements | `saveid`, `savedailychangeamount`, `savedailychangetype` | |
| `salaryreport` | Salary payment records | `employeeid`, `salarymonth`, `salaryreportnet` |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| `dailyentry` | Accounting journal entries | `dailyentryid`, `entryComment`, `thedate` | |
| `dailyentrycreditor` | Credit side of entries | `dailyentryid`, `accountstreeid`, `value` | |
| `dailyentrydebtor` | Debit side of entries | `dailyentryid`, `accountstreeid`, `value` | |
| `costcenter` | Cost center allocation | `costcenterid`, `costcentername` | |
| `costcenterdetail` | Cost center transaction details | `costcenterid`, `modelid`, `costamount` | |
| `bankaccount` | Bank account information | `bankaccountid`, `treeId`, `accountname` |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| `programsettings` | System configuration | `settingName`, `settingValue` | |
| `bank` | Bank master data | `bankid`, `bankname` | |
| `user` | User information for audit | `userid`, `username`, `saveids` | |
| `branch` | Branch filtering | `branchId`, `branchName` |
๐ง Key Functions
Transaction Type Constants
// Employee Personnel Transaction Types
const TRANSACTION_TYPES = [
1 => 'Bonus/Reward', // ู
ูุงูุฃุฉ
2 => 'Deduction/Fine', // ุฎุตู
/ุบุฑุงู
ุฉ
3 => 'Withdrawal', // ุณุญุจ
4 => 'Advance/Loan', // ุณููุฉ
5 => 'Absence Deduction', // ุฎุตู
ุบูุงุจ
6 => 'Loan Repayment', // ุณุฏุงุฏ ุณููุฉ
7 => 'Permission Deduction', // ุฎุตู
ุฅุฐู
8 => 'Debt Adjustment', // ุชุนุฏูู ุฑุตูุฏ
9 => 'Late Penalty', // ุฎุตู
ุชุฃุฎูุฑ
10 => 'Salary Receipt', // ูุจุถ ุฑุงุชุจ
11 => 'Extra Allowance', // ุจุฏู ุฅุถุงูู
12 => 'Overtime', // ุฅุถุงูู
13 => 'Holiday Work', // ุนู
ู ุนุทูุฉ
14 => 'Leave Deduction', // ุฎุตู
ุฅุฌุงุฒุฉ
15 => 'Salary Change Record' // ุชุณุฌูู ุชุบููุฑ ุฑุงุชุจ
];
Main Controller Actions
Default Action (Transaction Entry Form)
if (!isset($_GET['do'])) // Line 179
- โข Purpose: Display employee transaction entry form
- โข Process Flow:
Add Transaction
elseif ($do == "add") // Line 203
- โข Purpose: Process new employee financial transaction
- โข Parameters (from $_POST):
- type: Transaction type (1-15)
- empName: Employee ID
- empValue: Transaction amount
- paymethod: Payment method (0=cash, 1=bank)
- employeepersonneldate: Transaction date
- desc: Transaction description
- saveid: Cash account ID (if cash payment)
- bankid, bankaccountid, checkNo: Bank details (if bank payment)
- Costcenterid: Cost center for allocation
- netSalary: Employee's current net salary
- โข Process Flow:
Core Business Functions
add() Function
function add($employeepersonnelvalue, $saveInNextMonth = 0, $paymethod = 0,
$employeepersonneltype = 0, $deviceid = '01', $employeeid,
$employeepersonneldate, $userid = 0, $saveid = 0) // Line 826
- โข Purpose: Core function to process employee financial transaction
- โข Parameters:
- $employeepersonnelvalue: Transaction amount
- $saveInNextMonth: Flag for next month processing
- $paymethod: Payment method (0=cash, 1=bank)
- $employeepersonneltype: Transaction type
- $deviceid: Device/source identifier
- $employeeid: Employee ID
- $employeepersonneldate: Transaction date
- $userid: User performing transaction
- $saveid: Cash/bank account ID
- โข Process Flow:
- โข Debt Calculation Logic:
// Advance/Loan (Type 4)
if ($employeepersonneltype == 4) {
$empdeptafter = $empdept + $employeepersonnelvalue;
}
// Loan Repayment (Type 6)
elseif ($employeepersonneltype == 6) {
$empdeptafter = $empdept - $employeepersonnelvalue;
}
// Debt Adjustment (Type 8)
elseif ($employeepersonneltype == 8) {
$empdeptafter = $employeepersonnelvalue; // Set absolute value
}
show() Function
function show() // Line 458
- โข Purpose: Display employee transaction history with filtering
- โข Features:
- Date range filtering
- Employee-specific filtering
- Transaction type filtering
- Branch-based security
- Pagination support
delete() Function
function delete() // Line 742
- โข Purpose: Reverse/cancel employee transaction
- โข Process Flow:
curlAddSalary() Function
function curlAddSalary($empid, $salarymonthdate, $Costcenterid) // Line 1261
- โข Purpose: Automated salary processing via internal API
- โข Process: Makes CURL request to salaryReportController for salary payment
getEmployeeNetSalary() Function
function getEmployeeNetSalary($id) // Line 1135
- โข Purpose: Calculate employee's available net salary for advances
- โข Calculation:
Net Salary = Base Salary + Bonuses + Allowances
- (Existing Advances + Deductions + Taxes)
- Already Withdrawn This Month
Utility Functions
Cash Management Functions
function getSaveValueBefore($saveid) // Get current balance
function updateSave($saveid, $savevalueafter) // Update account balance
function insertSavedaily(...) // Record cash movement
doEmployeePersonalDailyEntry() Function
function doEmployeePersonalDailyEntry($EmployeepersonnelId) // Line 1194
- โข Purpose: Generate accounting entries for employee transactions
- โข Entry Types by Transaction:
Advance (Type 4):
Dr: Employee Advance Account
Cr: Cash/Bank Account
Repayment (Type 6):
Dr: Cash/Bank Account
Cr: Employee Advance Account
Bonus (Type 1):
Dr: Employee Account
Cr: Cash/Bank Account
Deduction (Type 2):
Dr: Cash/Bank Account
Cr: Employee Account
---
๐ Business Logic Flow
Employee Advance Processing Workflow
Loan Repayment Processing
Multi-Month Advance Logic
---
โ ๏ธ Common Issues
Known Bugs & Limitations
1. Salary Validation Logic
- Issue: Complex validation logic for advance amounts vs net salary
- Location: Lines 233-241
- Impact: May allow advances exceeding available salary in some cases
- Solution: Implement more robust salary validation
2. Transaction Splitting
- Issue: Multi-month transaction splitting may cause confusion
- Location: add() function processing
- Impact: Employees may not understand why advance is split
- Solution: Add clear communication about split transactions
3. Debt Calculation Race Conditions
- Issue: Multiple concurrent transactions may cause debt calculation errors
- Location: Employee debt update operations
- Impact: Incorrect debt balances
- Solution: Implement transaction locking or atomic operations
4. Payment Method Validation
- Issue: Insufficient validation for bank account details
- Location: Bank payment processing
- Impact: Invalid bank transactions may be recorded
- Solution: Add comprehensive bank account validation
PHP 8.2 Compatibility
1. Object Initialization
- All objects properly initialized before property assignment
- No "attempt to assign property on null" errors
2. Type Safety
- Proper float casting for financial calculations
- Safe array handling for transaction data
---
๐ Dependencies
Required Files
- โข
../public/impOpreation.php- Core operations - โข
../public/config.php- Database configuration - โข
../public/include_dao.php- DAO includes - โข
initiateStaticSessionCommingWithCurl.php- Session management - โข
dailyentryfun.php- Daily entry functions
Required DAOs
- โข
EmployeepersonnelDAO- Employee transaction records - โข
EmployeeDAO- Employee debt tracking - โข
SaveDAO- Cash account management - โข
SavedailyDAO- Daily cash movements - โข
BankaccountDAO- Bank account operations - โข
CostcenterDAO- Cost center allocation - โข
DailyentryDAO- Accounting entries - โข
SalaryreportDAO- Salary processing
Related Controllers
- โข Must coordinate with payroll system for salary deductions
- โข Integrates with accounting system for proper journal entries
- โข Works with cash management for payment processing
- โข Connects to cost center system for expense allocation
Template Files
- โข
employeePersonalview/add.html- Transaction entry form - โข
employeePersonalview/showfinsh.html- Transaction history - โข
employeePersonalview/editprint.html- Receipt printing - โข
succes.html- Success message - โข
error.html- Error message
Key Financial Features
- โข Multi-Type Transactions: Support for 15+ transaction types including advances, loans, bonuses, deductions
- โข Debt Tracking: Real-time employee debt balance management with before/after tracking
- โข Payment Flexibility: Support for cash and bank payments with check handling
- โข Smart Advance Logic: Automatic splitting of advances across pay periods based on available net salary
- โข Cost Center Integration: Department/project-wise expense allocation for all transactions
- โข Full Audit Trail: Complete tracking of all financial transactions with user and timestamp
- โข Accounting Integration: Automatic journal entry generation for all transactions
- โข Multi-Branch Support: Branch-based filtering and access control
- โข Receipt Generation: Professional receipt printing for all transactions
- โข Automated Processing: Integration with automated salary processing systems