# MobiVault360 - Implementation Tasks

**Project:** Mobile Phone Shop Management System  
**Framework:** Laravel 11 + Livewire 3 + Bootstrap 5  
**Target:** cPanel/Shared Hosting with Easy Deployment  

---

## Phase 1: Project Foundation & Setup

### 1.1 Laravel Project Initialization
- [ ] Create fresh Laravel 11 project
- [ ] Configure database connection (MySQL)
- [ ] Install core dependencies (Composer packages)
- [ ] Set up Git repository
- [ ] Configure environment variables

### 1.2 Core Packages Installation
- [ ] Install Laravel Breeze with Livewire
- [ ] Install Spatie Laravel Permission
- [ ] Install picqer/php-barcode-generator
- [ ] Install barryvdh/laravel-dompdf
- [ ] Install maatwebsite/laravel-excel
- [ ] Install Livewire 3
- [ ] Install Alpine.js

### 1.3 Frontend Setup
- [ ] Install Bootstrap 5
- [ ] Install Font Awesome 6
- [ ] Create base layout (app.blade.php)
- [ ] Create RTL stylesheet (rtl.css)
- [ ] Set up print stylesheet (print.css)

---

## Phase 2: Database Architecture

### 2.1 Core Tables Migration
- [ ] Create `settings` table
- [ ] Create `branches` table
- [ ] Create `users` table (extend default)
- [ ] Create roles and permissions tables
- [ ] Create `languages` table

### 2.2 Product & Inventory Tables
- [ ] Create `categories` table
- [ ] Create `products` table
- [ ] Create `inventory` table
- [ ] Create `inventory_adjustments` table

### 2.3 Customer & Supplier Tables
- [ ] Create `customers` table
- [ ] Create `customer_transactions` table
- [ ] Create `suppliers` table

### 2.4 Purchase Tables
- [ ] Create `purchase_orders` table
- [ ] Create `purchase_order_items` table
- [ ] Create `purchase_returns` table

### 2.5 Sales & POS Tables
- [ ] Create `pos_sessions` table
- [ ] Create `cash_transactions` table
- [ ] Create `sales` table
- [ ] Create `sale_items` table
- [ ] Create `payment_methods` table

### 2.6 Accounting Tables
- [ ] Create `accounts` table (Chart of Accounts)
- [ ] Create `journal_entries` table
- [ ] Create `journal_entry_lines` table

---

## Phase 3: Web-Based Installer (Priority)

### 3.1 Installer Core
- [ ] Create `/install` route
- [ ] Create installer layout
- [ ] Build server requirements checker
- [ ] Build database connection tester

### 3.2 Installer Steps (7 Steps)
- [ ] Step 1: Server requirements check
- [ ] Step 2: Database configuration form
- [ ] Step 3: Language selection
- [ ] Step 4: Shop details form
- [ ] Step 5: Branch mode selection
- [ ] Step 6: Payment methods setup
- [x] **Service Product Implementation**
  - [x] Database: `is_service` column <!-- id: 4 -->
  - [x] Logic: Scopes (`scopePhysical`, `scopeService`) <!-- id: 5 -->
  - [x] Logic: PO Exclusion for Services <!-- id: 6 -->
  - [x] POS: Description Input & Warranty Picker <!-- id: 7 -->
  - [x] Receipt: Print Service Details <!-- id: 8 -->
  - [x] UI: Product Type Dropdown <!-- id: 9 -->
- [ ] Step 7: Admin account creation

### 3.3 Installer Logic
- [ ] Environment file generator (.env creator)
- [ ] Database migration runner
- [ ] Seeder executor
- [ ] Admin user creator
- [ ] Settings saver
- [ ] Installer lockfile creator
- [ ] Auto-delete installer after success

---

## Phase 4: Module 1 - Multi-Language Support

### 4.1 Language Infrastructure
- [ ] Create SetLocale middleware
- [ ] Create language switcher component
- [ ] Set up session-based locale storage

### 4.2 English Translations
- [ ] Create `resources/lang/en/` files
- [ ] Translate common terms
- [ ] Translate validation messages
- [ ] Translate module-specific terms

### 4.3 Arabic Translations
- [ ] Create `resources/lang/ar/` files
- [ ] Translate all English files to Arabic
- [ ] Create RTL CSS styles
- [ ] Test RTL layout

---

## Phase 5: Module 2 - Multi-Branch Management

