Files
MKM/app/Actions/Ledgers/CreateLedgerAction.php
Jp 207f4c1609 feat(client): add financial reports and ledger management
- Add trial balance and general ledger pages to client resource with interactive tables
- Implement sales and expenses relation managers for client-specific transactions
- Enhance transaction handling with proper tax and withholding calculations
- Add date casting to Transaction model and define client relationships
- Configure super admin role bypass in AppServiceProvider
- Update Filament components and fix JavaScript formatting issues
2026-02-09 16:20:55 +08:00

34 lines
884 B
PHP

<?php
namespace App\Actions\Ledgers;
use App\Actions\BaseAction;
use App\Commands\Ledgers\CreateLedgerCommand;
use App\DataObjects\CreateBalanceDTO;
use App\DataObjects\CreateLedgerDTO;
use Closure;
use Spatie\LaravelData\Data;
class CreateLedgerAction extends BaseAction
{
public function __construct(
private readonly CreateLedgerCommand $createLedgerCommand,
) {}
public function __invoke(CreateLedgerDTO|Data $payload, Closure $next)
{
$ledger = $this->createLedgerCommand->execute($payload->data);
$payload->balanceDTO = new CreateBalanceDTO(
amount: $payload->amount,
is_starting: false,
ledger_id: $ledger->id,
account_id: $ledger->account_id,
branch_id: $ledger->branch_id,
type: $payload->type ?? 'debit',
);
return $next($payload);
}
}