# IFNEX Rate Importer — 4-Quadrant Model This package implements the **customer's original Excel format** for rate imports, replacing the old 2-zone (Document × Parcel) model with a proper **4-quadrant model**: ``` ┌──────────┬──────────────┬──────────────────┐ │ │ DOCUMENT │ NON-DOCUMENT │ ├──────────┼──────────────┼──────────────────┤ │ Export │ Export×Doc │ Export×Parcel │ │ Import │ Import×Doc │ Import×Parcel │ └──────────┴──────────────┴──────────────────┘ ``` Each quadrant is a separate weight × zone matrix (10 zones, weights 0.5–30 kg). Each country can have **different zones** for Parcel vs Document shipping. --- ## 📦 Files in this package | File | Purpose | |---|---| | `IFNEX_Rate_Template.xlsx` | The new blank template — give this to the customer | | `migrations/2026_10_29_000001_extend_rate_entries_for_4_quadrants.php` | DB schema: `rate_entries` (4-quadrant) + `country_zones` | | `Models/RateEntry.php` | Eloquent model with `lookup()` helper | | `Models/CountryZone.php` | Eloquent model with `lookupZone()` helper | | `Services/RateImportService.php` | The Excel parser — handles the customer's 2-sheet format | | `Services/PriceCalculatorService.php` | Updated calculator using the 4-quadrant model | | `Filament/Resources/RateImportResource.php` | Filament admin resource | | `Filament/Resources/RateImportResource/Pages/ImportRates.php` | Upload form page | | `Filament/Resources/views/rate-import.blade.php` | Blade view for the upload page | --- ## 🚀 Deployment steps ### 1. Copy files into your Laravel project ```bash # From your project root (e.g. /home/ifnex/web/system.ifnex.ir) cp download/ifnex-rate-importer/migrations/*.php database/migrations/ mkdir -p app/Models cp download/ifnex-rate-importer/Models/*.php app/Models/ mkdir -p app/Services cp download/ifnex-rate-importer/Services/*.php app/Services/ mkdir -p app/Filament/Resources cp -r download/ifnex-rate-importer/Filament/Resources/RateImportResource app/Filament/Resources/ cp download/ifnex-rate-importer/Filament/Resources/RateImportResource.php app/Filament/Resources/ mkdir -p resources/views/filament/pages cp download/ifnex-rate-importer/Filament/Resources/views/rate-import.blade.php resources/views/filament/pages/rate-import.blade.php ``` ### 2. Install PhpSpreadsheet (if not already) ```bash composer require phpoffice/phpspreadsheet ``` ### 3. Run the migration ```bash php artisan migrate ``` The migration is **safe** — it will: - Create `rate_entries` table if it doesn't exist - Or add the missing columns (`direction`, `service_type`, `currency`, `effective_at`) if it does - Create `country_zones` table for the country→zone mapping ### 4. Clear caches ```bash php artisan optimize:clear php artisan config:clear php artisan route:clear php artisan view:clear php artisan filament:assets ``` ### 5. Visit the admin panel Navigate to: `https://system.ifnex.ir/admin/rate-import` You should see the upload form. Upload the `IFNEX_Rate_Template.xlsx` (with your filled-in rates) and click **Import Rates**. --- ## 🔧 Filament v3 compatibility notes This page targets **Filament 3.x**. Key points: 1. **No `CanPoll` trait** — that trait was removed in Filament 3. We use `InteractsWithForms` instead. 2. **Form state path** — form values are stored in `$data` array, set via `->statePath('data')` on the form. 3. **`mount()` method** — required to initialize the form on page load via `$this->form->fill()`. 4. **Form rendering** — the view calls `{{ $this->form }}` directly inside the `