- rate approval: API creates pending proposals, manager approves - customer_credits + credit_settlements tables - CustomerCreditService (grant/settle via wallet) - rebuilt CustomerCreditResource - CustomerFinancialController: real foreign-currency debt - WP login redirect + custom login page wiring
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class ExchangeRateHistory extends Model
|
|
{
|
|
protected $table = 'exchange_rate_history';
|
|
|
|
protected $fillable = [
|
|
'currency_from',
|
|
'currency_to',
|
|
'old_rate',
|
|
'new_rate',
|
|
'change_percent',
|
|
'change_source',
|
|
'status',
|
|
'changed_by',
|
|
'approved_by',
|
|
'approved_at',
|
|
'api_source',
|
|
'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'old_rate' => 'decimal:2',
|
|
'new_rate' => 'decimal:2',
|
|
'change_percent' => 'decimal:4',
|
|
'approved_at' => 'datetime',
|
|
];
|
|
|
|
public function changedBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'changed_by');
|
|
}
|
|
|
|
public function approvedBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'approved_by');
|
|
}
|
|
|
|
// ─── Helpers ───────────────────────────────────
|
|
|
|
public function isPending(): bool
|
|
{
|
|
return $this->status === 'pending';
|
|
}
|
|
|
|
public function isApproved(): bool
|
|
{
|
|
return $this->status === 'approved';
|
|
}
|
|
} |