fix(rate-import): enlarge rate column + correct AED fallback rate

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.
This commit is contained in:
Kazem Alghasi 2026-10-29 19:09:35 +03:30
parent 58493feca4
commit 477418b349
3 changed files with 33 additions and 2 deletions

View File

@ -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('فعال'),

View File

@ -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)
],
/*

View File

@ -0,0 +1,31 @@
<?php
/**
* Migration: بزرگ‌کردن ستون rate برای پشتیبانی از مبالغ بزرگ ریالی
*
* ستون rate قبلاً decimal(12,4) بود که حداکثر ~100 میلیون را نگه می‌داشت.
* با تبدیل نرخ‌های درهم به ریال، ستون را به decimal(20,4) افزایش می‌دهیم
* که حداکثر ~100 تریلیون را نگه می‌دارد.
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('rate_entries', function (Blueprint $table) {
// decimal(20,4): 16 رقم قبل اعشار + 4 رقم بعد اعشار
$table->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();
});
}
};