Skip to content

Commit

Permalink
Fix variable name has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Apr 23, 2024
1 parent adda691 commit 9aa579a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions galette/lib/Galette/Entity/Contribution.php
Expand Up @@ -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');
}
}
Expand Down Expand Up @@ -249,7 +249,6 @@ protected function setFields(): self
return $this;
}


/**
* Sets end contribution date
*
Expand All @@ -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) {
Expand All @@ -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(
Expand Down

0 comments on commit 9aa579a

Please sign in to comment.