Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

IncomeStatement.php 2.6KB

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\IncomeStatementReportTransformer;
  9. use Filament\Forms\Form;
  10. use Filament\Support\Enums\Alignment;
  11. use Guava\FilamentClusters\Forms\Cluster;
  12. use Symfony\Component\HttpFoundation\StreamedResponse;
  13. class IncomeStatement extends BaseReportPage
  14. {
  15. protected static string $view = 'filament.company.pages.reports.income-statement';
  16. protected static ?string $slug = 'reports/income-statement';
  17. protected static bool $shouldRegisterNavigation = false;
  18. protected ReportService $reportService;
  19. protected ExportService $exportService;
  20. public function boot(ReportService $reportService, ExportService $exportService): void
  21. {
  22. $this->reportService = $reportService;
  23. $this->exportService = $exportService;
  24. }
  25. public function getTable(): array
  26. {
  27. return [
  28. Column::make('account_code')
  29. ->label('Account Code')
  30. ->toggleable()
  31. ->alignment(Alignment::Center),
  32. Column::make('account_name')
  33. ->label('Account')
  34. ->alignment(Alignment::Left),
  35. Column::make('net_movement')
  36. ->label('Amount')
  37. ->alignment(Alignment::Right),
  38. ];
  39. }
  40. public function filtersForm(Form $form): Form
  41. {
  42. return $form
  43. ->inlineLabel()
  44. ->columns()
  45. ->schema([
  46. $this->getDateRangeFormComponent(),
  47. Cluster::make([
  48. $this->getStartDateFormComponent(),
  49. $this->getEndDateFormComponent(),
  50. ])->hiddenLabel(),
  51. ]);
  52. }
  53. protected function buildReport(array $columns): ReportDTO
  54. {
  55. return $this->reportService->buildIncomeStatementReport($this->getFormattedStartDate(), $this->getFormattedEndDate(), $columns);
  56. }
  57. protected function getTransformer(ReportDTO $reportDTO): ExportableReport
  58. {
  59. return new IncomeStatementReportTransformer($reportDTO);
  60. }
  61. public function exportCSV(): StreamedResponse
  62. {
  63. return $this->exportService->exportToCsv($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
  64. }
  65. public function exportPDF(): StreamedResponse
  66. {
  67. return $this->exportService->exportToPdf($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
  68. }
  69. }