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.

AccountBalanceReportTransformer.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Transformers;
  3. use App\DTO\AccountDTO;
  4. class AccountBalanceReportTransformer extends BaseReportTransformer
  5. {
  6. public function getTitle(): string
  7. {
  8. return 'Account Balances';
  9. }
  10. public function getHeaders(): array
  11. {
  12. return ['', 'Account', 'Starting Balance', 'Debit', 'Credit', 'Net Movement', 'Ending Balance'];
  13. }
  14. public function getRightAlignedColumns(): array
  15. {
  16. return [2, 3, 4, 5, 6];
  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->startingBalance ?? '',
  37. $account->balance->debitBalance,
  38. $account->balance->creditBalance,
  39. $account->balance->netMovement,
  40. $account->balance->endingBalance ?? '',
  41. ];
  42. }, $accountCategory->accounts),
  43. 'summary' => [
  44. '',
  45. 'Total ' . $accountCategoryName,
  46. $accountCategory->summary->startingBalance ?? '',
  47. $accountCategory->summary->debitBalance,
  48. $accountCategory->summary->creditBalance,
  49. $accountCategory->summary->netMovement,
  50. $accountCategory->summary->endingBalance ?? '',
  51. ],
  52. ];
  53. }
  54. return $categories;
  55. }
  56. public function getOverallTotals(): array
  57. {
  58. return [
  59. '',
  60. 'Total for all accounts',
  61. '',
  62. $this->report->overallTotal->debitBalance,
  63. $this->report->overallTotal->creditBalance,
  64. '',
  65. '',
  66. ];
  67. }
  68. }