mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
add budget to docgen
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user