You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TrialBalance.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Filament\Company\Pages\Reports;
  3. use App\DTO\ReportDTO;
  4. use App\Services\ExportService;
  5. use App\Services\ReportService;
  6. use App\Transformers\TrialBalanceReportTransformer;
  7. use Filament\Forms\Components\Split;
  8. use Filament\Forms\Form;
  9. use Symfony\Component\HttpFoundation\StreamedResponse;
  10. class TrialBalance extends BaseReportPage
  11. {
  12. protected static string $view = 'filament.company.pages.reports.trial-balance';
  13. protected static ?string $slug = 'reports/trial-balance';
  14. protected static bool $shouldRegisterNavigation = false;
  15. protected ReportService $reportService;
  16. public ReportDTO $trialBalanceReport;
  17. protected ExportService $exportService;
  18. public function boot(ReportService $reportService, ExportService $exportService): void
  19. {
  20. $this->reportService = $reportService;
  21. $this->exportService = $exportService;
  22. }
  23. public function loadReportData(): void
  24. {
  25. $this->trialBalanceReport = $this->reportService->buildTrialBalanceReport($this->startDate, $this->endDate);
  26. }
  27. public function form(Form $form): Form
  28. {
  29. return $form
  30. ->schema([
  31. Split::make([
  32. $this->getDateRangeFormComponent(),
  33. $this->getStartDateFormComponent(),
  34. $this->getEndDateFormComponent(),
  35. ])->live(),
  36. ]);
  37. }
  38. public function exportCSV(): StreamedResponse
  39. {
  40. $transformer = new TrialBalanceReportTransformer($this->trialBalanceReport);
  41. return $this->exportService->exportToCsv($this->company, $transformer, $this->startDate, $this->endDate);
  42. }
  43. public function exportPDF(): StreamedResponse
  44. {
  45. $transformer = new TrialBalanceReportTransformer($this->trialBalanceReport);
  46. return $this->exportService->exportToPdf($this->company, $transformer, $this->startDate, $this->endDate);
  47. }
  48. }