123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
-
- namespace App\Filament\Company\Pages\Reports;
-
- use App\Contracts\ExportableReport;
- use App\DTO\ReportDTO;
- use App\Services\ExportService;
- use App\Services\ReportService;
- use App\Support\Column;
- use App\Transformers\CashFlowStatementReportTransformer;
- use Filament\Forms\Form;
- use Filament\Support\Enums\Alignment;
- use Guava\FilamentClusters\Forms\Cluster;
- use Livewire\Attributes\Url;
- use Symfony\Component\HttpFoundation\StreamedResponse;
-
- class CashFlowStatement extends BaseReportPage
- {
- protected static string $view = 'filament.company.pages.reports.cash-flow-statement';
-
- protected static ?string $slug = 'reports/cash-flow-statement';
-
- protected static bool $shouldRegisterNavigation = false;
-
- protected ReportService $reportService;
-
- protected ExportService $exportService;
-
- #[Url]
- public ?string $activeTab = 'summary';
-
- public function boot(ReportService $reportService, ExportService $exportService): void
- {
- $this->reportService = $reportService;
- $this->exportService = $exportService;
- }
-
- public function getTable(): array
- {
- return [
- Column::make('account_code')
- ->label('ACCOUNT CODE')
- ->toggleable(isToggledHiddenByDefault: true)
- ->alignment(Alignment::Left),
- Column::make('account_name')
- ->label('CASH INFLOWS AND OUTFLOWS')
- ->alignment(Alignment::Left),
- Column::make('net_movement')
- ->label($this->getDisplayDateRange())
- ->alignment(Alignment::Right),
- ];
- }
-
- public function filtersForm(Form $form): Form
- {
- return $form
- ->inlineLabel()
- ->columns()
- ->schema([
- $this->getDateRangeFormComponent(),
- Cluster::make([
- $this->getStartDateFormComponent(),
- $this->getEndDateFormComponent(),
- ])->hiddenLabel(),
- ]);
- }
-
- protected function buildReport(array $columns): ReportDTO
- {
- return $this->reportService->buildCashFlowStatementReport($this->getFormattedStartDate(), $this->getFormattedEndDate(), $columns);
- }
-
- protected function getTransformer(ReportDTO $reportDTO): ExportableReport
- {
- return new CashFlowStatementReportTransformer($reportDTO);
- }
-
- public function exportCSV(): StreamedResponse
- {
- return $this->exportService->exportToCsv($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
- }
-
- public function exportPDF(): StreamedResponse
- {
- return $this->exportService->exportToPdf($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
- }
- }
|