Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

AccountBalances.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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\AccountBalanceReportTransformer;
  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 AccountBalances extends BaseReportPage
  14. {
  15. protected static string $view = 'filament.company.pages.reports.detailed-report';
  16. protected ReportService $reportService;
  17. protected ExportService $exportService;
  18. public function boot(ReportService $reportService, ExportService $exportService): void
  19. {
  20. $this->reportService = $reportService;
  21. $this->exportService = $exportService;
  22. }
  23. /**
  24. * @return array<Column>
  25. */
  26. public function getTable(): array
  27. {
  28. return [
  29. Column::make('account_code')
  30. ->label('ACCOUNT CODE')
  31. ->toggleable(isToggledHiddenByDefault: true)
  32. ->alignment(Alignment::Left),
  33. Column::make('account_name')
  34. ->label('ACCOUNT')
  35. ->alignment(Alignment::Left),
  36. Column::make('starting_balance')
  37. ->label('STARTING BALANCE')
  38. ->toggleable()
  39. ->alignment(Alignment::Right),
  40. Column::make('debit_balance')
  41. ->label('DEBIT')
  42. ->toggleable()
  43. ->alignment(Alignment::Right),
  44. Column::make('credit_balance')
  45. ->label('CREDIT')
  46. ->toggleable()
  47. ->alignment(Alignment::Right),
  48. Column::make('net_movement')
  49. ->label('NET MOVEMENT')
  50. ->toggleable()
  51. ->alignment(Alignment::Right),
  52. Column::make('ending_balance')
  53. ->label('ENDING BALANCE')
  54. ->toggleable()
  55. ->alignment(Alignment::Right),
  56. ];
  57. }
  58. public function filtersForm(Form $form): Form
  59. {
  60. return $form
  61. ->inlineLabel()
  62. ->columns()
  63. ->schema([
  64. $this->getDateRangeFormComponent(),
  65. Cluster::make([
  66. $this->getStartDateFormComponent(),
  67. $this->getEndDateFormComponent(),
  68. ])->hiddenLabel(),
  69. ]);
  70. }
  71. protected function buildReport(array $columns): ReportDTO
  72. {
  73. return $this->reportService->buildAccountBalanceReport($this->getFormattedStartDate(), $this->getFormattedEndDate(), $columns);
  74. }
  75. protected function getTransformer(ReportDTO $reportDTO): ExportableReport
  76. {
  77. return new AccountBalanceReportTransformer($reportDTO);
  78. }
  79. public function exportCSV(): StreamedResponse
  80. {
  81. return $this->exportService->exportToCsv($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
  82. }
  83. public function exportPDF(): StreamedResponse
  84. {
  85. return $this->exportService->exportToPdf($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
  86. }
  87. }