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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Filament\Company\Pages\Reports;
  3. use App\Contracts\ExportableReport;
  4. use App\DTO\ReportDTO;
  5. use App\Filament\Forms\Components\DateRangeSelect;
  6. use App\Services\ExportService;
  7. use App\Services\ReportService;
  8. use App\Support\Column;
  9. use App\Transformers\BalanceSheetReportTransformer;
  10. use Filament\Forms\Form;
  11. use Filament\Support\Enums\Alignment;
  12. use Livewire\Attributes\Url;
  13. use Symfony\Component\HttpFoundation\StreamedResponse;
  14. class BalanceSheet extends BaseReportPage
  15. {
  16. protected static string $view = 'filament.company.pages.reports.balance-sheet';
  17. protected static bool $shouldRegisterNavigation = false;
  18. protected ReportService $reportService;
  19. protected ExportService $exportService;
  20. #[Url]
  21. public ?string $activeTab = 'summary';
  22. public function boot(ReportService $reportService, ExportService $exportService): void
  23. {
  24. $this->reportService = $reportService;
  25. $this->exportService = $exportService;
  26. }
  27. public function getTable(): array
  28. {
  29. return [
  30. Column::make('account_code')
  31. ->label('Account Code')
  32. ->toggleable(isToggledHiddenByDefault: true)
  33. ->alignment(Alignment::Left),
  34. Column::make('account_name')
  35. ->label('Account')
  36. ->alignment(Alignment::Left),
  37. Column::make('ending_balance')
  38. ->label('Amount')
  39. ->alignment(Alignment::Right),
  40. ];
  41. }
  42. public function filtersForm(Form $form): Form
  43. {
  44. return $form
  45. ->inlineLabel()
  46. ->columns(3)
  47. ->schema([
  48. DateRangeSelect::make('dateRange')
  49. ->label('As of')
  50. ->selectablePlaceholder(false)
  51. ->endDateField('asOfDate'),
  52. $this->getAsOfDateFormComponent()
  53. ->hiddenLabel()
  54. ->extraFieldWrapperAttributes([]),
  55. ]);
  56. }
  57. protected function buildReport(array $columns): ReportDTO
  58. {
  59. return $this->reportService->buildBalanceSheetReport($this->getFormattedAsOfDate(), $columns);
  60. }
  61. protected function getTransformer(ReportDTO $reportDTO): ExportableReport
  62. {
  63. return new BalanceSheetReportTransformer($reportDTO);
  64. }
  65. public function exportCSV(): StreamedResponse
  66. {
  67. return $this->exportService->exportToCsv($this->company, $this->report, endDate: $this->getFilterState('asOfDate'));
  68. }
  69. public function exportPDF(): StreamedResponse
  70. {
  71. return $this->exportService->exportToPdf($this->company, $this->report, endDate: $this->getFilterState('asOfDate'));
  72. }
  73. }