# Others Accounts

A Laravel 12 application for managing accounts, receive entries, payments, and reports using AJAX-powered modals, server-side DataTables, and invoice auto-generation.

## Overview

`Others Accounts` provides an admin-focused dashboard for managing:
- account setup and details
- receive transactions
- payment transactions
- account transaction reports by date range

The project uses Laravel Blade views, Tailwind CSS, Vite, and Axios for a responsive interface with minimal page reloads.

## Features

- Authentication: login, registration, and logout
- Admin-only dashboard and management pages via `auth` + `LsValidUser:admin`
- Accounts management:
  - create, edit, delete accounts
  - duplicate validation on account name + sector
  - status toggling (Active / Inactive)
  - on-demand account balance lookup
- Receive management:
  - create, edit, delete receive entries
  - invoice number auto-generation
  - remarks preview in DataTable rows
  - account selection filtered by receive-capable accounts
- Payment management:
  - create, edit, delete payment entries
  - invoice number auto-generation
  - account selection filtered by payment-capable accounts
- Account reports:
  - date-range report for payments and receives
  - previous balance calculation
- AJAX modal forms and server-side data processing for fast UI

## Technology Stack

- PHP 8.2
- Laravel 12
- Laravel Sanctum
- Tailwind CSS
- Vite
- Axios
- barryvdh/laravel-dompdf
- php-flasher/flasher-laravel
- PHPUnit, Laravel Pint, Laravel Pail

## Project Structure

- `app/Http/Controllers/` — controllers for Users, Accounts, Receives, Payments, and Reports
- `app/Models/` — Eloquent models: `Account`, `Receive`, `Payment`, `User`
- `app/Http/Controllers/ResponseController.php` — centralized JSON response helper
- `database/migrations/` — schema for accounts, receives, payments, and users
- `resources/views/` — Blade pages and modal partials
- `public/` — public assets and frontend libraries
- `routes/web.php` — application routes and middleware groups

## Database Tables

- `accounts_setup`
- `account_receive`
- `account_payment`
- `users`

### Key table fields

- `accounts_setup`: accounts_name, sector_name, mobile_no, credit_limit, category, opening_balance, Status
- `account_receive` / `account_payment`: accounts_id, pay_mode, amount, entry_date, invoice_no, remarks

## Requirements

- PHP 8.2+
- Composer
- Node.js + npm
- MySQL or compatible database

## Setup

1. Clone the repository
2. Install PHP dependencies
   ```bash
   composer install
   ```
3. Create `.env`
   ```bash
   copy .env.example .env
   ```
4. Generate the application key
   ```bash
   php artisan key:generate
   ```
5. Configure `.env` database settings
6. Run migrations
   ```bash
   php artisan migrate
   ```
7. Install frontend dependencies
   ```bash
   npm install
   ```
8. Build frontend assets
   ```bash
   npm run build
   ```
9. Start the application
   ```bash
   php artisan serve
   ```

## Development

- Run Vite development server:
  ```bash
  npm run dev
  ```
- Use the built-in setup script:
  ```bash
  composer run setup
  ```

## Testing

Run the Laravel test suite:

```bash
php artisan test
```

## Main Routes

Authentication
- `GET /login` — login page
- `POST /loginMatch` — login form submission
- `GET /register` — registration page
- `POST /registerSave` — registration form submission
- `GET /logout` — logout

Admin routes (protected by `auth` + `LsValidUser:admin`)
- `GET /dashboard` — dashboard
- `GET /accountSetupView` — account management page
- `GET /receiveView` — receive management page
- `GET /paymentView` — payment management page
- `GET /reportView` — report page
- `GET /AccountReport` — account report view
- `GET /AccountReportViewData` — account report data

Accounts API
- `POST /accounts/data` — DataTable account list
- `POST /accounts/check-duplicate` — duplicate account validation
- `GET /accounts/create` — account create modal
- `GET /accounts/{id}/edit` — account edit modal
- `POST /accounts` — create account
- `PUT /accounts/{id}` — update account
- `DELETE /accounts/{id}` — delete account
- `GET /accounts/allAccountsInfo` — all accounts JSON
- `GET /accounts/receiveInfo` — receive-capable accounts JSON
- `GET /accounts/paymentInfo` — payment-capable accounts JSON
- `GET /accounts/accountsBalance/{id}` — account balance summary

Receives API
- `POST /receives/data` — DataTable receive list
- `POST /receives/check-duplicate` — duplicate invoice check
- `GET /receives/create` — receive create modal
- `POST /receives` — store receive
- `GET /receives/{id}/edit` — edit receive modal
- `PUT /receives/{id}` — update receive
- `DELETE /receives/{id}` — delete receive
- `GET /receives/last-invoice` — fetch next receive invoice

Payments API
- `POST /payments/data` — DataTable payment list
- `POST /payments/check-duplicate` — duplicate invoice check
- `GET /payments/create` — payment create modal
- `POST /payments` — store payment
- `GET /payments/{id}/edit` — edit payment modal
- `PUT /payments/{id}` — update payment
- `DELETE /payments/{id}` — delete payment
- `GET /payments/last-invoice` — fetch next payment invoice

## Notes

- The app uses Blade templates and reusable modal partials for create/edit workflows.
- Data is loaded and updated via AJAX, with JSON responses from controller helpers.
- Account selection is filtered by `category` so only valid accounts appear for receives and payments.
- `AccountReportController` computes transaction history and previous balance for selected accounts.

## License

This project is open-sourced software licensed under the MIT license.
