docgen normalization budget: fix budget when person is null

This commit is contained in:
2022-03-30 21:35:02 +02:00
parent bc43d8bae5
commit eb2bad0f47
5 changed files with 120 additions and 42 deletions

View File

@@ -11,7 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\BudgetBundle\Service\Summary\SummaryBudget;
use Chill\BudgetBundle\Service\Summary\SummaryBudgetInterface;
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Civility;
@@ -45,7 +45,7 @@ class PersonDocGenNormalizer implements
private RelationshipRepository $relationshipRepository;
private SummaryBudget $summaryBudget;
private SummaryBudgetInterface $summaryBudget;
private TranslatableStringHelper $translatableStringHelper;
@@ -56,7 +56,7 @@ class PersonDocGenNormalizer implements
RelationshipRepository $relationshipRepository,
TranslatorInterface $translator,
TranslatableStringHelper $translatableStringHelper,
SummaryBudget $summaryBudget
SummaryBudgetInterface $summaryBudget
) {
$this->personRender = $personRender;
$this->relationshipRepository = $relationshipRepository;
@@ -214,6 +214,14 @@ class PersonDocGenNormalizer implements
$data['relations'] = [];
}
if ($context['docgen:person:with-budget'] ?? false) {
$data['budget']['person'] = $this->summaryBudget->getSummaryForPerson(null);
if ($context['docgen:person:with-household'] ?? false) {
$data['budget']['household'] = $this->summaryBudget->getSummaryForHousehold(null);
}
}
return $data;
}
}