feat: updates on expenses
This commit is contained in:
12
app/Filament/Pages/GeneralLedger.php
Normal file
12
app/Filament/Pages/GeneralLedger.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
|
||||
class GeneralLedger extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.general-ledger';
|
||||
}
|
||||
18
app/Filament/Pages/TrialBalance.php
Normal file
18
app/Filament/Pages/TrialBalance.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
|
||||
class TrialBalance extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.trial-balance';
|
||||
|
||||
public function getViewData(): array
|
||||
{
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ class BranchResource extends Resource
|
||||
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'code';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
namespace App\Filament\Resources\ClientResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClientResource;
|
||||
use App\Filament\Resources\ClientResource\RelationManagers\AccountsRelationManager;
|
||||
use App\Filament\Resources\ClientResource\RelationManagers\TransmittalsRelationManager;
|
||||
use Filament\Infolists\Components\Grid;
|
||||
use Filament\Infolists\Components\RepeatableEntry;
|
||||
use Filament\Infolists\Components\Section;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Infolists\Infolist;
|
||||
@@ -30,23 +27,23 @@ class ViewClient extends ViewRecord
|
||||
])->columns(3),
|
||||
]),
|
||||
|
||||
Section::make('Branches')->schema([
|
||||
RepeatableEntry::make('branches')
|
||||
->schema([
|
||||
TextEntry::make('code')->label('Branch Code'),
|
||||
TextEntry::make('current_series')->label('Branch Current Series'),
|
||||
])
|
||||
->hiddenLabel()
|
||||
->grid(2),
|
||||
])->collapsible(),
|
||||
// Section::make('Branches')->schema([
|
||||
// RepeatableEntry::make('branches')
|
||||
// ->schema([
|
||||
// TextEntry::make('code')->label('Branch Code'),
|
||||
// TextEntry::make('current_series')->label('Branch Current Series'),
|
||||
// ])
|
||||
// ->hiddenLabel()
|
||||
// ->grid(2),
|
||||
// ])->collapsible(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getRelationManagers(): array
|
||||
{
|
||||
return [
|
||||
AccountsRelationManager::class,
|
||||
TransmittalsRelationManager::class,
|
||||
];
|
||||
}
|
||||
// public function getRelationManagers(): array
|
||||
// {
|
||||
// return [
|
||||
// AccountsRelationManager::class,
|
||||
// TransmittalsRelationManager::class,
|
||||
// ];
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -45,18 +45,22 @@ class ExpenseResource extends Resource
|
||||
$set('branch_id', '');
|
||||
$set('voucher_number', static::getVoucherNumber($get));
|
||||
})
|
||||
->required()
|
||||
->live(),
|
||||
Select::make('branch_id')
|
||||
->relationship('branch', 'code')
|
||||
->options(fn ($get) => Branch::query()->where('client_id', $get('client'))->get()->pluck('code', 'id'))
|
||||
->afterStateUpdated(fn ($set, $get) => $set('voucher_number', static::getVoucherNumber($get)))
|
||||
->required()
|
||||
->live(),
|
||||
TextInput::make('supplier')->label('Supplier Name'),
|
||||
TextInput::make('supplier')->label('Supplier Name')->required(),
|
||||
TextInput::make('reference_number')->label('Reference Number'),
|
||||
TextInput::make('voucher_number')->label('Voucher Number')
|
||||
->default(fn ($get) => static::getVoucherNumber($get))
|
||||
->readOnly(),
|
||||
DatePicker::make('happened_on')->label('Date')->native(false),
|
||||
DatePicker::make('happened_on')->label('Date')
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
TableRepeater::make('transactions')
|
||||
->headers(fn (Get $get): array => static::getTransactionTableHeader($get))
|
||||
@@ -81,15 +85,15 @@ class ExpenseResource extends Resource
|
||||
public static function getTransactionTableHeader(Get $get): array
|
||||
{
|
||||
|
||||
if (! static::getIsVatable($get)) {
|
||||
return [
|
||||
Header::make('Charge Account'),
|
||||
Header::make('Description'),
|
||||
Header::make('Gross Amount'),
|
||||
Header::make('Withholding Tax'),
|
||||
Header::make('Net Amount'),
|
||||
];
|
||||
}
|
||||
// if (! static::getIsVatable($get)) {
|
||||
// return [
|
||||
// Header::make('Charge Account'),
|
||||
// Header::make('Description'),
|
||||
// Header::make('Gross Amount'),
|
||||
// Header::make('Withholding Tax'),
|
||||
// Header::make('Net Amount'),
|
||||
// ];
|
||||
// }
|
||||
|
||||
return [
|
||||
Header::make('Charge Account'),
|
||||
@@ -104,38 +108,24 @@ class ExpenseResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
public static function getIsVatable(Get $get): bool
|
||||
{
|
||||
$client = Client::find($get('client'));
|
||||
|
||||
return $client && $client->vatable;
|
||||
|
||||
}
|
||||
|
||||
public static function isVatable(bool $value): void
|
||||
{
|
||||
static::$isVatable = $value;
|
||||
dump('sett');
|
||||
}
|
||||
|
||||
public static function getTransactionTableFormSchema(Get $get): array
|
||||
{
|
||||
if (! static::getIsVatable($get)) {
|
||||
return [
|
||||
Select::make('account_id')->options(fn ($get) => static::getAccountOptions($get)),
|
||||
TextInput::make('description')->label('Description'),
|
||||
TextInput::make('gross_amount')->numeric()
|
||||
->live()
|
||||
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
|
||||
static::setDefaultFormValues($get, $set, $old, $state);
|
||||
})->default(0),
|
||||
TextInput::make('payable_withholding_tax')->numeric()->live()
|
||||
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
|
||||
static::setDefaultFormValues($get, $set, $old, $state);
|
||||
})->default(0),
|
||||
TextInput::make('net_amount')->numeric()->default(0),
|
||||
];
|
||||
}
|
||||
// if (! static::getIsVatable($get)) {
|
||||
// return [
|
||||
// Select::make('account_id')->options(fn ($get) => static::getAccountOptions($get)),
|
||||
// TextInput::make('description')->label('Description'),
|
||||
// TextInput::make('gross_amount')->numeric()
|
||||
// ->live()
|
||||
// ->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
|
||||
// static::setDefaultFormValues($get, $set, $old, $state);
|
||||
// })->default(0),
|
||||
// TextInput::make('payable_withholding_tax')->numeric()->live()
|
||||
// ->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
|
||||
// static::setDefaultFormValues($get, $set, $old, $state);
|
||||
// })->default(0),
|
||||
// TextInput::make('net_amount')->numeric()->default(0),
|
||||
// ];
|
||||
// }
|
||||
|
||||
return [
|
||||
Select::make('account_id')->options(fn ($get) => static::getAccountOptions($get)),
|
||||
@@ -227,6 +217,20 @@ class ExpenseResource extends Resource
|
||||
$set('net_amount', number_format($netAmount, 2));
|
||||
}
|
||||
|
||||
public static function getIsVatable(Get $get): bool
|
||||
{
|
||||
$client = Client::find($get('client'));
|
||||
|
||||
return $client && $client->vatable;
|
||||
|
||||
}
|
||||
|
||||
public static function isVatable(bool $value): void
|
||||
{
|
||||
static::$isVatable = $value;
|
||||
dump('sett');
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
|
||||
Reference in New Issue
Block a user