feat: updates on expenses
This commit is contained in:
@@ -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