# Task 01 — Expansion Overview & Architecture

## Goal
Confirm the architecture plan and existing module state before any changes are made.

## Pre-flight Checks (do these before writing any code)

1. Confirm Finance module is operational:
   - `fiscal_years` table has at least one active year
   - `accounts` table exists with chart of accounts
   - `journals` table exists
   - `journal_entries` and `journal_entry_lines` tables exist

2. Confirm existing Sales tables:
   - `customers`, `sales_orders`, `sales_order_lines`, `invoices`, `invoice_lines`

3. Confirm existing Inventory tables:
   - `warehouses`, `items`, `stock_movements`

4. Confirm existing Core tables:
   - `branches`, `number_sequences`, `finance_payment_methods`

## Architecture to Follow

```
Layer order (strict):
  Migrations → Models → Services → FormRequests → Controllers → Views → Permissions → Routes
```

## Folder Targets

```
app/Models/
  Inventory/
    Setup/        ← ItemCategory, UnitOfMeasure (new)
    Supplier/     ← Supplier (new)
    Purchase/     ← PurchaseOrder, PurchaseOrderLine, PurchaseReceipt, PurchaseReceiptLine (new)
  Sales/
    Setup/        ← SalesTaxRate (new)
    Quotation/    ← SalesQuotation, SalesQuotationLine (new)
    Payment/      ← SalesPayment (new)
    Return/       ← SalesReturn, SalesReturnLine (new)

app/Services/
  Inventory/
    Setup/        ← ItemCategoryService, UnitOfMeasureService
    Supplier/     ← SupplierService
    Purchase/     ← PurchaseOrderService, PurchaseReceiptService
    Stock/        ← StockBalanceService (CRITICAL)
    Valuation/    ← AverageCostService
    Finance/      ← InventoryPostingService
  Sales/
    Setup/        ← SalesTaxRateService
    Quotation/    ← QuotationService
    Payment/      ← SalesPaymentService
    Return/       ← SalesReturnService
    Finance/      ← SalesPostingService (CRITICAL)
```

## Number Sequence Keys to Register

Add these to number_sequences seeder or setup:

| module | document | prefix example |
|--------|----------|---------------|
| inventory | purchase_order | PO- |
| inventory | purchase_receipt | GRN- |
| sales | quotation | QT- |
| sales | payment | PMT- |
| sales | return | RTN- |

## Output Required

No code generated in this task.
Output only:
1. Confirmation that pre-flight checks pass
2. List of tables that need to be created (from MASTER_PLAN.md section 6)
3. List of tables that need to be altered
