Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CashFlowStatement.php 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace App\Filament\Company\Pages\Reports;
  3. use App\Contracts\ExportableReport;
  4. use App\DTO\ReportDTO;
  5. use App\Services\ExportService;
  6. use App\Services\ReportService;
  7. use App\Support\Column;
  8. use App\Transformers\CashFlowStatementReportTransformer;
  9. use Filament\Forms\Form;
  10. use Filament\Support\Enums\Alignment;
  11. use Guava\FilamentClusters\Forms\Cluster;
  12. use Livewire\Attributes\Url;
  13. use Symfony\Component\HttpFoundation\StreamedResponse;
  14. class CashFlowStatement extends BaseReportPage
  15. {
  16. protected static string $view = 'filament.company.pages.reports.cash-flow-statement';
  17. protected static ?string $slug = 'reports/cash-flow-statement';
  18. protected static bool $shouldRegisterNavigation = false;
  19. protected ReportService $reportService;
  20. protected ExportService $exportService;
  21. #[Url]
  22. public ?string $activeTab = 'summary';
  23. public function boot(ReportService $reportService, ExportService $exportService): void
  24. {
  25. $this->reportService = $reportService;
  26. $this->exportService = $exportService;
  27. }
  28. public function getTable(): array
  29. {
  30. return [
  31. Column::make('account_name')
  32. ->label('Account')
  33. ->alignment(Alignment::Left),
  34. Column::make('net_movement')
  35. ->label('Amount')
  36. ->alignment(Alignment::Right),
  37. ];
  38. }
  39. public function filtersForm(Form $form): Form
  40. {
  41. return $form
  42. ->inlineLabel()
  43. ->columns()
  44. ->schema([
  45. $this->getDateRangeFormComponent(),
  46. Cluster::make([
  47. $this->getStartDateFormComponent(),
  48. $this->getEndDateFormComponent(),
  49. ])->hiddenLabel(),
  50. ]);
  51. }
  52. protected function buildReport(array $columns): ReportDTO
  53. {
  54. return $this->reportService->buildCashFlowStatementReport($this->getFormattedStartDate(), $this->getFormattedEndDate(), $columns);
  55. }
  56. protected function getTransformer(ReportDTO $reportDTO): ExportableReport
  57. {
  58. return new CashFlowStatementReportTransformer($reportDTO);
  59. }
  60. public function exportCSV(): StreamedResponse
  61. {
  62. return $this->exportService->exportToCsv($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
  63. }
  64. public function exportPDF(): StreamedResponse
  65. {
  66. return $this->exportService->exportToPdf($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
  67. }
  68. }