|
|
@@ -113,18 +113,19 @@ class Utils
|
|
|
|
|
|
/**
|
|
|
* Retourne dans quelle année de cotisation on est aujourd'hui
|
|
|
+ * @param \DateTime|null $date
|
|
|
* @return int
|
|
|
* @throws \Exception
|
|
|
* @see UtilsTest::testGetCurrentCotisationYear()
|
|
|
*/
|
|
|
- public function getCurrentCotisationYear(): int {
|
|
|
- $today = new \DateTime('now');
|
|
|
- $year = intval($today->format('Y'));
|
|
|
+ public function getCurrentCotisationYear(\DateTime $date = null): int {
|
|
|
+ $date = $date ?? new \DateTime('now');
|
|
|
+ $year = (int)$date->format('Y');
|
|
|
|
|
|
$base_date = new \DateTime($year . '-09-01');
|
|
|
$dateStart = new \DateTime($year . '-01-01');
|
|
|
|
|
|
- if ($today >= $dateStart && $today <= $base_date) {
|
|
|
+ if ($date >= $dateStart && $date <= $base_date) {
|
|
|
$cotisationYear = $year;
|
|
|
} else {
|
|
|
$cotisationYear = $year + 1;
|