# Invoice Number Settings Module - Installation Guide

## ✅ Module is Ready for Installation!

The module now has a complete installation system and can be installed via the Module Manager.

## Installation Steps

### Step 1: Access Module Manager

1. Login to UltimatePOS as **Superadmin**
2. Go to **Settings → Module Manager**
3. Find **InvoiceNumberSettings** in the module list

### Step 2: Install the Module

1. Click the **Install** button next to InvoiceNumberSettings
2. The installation will:
   - Run database migrations
   - Add `invoice_number_type` column to `business` table
   - Add UNIQUE index to `transactions.invoice_no`
   - Register the module version
3. You'll see a success message when installation completes

### Step 3: Verify Installation

1. Go to **Settings → Business Settings**
2. You should see a new tab: **Invoice Settings**
3. The module is ready to use!

## Module Structure

```
Modules/InvoiceNumberSettings/
├── Database/
│   └── Migrations/              # Database migrations
│       ├── add_invoice_number_type_to_business_table.php
│       └── add_unique_index_to_transactions_invoice_no.php
├── Http/
│   └── Controllers/
│       └── InstallController.php  # Install/Update/Uninstall controller
├── Providers/
│   ├── InvoiceNumberSettingsServiceProvider.php  # Main service provider
│   └── RouteServiceProvider.php   # Route registration
├── Resources/
│   ├── lang/en/                  # Language files
│   │   └── invoice.php
│   └── views/business/partials/   # View files
│       └── settings_invoice.blade.php
├── Routes/
│   └── web.php                    # Module routes
├── module.json                    # Module configuration
├── README.md                      # User documentation
├── INSTALLATION.md                # Detailed installation guide
├── INSTALL_GUIDE.md               # This file
└── MODULE_SUMMARY.md              # Technical summary
```

## Features

✅ **Install Controller**: Handles install, update, and uninstall operations  
✅ **Routes**: Properly registered install routes  
✅ **Migrations**: Database changes run automatically on install  
✅ **Views**: Invoice Settings UI integrated  
✅ **Language Support**: All messages translated  
✅ **Module Manager Integration**: Appears in module list with Install button  

## Configuration

After installation:

1. Go to **Settings → Business Settings**
2. Click **Invoice Settings** tab
3. Select your preferred invoice number type:
   - **Sequential**: Auto-incrementing (INV-000001, INV-000002...)
   - **Random**: Random alphanumeric (INV-A1B2C3D4...)
4. Click **Update Settings**

## Troubleshooting

### Install Button Not Showing

- Clear cache: `php artisan cache:clear`
- Check that `module.json` is valid
- Verify module is in `Modules/InvoiceNumberSettings/` directory

### Installation Fails

- Check logs: `storage/logs/laravel.log`
- Verify database permissions
- Ensure migrations directory is readable

### Module Not Appearing

- Run: `php artisan module:publish`
- Clear config: `php artisan config:clear`
- Check module.json syntax

## Uninstallation

To uninstall:

1. Go to **Settings → Module Manager**
2. Find **InvoiceNumberSettings**
3. Click **Uninstall**

**Note**: Uninstalling removes the module version record but does NOT:
- Remove database columns (to preserve data)
- Remove UNIQUE index (for data integrity)
- Remove core code modifications

## Support

For issues:
1. Check installation logs
2. Review MODULE_SUMMARY.md for technical details
3. Contact UltimatePOS support

---

**Module Version**: 1.0.0  
**Last Updated**: 2026-01-19
