diff --git a/galette/lib/Galette/Entity/Contribution.php b/galette/lib/Galette/Entity/Contribution.php index 5f48be896..940b8c79d 100644 --- a/galette/lib/Galette/Entity/Contribution.php +++ b/galette/lib/Galette/Entity/Contribution.php @@ -173,7 +173,7 @@ public function __construct(Db $zdb, Login $login, int|array|ArrayObject $args = } else { // Caution : the next_begin_date is the day after the due_date. $next_begin_date = clone $due_date; - $next_begin_date->add(new \DateInterval('P1D')); + $next_begin_date->add(new DateInterval('P1D')); $this->begin_date = $next_begin_date->format('Y-m-d'); } } @@ -249,7 +249,6 @@ protected function setFields(): self return $this; } - /** * Sets end contribution date * @@ -263,11 +262,11 @@ private function retrieveEndDate(): void $begin_date = new \DateTime($this->begin_date); if ($preferences->pref_beg_membership != '') { //case beginning of membership - if ($this->_type->extension < 1) { // 0 = donate; -1= else duration (months) + if ($this->type->extension < 1) { // 0 = donate; -1= else duration (months) list($j, $m) = explode('/', $preferences->pref_beg_membership); $next_begin_date = new DateTime($begin_date->format('Y') . '-' . $m . '-' . $j); while ($next_begin_date <= $begin_date) { - $next_begin_date->add(new \DateInterval('P1Y')); + $next_begin_date->add(new DateInterval('P1Y')); } if ($preferences->pref_membership_offermonths > 0) { @@ -276,33 +275,33 @@ private function retrieveEndDate(): void //count days between next membership begin date and offered months $tdate = clone $next_begin_date; - $tdate->sub(new \DateInterval('P' . $preferences->pref_membership_offermonths . 'M')); + $tdate->sub(new DateInterval('P' . $preferences->pref_membership_offermonths . 'M')); $diff2 = (int)$next_begin_date->diff($tdate)->format('%a'); //when number of days until next membership begin date is less than or equal to the offered months, it's free :) if ($diff1 <= $diff2) { - $next_begin_date->add(new \DateInterval('P1Y')); + $next_begin_date->add(new DateInterval('P1Y')); } } // Caution : the end_date to retrieve is the day before the next_begin_date. $end_date = clone $next_begin_date; - $end_date->sub(new \DateInterval('P1D')); + $end_date->sub(new DateInterval('P1D')); } else { - $dext = new \DateInterval('P' . $this->_type->extension . 'M'); + $dext = new DateInterval('P' . $this->type->extension . 'M'); $end_date = $begin_date->add($dext); - $end_date->sub(new \DateInterval('P1D')); //-1 day + $end_date->sub(new DateInterval('P1D')); //-1 day } } elseif ($preferences->pref_membership_ext != '') { //case membership extension if ($this->extension == null) { $this->extension = $preferences->pref_membership_ext; } - $dext = new \DateInterval('P' . $this->extension . 'M'); + $dext = new DateInterval('P' . $this->extension . 'M'); // Caution : the end_date to retrieve is the day before the next_begin_date. $next_begin_date = $begin_date->add($dext); $end_date = clone $next_begin_date; - $end_date->sub(new \DateInterval('P1D')); + $end_date->sub(new DateInterval('P1D')); $this->end_date = $end_date->format('Y-m-d'); } else { throw new \RuntimeException(