feat : ajout de fixtures
This commit is contained in:
Generated
+28
-25
@@ -7,9 +7,11 @@
|
|||||||
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="feat : mise à jour du bon de réception">
|
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="feat : mise à jour du bon de réception">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/frontend/components/reception/reception-product-received.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/components/reception/reception-product-received.vue" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/frontend/components/reception/reception-weight.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/components/reception/reception-weight.vue" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/frontend/components/reception/reception-weight.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/components/reception/reception-weight.vue" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/frontend/composables/usePdfPrinter.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/composables/usePdfPrinter.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/frontend/composables/usePdfPrinter.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/composables/usePdfPrinter.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/templates/reception_voucher.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/templates/reception_voucher.html.twig" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Command/SeedCommand.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Command/SeedCommand.php" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/DataFixtures/ReferenceFixtures.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/DataFixtures/ReferenceFixtures.php" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -35,7 +37,7 @@
|
|||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||||
<map>
|
<map>
|
||||||
<entry key="$PROJECT_DIR$" value="develop" />
|
<entry key="$PROJECT_DIR$" value="feat/poc-identification-bovin" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
@@ -215,34 +217,34 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RunOnceActivity.MCP Project settings loaded": "true",
|
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
"git-widget-placeholder": "feat/finalisation-reception-marchandise",
|
"git-widget-placeholder": "develop",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"DatabaseDriversLRU": [
|
"DatabaseDriversLRU": [
|
||||||
"postgresql"
|
"postgresql"
|
||||||
],
|
],
|
||||||
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
||||||
"TEXT"
|
"TEXT"
|
||||||
],
|
],
|
||||||
"vue.recent.templates": [
|
"vue.recent.templates": [
|
||||||
"Vue Composition API Component"
|
"Vue Composition API Component"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\m-tristan\workspace\Ferme" />
|
<recent name="\\wsl.localhost\Ubuntu-24.04\home\m-tristan\workspace\Ferme" />
|
||||||
@@ -279,6 +281,7 @@
|
|||||||
<workItem from="1769696465294" duration="8573000" />
|
<workItem from="1769696465294" duration="8573000" />
|
||||||
<workItem from="1769756623432" duration="21592000" />
|
<workItem from="1769756623432" duration="21592000" />
|
||||||
<workItem from="1770015653091" duration="73000" />
|
<workItem from="1770015653091" duration="73000" />
|
||||||
|
<workItem from="1770040138216" duration="6492000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="feat : Ajout de pinia, création de la table weight et reception mise en place du système de step pour les receptions (WIP)">
|
<task id="LOCAL-00001" summary="feat : Ajout de pinia, création de la table weight et reception mise en place du système de step pour les receptions (WIP)">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
|||||||
+345
-83
@@ -27,6 +27,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
)]
|
)]
|
||||||
class SeedCommand extends Command
|
class SeedCommand extends Command
|
||||||
{
|
{
|
||||||
|
private int $created = 0;
|
||||||
|
private int $updated = 0;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager
|
private readonly EntityManagerInterface $entityManager
|
||||||
) {
|
) {
|
||||||
@@ -37,55 +40,32 @@ class SeedCommand extends Command
|
|||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$created = 0;
|
$this->created = 0;
|
||||||
$updated = 0;
|
$this->updated = 0;
|
||||||
|
|
||||||
$truckRepo = $this->entityManager->getRepository(Truck::class);
|
$trucks = $this->seedTrucks();
|
||||||
$carrierRepo = $this->entityManager->getRepository(Carrier::class);
|
$carriers = $this->seedCarriers();
|
||||||
$driverRepo = $this->entityManager->getRepository(Driver::class);
|
$this->seedDriversAndVehicles($carriers['liot'] ?? null, $trucks['citerne'] ?? null, $trucks['porteur'] ?? null, $io);
|
||||||
$vehicleRepo = $this->entityManager->getRepository(Vehicle::class);
|
$this->seedMerchandiseTypes();
|
||||||
$merchandiseTypeRepo = $this->entityManager->getRepository(MerchandiseType::class);
|
$this->seedPelletTypes();
|
||||||
$pelletTypeRepo = $this->entityManager->getRepository(PelletType::class);
|
$this->seedBuildings();
|
||||||
$buildingRepo = $this->entityManager->getRepository(Building::class);
|
$this->seedReceptionTypes();
|
||||||
$receptionTypeRepo = $this->entityManager->getRepository(ReceptionType::class);
|
$this->seedSuppliers();
|
||||||
$addressRepo = $this->entityManager->getRepository(Address::class);
|
|
||||||
$supplierRepo = $this->entityManager->getRepository(Supplier::class);
|
|
||||||
|
|
||||||
$upsertByCode = function (string $entityClass, string $code, callable $apply) use (&$created, &$updated) {
|
$this->entityManager->flush();
|
||||||
$repo = $this->entityManager->getRepository($entityClass);
|
|
||||||
$entity = $repo->findOneBy(['code' => $code]);
|
$io->success(sprintf('Seed completed: %d created, %d updated.', $this->created, $this->updated));
|
||||||
if (!$entity) {
|
|
||||||
$entity = new $entityClass();
|
return Command::SUCCESS;
|
||||||
++$created;
|
|
||||||
} else {
|
|
||||||
++$updated;
|
|
||||||
}
|
}
|
||||||
$apply($entity);
|
|
||||||
$this->entityManager->persist($entity);
|
|
||||||
|
|
||||||
return $entity;
|
|
||||||
};
|
|
||||||
|
|
||||||
$upsertByName = function (string $entityClass, string $name, callable $apply) use (&$created, &$updated) {
|
|
||||||
$repo = $this->entityManager->getRepository($entityClass);
|
|
||||||
$entity = $repo->findOneBy(['name' => $name]);
|
|
||||||
if (!$entity) {
|
|
||||||
$entity = new $entityClass();
|
|
||||||
++$created;
|
|
||||||
} else {
|
|
||||||
++$updated;
|
|
||||||
}
|
|
||||||
$apply($entity);
|
|
||||||
$this->entityManager->persist($entity);
|
|
||||||
|
|
||||||
return $entity;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private function seedTrucks(): array
|
||||||
|
{
|
||||||
$trucks = ['Citerne', 'Porteur'];
|
$trucks = ['Citerne', 'Porteur'];
|
||||||
$citerne = null;
|
$citerne = null;
|
||||||
$porteur = null;
|
$porteur = null;
|
||||||
foreach ($trucks as $name) {
|
foreach ($trucks as $name) {
|
||||||
$truck = $upsertByName(Truck::class, $name, static fn (Truck $truck) => $truck->setName($name));
|
$truck = $this->upsertByName(Truck::class, $name, static fn (Truck $truck) => $truck->setName($name));
|
||||||
if ('Citerne' === $name) {
|
if ('Citerne' === $name) {
|
||||||
$citerne = $truck;
|
$citerne = $truck;
|
||||||
}
|
}
|
||||||
@@ -94,13 +74,21 @@ class SeedCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'citerne' => $citerne,
|
||||||
|
'porteur' => $porteur,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedCarriers(): array
|
||||||
|
{
|
||||||
$carriers = [
|
$carriers = [
|
||||||
['name' => 'LIOT', 'code' => 'LIOT'],
|
['name' => 'LIOT', 'code' => 'LIOT'],
|
||||||
['name' => 'LUI-MEME', 'code' => 'LUI-MEME'],
|
['name' => 'LUI-MEME', 'code' => 'LUI-MEME'],
|
||||||
];
|
];
|
||||||
$liot = null;
|
$liot = null;
|
||||||
foreach ($carriers as $carrierData) {
|
foreach ($carriers as $carrierData) {
|
||||||
$carrier = $upsertByCode(Carrier::class, $carrierData['code'], static function (Carrier $carrier) use ($carrierData) {
|
$carrier = $this->upsertByCode(Carrier::class, $carrierData['code'], static function (Carrier $carrier) use ($carrierData) {
|
||||||
$carrier
|
$carrier
|
||||||
->setName($carrierData['name'])
|
->setName($carrierData['name'])
|
||||||
->setCode($carrierData['code'])
|
->setCode($carrierData['code'])
|
||||||
@@ -111,15 +99,30 @@ class SeedCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($liot && $citerne && $porteur) {
|
return [
|
||||||
|
'liot' => $liot,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedDriversAndVehicles(?Carrier $liot, ?Truck $citerne, ?Truck $porteur, SymfonyStyle $io): void
|
||||||
|
{
|
||||||
|
if (!$liot || !$citerne || !$porteur) {
|
||||||
|
$io->warning('Transport data not fully available; drivers/vehicles skipped.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$driverRepo = $this->entityManager->getRepository(Driver::class);
|
||||||
|
$vehicleRepo = $this->entityManager->getRepository(Vehicle::class);
|
||||||
|
|
||||||
$drivers = ['Eddy', 'Jean-Christophe', 'Etienne', 'Hersand'];
|
$drivers = ['Eddy', 'Jean-Christophe', 'Etienne', 'Hersand'];
|
||||||
foreach ($drivers as $name) {
|
foreach ($drivers as $name) {
|
||||||
$driver = $driverRepo->findOneBy(['name' => $name, 'carrier' => $liot]);
|
$driver = $driverRepo->findOneBy(['name' => $name, 'carrier' => $liot]);
|
||||||
if (!$driver) {
|
if (!$driver) {
|
||||||
$driver = new Driver();
|
$driver = new Driver();
|
||||||
++$created;
|
++$this->created;
|
||||||
} else {
|
} else {
|
||||||
++$updated;
|
++$this->updated;
|
||||||
}
|
}
|
||||||
$driver
|
$driver
|
||||||
->setName($name)
|
->setName($name)
|
||||||
@@ -139,9 +142,9 @@ class SeedCommand extends Command
|
|||||||
$vehicle = $vehicleRepo->findOneBy(['plate' => $vehicleData['plate']]);
|
$vehicle = $vehicleRepo->findOneBy(['plate' => $vehicleData['plate']]);
|
||||||
if (!$vehicle) {
|
if (!$vehicle) {
|
||||||
$vehicle = new Vehicle();
|
$vehicle = new Vehicle();
|
||||||
++$created;
|
++$this->created;
|
||||||
} else {
|
} else {
|
||||||
++$updated;
|
++$this->updated;
|
||||||
}
|
}
|
||||||
$vehicle
|
$vehicle
|
||||||
->setPlate($vehicleData['plate'])
|
->setPlate($vehicleData['plate'])
|
||||||
@@ -150,24 +153,27 @@ class SeedCommand extends Command
|
|||||||
;
|
;
|
||||||
$this->entityManager->persist($vehicle);
|
$this->entityManager->persist($vehicle);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$io->warning('Transport data not fully available; drivers/vehicles skipped.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function seedMerchandiseTypes(): void
|
||||||
|
{
|
||||||
$merchandiseTypes = [
|
$merchandiseTypes = [
|
||||||
['label' => 'Foin', 'code' => 'FOIN'],
|
['label' => 'Foin', 'code' => 'FOIN'],
|
||||||
['label' => 'Paille', 'code' => 'PAILLE'],
|
['label' => 'Paille', 'code' => 'PAILLE'],
|
||||||
['label' => 'Granule', 'code' => 'GRANULE'],
|
['label' => 'Granule', 'code' => 'GRANULE'],
|
||||||
];
|
];
|
||||||
foreach ($merchandiseTypes as $type) {
|
foreach ($merchandiseTypes as $type) {
|
||||||
$upsertByCode(MerchandiseType::class, $type['code'], static function (MerchandiseType $entity) use ($type) {
|
$this->upsertByCode(MerchandiseType::class, $type['code'], static function (MerchandiseType $entity) use ($type) {
|
||||||
$entity
|
$entity
|
||||||
->setLabel($type['label'])
|
->setLabel($type['label'])
|
||||||
->setCode($type['code'])
|
->setCode($type['code'])
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedPelletTypes(): void
|
||||||
|
{
|
||||||
$pelletTypes = [
|
$pelletTypes = [
|
||||||
['label' => 'JB croissance', 'code' => 'K750'],
|
['label' => 'JB croissance', 'code' => 'K750'],
|
||||||
['label' => 'Genisse herbe', 'code' => 'K500'],
|
['label' => 'Genisse herbe', 'code' => 'K500'],
|
||||||
@@ -175,82 +181,338 @@ class SeedCommand extends Command
|
|||||||
['label' => 'Bovin mise en forme', 'code' => 'K400'],
|
['label' => 'Bovin mise en forme', 'code' => 'K400'],
|
||||||
];
|
];
|
||||||
foreach ($pelletTypes as $type) {
|
foreach ($pelletTypes as $type) {
|
||||||
$upsertByCode(PelletType::class, $type['code'], static function (PelletType $entity) use ($type) {
|
$this->upsertByCode(PelletType::class, $type['code'], static function (PelletType $entity) use ($type) {
|
||||||
$entity
|
$entity
|
||||||
->setLabel($type['label'])
|
->setLabel($type['label'])
|
||||||
->setCode($type['code'])
|
->setCode($type['code'])
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedBuildings(): void
|
||||||
|
{
|
||||||
$buildings = [
|
$buildings = [
|
||||||
['label' => 'Bâtiment 1', 'code' => 'B1'],
|
['label' => 'Bâtiment 1', 'code' => 'B1'],
|
||||||
['label' => 'Bâtiment 2', 'code' => 'B2'],
|
['label' => 'Bâtiment 2', 'code' => 'B2'],
|
||||||
['label' => 'Bâtiment 3', 'code' => 'B3'],
|
['label' => 'Bâtiment 3', 'code' => 'B3'],
|
||||||
];
|
];
|
||||||
foreach ($buildings as $buildingData) {
|
foreach ($buildings as $buildingData) {
|
||||||
$upsertByCode(Building::class, $buildingData['code'], static function (Building $entity) use ($buildingData) {
|
$this->upsertByCode(Building::class, $buildingData['code'], static function (Building $entity) use ($buildingData) {
|
||||||
$entity
|
$entity
|
||||||
->setLabel($buildingData['label'])
|
->setLabel($buildingData['label'])
|
||||||
->setCode($buildingData['code'])
|
->setCode($buildingData['code'])
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedReceptionTypes(): void
|
||||||
|
{
|
||||||
$receptionTypes = [
|
$receptionTypes = [
|
||||||
['label' => 'Marchandises', 'code' => 'MARCHANDISES'],
|
['label' => 'Marchandises', 'code' => 'MARCHANDISES'],
|
||||||
['label' => 'Bovins', 'code' => 'BOVINS'],
|
['label' => 'Bovins', 'code' => 'BOVINS'],
|
||||||
];
|
];
|
||||||
foreach ($receptionTypes as $type) {
|
foreach ($receptionTypes as $type) {
|
||||||
$upsertByCode(ReceptionType::class, $type['code'], static function (ReceptionType $entity) use ($type) {
|
$this->upsertByCode(ReceptionType::class, $type['code'], static function (ReceptionType $entity) use ($type) {
|
||||||
$entity
|
$entity
|
||||||
->setLabel($type['label'])
|
->setLabel($type['label'])
|
||||||
->setCode($type['code'])
|
->setCode($type['code'])
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$address = $addressRepo->findOneBy([
|
private function seedSuppliers(): void
|
||||||
|
{
|
||||||
|
$suppliers = [
|
||||||
|
[
|
||||||
|
'name' => 'LIOT',
|
||||||
|
'email' => 'lpc.contacts@lpc-liot.fr',
|
||||||
|
'phone' => '05.49.20.09.10',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
'label' => 'LIOT CHATELLERAULT',
|
'label' => 'LIOT CHATELLERAULT',
|
||||||
|
'street' => "14 Allée d'Argenson",
|
||||||
|
'street2' => 'ZI Nord',
|
||||||
'postalCode' => '86100',
|
'postalCode' => '86100',
|
||||||
]);
|
'city' => 'CHATELLERAULT',
|
||||||
if (!$address) {
|
'countryCode' => 'FR',
|
||||||
$address = new Address();
|
],
|
||||||
++$created;
|
],
|
||||||
} else {
|
],
|
||||||
++$updated;
|
[
|
||||||
}
|
'name' => 'ARNAULT EURL',
|
||||||
$address
|
'email' => 'eurl.arnault86@orange.fr',
|
||||||
->setLabel('LIOT CHATELLERAULT')
|
'phone' => '05.49.02.65.27',
|
||||||
->setStreet("14 Allée d'Argenson")
|
'addresses' => [
|
||||||
->setStreet2('ZI Nord')
|
[
|
||||||
->setPostalCode('86100')
|
'label' => 'ARNAULT EURL',
|
||||||
->setCity('CHATELLERAULT')
|
'street' => 'Moulin du Guéret',
|
||||||
->setCountryCode('FR')
|
'street2' => 'B.P 30425',
|
||||||
;
|
'postalCode' => '86100',
|
||||||
$this->entityManager->persist($address);
|
'city' => 'Antran',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'EARL DES GONNIERES',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => '06.80.14.18.82',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'EARL DES GONNIERES',
|
||||||
|
'street' => "27 Route d'Ingrandes",
|
||||||
|
'street2' => 'Les Gonnières',
|
||||||
|
'postalCode' => '86220',
|
||||||
|
'city' => 'OYRE',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'EARL LESIGNY BABY',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => '05.49.86.17.95',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'EARL LESIGNY BABY',
|
||||||
|
'street' => '2 Lieu Dit Les Bouquins',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86270',
|
||||||
|
'city' => 'LESIGNY',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'FEDER',
|
||||||
|
'email' => 'contact@uco-feder.fr',
|
||||||
|
'phone' => '03.85.24.25.50',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'FEDER',
|
||||||
|
'street' => 'Molaise',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '71120',
|
||||||
|
'city' => 'CHAROLLES',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => "GAEC DE L'ESPOIR",
|
||||||
|
'email' => 'contact@uco-feder.fr',
|
||||||
|
'phone' => '05.49.86.57.24',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => "GAEC DE L'ESPOIR",
|
||||||
|
'street' => 'La Moujonnerie',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86450',
|
||||||
|
'city' => 'PLEUMARTIN',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'GRAVELEAU',
|
||||||
|
'email' => 'contact@graveleau-sarl.fr',
|
||||||
|
'phone' => '05.49.23.51.66',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'GRAVELEAU',
|
||||||
|
'street' => '3, Le Jeu',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86220',
|
||||||
|
'city' => 'INGRANDES',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'LORTHOLARY',
|
||||||
|
'email' => 'contact86@lortholarybetail.com',
|
||||||
|
'phone' => '05.49.52.77.10',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'LORTHOLARY',
|
||||||
|
'street' => 'Ferme de Geniec',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86550',
|
||||||
|
'city' => 'MIGNALOUX BEAUVOIR',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'NATERA',
|
||||||
|
'email' => 'contact86@lortholarybetail.com',
|
||||||
|
'phone' => '05.65.67.89.46',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'NATERA',
|
||||||
|
'street' => 'Bd des Balquières',
|
||||||
|
'street2' => 'BP 3220',
|
||||||
|
'postalCode' => '12032',
|
||||||
|
'city' => 'RODEZ CEDEX 9',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'SCEA des Bariollières',
|
||||||
|
'email' => 'elisregnier@gmail.com',
|
||||||
|
'phone' => '06.09.37.65.61',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'SCEA des Bariollières',
|
||||||
|
'street' => '2 rue des Barriollières',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86220',
|
||||||
|
'city' => 'INGRANDES',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'SCEA SENE',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => null,
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'SCEA SENE',
|
||||||
|
'street' => '3 Route de la Roche Posay',
|
||||||
|
'street2' => 'Les Girouettes',
|
||||||
|
'postalCode' => '86100',
|
||||||
|
'city' => 'CHATELLERAULT',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'TERRENA',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => '02.51.67.17.98',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'TERRENA',
|
||||||
|
'street' => 'La Blanchardière',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '44522',
|
||||||
|
'city' => 'MESANGER',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'TRICHERIE COOPERATIVE',
|
||||||
|
'email' => 'contact@cooptricherie.fr',
|
||||||
|
'phone' => '05.49.19.44.33',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'TRICHERIE COOPERATIVE',
|
||||||
|
'street' => 'B.P n°2',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86490',
|
||||||
|
'city' => 'BEAUMONT',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'TURPAULT Muriel',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => null,
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'TURPAULT Muriel',
|
||||||
|
'street' => '23Bis Rue Marcel Pagnol',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86100',
|
||||||
|
'city' => 'TARGE',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
$supplier = $supplierRepo->findOneBy(['name' => 'LIOT']);
|
foreach ($suppliers as $supplierData) {
|
||||||
if (!$supplier) {
|
$supplier = $this->upsertByName(Supplier::class, $supplierData['name'], static function (Supplier $supplier) use ($supplierData) {
|
||||||
$supplier = new Supplier();
|
|
||||||
++$created;
|
|
||||||
} else {
|
|
||||||
++$updated;
|
|
||||||
}
|
|
||||||
$supplier
|
$supplier
|
||||||
->setName('LIOT')
|
->setName($supplierData['name'])
|
||||||
->setEmail('lpc.contacts@lpc-liot.fr')
|
->setEmail($supplierData['email'])
|
||||||
->setPhone('05.49.20.09.10')
|
->setPhone($supplierData['phone'])
|
||||||
;
|
;
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($supplierData['addresses'] as $addressData) {
|
||||||
|
$address = $this->upsertAddress($addressData);
|
||||||
if (!$supplier->getAddresses()->contains($address)) {
|
if (!$supplier->getAddresses()->contains($address)) {
|
||||||
$supplier->getAddresses()->add($address);
|
$supplier->getAddresses()->add($address);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->entityManager->persist($supplier);
|
$this->entityManager->persist($supplier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->entityManager->flush();
|
private function upsertByCode(string $entityClass, string $code, callable $apply): object
|
||||||
|
{
|
||||||
|
$repo = $this->entityManager->getRepository($entityClass);
|
||||||
|
$entity = $repo->findOneBy(['code' => $code]);
|
||||||
|
if (!$entity) {
|
||||||
|
$entity = new $entityClass();
|
||||||
|
++$this->created;
|
||||||
|
} else {
|
||||||
|
++$this->updated;
|
||||||
|
}
|
||||||
|
$apply($entity);
|
||||||
|
$this->entityManager->persist($entity);
|
||||||
|
|
||||||
$io->success(sprintf('Seed completed: %d created, %d updated.', $created, $updated));
|
return $entity;
|
||||||
|
}
|
||||||
|
|
||||||
return Command::SUCCESS;
|
private function upsertByName(string $entityClass, string $name, callable $apply): object
|
||||||
|
{
|
||||||
|
$repo = $this->entityManager->getRepository($entityClass);
|
||||||
|
$entity = $repo->findOneBy(['name' => $name]);
|
||||||
|
if (!$entity) {
|
||||||
|
$entity = new $entityClass();
|
||||||
|
++$this->created;
|
||||||
|
} else {
|
||||||
|
++$this->updated;
|
||||||
|
}
|
||||||
|
$apply($entity);
|
||||||
|
$this->entityManager->persist($entity);
|
||||||
|
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function upsertAddress(array $addressData): Address
|
||||||
|
{
|
||||||
|
$addressRepo = $this->entityManager->getRepository(Address::class);
|
||||||
|
$address = $addressRepo->findOneBy([
|
||||||
|
'label' => $addressData['label'],
|
||||||
|
'postalCode' => $addressData['postalCode'],
|
||||||
|
]);
|
||||||
|
if (!$address) {
|
||||||
|
$address = new Address();
|
||||||
|
++$this->created;
|
||||||
|
} else {
|
||||||
|
++$this->updated;
|
||||||
|
}
|
||||||
|
$address
|
||||||
|
->setLabel($addressData['label'])
|
||||||
|
->setStreet($addressData['street'])
|
||||||
|
->setStreet2($addressData['street2'])
|
||||||
|
->setPostalCode($addressData['postalCode'])
|
||||||
|
->setCity($addressData['city'])
|
||||||
|
->setCountryCode($addressData['countryCode'])
|
||||||
|
;
|
||||||
|
$this->entityManager->persist($address);
|
||||||
|
|
||||||
|
return $address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\DataFixtures;
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\Address;
|
||||||
use App\Entity\Building;
|
use App\Entity\Building;
|
||||||
use App\Entity\MerchandiseType;
|
use App\Entity\MerchandiseType;
|
||||||
use App\Entity\PelletType;
|
use App\Entity\PelletType;
|
||||||
use App\Entity\ReceptionType;
|
use App\Entity\ReceptionType;
|
||||||
|
use App\Entity\Supplier;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
@@ -67,6 +69,242 @@ class ReferenceFixtures extends Fixture
|
|||||||
$manager->persist($receptionType);
|
$manager->persist($receptionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$suppliers = [
|
||||||
|
[
|
||||||
|
'name' => 'LIOT',
|
||||||
|
'email' => 'lpc.contacts@lpc-liot.fr',
|
||||||
|
'phone' => '05.49.20.09.10',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'LIOT CHATELLERAULT',
|
||||||
|
'street' => "14 Allée d'Argenson",
|
||||||
|
'street2' => 'ZI Nord',
|
||||||
|
'postalCode' => '86100',
|
||||||
|
'city' => 'CHATELLERAULT',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'ARNAULT EURL',
|
||||||
|
'email' => 'eurl.arnault86@orange.fr',
|
||||||
|
'phone' => '05.49.02.65.27',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'ARNAULT EURL',
|
||||||
|
'street' => 'Moulin du Guéret',
|
||||||
|
'street2' => 'B.P 30425',
|
||||||
|
'postalCode' => '86100',
|
||||||
|
'city' => 'Antran',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'EARL DES GONNIERES',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => '06.80.14.18.82',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'EARL DES GONNIERES',
|
||||||
|
'street' => "27 Route d'Ingrandes",
|
||||||
|
'street2' => 'Les Gonnières',
|
||||||
|
'postalCode' => '86220',
|
||||||
|
'city' => 'OYRE',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'EARL LESIGNY BABY',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => '05.49.86.17.95',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'EARL LESIGNY BABY',
|
||||||
|
'street' => '2 Lieu Dit Les Bouquins',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86270',
|
||||||
|
'city' => 'LESIGNY',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'FEDER',
|
||||||
|
'email' => 'contact@uco-feder.fr',
|
||||||
|
'phone' => '03.85.24.25.50',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'FEDER',
|
||||||
|
'street' => 'Molaise',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '71120',
|
||||||
|
'city' => 'CHAROLLES',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => "GAEC DE L'ESPOIR",
|
||||||
|
'email' => 'contact@uco-feder.fr',
|
||||||
|
'phone' => '05.49.86.57.24',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => "GAEC DE L'ESPOIR",
|
||||||
|
'street' => 'La Moujonnerie',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86450',
|
||||||
|
'city' => 'PLEUMARTIN',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'GRAVELEAU',
|
||||||
|
'email' => 'contact@graveleau-sarl.fr',
|
||||||
|
'phone' => '05.49.23.51.66',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'GRAVELEAU',
|
||||||
|
'street' => '3, Le Jeu',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86220',
|
||||||
|
'city' => 'INGRANDES',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'LORTHOLARY',
|
||||||
|
'email' => 'contact86@lortholarybetail.com',
|
||||||
|
'phone' => '05.49.52.77.10',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'LORTHOLARY',
|
||||||
|
'street' => 'Ferme de Geniec',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86550',
|
||||||
|
'city' => 'MIGNALOUX BEAUVOIR',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'NATERA',
|
||||||
|
'email' => 'contact86@lortholarybetail.com',
|
||||||
|
'phone' => '05.65.67.89.46',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'NATERA',
|
||||||
|
'street' => 'Bd des Balquières',
|
||||||
|
'street2' => 'BP 3220',
|
||||||
|
'postalCode' => '12032',
|
||||||
|
'city' => 'RODEZ CEDEX 9',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'SCEA des Bariollières',
|
||||||
|
'email' => 'elisregnier@gmail.com',
|
||||||
|
'phone' => '06.09.37.65.61',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'SCEA des Bariollières',
|
||||||
|
'street' => '2 rue des Barriollières',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86220',
|
||||||
|
'city' => 'INGRANDES',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'SCEA SENE',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => null,
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'SCEA SENE',
|
||||||
|
'street' => '3 Route de la Roche Posay',
|
||||||
|
'street2' => 'Les Girouettes',
|
||||||
|
'postalCode' => '86100',
|
||||||
|
'city' => 'CHATELLERAULT',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'TERRENA',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => '02.51.67.17.98',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'TERRENA',
|
||||||
|
'street' => 'La Blanchardière',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '44522',
|
||||||
|
'city' => 'MESANGER',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'TRICHERIE COOPERATIVE',
|
||||||
|
'email' => 'contact@cooptricherie.fr',
|
||||||
|
'phone' => '05.49.19.44.33',
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'TRICHERIE COOPERATIVE',
|
||||||
|
'street' => 'B.P n°2',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86490',
|
||||||
|
'city' => 'BEAUMONT',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'TURPAULT Muriel',
|
||||||
|
'email' => null,
|
||||||
|
'phone' => null,
|
||||||
|
'addresses' => [
|
||||||
|
[
|
||||||
|
'label' => 'TURPAULT Muriel',
|
||||||
|
'street' => '23Bis Rue Marcel Pagnol',
|
||||||
|
'street2' => null,
|
||||||
|
'postalCode' => '86100',
|
||||||
|
'city' => 'TARGE',
|
||||||
|
'countryCode' => 'FR',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($suppliers as $supplierData) {
|
||||||
|
$supplier = new Supplier()
|
||||||
|
->setName($supplierData['name'])
|
||||||
|
->setEmail($supplierData['email'])
|
||||||
|
->setPhone($supplierData['phone'])
|
||||||
|
;
|
||||||
|
|
||||||
|
foreach ($supplierData['addresses'] as $addressData) {
|
||||||
|
$address = new Address()
|
||||||
|
->setLabel($addressData['label'])
|
||||||
|
->setStreet($addressData['street'])
|
||||||
|
->setStreet2($addressData['street2'])
|
||||||
|
->setPostalCode($addressData['postalCode'])
|
||||||
|
->setCity($addressData['city'])
|
||||||
|
->setCountryCode($addressData['countryCode'])
|
||||||
|
;
|
||||||
|
$manager->persist($address);
|
||||||
|
$supplier->getAddresses()->add($address);
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->persist($supplier);
|
||||||
|
}
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user