Skip to content

Commit

Permalink
ESEB-155: Test
Browse files Browse the repository at this point in the history
  • Loading branch information
omarabuhussein committed Dec 18, 2023
1 parent a0f3d4b commit d4932ce
Showing 1 changed file with 0 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -162,27 +154,13 @@ public function setStartDate(DateTime $startDate) {
$this->startDate = $startDate;
}

/**
* @return DateTime|null
*/
public function getJoinDate() {
return $this->joinDate;
}

/**
* @param DateTime|null $joinDate
*/
public function setJoinDate(DateTime $joinDate) {
$this->joinDate = $joinDate;
}

/**
* @return DateTime|null
*/
public function getEndDate() {
return $this->endDate;
}

/**
* @param DateTime|null $endDate
*/
Expand All @@ -197,41 +175,11 @@ public function getProRatedNumber() {
return $this->proRatedNumber;
}

/**
* @param int $proRatedNumber
*/
public function setProRatedNumber(int $proRatedNumber) {
$this->proRatedNumber = $proRatedNumber;
}

/**
* @return string
*/
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'));
}

}

0 comments on commit d4932ce

Please sign in to comment.