Benutzerdefinierten Bauteilstatus einführen

This commit is contained in:
Marcel Diegelmann 2025-03-24 15:15:15 +01:00
parent 0dc7dbdb03
commit ee54687f9d
56 changed files with 1312 additions and 31 deletions

View file

@ -29,6 +29,7 @@ use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\PartCustomState;
use App\Entity\Parts\StorageLocation;
use App\Entity\Parts\Supplier;
use Doctrine\ORM\EntityManagerInterface;
@ -148,6 +149,26 @@ class PKDatastructureImporter
return is_countable($partunit_data) ? count($partunit_data) : 0;
}
public function importPartCustomStates(array $data): int
{
if (!isset($data['partcustomstate'])) {
throw new \RuntimeException('$data must contain a "partcustomstate" key!');
}
$partCustomStateData = $data['partcustomstate'];
foreach ($partCustomStateData as $partCustomState) {
$customState = new PartCustomState();
$customState->setName($partCustomState['name']);
$this->setIDOfEntity($customState, $partCustomState['id']);
$this->em->persist($customState);
}
$this->em->flush();
return is_countable($partCustomStateData) ? count($partCustomStateData) : 0;
}
public function importCategories(array $data): int
{
if (!isset($data['partcategory'])) {

View file

@ -91,6 +91,8 @@ class PKPartImporter
$this->setAssociationField($entity, 'partUnit', MeasurementUnit::class, $part['partUnit_id']);
}
$this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class, $part['partCustomState_id']);
//Create a part lot to store the stock level and location
$lot = new PartLot();
$lot->setAmount((float) ($part['stockLevel'] ?? 0));