add budget to docgen

This commit is contained in:
2022-03-24 18:22:49 +01:00
parent 531f940b65
commit 84f9fdba28
8 changed files with 199 additions and 5 deletions

View File

@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\Query\Parameter;
use Knp\Menu\MenuItem;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
@@ -26,10 +25,10 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
{
protected AuthorizationCheckerInterface $authorizationChecker;
protected TranslatorInterface $translator;
protected ParameterBagInterface $parameterBag;
protected TranslatorInterface $translator;
/**
* SectionMenuBuilder constructor.
*/

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\BudgetBundle\Service\Summary\SummaryBudget;
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Civility;
@@ -44,6 +45,8 @@ class PersonDocGenNormalizer implements
private RelationshipRepository $relationshipRepository;
private SummaryBudget $summaryBudget;
private TranslatableStringHelper $translatableStringHelper;
private TranslatorInterface $translator;
@@ -52,12 +55,14 @@ class PersonDocGenNormalizer implements
PersonRenderInterface $personRender,
RelationshipRepository $relationshipRepository,
TranslatorInterface $translator,
TranslatableStringHelper $translatableStringHelper
TranslatableStringHelper $translatableStringHelper,
SummaryBudget $summaryBudget
) {
$this->personRender = $personRender;
$this->relationshipRepository = $relationshipRepository;
$this->translator = $translator;
$this->translatableStringHelper = $translatableStringHelper;
$this->summaryBudget = $summaryBudget;
}
public function normalize($person, $format = null, array $context = [])
@@ -127,6 +132,7 @@ class PersonDocGenNormalizer implements
'docgen:expects' => Household::class,
'docgen:person:with-household' => false,
'docgen:person:with-relations' => false,
'docgen:person:with-budget' => false,
])
);
}
@@ -139,10 +145,19 @@ class PersonDocGenNormalizer implements
'docgen:person:with-household' => false,
'docgen:person:with-relation' => false,
'docgen:relationship:counterpart' => $person,
'docgen:person:with-budget' => false,
])
);
}
if ($context['docgen:person:with-budget'] ?? false) {
$data['budget']['person'] = $this->summaryBudget->getSummaryForPerson($person);
if ($context['docgen:person:with-household'] ?? false) {
$data['budget']['household'] = $this->summaryBudget->getSummaryForHousehold($person->getCurrentHousehold());
}
}
return $data;
}

View File

@@ -191,6 +191,7 @@ class AccompanyingPeriodContext implements
'groups' => 'docgen:read',
'docgen:person:with-household' => true,
'docgen:person:with-relations' => true,
'docgen:person:with-budget' => true,
]);
}
}

View File

@@ -114,7 +114,10 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface
$data = array_merge($data, $this->baseContextData->getData());
$data['person'] = $this->normalizer->normalize($entity, 'docgen', [
'docgen:expects' => Person::class,
'groups' => ['docgen:read', 'docgen:person:with-household', 'docgen:person:with-relations'],
'groups' => ['docgen:read'],
'docgen:person:with-household' => true,
'docgen:person:with-relations' => true,
'docgen:person:with-budget' => true,
]);
return $data;