Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CashFlowStatement.php 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Filament\Company\Pages\Reports;
  3. use App\Contracts\ExportableReport;
  4. use App\DTO\ReportDTO;
  5. use App\Filament\Company\Pages\Concerns\HasReportTabs;
  6. use App\Services\ExportService;
  7. use App\Services\ReportService;
  8. use App\Support\Column;
  9. use App\Transformers\CashFlowStatementReportTransformer;
  10. use Filament\Forms\Form;
  11. use Filament\Support\Enums\Alignment;
  12. use Guava\FilamentClusters\Forms\Cluster;
  13. use Symfony\Component\HttpFoundation\StreamedResponse;
  14. class CashFlowStatement extends BaseReportPage
  15. {
  16. use HasReportTabs;
  17. protected static string $view = 'filament.company.pages.reports.cash-flow-statement';
  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(isToggledHiddenByDefault: true)
  31. ->alignment(Alignment::Left),
  32. Column::make('account_name')
  33. ->label('CASH INFLOWS AND OUTFLOWS')
  34. ->alignment(Alignment::Left),
  35. Column::make('net_movement')
  36. ->label($this->getDisplayDateRange())
  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->buildCashFlowStatementReport($this->getFormattedStartDate(), $this->getFormattedEndDate(), $columns);
  56. }
  57. protected function getTransformer(ReportDTO $reportDTO): ExportableReport
  58. {
  59. return new CashFlowStatementReportTransformer($reportDTO);
  60. }
  61. public function exportCSV(): StreamedResponse
  62. {
  63. return $this->exportService->exportToCsv($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'), $this->getActiveTab());
  64. }
  65. public function exportPDF(): StreamedResponse
  66. {
  67. return $this->exportService->exportToPdf($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'), $this->getActiveTab());
  68. }
  69. }