# Products & Variants Unification - Implementation Plan


## Table of Contents

1. [Phase 1: Foundation - Schema Enhancement](#phase-1-foundation---schema-enhancement)
2. [Phase 2: Permission System Setup](#phase-2-permission-system-setup)
3. [Phase 3: Model Layer Unification](#phase-3-model-layer-unification)
4. [Phase 4: Service Layer Unification](#phase-4-service-layer-unification)
5. [Phase 5: Repository Layer Updates](#phase-5-repository-layer-updates)
6. [Phase 6: Controller & API Consolidation](#phase-6-controller--api-consolidation)
7. [Phase 7: Event System Integration](#phase-7-event-system-integration)
8. [Phase 8: Data Migration](#phase-8-data-migration)
9. [Phase 9: Financial Integration](#phase-9-financial-integration)
10. [Phase 10: Testing & Validation](#phase-10-testing--validation)
11. [Phase 11: Cleanup & Deprecation](#phase-11-cleanup--deprecation)

---

## Phase 1: Foundation - Schema Enhancement

### 1.1 Multi-Tenancy Support for Catalog Products

---

### 1.2

---

### 1.3 Multi-Tenancy Support for Catalog Materials

---

### 1.4 Multi-Tenancy Support for Related Tables

---

## Phase 2: Permission System Setup

### 2.1 Create Unified Product Permissions

### 2.2 Permission Mapping Table

---

## Phase 3: Model Layer Unification

### 3.1 Enhance Catalog Product Model

### 3.2 Enhance ProductVariant Model

### 3.3 Enhance ProductVariantPrice Model

### 3.4 Enhance Material Model (Unified)

### 3.5 Create Bridge/Compatibility Models

### 4.2 Create Unified Material Service

### 4.3 Migrate Sales Services Logic

### 4.4 Migrate Construction Material Services Logic

### 4.5 Enhance Existing Catalog Services

---

## Phase 5: Repository Layer Updates

### 5.1 Update Product Repository

### 5.2 Update Variant Repository

### 5.3 Create/Update Material Repository

### 5.4 Create Price Repository

---

## Phase 6: Controller & API Consolidation

### 6.1 Create Unified API Controllers

### 6.2 Create Request Validation Classes

### 6.4 Create Unified Routes

---

## Phase 7: Event System Integration

### 7.1 Create Unified Events

### 7.2 Create/Update Event Listeners

---

## Phase 8: Data Migration

### 8.1 Create Data Migration Scripts

### 8.2 Create Migration Mapping Tables

### 8.3 Create Verification Commands

---

## Phase 9: Financial Integration

### 9.1 Tax Integration

### 9.2 ChartOfAccount Integration

### 9.3 Invoice Integration

### 9.4 Update Financial Reports

---

## Phase 10: Testing & Validation

### 10.1 Unit Tests

### 10.2 Feature Tests

### 10.3 Integration Tests

### 10.4 Create Test Data Factories

---

## Phase 11: Cleanup & Deprecation

### 11.1 Mark Deprecated Code

### 11.2 Update Documentation

### 11.3 Final Cleanup (Post-Migration Verification)

---

## Appendix A: File Checklist

### New Files to Create

### Files to Modify

### Files to Deprecate (Mark, Don't Delete)

---

## Appendix B: Database Schema Changes Summary

### Tables to Add Columns

### New Tables

---

## Appendix C: Permission Mapping Reference

---

## Appendix D: Simple Product Migration Example

### Sales Product → Catalog Product + Variant

---
