Add gold credit feature gated by SuperAdmin enable_gold_credit.

Port tables, APIs, and overdue cron from goldali, default the flag off, and keep customer routes behind auth.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-30 00:17:01 +03:30
co-authored by Cursor
parent a8be3d499b
commit 050bd26318
18 changed files with 1670 additions and 5 deletions
+61
View File
@@ -0,0 +1,61 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class GoldCredit extends Model
{
protected $fillable = [
'customer_id',
'gold_amount',
'months',
'interest_type',
'interest_value',
'delivery_method',
'status',
'source',
'total_interest_gold',
'total_payable_gold',
'paid_gold',
'paid_rial',
'created_by',
'notes',
'has_check',
'has_contract',
'check_note',
'contract_note',
'penalty_type',
'penalty_amount',
'grace_hours',
];
protected $casts = [
'gold_amount' => 'float',
'interest_value' => 'float',
'total_interest_gold' => 'float',
'total_payable_gold' => 'float',
'paid_gold' => 'float',
'paid_rial' => 'integer',
'has_check' => 'boolean',
'has_contract' => 'boolean',
'penalty_amount' => 'float',
];
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class);
}
public function installments(): HasMany
{
return $this->hasMany(GoldCreditInstallment::class)->orderBy('installment_number');
}
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class GoldCreditInstallment extends Model
{
protected $fillable = [
'gold_credit_id',
'installment_number',
'due_date',
'amount_soot',
'principal_gold',
'interest_gold',
'total_gold',
'paid_gold',
'paid_rial',
'status',
'paid_at',
'warning_sms_sent_at',
'reminder_3d_sent_at',
'reminder_1d_sent_at',
'penalty_started_at',
'last_penalty_at',
'penalty_days',
'penalty_rial',
'penalty_gold',
];
protected $casts = [
'due_date' => 'date',
'principal_gold' => 'float',
'interest_gold' => 'float',
'total_gold' => 'float',
'paid_gold' => 'float',
'paid_rial' => 'integer',
'paid_at' => 'datetime',
'warning_sms_sent_at' => 'datetime',
'reminder_3d_sent_at' => 'datetime',
'reminder_1d_sent_at' => 'datetime',
'penalty_started_at' => 'datetime',
'last_penalty_at' => 'datetime',
'penalty_gold' => 'float',
];
public function goldCredit(): BelongsTo
{
return $this->belongsTo(GoldCredit::class);
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class GoldCreditRequest extends Model
{
protected $fillable = [
'customer_id',
'requested_gold',
'requested_months',
'note',
'status',
'admin_note',
'gold_credit_id',
];
protected $casts = [
'requested_gold' => 'float',
];
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class);
}
public function goldCredit(): BelongsTo
{
return $this->belongsTo(GoldCredit::class);
}
}