### 5.1 Branch Model & Controller
- [ ] Create Branch model
- [ ] Create BranchController (CRUD)
- [ ] Add branch validation rules

### 5.2 Branch Views (Livewire)
- [ ] Create branch listing component
- [ ] Create branch create/edit form
- [ ] Create branch status toggle
- [ ] Add branch filter to reports

### 5.3 Branch Scope Integration
- [ ] Add branch_id to relevant models
- [ ] Create branch scope middleware
- [ ] Update queries to filter by branch

---

## Phase 6: Module 3 - User Management & Permissions

### 6.1 Roles & Permissions Setup
- [ ] Create roles seeder (Super Admin, Owner, Accounting, Cashier)
- [ ] Create permissions seeder
- [ ] Assign permissions to roles

### 6.2 User Management
- [ ] Create UserController (CRUD)
- [ ] Create user listing component
- [ ] Create user create/edit form
- [ ] Add role assignment
- [ ] Add branch assignment

### 6.3 Authentication & Authorization
- [ ] Set up Laravel Breeze
- [ ] Add role-based middleware
- [ ] Add permission checks in views
- [ ] Create access denied page

---

## Phase 7: Module 4 - Customer Management

### 7.1 Customer Model & Controller
- [ ] Create Customer model
- [ ] Create CustomerController (CRUD)
- [ ] Create CustomerTransaction model

### 7.2 Customer Views (Livewire)
- [ ] Create customer listing component
- [ ] Create customer create/edit form
- [ ] Create customer search component
- [ ] Create customer balance display

### 7.3 Customer Credit System
- [ ] Implement credit balance calculation
- [ ] Create transaction history view
- [ ] Create due settlement form
- [ ] Add customer to POS interface

---

## Phase 8: Module 5 - Products & Categories

### 8.1 Category Setup
- [ ] Create Category model
- [ ] Create CategoryController (CRUD)
- [ ] Seed default categories (Devices, Accessories, Repair)

### 8.2 Product Management
- [ ] Create Product model
- [ ] Create ProductController (CRUD)
- [ ] Create product listing component
- [ ] Create product create/edit form
- [ ] Add SKU auto-generation

### 8.3 Barcode System
- [ ] Create BarcodeController
- [ ] Integrate barcode generator library
- [ ] Create barcode print view (single)
- [ ] Create barcode batch print view
- [ ] Add barcode label size options

---

## Phase 9: Module 6 - Supplier Management

### 9.1 Supplier Model & Controller
- [ ] Create Supplier model
- [ ] Create SupplierController (CRUD)

### 9.2 Supplier Views (Livewire)
- [ ] Create supplier listing component
- [ ] Create supplier create/edit form
- [ ] Create supplier search component

---

## Phase 10: Module 7 - Purchase Orders

### 10.1 Purchase Order Core
- [ ] Create PurchaseOrder model
- [ ] Create PurchaseOrderItem model
- [ ] Create PurchaseOrderController

### 10.2 PO Views (Livewire)
- [ ] Create PO listing component
- [ ] Create PO create form
- [ ] Create PO items table (add/remove items)
- [ ] Create PO approval workflow
- [ ] Create PO receive form

### 10.3 Quick PO from POS
- [ ] Create Quick PO modal in POS
- [ ] Add supplier selector
- [ ] Add product quick-add
- [ ] Submit to create PO

### 10.4 PO Integration
- [ ] Update inventory on receive
- [ ] Create journal entry on receive
- [ ] Send notification to accountant

---

## Phase 11: Module 8 - Purchase Returns

### 11.1 Purchase Return Core
- [ ] Create PurchaseReturn model
- [ ] Create PurchaseReturnController

### 11.2 Return Views (Livewire)
- [ ] Create return listing component
- [ ] Create return form (select PO)
- [ ] Create return items selection

### 11.3 Return Integration
- [ ] Deduct from inventory
- [ ] Reverse journal entry
- [ ] Update PO status

---

## Phase 12: Module 9 - Inventory Management

### 12.1 Inventory Core
- [ ] Create Inventory model
- [ ] Create InventoryService (business logic)
- [ ] Create InventoryController

### 12.2 Inventory Views
- [ ] Create inventory listing component
- [ ] Create stock level display
- [ ] Create low stock alerts
- [ ] Create inventory by branch view

