upgrade to filament v4
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use Closure;
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
abstract class BaseAction
|
||||
{
|
||||
abstract public function __invoke(Data $payload, \Closure $next) ;
|
||||
abstract public function __invoke(Data $payload, Closure $next) ;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Actions\Branch;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use App\Actions\BaseAction;
|
||||
use App\Commands\Series\CreateSeriesCommand;
|
||||
use App\DataObjects\CreateBranchDTO;
|
||||
@@ -15,7 +18,7 @@ class StoreBranchSeries extends BaseAction
|
||||
private CreateSeriesCommand $createSeriesCommand
|
||||
) {}
|
||||
|
||||
public function __invoke(CreateBranchDTO|Data $payload, \Closure $next)
|
||||
public function __invoke(CreateBranchDTO|Data $payload, Closure $next)
|
||||
{
|
||||
try {
|
||||
$seriesPayload = CreateSeriesDTO::from(['branch_id' => $payload->branch->id, 'series' => $payload->data['series'], 'is_start' => true]);
|
||||
@@ -23,8 +26,8 @@ class StoreBranchSeries extends BaseAction
|
||||
$payload->series = $this->createSeriesCommand->execute($seriesPayload->toArray());
|
||||
|
||||
return $next($payload);
|
||||
} catch (\Exception $exception) {
|
||||
throw new \LogicException('Failed to create branch series', $exception->getMessage());
|
||||
} catch (Exception $exception) {
|
||||
throw new LogicException('Failed to create branch series', $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Actions\Sales;
|
||||
|
||||
use Exception;
|
||||
use App\Actions\Transactions\CreateRecordTransactionsAction;
|
||||
use App\Commands\Sales\CreateSaleCommand;
|
||||
use App\Commands\Series\CreateSeriesCommand;
|
||||
@@ -44,9 +45,9 @@ class CreateSaleAction
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
DB::rollBack();
|
||||
throw new \Exception('Failed to save transactions : '.$exception->getMessage());
|
||||
throw new Exception('Failed to save transactions : '.$exception->getMessage());
|
||||
}
|
||||
|
||||
return $record;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Actions\Transactions;
|
||||
|
||||
use App\Models\Expense;
|
||||
use App\Actions\Balances\CreateBalanceAction;
|
||||
use App\Actions\BaseAction;
|
||||
use App\Actions\Ledgers\CreateLedgerAction;
|
||||
@@ -34,7 +35,7 @@ class CreateTransactionAction extends BaseAction
|
||||
public function transactionAccountLedger($payload): void
|
||||
{
|
||||
$branch = $payload->transaction->branch;
|
||||
$isExpense = $payload->transactionable instanceof \App\Models\Expense;
|
||||
$isExpense = $payload->transactionable instanceof Expense;
|
||||
$type = $isExpense ? 'debit' : 'credit';
|
||||
|
||||
$discount = $payload->transaction->discount ?? 0.00;
|
||||
@@ -102,7 +103,7 @@ class CreateTransactionAction extends BaseAction
|
||||
|
||||
public function withHoldingAccountLedger($payload): void
|
||||
{
|
||||
$isExpense = $payload->transactionable instanceof \App\Models\Expense;
|
||||
$isExpense = $payload->transactionable instanceof Expense;
|
||||
$accountName = $isExpense ? 'Payable Withholding Tax' : 'Creditable Withholding Tax';
|
||||
$type = $isExpense ? 'credit' : 'debit';
|
||||
$clientId = $payload->transactionable->branch->client_id;
|
||||
@@ -128,7 +129,7 @@ class CreateTransactionAction extends BaseAction
|
||||
|
||||
public function cashAccountLedger($payload): void
|
||||
{
|
||||
$isExpense = $payload->transactionable instanceof \App\Models\Expense;
|
||||
$isExpense = $payload->transactionable instanceof Expense;
|
||||
$type = $isExpense ? 'credit' : 'debit';
|
||||
$wht = $isExpense ? ($payload->transaction->payable_withholding_tax ?? 0) : ($payload->transaction->creditable_withholding_tax ?? 0);
|
||||
$amount = ($payload->transaction->gross_amount ?? 0) - $wht;
|
||||
@@ -153,7 +154,7 @@ class CreateTransactionAction extends BaseAction
|
||||
|
||||
public function discountAccountLedger($payload): void
|
||||
{
|
||||
$isExpense = $payload->transactionable instanceof \App\Models\Expense;
|
||||
$isExpense = $payload->transactionable instanceof Expense;
|
||||
$type = $isExpense ? 'credit' : 'debit';
|
||||
$amount = $payload->transaction->discount ?? 0.00;
|
||||
$clientId = $payload->transactionable->branch->client_id;
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Actions\Transmittal;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use App\Actions\BaseAction;
|
||||
use App\Commands\Transmittal\StoreTransmittalCommand;
|
||||
use App\DataObjects\CreateTransmittalDTO;
|
||||
@@ -15,15 +18,15 @@ class CreateTransmittal extends BaseAction
|
||||
private readonly StoreTransmittalCommand $storeTransmittalCommand
|
||||
) {}
|
||||
|
||||
public function __invoke(CreateTransmittalDTO | Data $payload, \Closure $next)
|
||||
public function __invoke(CreateTransmittalDTO | Data $payload, Closure $next)
|
||||
{
|
||||
try {
|
||||
$payload->transmittal = $this->storeTransmittalCommand->execute(Arr::except($payload->data, ['files']));
|
||||
|
||||
return $next($payload);
|
||||
} catch (\Exception $exception)
|
||||
} catch (Exception $exception)
|
||||
{
|
||||
throw new \LogicException('Error creating transmittal: ' . $exception->getMessage());
|
||||
throw new LogicException('Error creating transmittal: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Actions\Transmittal;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use App\Actions\BaseAction;
|
||||
use App\Commands\Transmittal\StoreCommentCommand;
|
||||
use App\Commands\Transmittal\StoreFileCommand;
|
||||
@@ -22,7 +25,7 @@ class CreateTransmittalFiles extends BaseAction
|
||||
private readonly StoreRemarkCommand $storeRemarkCommand
|
||||
) {}
|
||||
|
||||
public function __invoke(CreateTransmittalDTO | Data $payload, \Closure $next)
|
||||
public function __invoke(CreateTransmittalDTO | Data $payload, Closure $next)
|
||||
{
|
||||
try {
|
||||
$files = Arr::only($payload->data, 'files');
|
||||
@@ -55,9 +58,9 @@ class CreateTransmittalFiles extends BaseAction
|
||||
$payload->files = $filesCreated;
|
||||
|
||||
return $next($payload);
|
||||
} catch (\Exception $exception)
|
||||
} catch (Exception $exception)
|
||||
{
|
||||
throw new \LogicException('Error creating transmittal files: ' . $exception->getMessage());
|
||||
throw new LogicException('Error creating transmittal files: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user