mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-29 12:41:40 +00:00
Consider the prices of built instances of subprojects (#1459)
* Consider the prices of built instances of subprojects * Add test * fix test * fix test * fix test... * fix test again
This commit is contained in:
parent
0169c2d1fa
commit
8c52407c99
2 changed files with 32 additions and 1 deletions
|
|
@ -208,6 +208,33 @@ final class ProjectBuildHelperTest extends WebTestCase
|
|||
$this->assertTrue(BigDecimal::of('6.00')->isEqualTo($result));
|
||||
}
|
||||
|
||||
public function testCalculateTotalBuildPriceWithBuildPartFromSubproject(): void
|
||||
{
|
||||
$project = new Project();
|
||||
$entry = new ProjectBOMEntry();
|
||||
$entry->setPart($this->makePartWithPrice(1.50));
|
||||
$entry->setQuantity(4);
|
||||
$project->addBomEntry($entry);
|
||||
|
||||
$subproject = new Project();
|
||||
$subentry = new ProjectBOMEntry();
|
||||
$subentry->setPart($this->makePartWithPrice(3.5));
|
||||
$subentry->setQuantity(3);
|
||||
$subproject->addBomEntry($subentry);
|
||||
|
||||
$part = new Part();
|
||||
$entry2 = new ProjectBOMEntry();
|
||||
$entry2->setPart($part);
|
||||
$entry2->setQuantity(2);
|
||||
$part->setBuiltProject($subproject);
|
||||
$project->addBomEntry($entry2);
|
||||
|
||||
// 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('27.00')->isEqualTo($result));
|
||||
}
|
||||
|
||||
public function testCalculateUnitBuildPriceEqualsTotal(): void
|
||||
{
|
||||
$project = new Project();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue