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