### 12.3 Inventory Adjustments
- [ ] Create InventoryAdjustment model
- [ ] Create adjustment form
- [ ] Add adjustment reasons dropdown
- [ ] Create adjustment history view

### 12.4 Inventory Integration
- [ ] Auto-update on PO receive
- [ ] Auto-update on sale
- [ ] Auto-update on return
- [ ] Calculate weighted average cost

---

## Phase 13: Module 10 - Chart of Accounts

### 13.1 Account Setup
- [ ] Create Account model
- [ ] Create AccountController (CRUD)
- [ ] Create account types enum

### 13.2 Account Seeder
- [ ] Seed Assets accounts (1000)
- [ ] Seed Liabilities accounts (2000)
- [ ] Seed Equity accounts (3000)
- [ ] Seed Revenue accounts (4000)
- [ ] Seed Expense accounts (5000)
- [ ] Include Intermediate Sales Account (1500)

### 13.3 Account Views (Livewire)
- [ ] Create account listing component (tree view)
- [ ] Create account create/edit form
- [ ] Add parent account selector
- [ ] Add account validation

---

## Phase 14: Module 11 - Journal Entries

### 14.1 Journal Entry Core
- [ ] Create JournalEntry model
- [ ] Create JournalEntryLine model
- [ ] Create JournalEntryController
- [ ] Create AccountingService

### 14.2 Journal Entry Views
- [ ] Create journal listing component
- [ ] Create manual journal entry form
- [ ] Add debit/credit line items (dynamic)
- [ ] Validate debits = credits

### 14.3 Auto Journal Entries
- [ ] Create entry on sale (to intermediate)
- [ ] Create entry on PO receive
- [ ] Create entry on purchase return
- [ ] Create entry on inventory adjustment
- [ ] Create entry on session review

---

## Phase 15: Module 12 - Payment Methods

### 15.1 Payment Method Setup
- [ ] Create PaymentMethod model
- [ ] Create PaymentMethodController
- [ ] Seed default methods (Cash, Card)

### 15.2 Payment Method Views
- [ ] Create payment method listing
- [ ] Create payment method form
- [ ] Add icon selector
- [ ] Add enable/disable toggle

---

## Phase 16: Module 13 - POS Sessions

### 16.1 POS Session Core
- [ ] Create POSSession model
- [ ] Create POSSessionController
- [ ] Create session open form (opening cash)

### 16.2 Session Views (Livewire)
- [ ] Create active session display
- [ ] Create session close form
- [ ] Calculate expected vs actual cash
- [ ] Show cash in/out summary

### 16.3 Session Review (Accountant)
- [ ] Create pending sessions list
- [ ] Create session review form
- [ ] Transfer from intermediate to final accounts
- [ ] Mark session as reviewed

---

## Phase 17: Module 14 - Cash Drawer (Cash In/Out)

### 17.1 Cash Transaction Core
- [ ] Create CashTransaction model
- [ ] Create CashTransactionController

### 17.2 Cash In/Out Views (POS)
- [ ] Create Cash In modal
- [ ] Create Cash Out modal
- [ ] Add reason dropdown
- [ ] Display in session summary

---

## Phase 18: Module 15 - POS Interface (Main)

### 18.1 POS Core (Livewire Component)
- [ ] Create main POS Livewire component
- [ ] Add session check (must be open)
- [ ] Create product search (by name/barcode)
- [ ] Create category tabs (Devices, Accessories, Repair)

### 18.2 Cart Management
- [ ] Add product to cart
- [ ] Update quantity in cart
- [ ] Remove from cart
- [ ] Apply discount (% or fixed) per item
- [ ] Calculate cart totals

### 18.3 POS Features
- [ ] Customer selector with balance display
- [ ] Payment method selector
- [ ] Sell on credit toggle
- [ ] Due settlement modal
- [ ] Warranty date picker per item
- [ ] Repair notes field

### 18.4 POS Actions
- [ ] Process cash sale
- [ ] Process card sale
- [ ] Process credit sale
- [ ] Clear cart
- [ ] Hold sale (save for later)

### 18.5 POS Integration
- [ ] Update inventory on sale
- [ ] Create journal entry
- [ ] Update customer balance (if credit)
- [ ] Generate receipt

---

## Phase 19: Module 16 - Receipt Printing

### 19.1 Receipt Template
- [ ] Create receipt blade view
- [ ] Add shop logo and details
- [ ] Add receipt number and date
- [ ] Add customer name and balance

