mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fixes for budgets
This commit is contained in:
parent
ac12e75714
commit
0833bb49ca
@ -19,6 +19,7 @@ use Chill\PersonBundle\Entity\Household\Household;
|
|||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Monolog\DateTimeImmutable;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
@ -123,10 +124,34 @@ class ElementController extends AbstractController
|
|||||||
$results = $this->calculator->calculateDefault($elements);
|
$results = $this->calculator->calculateDefault($elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// quick solution to calculate the sum, difference and amount from
|
||||||
|
// controller. This should be done from the calculators
|
||||||
|
// TODO replace this by calculators
|
||||||
|
$wholeCharges = $actualCharges;
|
||||||
|
$wholeResources = $actualResources;
|
||||||
|
foreach ($household->getCurrentPersons() as $person) {
|
||||||
|
$wholeCharges = array_merge(
|
||||||
|
$wholeCharges,
|
||||||
|
$this->em
|
||||||
|
->getRepository(Charge::class)
|
||||||
|
->findByEntityAndDate($person, $now));
|
||||||
|
$wholeResources = array_merge(
|
||||||
|
$wholeResources,
|
||||||
|
$this->em
|
||||||
|
->getRepository(Resource::class)
|
||||||
|
->findByEntityAndDate($person, $now));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('ChillBudgetBundle:Household:index.html.twig', [
|
return $this->render('ChillBudgetBundle:Household:index.html.twig', [
|
||||||
'household' => $household,
|
'household' => $household,
|
||||||
'charges' => $charges,
|
'charges' => $charges,
|
||||||
'resources' => $ressources,
|
'resources' => $ressources,
|
||||||
|
'wholeResources' => array_filter($wholeResources, function (Resource $r) use ($now) {
|
||||||
|
return $r->getStartDate() <= $now and ($r->getEndDate() === null or $r->getEndDate() >= $now);
|
||||||
|
}),
|
||||||
|
'wholeCharges' => array_filter($wholeCharges, function (Charge $c) use ($now) {
|
||||||
|
return $c->getStartDate() <= $now and ($c->getEndDate() === null or $c->getEndDate() >= $now);
|
||||||
|
}),
|
||||||
'results' => $results ?? [],
|
'results' => $results ?? [],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,16 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
/** @var Person $person */
|
/** @var Person $person */
|
||||||
$person = $parameters['person'];
|
$person = $parameters['person'];
|
||||||
|
|
||||||
// if ($this->authorizationChecker->isGranted(BudgetElementVoter::SHOW, $person)) {
|
if ($this->authorizationChecker->isGranted(BudgetElementVoter::SEE, $person)) {
|
||||||
$menu->addChild(
|
$menu->addChild(
|
||||||
$this->translator->trans('Budget'),
|
$this->translator->trans('Budget'),
|
||||||
[
|
[
|
||||||
'route' => 'chill_budget_elements_index',
|
'route' => 'chill_budget_elements_index',
|
||||||
'routeParameters' => ['id' => $person->getId()],
|
'routeParameters' => ['id' => $person->getId()],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->setExtra('order', 4000);
|
->setExtra('order', 4000);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@ -30,8 +30,11 @@ class ResourceRepository extends EntityRepository
|
|||||||
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
||||||
|
|
||||||
$qb->where("c.{$entityStr} = :{$entityStr}")
|
$qb->where("c.{$entityStr} = :{$entityStr}")
|
||||||
->andWhere('c.startDate < :date')
|
// TODO: in controller, the budget and charges asked are also for future and actual
|
||||||
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
//->andWhere('c.startDate < :date')
|
||||||
|
// TODO: there is a misconception here, the end date must be lower or null. startDate are never null
|
||||||
|
//->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||||
|
;
|
||||||
|
|
||||||
if (null !== $sort) {
|
if (null !== $sort) {
|
||||||
$qb->orderBy($sort);
|
$qb->orderBy($sort);
|
||||||
@ -39,7 +42,7 @@ class ResourceRepository extends EntityRepository
|
|||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters([
|
||||||
$entityStr => $entity,
|
$entityStr => $entity,
|
||||||
'date' => $date,
|
//'date' => $date,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
|
@ -32,65 +32,43 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if resources|length == 0 and charges|length == 0 %}
|
|
||||||
{# <div class="flex-table"> #}
|
|
||||||
{# <div class="item-bloc">
|
|
||||||
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
|
|
||||||
</div> #}
|
|
||||||
{# </div> #}
|
|
||||||
|
|
||||||
|
<h3 class="subtitle">{{ 'Actual budget'|trans }}</h3>
|
||||||
|
|
||||||
|
{% if actualCharges|length > 0 or actualResources|length > 0 %}
|
||||||
|
{% include 'ChillBudgetBundle:Budget:_current_budget.html.twig' with {
|
||||||
|
'actualResources': actualResources,
|
||||||
|
'actualCharges': actualCharges,
|
||||||
|
'results': results,
|
||||||
|
'entity': entity
|
||||||
|
} %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
<div class="flex-table">
|
||||||
<h2 class="subtitle">{{ 'Actual budget'|trans }}</h3>
|
<div class="item-bloc">
|
||||||
|
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
|
||||||
{% if actualCharges|length > 0 or actualResources|length > 0 %}
|
|
||||||
{% include 'ChillBudgetBundle:Budget:_current_budget.html.twig' with {
|
|
||||||
'actualResources': actualResources,
|
|
||||||
'actualCharges': actualCharges,
|
|
||||||
'results': results,
|
|
||||||
'entity': entity
|
|
||||||
} %}
|
|
||||||
{% else %}
|
|
||||||
<div class="flex-table">
|
|
||||||
<div class="item-bloc">
|
|
||||||
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if pastCharges|length > 0 or pastResources|length > 0 %}
|
||||||
<h2 class="subtitle">{{ 'Past budget'|trans }}</h2>
|
<h2 class="subtitle">{{ 'Past budget'|trans }}</h2>
|
||||||
|
|
||||||
{% if pastCharges|length > 0 or pastResources|length > 0 %}
|
{% include 'ChillBudgetBundle:Budget:_past_budget.html.twig' with {
|
||||||
{% include 'ChillBudgetBundle:Budget:_past_budget.html.twig' with {
|
'pastCharges': pastCharges,
|
||||||
'pastCharges': pastCharges,
|
'pastResources': pastResources,
|
||||||
'pastResources': pastResources,
|
'entity': entity
|
||||||
'entity': entity
|
} %}
|
||||||
} %}
|
{% endif %}
|
||||||
{% else %}
|
|
||||||
<div class="flex-table">
|
|
||||||
<div class="item-bloc">
|
|
||||||
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
{% if futureCharges|length > 0 or futureResources|length > 0 %}
|
||||||
<h2 class="subtitle">{{ 'Future budget'|trans }}</h2>
|
<h2 class="subtitle">{{ 'Future budget'|trans }}</h2>
|
||||||
|
|
||||||
{% if futureCharges|length > 0 or futureResources|length > 0 %}
|
{% include 'ChillBudgetBundle:Budget:_future_budget.html.twig' with {
|
||||||
{% include 'ChillBudgetBundle:Budget:_future_budget.html.twig' with {
|
'futureResources': futureResources,
|
||||||
'futureResources': futureResources,
|
'futureCharges': futureCharges,
|
||||||
'futureCharges': futureCharges,
|
'entity': entity
|
||||||
'entity': entity
|
} %}
|
||||||
} %}
|
{% endif %}
|
||||||
{% else %}
|
|
||||||
<div class="flex-table">
|
|
||||||
<div class="item-bloc">
|
|
||||||
<p><span class="chill-no-data-statement">{{ "There isn't any element recorded"|trans }}</span></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{# <h2 class="subtitle">{{ 'Actual budget'|trans }}</h2> #}
|
{# <h2 class="subtitle">{{ 'Actual budget'|trans }}</h2> #}
|
||||||
|
|
||||||
<div class="flex-table">
|
<div class="flex-table">
|
||||||
<h3 class="family-title">{{ 'Actual resources'|trans }}</h3>
|
<h4 class="family-title">{{ 'Actual resources'|trans }}</h4>
|
||||||
|
|
||||||
{% if actualResources|length > 0 %}
|
{% if actualResources|length > 0 %}
|
||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
@ -17,6 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex-table">
|
<div class="flex-table">
|
||||||
|
<h4 class="family-title">{{ 'Actual charges'|trans }}</h4>
|
||||||
{% if actualCharges|length > 0 %}
|
{% if actualCharges|length > 0 %}
|
||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
{{ table_elements(actualCharges, 'charge') }}
|
{{ table_elements(actualCharges, 'charge') }}
|
||||||
@ -26,4 +27,4 @@
|
|||||||
<span class="chill-no-data-statement">{{ 'No charges registered'|trans }}</span>
|
<span class="chill-no-data-statement">{{ 'No charges registered'|trans }}</span>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,7 +14,10 @@
|
|||||||
{% set total = total + f.amount %}
|
{% set total = total + f.amount %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="column-wide el-type">
|
<td class="column-wide el-type">
|
||||||
{{ f.type|budget_element_type_display(family) }}
|
<span class="badge-title">
|
||||||
|
<span class="title_label title_label_{{ family }}"></span>
|
||||||
|
<span class="title_action">{{ f.type|budget_element_type_display(family) }}<span>
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="column-small">{{ f.amount|format_currency('EUR') }}</td>
|
<td class="column-small">{{ f.amount|format_currency('EUR') }}</td>
|
||||||
<td class="column-wide">
|
<td class="column-wide">
|
||||||
@ -91,4 +94,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-create' }, 'label': 'Edit' } ) }}
|
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-edit' }, 'label': 'Edit' } ) }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
} %}
|
} %}
|
||||||
|
|
||||||
<div class="flex-table">
|
<div class="flex-table">
|
||||||
<h3 class="family-title">{{ 'Budget calculator'|trans }}</h2>
|
<h3 class="family-title">{{ 'Budget calculator'|trans }}</h3>
|
||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
{{ table_results(charges, resources) }}
|
{{ table_results(wholeCharges, wholeResources) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -45,7 +45,7 @@
|
|||||||
data-bs-target="#collapse_{{ member.id }}"
|
data-bs-target="#collapse_{{ member.id }}"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
aria-controls="collapse_{{ member.id }}">
|
aria-controls="collapse_{{ member.id }}">
|
||||||
<span class="folded">{{ 'Show budget of %name%'|trans({'%name%': member.firstName ~ " " ~ member.lastName }) }}</span>
|
<span class="folded">{{ 'Show budget of %name%'|trans({'%name%': member.firstName ~ " " ~ member.lastName }) }} ({{ 'budget.number of elements'|trans({ 'nb_items': member.getBudgetResources|length + member.getBudgetResources|length }) }})</span>
|
||||||
<span class="unfolded text-secondary">{{ 'Hide budget of %name%'|trans({'%name%': member.firstName ~ " " ~ member.lastName }) }}</span>
|
<span class="unfolded text-secondary">{{ 'Hide budget of %name%'|trans({'%name%': member.firstName ~ " " ~ member.lastName }) }}</span>
|
||||||
</button>
|
</button>
|
||||||
</h2>
|
</h2>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-create' }, 'label': 'Edit' } ) }}
|
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-edit' }, 'label': 'Edit' } ) }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
Chill\BudgetBundle\Menu\PersonMenuBuilder:
|
Chill\BudgetBundle\Menu\PersonMenuBuilder:
|
||||||
autowire: true
|
autowire: true
|
||||||
tags:
|
autoconfigure: true
|
||||||
- { name: 'chill.menu_builder' }
|
|
||||||
Chill\BudgetBundle\Menu\HouseholdMenuBuilder:
|
Chill\BudgetBundle\Menu\HouseholdMenuBuilder:
|
||||||
autowire: true
|
autowire: true
|
||||||
tags:
|
autoconfigure: true
|
||||||
- { name: 'chill.menu_builder' }
|
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
budget:
|
||||||
|
number of elements: >-
|
||||||
|
{nb_items, plural,
|
||||||
|
=0 {Aucun élément}
|
||||||
|
one {Un élément}
|
||||||
|
many {# éléments}
|
||||||
|
other {# éléments}
|
||||||
|
}
|
@ -2,8 +2,8 @@ Budget: Budget
|
|||||||
Resource: Ressource
|
Resource: Ressource
|
||||||
Charge: Charge
|
Charge: Charge
|
||||||
Budget for %name%: Budget de %name%
|
Budget for %name%: Budget de %name%
|
||||||
Budget for household %household%: Budget de ménage %household%
|
Budget for household %household%: Budget du ménage
|
||||||
Current budget household members: Budgets actuelles des membres du ménage
|
Current budget household members: Budget actuel des membres du ménage
|
||||||
Show budget of %name%: Montrer budget de %name%
|
Show budget of %name%: Montrer budget de %name%
|
||||||
See complete budget: Voir budget complet
|
See complete budget: Voir budget complet
|
||||||
Hide budget: Masquer
|
Hide budget: Masquer
|
||||||
@ -29,7 +29,7 @@ End of validity period: Fin de la période de validité
|
|||||||
Total: Total
|
Total: Total
|
||||||
Create new resource: Créer une nouvelle ressource
|
Create new resource: Créer une nouvelle ressource
|
||||||
Create new charge: Créer une nouvelle charge
|
Create new charge: Créer une nouvelle charge
|
||||||
See person: Voir person
|
See person: Voir personne
|
||||||
|
|
||||||
There isn't any element recorded: Aucun élément enregistré
|
There isn't any element recorded: Aucun élément enregistré
|
||||||
No resources registered: Aucune ressource enregistrée
|
No resources registered: Aucune ressource enregistrée
|
||||||
@ -70,7 +70,7 @@ charge.help.not-concerned: Non concerné
|
|||||||
|
|
||||||
Budget calculator: Calculs et indices sur le budget
|
Budget calculator: Calculs et indices sur le budget
|
||||||
Budget calculator result: Résultats
|
Budget calculator result: Résultats
|
||||||
The balance: Le solde budgétaire
|
The balance: Différence entre ressources et charges
|
||||||
|
|
||||||
Valid since %startDate% until %endDate%: Valide depuis le %startDate% jusqu'au %endDate%
|
Valid since %startDate% until %endDate%: Valide depuis le %startDate% jusqu'au %endDate%
|
||||||
Valid since %startDate%: Valide depuis le %startDate%
|
Valid since %startDate%: Valide depuis le %startDate%
|
||||||
|
@ -159,8 +159,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
private $birthdate;
|
private $birthdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read-only field, computed by the database.
|
|
||||||
*
|
|
||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(
|
||||||
* targetEntity=Charge::class,
|
* targetEntity=Charge::class,
|
||||||
* mappedBy="person"
|
* mappedBy="person"
|
||||||
@ -169,8 +167,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
private Collection $budgetCharges;
|
private Collection $budgetCharges;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read-only field, computed by the database.
|
|
||||||
*
|
|
||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(
|
||||||
* targetEntity=Resource::class,
|
* targetEntity=Resource::class,
|
||||||
* mappedBy="person"
|
* mappedBy="person"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user