diff --git a/CRM/MembershipExtras/Service/MembershipPeriodType/FixedPeriodTypeCalculator.php b/CRM/MembershipExtras/Service/MembershipPeriodType/FixedPeriodTypeCalculator.php index 6603af26..cac42f6b 100644 --- a/CRM/MembershipExtras/Service/MembershipPeriodType/FixedPeriodTypeCalculator.php +++ b/CRM/MembershipExtras/Service/MembershipPeriodType/FixedPeriodTypeCalculator.php @@ -124,19 +124,11 @@ private function calculateProRataAmounts($membershipType, $proRataScheme, $nonPr $this->proRatedUnit = self::BY_MONTHS; $duration = self::TWELVE_MONTHS; $this->proRatedNumber = $membershipTypeDurationCalculator->calculateMonthsBasedOnDates($this->startDate, $this->endDate, $this->joinDate); - if ($this->isDurationWithInOneYearPeriod($duration, $this->proRatedNumber) && !empty($this->endDate)) { - $this->reCalculateEndDate(); - $this->proRatedNumber = $membershipTypeDurationCalculator->calculateMonthsBasedOnDates($this->startDate, $this->endDate, $this->joinDate); - } } else { $this->proRatedUnit = self::BY_DAYS; $duration = $membershipTypeDurationCalculator->calculateOriginalInDays(); $this->proRatedNumber = $membershipTypeDurationCalculator->calculateDaysBasedOnDates($this->startDate, $this->endDate, $this->joinDate); - if ($this->isDurationWithInOneYearPeriod($duration, $this->proRatedNumber) && !empty($this->endDate)) { - $this->reCalculateEndDate(); - $this->proRatedNumber = $membershipTypeDurationCalculator->calculateDaysBasedOnDates($this->startDate, $this->endDate, $this->joinDate); - } } $membershipAmount = $nonProRatedAmounts['amount']; @@ -162,13 +154,6 @@ public function setStartDate(DateTime $startDate) { $this->startDate = $startDate; } - /** - * @return DateTime|null - */ - public function getJoinDate() { - return $this->joinDate; - } - /** * @param DateTime|null $joinDate */ @@ -176,13 +161,6 @@ public function setJoinDate(DateTime $joinDate) { $this->joinDate = $joinDate; } - /** - * @return DateTime|null - */ - public function getEndDate() { - return $this->endDate; - } - /** * @param DateTime|null $endDate */ @@ -197,13 +175,6 @@ public function getProRatedNumber() { return $this->proRatedNumber; } - /** - * @param int $proRatedNumber - */ - public function setProRatedNumber(int $proRatedNumber) { - $this->proRatedNumber = $proRatedNumber; - } - /** * @return string */ @@ -211,27 +182,4 @@ public function getProRatedUnit() { return $this->proRatedUnit; } - /** - * @param string $proRatedUnit - */ - public function setProRatedUnit(string $proRatedUnit) { - $this->proRatedUnit = $proRatedUnit; - } - - /** - * Checks if no of different days is greater than duration. - * Example, start date and end date more than original in days. - */ - private function isDurationWithInOneYearPeriod($duration, $diff) { - return $diff > $duration; - } - - /** - * Subtracts end date by 1 year as - * Membership extras default fixed membership to 1 year duration. - */ - private function reCalculateEndDate() { - $this->endDate->sub(new DateInterval('P1Y')); - } - }