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.

TrialBalanceReportTransformer.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Transformers;
  3. use App\DTO\AccountDTO;
  4. use App\DTO\ReportCategoryDTO;
  5. class TrialBalanceReportTransformer extends BaseReportTransformer
  6. {
  7. public function getTitle(): string
  8. {
  9. return 'Trial Balance';
  10. }
  11. public function getHeaders(): array
  12. {
  13. return ['', 'Account', 'Debit', 'Credit'];
  14. }
  15. public function getRightAlignedColumns(): array
  16. {
  17. return [2, 3];
  18. }
  19. public function getLeftAlignedColumns(): array
  20. {
  21. return [1];
  22. }
  23. public function getCenterAlignedColumns(): array
  24. {
  25. return [0];
  26. }
  27. /**
  28. * @return ReportCategoryDTO[]
  29. */
  30. public function getCategories(): array
  31. {
  32. $categories = [];
  33. foreach ($this->report->categories as $accountCategoryName => $accountCategory) {
  34. $categories[] = new ReportCategoryDTO(
  35. header: ['', $accountCategoryName, '', ''],
  36. data: array_map(static function (AccountDTO $account) {
  37. return [
  38. $account->accountCode,
  39. $account->accountName,
  40. $account->balance->debitBalance,
  41. $account->balance->creditBalance,
  42. ];
  43. }, $accountCategory->accounts),
  44. summary: [
  45. '',
  46. 'Total ' . $accountCategoryName,
  47. $accountCategory->summary->debitBalance,
  48. $accountCategory->summary->creditBalance,
  49. ],
  50. );
  51. }
  52. return $categories;
  53. }
  54. public function getOverallTotals(): array
  55. {
  56. return [
  57. '',
  58. 'Total for all accounts',
  59. $this->report->overallTotal->debitBalance,
  60. $this->report->overallTotal->creditBalance,
  61. ];
  62. }
  63. }