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.7KB

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