From 477418b349a786724e75ac407bd1cfc441782910 Mon Sep 17 00:00:00 2001 From: Kazem Alghasi Date: Thu, 29 Oct 2026 19:09:35 +0330 Subject: [PATCH] fix(rate-import): enlarge rate column + correct AED fallback rate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two issues caused the rate import to fail with 1237 'Out of range value for column rate' errors: 1. The rate column was decimal(12,4) — max ~100 million. Converted IRR values for larger shipments exceed this. Migrate to decimal(20,4) which handles up to ~100 trillion. 2. The fallback AED→IRR rate in config/ifnex.php was 455,000 (way too high — should be ~14,000). Update to a realistic market rate. Also improve the CurrencyResource helperText to remind users to enter rates in Rials (not Tomans) and provide realistic examples for AED, USD, and EUR. --- .../Filament/Resources/CurrencyResource.php | 2 +- 04_Laravel/config/ifnex.php | 2 +- ...30000_enlarge_rate_entries_rate_column.php | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 04_Laravel/database/migrations/2026_10_29_130000_enlarge_rate_entries_rate_column.php diff --git a/04_Laravel/app/Filament/Resources/CurrencyResource.php b/04_Laravel/app/Filament/Resources/CurrencyResource.php index 0998916..c1394ba 100644 --- a/04_Laravel/app/Filament/Resources/CurrencyResource.php +++ b/04_Laravel/app/Filament/Resources/CurrencyResource.php @@ -50,7 +50,7 @@ class CurrencyResource extends Resource ->default(0) ->suffix('ریال') ->label('نرخ نسبت به ریال') - ->helperText('این نرخ مبناست. با تغییر این فیلد، نرخ جدید در تاریخچه ثبت می‌شود.'), +->helperText('⚠️ مقدار به ریال (نه تومان) وارد کنید. مثال‌های واقعی: AED ≈ 14,000 ریال (1,400 تومان) | USD ≈ 53,000 ریال (5,300 تومان) | EUR ≈ 58,000 ریال (5,800 تومان). با تغییر این فیلد، نرخ جدید در تاریخچه ثبت می‌شود.'), Forms\Components\Toggle::make('is_active') ->default(true) ->label('فعال'), diff --git a/04_Laravel/config/ifnex.php b/04_Laravel/config/ifnex.php index fd70474..64ba0b3 100644 --- a/04_Laravel/config/ifnex.php +++ b/04_Laravel/config/ifnex.php @@ -124,7 +124,7 @@ return [ 'vat_rate' => 0.09, // ۹٪ مالیات بر ارزش افزوده 'profit_margin' => 1.25, // ۲۵٪ حاشیه سود 'packing_cost' => 100000, // ۱۰۰,۰۰۰ ریال هزینه بسته‌بندی پیش‌فرض - 'aed_to_irr' => 455000, // نرخ درهم به ریال (fallback) + 'aed_to_irr' => 14000, // نرخ درهم به ریال (fallback) ], /* diff --git a/04_Laravel/database/migrations/2026_10_29_130000_enlarge_rate_entries_rate_column.php b/04_Laravel/database/migrations/2026_10_29_130000_enlarge_rate_entries_rate_column.php new file mode 100644 index 0000000..d5beab4 --- /dev/null +++ b/04_Laravel/database/migrations/2026_10_29_130000_enlarge_rate_entries_rate_column.php @@ -0,0 +1,31 @@ +decimal('rate', 20, 4)->comment('in IRR (Iranian Rial)')->change(); + }); + } + + public function down(): void + { + Schema::table('rate_entries', function (Blueprint $table) { + $table->decimal('rate', 12, 4)->change(); + }); + } +}; \ No newline at end of file