feat: updates on expenses

This commit is contained in:
JP
2024-10-31 00:53:13 +08:00
parent daa6f692e1
commit 06a2035cc8
7 changed files with 207 additions and 60 deletions

View 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';
}

View 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 [];
}
}

View File

@@ -23,6 +23,8 @@ class BranchResource extends Resource
protected static bool $shouldRegisterNavigation = false; protected static bool $shouldRegisterNavigation = false;
protected static ?string $recordTitleAttribute = 'code';
public static function form(Form $form): Form public static function form(Form $form): Form
{ {
return $form return $form

View File

@@ -3,10 +3,7 @@
namespace App\Filament\Resources\ClientResource\Pages; namespace App\Filament\Resources\ClientResource\Pages;
use App\Filament\Resources\ClientResource; 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\Grid;
use Filament\Infolists\Components\RepeatableEntry;
use Filament\Infolists\Components\Section; use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry; use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist; use Filament\Infolists\Infolist;
@@ -30,23 +27,23 @@ class ViewClient extends ViewRecord
])->columns(3), ])->columns(3),
]), ]),
Section::make('Branches')->schema([ // Section::make('Branches')->schema([
RepeatableEntry::make('branches') // RepeatableEntry::make('branches')
->schema([ // ->schema([
TextEntry::make('code')->label('Branch Code'), // TextEntry::make('code')->label('Branch Code'),
TextEntry::make('current_series')->label('Branch Current Series'), // TextEntry::make('current_series')->label('Branch Current Series'),
]) // ])
->hiddenLabel() // ->hiddenLabel()
->grid(2), // ->grid(2),
])->collapsible(), // ])->collapsible(),
]); ]);
} }
public function getRelationManagers(): array // public function getRelationManagers(): array
{ // {
return [ // return [
AccountsRelationManager::class, // AccountsRelationManager::class,
TransmittalsRelationManager::class, // TransmittalsRelationManager::class,
]; // ];
} // }
} }

View File

@@ -45,18 +45,22 @@ class ExpenseResource extends Resource
$set('branch_id', ''); $set('branch_id', '');
$set('voucher_number', static::getVoucherNumber($get)); $set('voucher_number', static::getVoucherNumber($get));
}) })
->required()
->live(), ->live(),
Select::make('branch_id') Select::make('branch_id')
->relationship('branch', 'code') ->relationship('branch', 'code')
->options(fn ($get) => Branch::query()->where('client_id', $get('client'))->get()->pluck('code', 'id')) ->options(fn ($get) => Branch::query()->where('client_id', $get('client'))->get()->pluck('code', 'id'))
->afterStateUpdated(fn ($set, $get) => $set('voucher_number', static::getVoucherNumber($get))) ->afterStateUpdated(fn ($set, $get) => $set('voucher_number', static::getVoucherNumber($get)))
->required()
->live(), ->live(),
TextInput::make('supplier')->label('Supplier Name'), TextInput::make('supplier')->label('Supplier Name')->required(),
TextInput::make('reference_number')->label('Reference Number'), TextInput::make('reference_number')->label('Reference Number'),
TextInput::make('voucher_number')->label('Voucher Number') TextInput::make('voucher_number')->label('Voucher Number')
->default(fn ($get) => static::getVoucherNumber($get)) ->default(fn ($get) => static::getVoucherNumber($get))
->readOnly(), ->readOnly(),
DatePicker::make('happened_on')->label('Date')->native(false), DatePicker::make('happened_on')->label('Date')
->required()
->native(false),
TableRepeater::make('transactions') TableRepeater::make('transactions')
->headers(fn (Get $get): array => static::getTransactionTableHeader($get)) ->headers(fn (Get $get): array => static::getTransactionTableHeader($get))
@@ -81,15 +85,15 @@ class ExpenseResource extends Resource
public static function getTransactionTableHeader(Get $get): array public static function getTransactionTableHeader(Get $get): array
{ {
if (! static::getIsVatable($get)) { // if (! static::getIsVatable($get)) {
return [ // return [
Header::make('Charge Account'), // Header::make('Charge Account'),
Header::make('Description'), // Header::make('Description'),
Header::make('Gross Amount'), // Header::make('Gross Amount'),
Header::make('Withholding Tax'), // Header::make('Withholding Tax'),
Header::make('Net Amount'), // Header::make('Net Amount'),
]; // ];
} // }
return [ return [
Header::make('Charge Account'), 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 public static function getTransactionTableFormSchema(Get $get): array
{ {
if (! static::getIsVatable($get)) { // if (! static::getIsVatable($get)) {
return [ // return [
Select::make('account_id')->options(fn ($get) => static::getAccountOptions($get)), // Select::make('account_id')->options(fn ($get) => static::getAccountOptions($get)),
TextInput::make('description')->label('Description'), // TextInput::make('description')->label('Description'),
TextInput::make('gross_amount')->numeric() // TextInput::make('gross_amount')->numeric()
->live() // ->live()
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) { // ->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
static::setDefaultFormValues($get, $set, $old, $state); // static::setDefaultFormValues($get, $set, $old, $state);
})->default(0), // })->default(0),
TextInput::make('payable_withholding_tax')->numeric()->live() // TextInput::make('payable_withholding_tax')->numeric()->live()
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) { // ->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
static::setDefaultFormValues($get, $set, $old, $state); // static::setDefaultFormValues($get, $set, $old, $state);
})->default(0), // })->default(0),
TextInput::make('net_amount')->numeric()->default(0), // TextInput::make('net_amount')->numeric()->default(0),
]; // ];
} // }
return [ return [
Select::make('account_id')->options(fn ($get) => static::getAccountOptions($get)), 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)); $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 public static function table(Table $table): Table
{ {
return $table return $table

View File

@@ -0,0 +1,69 @@
<x-filament-panels::page>
<div class="relative overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" class="px-6 py-3">
Product name
</th>
<th scope="col" class="px-6 py-3">
Color
</th>
<th scope="col" class="px-6 py-3">
Category
</th>
<th scope="col" class="px-6 py-3">
Price
</th>
</tr>
</thead>
<tbody>
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
Apple MacBook Pro 17"
</th>
<td class="px-6 py-4">
Silver
</td>
<td class="px-6 py-4">
Laptop
</td>
<td class="px-6 py-4">
$2999
</td>
</tr>
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
Microsoft Surface Pro
</th>
<td class="px-6 py-4">
White
</td>
<td class="px-6 py-4">
Laptop PC
</td>
<td class="px-6 py-4">
$1999
</td>
</tr>
<tr class="bg-white dark:bg-gray-800">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
Magic Mouse 2
</th>
<td class="px-6 py-4">
Black
</td>
<td class="px-6 py-4">
Accessories
</td>
<td class="px-6 py-4">
$99
</td>
</tr>
</tbody>
</table>
</div>
</x-filament-panels::page>

View File

@@ -0,0 +1,45 @@
<x-filament-panels::page>
<div class="relative overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" class="px-6 py-3">
Account
</th>
<th scope="col" class="px-6 py-3">
Debit Amount
</th>
<th scope="col" class="px-6 py-3">
Credit Amount
</th>
</tr>
</thead>
<tbody>
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
Apple MacBook Pro 17"
</th>
<td class="px-6 py-4">
$2999
</td>
<td class="px-6 py-4">
$2999
</td>
</tr>
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" class="px-6 py-4 font-medium text-red-700 whitespace-nowrap dark:text-red-700">
Total
</th>
<td class="px-6 py-4">
$1999
</td>
<td class="px-6 py-4">
$1999
</td>
</tr>
</tbody>
</table>
</div>
</x-filament-panels::page>