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.

TrialBalance.php 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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\TrialBalanceReportTransformer;
  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 TrialBalance extends BaseReportPage
  14. {
  15. protected static string $view = 'filament.company.pages.reports.detailed-report';
  16. protected static ?string $slug = 'reports/trial-balance';
  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('debit_balance')
  36. ->label('Debit')
  37. ->toggleable()
  38. ->alignment(Alignment::Right),
  39. Column::make('credit_balance')
  40. ->label('Credit')
  41. ->toggleable()
  42. ->alignment(Alignment::Right),
  43. ];
  44. }
  45. public function form(Form $form): Form
  46. {
  47. return $form
  48. ->inlineLabel()
  49. ->columns([
  50. 'lg' => 1,
  51. '2xl' => 2,
  52. ])
  53. ->live()
  54. ->schema([
  55. $this->getDateRangeFormComponent(),
  56. Cluster::make([
  57. $this->getStartDateFormComponent(),
  58. $this->getEndDateFormComponent(),
  59. ])->hiddenLabel(),
  60. ]);
  61. }
  62. protected function buildReport(array $columns): ReportDTO
  63. {
  64. return $this->reportService->buildTrialBalanceReport($this->startDate, $this->endDate, $columns);
  65. }
  66. protected function getTransformer(ReportDTO $reportDTO): ExportableReport
  67. {
  68. return new TrialBalanceReportTransformer($reportDTO);
  69. }
  70. public function exportCSV(): StreamedResponse
  71. {
  72. return $this->exportService->exportToCsv($this->company, $this->report, $this->startDate, $this->endDate);
  73. }
  74. public function exportPDF(): StreamedResponse
  75. {
  76. return $this->exportService->exportToPdf($this->company, $this->report, $this->startDate, $this->endDate);
  77. }
  78. }