### 19.2 Receipt Content
- [ ] Add line items table
- [ ] Add discounts
- [ ] Add warranty dates per item
- [ ] Add total and payment method
- [ ] Add previous/new balance (if credit)
- [ ] Add thank you message

### 19.3 Receipt Features
- [ ] Create print CSS (thermal 80mm)
- [ ] Add print button in POS
- [ ] Add reprint option
- [ ] Auto-print after sale (optional)

---

## Phase 20: Module 17 - Financial Reports

### 20.1 Report Infrastructure
- [ ] Create ReportController
- [ ] Create report base layout
- [ ] Add date range filter
- [ ] Add branch filter
- [ ] Add export to PDF
- [ ] Add export to Excel

### 20.2 Accounting Reports
- [ ] Trial Balance report
- [ ] Income Statement (P&L)
- [ ] Balance Sheet
- [ ] General Ledger

### 20.3 Operational Reports
- [ ] Sales Report (by date/category/branch)
- [ ] Purchase Report (by date/supplier)
- [ ] Inventory Report (stock levels/values)
- [ ] Customer Balances Report
- [ ] Session Summary Report
- [ ] Cash Flow Report

---

## Phase 21: Settings & Configuration

### 21.1 System Settings
- [ ] Create Setting model
- [ ] Create SettingsController
- [ ] Create settings form (shop details)
- [ ] Add logo upload
- [ ] Add currency settings

### 21.2 Settings Views
- [ ] General settings page
- [ ] Branch settings
- [ ] Accounting settings
- [ ] Notification settings

---

## Phase 22: Dashboard & Analytics

### 22.1 Dashboard Components
- [ ] Today's sales widget
- [ ] Low stock alerts widget
- [ ] Recent transactions widget
- [ ] Customer dues widget
- [ ] Quick actions widget

### 22.2 Charts & Graphs
- [ ] Sales trend chart (last 7 days)
- [ ] Revenue by category (pie chart)
- [ ] Branch comparison chart

---

## Phase 23: Testing & Quality Assurance

### 23.1 Unit Testing
- [ ] Test inventory calculations
- [ ] Test accounting calculations
- [ ] Test customer credit calculations

### 23.2 Feature Testing
- [ ] Test complete sale flow
- [ ] Test PO to inventory flow
- [ ] Test session close flow
- [ ] Test accountant review flow

### 23.3 Integration Testing
- [ ] Test installer on fresh database
- [ ] Test multi-language switching
- [ ] Test multi-branch data isolation
- [ ] Test role-based access

---

## Phase 24: Deployment Preparation

### 24.1 Optimization
- [ ] Run `composer install --optimize-autoloader --no-dev`
- [ ] Run `php artisan config:cache`
- [ ] Run `php artisan route:cache`
- [ ] Run `php artisan view:cache`
- [ ] Minify CSS/JS assets

### 24.2 Security Hardening
- [ ] Remove installer files after setup
- [ ] Add security headers to .htaccess
- [ ] Protect .env file
- [ ] Set correct file permissions
- [ ] Add CSRF protection to all forms

### 24.3 Documentation
- [ ] Create INSTALL.txt
- [ ] Create README.md
- [ ] Create user manual (PDF)
- [ ] Create admin guide
- [ ] Create API documentation (if needed)

### 24.4 Deployment Package
- [ ] Create deployment zip file
- [ ] Include vendor folder (no composer needed)
- [ ] Include pre-configured .htaccess
- [ ] Include installer
- [ ] Test on cPanel demo environment

---

## Phase 25: Post-Deployment

### 25.1 Monitoring
- [ ] Set up error logging
- [ ] Set up database backup schedule
- [ ] Create health check endpoint

### 25.2 Future Enhancements (Backlog)
- [ ] Mobile app API (Laravel Sanctum)
- [ ] Multi-tenancy support
- [ ] WhatsApp notifications
- [ ] Email receipts
- [ ] SMS notifications
- [ ] Advanced analytics dashboard
- [ ] Employee attendance module
- [ ] Expenses management module

---

## Progress Summary

**Total Tasks:** ~250+  
**Completed:** 0  
**In Progress:** 0  
**Remaining:** 250+  

**Current Phase:** Phase 1 - Project Foundation  
**Next Milestone:** Complete installer and basic Laravel setup
