Hoan thien core finance v2
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Settlements\Pages;
|
||||
|
||||
use App\Filament\Resources\Settlements\SettlementResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSettlement extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SettlementResource::class;
|
||||
}
|
||||
11
app/Filament/Resources/Settlements/Pages/EditSettlement.php
Normal file
11
app/Filament/Resources/Settlements/Pages/EditSettlement.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Settlements\Pages;
|
||||
|
||||
use App\Filament\Resources\Settlements\SettlementResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSettlement extends EditRecord
|
||||
{
|
||||
protected static string $resource = SettlementResource::class;
|
||||
}
|
||||
11
app/Filament/Resources/Settlements/Pages/ListSettlements.php
Normal file
11
app/Filament/Resources/Settlements/Pages/ListSettlements.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Settlements\Pages;
|
||||
|
||||
use App\Filament\Resources\Settlements\SettlementResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSettlements extends ListRecords
|
||||
{
|
||||
protected static string $resource = SettlementResource::class;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Settlements\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SettlementForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Section::make('Thông tin quyết toán')
|
||||
->columnSpan(2)
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('product_id')
|
||||
->label('Sản phẩm')
|
||||
->relationship('product', 'code')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
TextInput::make('type')
|
||||
->label('Loại quyết toán')
|
||||
->required(),
|
||||
|
||||
TextInput::make('temp_value')
|
||||
->label('Giá trị tạm tính')
|
||||
->numeric()
|
||||
->prefix('VND')
|
||||
->required(),
|
||||
|
||||
TextInput::make('final_value')
|
||||
->label('Giá trị chốt')
|
||||
->numeric()
|
||||
->prefix('VND')
|
||||
->required(),
|
||||
|
||||
TextInput::make('difference')
|
||||
->label('Chênh lệch')
|
||||
->numeric()
|
||||
->prefix('VND')
|
||||
->required(),
|
||||
|
||||
TextInput::make('red_book_status')
|
||||
->label('Trạng thái sổ đỏ')
|
||||
->required(),
|
||||
|
||||
DatePicker::make('issue_date')
|
||||
->label('Ngày cấp sổ')
|
||||
->nullable(),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
42
app/Filament/Resources/Settlements/SettlementResource.php
Normal file
42
app/Filament/Resources/Settlements/SettlementResource.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Settlements;
|
||||
|
||||
use App\Filament\Resources\Settlements\Pages;
|
||||
use App\Models\Settlement;
|
||||
use App\Enums\NavigationGroup;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\Settlements\Schemas\SettlementForm;
|
||||
use App\Filament\Resources\Settlements\Tables\SettlementsTable;
|
||||
|
||||
class SettlementResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Settlement::class;
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-clipboard-document-check';
|
||||
protected static string | \UnitEnum | null $navigationGroup = NavigationGroup::TRANSACTION->value;
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static ?string $modelLabel = 'Quyết toán';
|
||||
protected static ?string $pluralModelLabel = 'Quyết toán & Sổ đỏ';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SettlementForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SettlementsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListSettlements::route('/'),
|
||||
'create' => Pages\CreateSettlement::route('/create'),
|
||||
'edit' => Pages\EditSettlement::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user