<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PartnerInvoice extends Model
{
    use HasFactory;

    protected $fillable = [
        'tenant_id',
        'partner_id',
        'period_start',
        'period_end',
        'total_trips',
        'total_wholesale_amount',
        'currency',
        'status',
        'due_date',
        'issued_at',
        'paid_at',
        'notes',
    ];

    protected $casts = [
        'total_wholesale_amount' => 'decimal:2',
        'period_start' => 'date',
        'period_end' => 'date',
        'due_date' => 'date',
        'issued_at' => 'datetime',
        'paid_at' => 'datetime',
    ];

    public function partner(): BelongsTo
    {
        return $this->belongsTo(Partner::class);
    }

    public function tenant(): BelongsTo
    {
        return $this->belongsTo(Tenant::class);
    }
}
