| Conditions | 2 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 2.3349 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 1 | public static function build(): iterable |
|
| 17 | { |
||
| 18 | 1 | yield 'exportAccountingReport' => fn () => [ |
|
| 19 | 1 | 'type' => Type::nonNull(Type::string()), |
|
| 20 | 1 | 'description' => 'Prepare an accounting report and return the URL to download it', |
|
| 21 | 1 | 'args' => [ |
|
| 22 | 1 | 'date' => _types()->get('Date'), |
|
| 23 | 1 | 'showBudget' => Type::nonNull(Type::boolean()), |
|
| 24 | 1 | ], |
|
| 25 | 1 | 'resolve' => function ($root, array $args, SessionInterface $session): string { |
|
| 26 | global $container; |
||
| 27 | |||
| 28 | /** @var AccountingReport $exporter */ |
||
| 29 | $exporter = $container->get(AccountingReport::class); |
||
| 30 | |||
| 31 | if ($args['date']) { |
||
| 32 | $exporter->setDate($args['date']); |
||
| 33 | } |
||
| 34 | $exporter->showBudget($args['showBudget']); |
||
| 35 | |||
| 36 | // Select root accounts |
||
| 37 | /** @var AccountRepository $accountRepository */ |
||
| 38 | $accountRepository = _em()->getRepository(Account::class); |
||
| 39 | $rootAccountsQuery = $accountRepository->getRootAccountsQuery(); |
||
| 40 | |||
| 41 | return $exporter->export($rootAccountsQuery->getResult()); |
||
|
|
|||
| 42 | 1 | }, |
|
| 46 |