# Income & Expense System (Laravel)

Laravel version of the Income & Expense management system. Converted from the original PHP application.

## Requirements

- PHP 8.2+
- Composer
- MySQL 5.7+ / MariaDB
- Extensions: pdo_mysql, mbstring, openssl, tokenizer, xml, ctype, json

## Installation

1. **Install dependencies** (already done if created via composer)
   ```bash
   composer install
   ```

2. **Configure environment**
   ```bash
   cp .env.example .env
   php artisan key:generate
   ```
   Edit `.env` — set `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD`.

3. **Run migrations and seed**
   ```bash
   php artisan migrate --seed
   ```
   Or fresh install:
   ```bash
   php artisan migrate:fresh --seed
   ```

## Running the Application

### Option 1: Artisan serve (development)
```bash
php artisan serve
```
Open: http://localhost:8000

### Option 2: XAMPP / Apache
1. Ensure `mod_rewrite` is enabled.
2. Point document root to `im-laravel/public` (or create virtual host).
3. Or access: `http://localhost/im-laravel/public/`
4. Set `APP_URL=http://localhost/im-laravel/public` in `.env`.

## Default Login

- **Email:** admin@example.com
- **Password:** admin123

## Features

- **Transactions:** Income, Expense, Balance Transfer
- **Loans:** Loan Receivable, Loan Collection, Loan Collection Report, Loan Payable
- **Masters:** Accounts, Companies, Income/Expense Categories, Income Receive Employees, Income Transfer to Admins
- **Locations:** Branches, Zones, Sub Zones, Employees
- **Admin:** Users, Menus, Permissions (admin-only)
- **Auth:** Session-based login with role (admin/employee) and granular permissions

## Project Structure

- `app/Http/Controllers/` — Controllers
- `app/Models/` — Eloquent models
- `app/Services/` — MenuService
- `app/Helpers/` — MenuHelper (URL mapping)
- `app/Http/Middleware/` — EnsureUserHasPermission, EnsureAdmin
- `resources/views/` — Blade templates
- `routes/web.php` — Web routes
- `database/migrations/` — Database migrations
- `database/seeders/` — DataSeeder, PermissionSeeder, MenuSeeder

## Migrations

Migrations create: companies, branches, zones, sub_zones, employees, income_categories, expense_categories, accounts, users, permissions, user_permissions, incomes, expenses, balance_transfers, loans, loan_payments, loan_collections, payment_types, borrower_profiles, loan_receivables, income_receive_employees, income_transfer_to_admins, menus.
