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