From 89560f909be007901a4e432de865e8467f286cf0 Mon Sep 17 00:00:00 2001 From: Drahma Date: Fri, 25 Oct 2024 12:13:01 +0300 Subject: [PATCH 1/5] HP-2166/Store_Action_Usage_Interval_in_the_action_table --- src/action/AbstractAction.php | 17 +++++++++++++++-- src/action/ActionInterface.php | 2 ++ src/action/UsageInterval.php | 17 ++++++++++++----- tests/unit/action/UsageIntervalTest.php | 16 ++++++++-------- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/action/AbstractAction.php b/src/action/AbstractAction.php index 42857d01..e6c10c0b 100755 --- a/src/action/AbstractAction.php +++ b/src/action/AbstractAction.php @@ -55,6 +55,8 @@ abstract class AbstractAction implements \JsonSerializable, ActionInterface /** @var ActionInterface */ protected $parent; + protected float $fraction_of_month; + /** * @param SaleInterface $sale * @param ActionInterface $parent @@ -68,7 +70,8 @@ public function __construct( DateTimeImmutable $time, SaleInterface $sale = null, ActionState $state = null, - ActionInterface $parent = null + ActionInterface $parent = null, + $fractionOfMonth = 0.0 ) { $this->id = $id; $this->type = $type; @@ -79,6 +82,7 @@ public function __construct( $this->sale = $sale; $this->state = $state; $this->parent = $parent; + $this->fraction_of_month = $fractionOfMonth; } /** @@ -218,6 +222,10 @@ public function setSale(SaleInterface $sale) $this->sale = $sale; } + public function getFractionOfMonth(): float + { + return $this->fraction_of_month; + } /** * {@inheritdoc} */ @@ -232,6 +240,11 @@ public function getUsageInterval(): UsageInterval return UsageInterval::wholeMonth($this->getTime()); } - return UsageInterval::withinMonth($this->getTime(), $this->getSale()->getTime(), $this->getSale()->getCloseTime()); + return UsageInterval::withinMonth( + $this->getTime(), + $this->getSale()->getTime(), + $this->getSale()->getCloseTime(), + $this->getFractionOfMonth() + ); } } diff --git a/src/action/ActionInterface.php b/src/action/ActionInterface.php index 4662c1b0..456a120a 100644 --- a/src/action/ActionInterface.php +++ b/src/action/ActionInterface.php @@ -82,4 +82,6 @@ public function hasSale(); public function setSale(SaleInterface $sale); public function getUsageInterval(): UsageInterval; + + public function getFractionOfMonth(): float; } diff --git a/src/action/UsageInterval.php b/src/action/UsageInterval.php index 2daabdaf..2fe5bbbc 100644 --- a/src/action/UsageInterval.php +++ b/src/action/UsageInterval.php @@ -51,7 +51,8 @@ public static function wholeMonth(DateTimeImmutable $time): self public static function withinMonth( DateTimeImmutable $month, DateTimeImmutable $start, - ?DateTimeImmutable $end + ?DateTimeImmutable $end, + float $fractionOfMonth ): self { $month = self::toMonth($month); $nextMonth = $month->modify('+1 month'); @@ -71,10 +72,16 @@ public static function withinMonth( } $effectiveSince = max($start, $month); - $effectiveTill = min( - $end ?? new DateTimeImmutable('2999-01-01'), - $month->modify('+1 month') - ); + + if ($fractionOfMonth === 1.0) { + $calcEnd = $month->modify('+1 month'); + } else { + $startTime = strtotime(($month->format('D, d M Y H:i:s O'))); + $finishTime = strtotime($nextMonth->format('D, d M Y H:i:s O')); + $interval = 'PT' . (($finishTime - $startTime) * $fractionOfMonth) . 'S'; + $calcEnd = $effectiveSince->add(new \DateInterval($interval)); + } + $effectiveTill = (!empty($end) && $end < $calcEnd) ? $end : $calcEnd; return new self( $effectiveSince, diff --git a/tests/unit/action/UsageIntervalTest.php b/tests/unit/action/UsageIntervalTest.php index 12282720..def4f709 100644 --- a/tests/unit/action/UsageIntervalTest.php +++ b/tests/unit/action/UsageIntervalTest.php @@ -35,7 +35,7 @@ public function testWithinMonth(array $constructor, array $expectations): void $this->expectExceptionMessage($expectations['expectedExceptionMessage']); } - $interval = UsageInterval::withinMonth($month, $start, $end); + $interval = UsageInterval::withinMonth($month, $start, $end, $constructor['fraction']); $this->assertEquals($expectations['start'], $interval->start()->format("Y-m-d H:i:s")); $this->assertEquals($expectations['end'], $interval->end()->format("Y-m-d H:i:s")); @@ -47,7 +47,7 @@ public function testWithinMonth(array $constructor, array $expectations): void public function provideWithinMonth() { yield 'For a start and end dates outside the month, the interval is the whole month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-01-01 00:00:00', 'end' => '2023-10-01 00:00:00'], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-01-01 00:00:00', 'end' => '2023-10-01 00:00:00', 'fraction' => 1], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-03-01 00:00:00', @@ -58,7 +58,7 @@ public function provideWithinMonth() ]; yield 'When start date is greater than a month, the interval is a fraction of month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => null], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => null, 'fraction' => 0.5], [ 'start' => '2023-02-15 00:00:00', 'end' => '2023-03-01 00:00:00', @@ -69,7 +69,7 @@ public function provideWithinMonth() ]; yield 'When end date is less than a month, the interval is a fraction of month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-02-15 00:00:00'], + ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-02-15 00:00:00', 'fraction' => 0.5], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-02-15 00:00:00', @@ -80,7 +80,7 @@ public function provideWithinMonth() ]; yield 'When start and end dates are within a month, the interval is a fraction of month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => '2023-02-20 00:00:00'], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => '2023-02-20 00:00:00', 'fraction' => 0.17857142857142858], [ 'start' => '2023-02-15 00:00:00', 'end' => '2023-02-20 00:00:00', @@ -91,7 +91,7 @@ public function provideWithinMonth() ]; yield 'When start date is greater than current month, the interval is zero' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => null], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => null, 'fraction' => 0], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-02-01 00:00:00', @@ -102,7 +102,7 @@ public function provideWithinMonth() ]; yield 'When end date is less than current month, the interval is zero' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-01-15 00:00:00'], + ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-01-15 00:00:00', 'fraction' => 0], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-02-01 00:00:00', @@ -113,7 +113,7 @@ public function provideWithinMonth() ]; yield 'When a start date is greater than the end an exception is thrown' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => '2023-02-15 00:00:00'], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => '2023-02-15 00:00:00', 'fraction' => 0], [ 'expectedException' => InvalidArgumentException::class, 'expectedExceptionMessage' => 'Start date must be less than end date', From df66a14330c6b438eab64e1de958f6df40ad5981 Mon Sep 17 00:00:00 2001 From: Drahma Date: Fri, 25 Oct 2024 12:39:47 +0300 Subject: [PATCH 2/5] HP-2166/Fixed behat --- tests/behat/bootstrap/FeatureContext.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/behat/bootstrap/FeatureContext.php b/tests/behat/bootstrap/FeatureContext.php index 3b790c8d..5ecdcc8e 100644 --- a/tests/behat/bootstrap/FeatureContext.php +++ b/tests/behat/bootstrap/FeatureContext.php @@ -188,14 +188,27 @@ public function actionIs(string $target, string $type, float $amount, string $un $type = Type::anyId($type); $target = new Target(Target::ANY, $target); $time = new DateTimeImmutable($date); + $fractionOfMonth = 1; if ($this->sale->getCloseTime() instanceof DateTimeImmutable) { - $amount = $amount * $this->getFractionOfMonth( + $fractionOfMonth = $this->getFractionOfMonth( $time, $time, $this->sale->getCloseTime() ); + $amount = $amount * $fractionOfMonth; } $quantity = Quantity::create($unit, $amount); - $this->action = new Action(null, $type, $target, $quantity, $this->customer, $time); + $this->action = new Action( + null, + $type, + $target, + $quantity, + $this->customer, + $time, + null, + null, + null, + $fractionOfMonth + ); } private function getFractionOfMonth(DateTimeImmutable $month, DateTimeImmutable $startTime, DateTimeImmutable $endTime): float From 96c368ddbf9df6ee945600848a0ed4ba8ac99e25 Mon Sep 17 00:00:00 2001 From: Drahma Date: Mon, 28 Oct 2024 18:51:10 +0200 Subject: [PATCH 3/5] HP-2166/Fixed after review --- src/action/AbstractAction.php | 16 ++-- src/action/UsageInterval.php | 40 +++++++-- tests/unit/action/UsageIntervalTest.php | 107 ++++++++++++++++++++++-- 3 files changed, 145 insertions(+), 18 deletions(-) diff --git a/src/action/AbstractAction.php b/src/action/AbstractAction.php index e6c10c0b..284bbeb5 100755 --- a/src/action/AbstractAction.php +++ b/src/action/AbstractAction.php @@ -55,7 +55,7 @@ abstract class AbstractAction implements \JsonSerializable, ActionInterface /** @var ActionInterface */ protected $parent; - protected float $fraction_of_month; + protected float $fractionOfMonth; /** * @param SaleInterface $sale @@ -71,7 +71,7 @@ public function __construct( SaleInterface $sale = null, ActionState $state = null, ActionInterface $parent = null, - $fractionOfMonth = 0.0 + float $fractionOfMonth = 0.0 ) { $this->id = $id; $this->type = $type; @@ -82,7 +82,7 @@ public function __construct( $this->sale = $sale; $this->state = $state; $this->parent = $parent; - $this->fraction_of_month = $fractionOfMonth; + $this->fractionOfMonth = $fractionOfMonth; } /** @@ -240,11 +240,17 @@ public function getUsageInterval(): UsageInterval return UsageInterval::wholeMonth($this->getTime()); } + if ($this->getFractionOfMonth() > 0) { + return UsageInterval::withMonthAndFraction( + $this->getTime(), + $this->getSale()->getTime(), + $this->getFractionOfMonth() + ); + } return UsageInterval::withinMonth( $this->getTime(), $this->getSale()->getTime(), - $this->getSale()->getCloseTime(), - $this->getFractionOfMonth() + $this->getSale()->getCloseTime() ); } } diff --git a/src/action/UsageInterval.php b/src/action/UsageInterval.php index 2fe5bbbc..4956ac31 100644 --- a/src/action/UsageInterval.php +++ b/src/action/UsageInterval.php @@ -51,8 +51,7 @@ public static function wholeMonth(DateTimeImmutable $time): self public static function withinMonth( DateTimeImmutable $month, DateTimeImmutable $start, - ?DateTimeImmutable $end, - float $fractionOfMonth + ?DateTimeImmutable $end ): self { $month = self::toMonth($month); $nextMonth = $month->modify('+1 month'); @@ -71,17 +70,48 @@ public static function withinMonth( $end = $month; } + $effectiveSince = max($start, $month); + $effectiveTill = min( + $end ?? new DateTimeImmutable('2999-01-01'), + $month->modify('+1 month') + ); + + return new self( + $effectiveSince, + $effectiveTill, + ); + } + + /** + * Calculates the usage interval for the given month for the given start date and fraction of month value. + * + * @param DateTimeImmutable $month the month to calculate the usage interval for + * @param DateTimeImmutable $start the start date of the sale + * @param float $fractionOfMonth the fraction of manth + * @return static + */ + public static function withMonthAndFraction( + DateTimeImmutable $month, + DateTimeImmutable $start, + float $fractionOfMonth + ): self { + $month = self::toMonth($month); + $nextMonth = $month->modify('+1 month'); + + if ($start >= $nextMonth) { + $start = $month; + } + $effectiveSince = max($start, $month); if ($fractionOfMonth === 1.0) { - $calcEnd = $month->modify('+1 month'); + $effectiveTill = $month->modify('+1 month'); } else { $startTime = strtotime(($month->format('D, d M Y H:i:s O'))); $finishTime = strtotime($nextMonth->format('D, d M Y H:i:s O')); $interval = 'PT' . (($finishTime - $startTime) * $fractionOfMonth) . 'S'; - $calcEnd = $effectiveSince->add(new \DateInterval($interval)); + $effectiveTill = $effectiveSince->add(new \DateInterval($interval)); } - $effectiveTill = (!empty($end) && $end < $calcEnd) ? $end : $calcEnd; return new self( $effectiveSince, diff --git a/tests/unit/action/UsageIntervalTest.php b/tests/unit/action/UsageIntervalTest.php index def4f709..57d7d4e4 100644 --- a/tests/unit/action/UsageIntervalTest.php +++ b/tests/unit/action/UsageIntervalTest.php @@ -35,7 +35,7 @@ public function testWithinMonth(array $constructor, array $expectations): void $this->expectExceptionMessage($expectations['expectedExceptionMessage']); } - $interval = UsageInterval::withinMonth($month, $start, $end, $constructor['fraction']); + $interval = UsageInterval::withinMonth($month, $start, $end); $this->assertEquals($expectations['start'], $interval->start()->format("Y-m-d H:i:s")); $this->assertEquals($expectations['end'], $interval->end()->format("Y-m-d H:i:s")); @@ -47,7 +47,7 @@ public function testWithinMonth(array $constructor, array $expectations): void public function provideWithinMonth() { yield 'For a start and end dates outside the month, the interval is the whole month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-01-01 00:00:00', 'end' => '2023-10-01 00:00:00', 'fraction' => 1], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-01-01 00:00:00', 'end' => '2023-10-01 00:00:00'], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-03-01 00:00:00', @@ -58,7 +58,7 @@ public function provideWithinMonth() ]; yield 'When start date is greater than a month, the interval is a fraction of month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => null, 'fraction' => 0.5], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => null], [ 'start' => '2023-02-15 00:00:00', 'end' => '2023-03-01 00:00:00', @@ -69,7 +69,7 @@ public function provideWithinMonth() ]; yield 'When end date is less than a month, the interval is a fraction of month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-02-15 00:00:00', 'fraction' => 0.5], + ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-02-15 00:00:00'], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-02-15 00:00:00', @@ -80,7 +80,7 @@ public function provideWithinMonth() ]; yield 'When start and end dates are within a month, the interval is a fraction of month' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => '2023-02-20 00:00:00', 'fraction' => 0.17857142857142858], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'end' => '2023-02-20 00:00:00'], [ 'start' => '2023-02-15 00:00:00', 'end' => '2023-02-20 00:00:00', @@ -91,7 +91,7 @@ public function provideWithinMonth() ]; yield 'When start date is greater than current month, the interval is zero' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => null, 'fraction' => 0], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => null], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-02-01 00:00:00', @@ -102,7 +102,7 @@ public function provideWithinMonth() ]; yield 'When end date is less than current month, the interval is zero' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-01-15 00:00:00', 'fraction' => 0], + ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'end' => '2023-01-15 00:00:00'], [ 'start' => '2023-02-01 00:00:00', 'end' => '2023-02-01 00:00:00', @@ -113,11 +113,102 @@ public function provideWithinMonth() ]; yield 'When a start date is greater than the end an exception is thrown' => [ - ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => '2023-02-15 00:00:00', 'fraction' => 0], + ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'end' => '2023-02-15 00:00:00'], [ 'expectedException' => InvalidArgumentException::class, 'expectedExceptionMessage' => 'Start date must be less than end date', ] ]; } + + /** + * @dataProvider provideWithMonthAndFraction + */ + public function testWithMonthAndFraction(array $constructor, array $expectations): void + { + $month = new DateTimeImmutable($constructor['month']); + $start = new DateTimeImmutable($constructor['start']); + + if (isset($expectations['expectedException'])) { + $this->expectException($expectations['expectedException']); + $this->expectExceptionMessage($expectations['expectedExceptionMessage']); + } + + $interval = UsageInterval::withMonthAndFraction($month, $start, $constructor['fraction']); + + $this->assertEquals($expectations['start'], $interval->start()->format("Y-m-d H:i:s")); + $this->assertEquals($expectations['end'], $interval->end()->format("Y-m-d H:i:s")); + $this->assertSame($expectations['ratioOfMonth'], $interval->ratioOfMonth()); + $this->assertSame($expectations['seconds'], $interval->seconds()); + $this->assertSame($expectations['secondsInMonth'], $interval->secondsInMonth()); + } + + public function provideWithMonthAndFraction() + { + yield 'For a start and end dates outside the month, the interval is the whole month' => [ + ['month' => '2023-02-01 00:00:00', 'start' => '2023-01-01 00:00:00', 'fraction' => 1], + [ + 'start' => '2023-02-01 00:00:00', + 'end' => '2023-03-01 00:00:00', + 'ratioOfMonth' => 1.0, + 'seconds' => 2_419_200, + 'secondsInMonth' => 2_419_200, + ] + ]; + + yield 'When start date is greater than a month, the interval is a fraction of month' => [ + ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'fraction' => 0.5], + [ + 'start' => '2023-02-15 00:00:00', + 'end' => '2023-03-01 00:00:00', + 'ratioOfMonth' => 0.5, + 'seconds' => 1_209_600, + 'secondsInMonth' => 2_419_200, + ] + ]; + + yield 'When end date is less than a month, the interval is a fraction of month' => [ + ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'fraction' => 0.5], + [ + 'start' => '2023-02-01 00:00:00', + 'end' => '2023-02-15 00:00:00', + 'ratioOfMonth' => 0.5, + 'seconds' => 1_209_600, + 'secondsInMonth' => 2_419_200, + ] + ]; + + yield 'When start and end dates are within a month, the interval is a fraction of month' => [ + ['month' => '2023-02-01 00:00:00', 'start' => '2023-02-15 00:00:00', 'fraction' => 0.17857142857142858], + [ + 'start' => '2023-02-15 00:00:00', + 'end' => '2023-02-20 00:00:00', + 'ratioOfMonth' => 0.17857142857142858, + 'seconds' => 432_000, + 'secondsInMonth' => 2_419_200, + ] + ]; + + yield 'When start date is greater than current month, the interval is zero' => [ + ['month' => '2023-02-01 00:00:00', 'start' => '2023-03-15 00:00:00', 'fraction' => 0], + [ + 'start' => '2023-02-01 00:00:00', + 'end' => '2023-02-01 00:00:00', + 'ratioOfMonth' => 0.0, + 'seconds' => 0, + 'secondsInMonth' => 2_419_200, + ] + ]; + + yield 'When end date is less than current month, the interval is zero' => [ + ['month' => '2023-02-01 00:00:00', 'start' => '2021-10-02 19:01:10', 'fraction' => 0], + [ + 'start' => '2023-02-01 00:00:00', + 'end' => '2023-02-01 00:00:00', + 'ratioOfMonth' => 0.0, + 'seconds' => 0, + 'secondsInMonth' => 2_419_200, + ] + ]; + } } From ab5edab3519dd7198ffb83a49566daca480afcc0 Mon Sep 17 00:00:00 2001 From: Drahma Date: Wed, 30 Oct 2024 14:19:41 +0200 Subject: [PATCH 4/5] HP-2166/Added exclude value of fraction --- src/action/UsageInterval.php | 10 ++++++---- tests/unit/action/UsageIntervalTest.php | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/action/UsageInterval.php b/src/action/UsageInterval.php index 4956ac31..a1280d9f 100644 --- a/src/action/UsageInterval.php +++ b/src/action/UsageInterval.php @@ -95,6 +95,9 @@ public static function withMonthAndFraction( DateTimeImmutable $start, float $fractionOfMonth ): self { + if ($fractionOfMonth < 0 || $fractionOfMonth > 1) { + throw new InvalidArgumentException('Fraction of month must be between 0 and 1'); + } $month = self::toMonth($month); $nextMonth = $month->modify('+1 month'); @@ -107,10 +110,9 @@ public static function withMonthAndFraction( if ($fractionOfMonth === 1.0) { $effectiveTill = $month->modify('+1 month'); } else { - $startTime = strtotime(($month->format('D, d M Y H:i:s O'))); - $finishTime = strtotime($nextMonth->format('D, d M Y H:i:s O')); - $interval = 'PT' . (($finishTime - $startTime) * $fractionOfMonth) . 'S'; - $effectiveTill = $effectiveSince->add(new \DateInterval($interval)); + $monthDays = (int) $month->format('t'); + $days = (int) round($monthDays * $fractionOfMonth); + $effectiveTill = $effectiveSince->modify(sprintf('+%d days', $days)); } return new self( diff --git a/tests/unit/action/UsageIntervalTest.php b/tests/unit/action/UsageIntervalTest.php index 57d7d4e4..4951434c 100644 --- a/tests/unit/action/UsageIntervalTest.php +++ b/tests/unit/action/UsageIntervalTest.php @@ -211,4 +211,27 @@ public function provideWithMonthAndFraction() ] ]; } + + /** + * @dataProvider provideInvalidFractionOfMonthValues + */ + public function testWithMonthAndFractionInvalidValues(float $fractionOfMonth): void + { + $month = new DateTimeImmutable('2023-01-01'); + $start = new DateTimeImmutable('2023-01-15'); + + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Fraction of month must be between 0 and 1'); + + UsageInterval::withMonthAndFraction($month, $start, $fractionOfMonth); + } + + public function provideInvalidFractionOfMonthValues(): array + { + return [ + [-0.1], + [1.1], + [2.0], + ]; + } } From 93e06575de02066433104af81032b0c66b8c266b Mon Sep 17 00:00:00 2001 From: Drahma Date: Wed, 30 Oct 2024 14:54:30 +0200 Subject: [PATCH 5/5] HP-2166/Changed property name --- src/action/AbstractAction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/action/AbstractAction.php b/src/action/AbstractAction.php index 284bbeb5..84352f41 100755 --- a/src/action/AbstractAction.php +++ b/src/action/AbstractAction.php @@ -224,7 +224,7 @@ public function setSale(SaleInterface $sale) public function getFractionOfMonth(): float { - return $this->fraction_of_month; + return $this->fractionOfMonth; } /** * {@inheritdoc}