diff --git a/src/Services/ProjectSystem/ProjectBuildHelper.php b/src/Services/ProjectSystem/ProjectBuildHelper.php index ac346284..090f9e66 100644 --- a/src/Services/ProjectSystem/ProjectBuildHelper.php +++ b/src/Services/ProjectSystem/ProjectBuildHelper.php @@ -244,7 +244,7 @@ final readonly class ProjectBuildHelper private function getBomEntryUnitPrice(ProjectBOMEntry $entry, int $number_of_builds, ?Currency $currency): ?BigDecimal { if ($entry->getPart() && $entry->getPart()->getBuiltProject() instanceof Project){ - return $this->calculateTotalBuildPrice($entry->getPart()->getBuiltProject(), intval($entry->getQuantity()), $entry->getPriceCurrency()); + return $this->calculateTotalBuildPrice($entry->getPart()->getBuiltProject(), 1, $entry->getPriceCurrency()); } if ($entry->getPart() instanceof Part) { diff --git a/tests/Services/ProjectSystem/ProjectBuildHelperTest.php b/tests/Services/ProjectSystem/ProjectBuildHelperTest.php index 095e6d95..1e311730 100644 --- a/tests/Services/ProjectSystem/ProjectBuildHelperTest.php +++ b/tests/Services/ProjectSystem/ProjectBuildHelperTest.php @@ -219,7 +219,7 @@ final class ProjectBuildHelperTest extends WebTestCase $subproject = new Project(); $subentry = new ProjectBOMEntry(); $subentry->setPart($this->makePartWithPrice(3.5)); - $subentry->setQuantity(2); + $subentry->setQuantity(3); $subproject->addBomEntry($subentry); $part = new Part(); @@ -229,10 +229,10 @@ final class ProjectBuildHelperTest extends WebTestCase $part->setBuiltProject($subproject); $project->addBomEntry($entry2); - // 4 × 1.50 + 2 x (2 x 3.5) = 20.00 for 1 build + // 4 × 1.50 + 2 x (3 x 3.5) = 27.00 for 1 build $result = $this->service->calculateTotalBuildPrice($project, 1); $this->assertNotNull($result); - $this->assertTrue(BigDecimal::of('20.00')->isEqualTo($result)); + $this->assertTrue(BigDecimal::of('27.00')->isEqualTo($result)); } public function testCalculateUnitBuildPriceEqualsTotal(): void