<?php

namespace App\Filament\Resources\Settlements\Tables;

use Filament\Tables;
use Filament\Tables\Table;

class SettlementsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('product.code')
                    ->label('Sản phẩm')
                    ->searchable()
                    ->sortable(),

                Tables\Columns\TextColumn::make('type')
                    ->label('Loại QT')
                    ->badge(),

                Tables\Columns\TextColumn::make('temp_value')
                    ->label('Tạm tính')
                    ->money('VND')
                    ->sortable(),

                Tables\Columns\TextColumn::make('final_value')
                    ->label('Chốt')
                    ->money('VND')
                    ->sortable(),

                Tables\Columns\TextColumn::make('difference')
                    ->label('Chênh lệch')
                    ->money('VND')
                    ->color(fn ($state) => (float) $state > 0 ? 'danger' : 'success'),

                Tables\Columns\TextColumn::make('red_book_status')
                    ->label('Trạng thái sổ')
                    ->badge(),

                Tables\Columns\TextColumn::make('issue_date')
                    ->label('Ngày cấp')
                    ->date('d/m/Y')
                    ->placeholder('Chưa cấp'),
            ])
            ->defaultSort('created_at', 'desc');
    }
}
