implemented inventur and changed warehousearticle/category

This commit is contained in:
2025-12-15 23:47:16 +01:00
parent b43925d37e
commit 3000c9e2e7
18 changed files with 2711 additions and 13 deletions

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateWarehouseStocktakeTables extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
// 1. Main Stocktake Session Table
$stocktake = $this->table('WarehouseStocktake');
$stocktake->addColumn('stocktakeNumber', 'string', ['limit' => 50, 'null' => true])
->addColumn('title', 'string', ['limit' => 255])
->addColumn('description', 'text', ['null' => true])
->addColumn('warehouseLocationId', 'integer', ['signed' => true])
->addColumn('status', 'enum', ['values' => ['planned', 'in_progress', 'completed', 'cancelled'], 'default' => 'planned'])
->addColumn('startedAt', 'integer', ['null' => true])
->addColumn('completedAt', 'integer', ['null' => true])
->addColumn('startedBy', 'integer', ['null' => true, 'signed' => false])
->addColumn('completedBy', 'integer', ['null' => true, 'signed' => false])
->addColumn('totalItems', 'integer', ['default' => 0])
->addColumn('totalScannedItems', 'integer', ['default' => 0])
->addColumn('notes', 'text', ['null' => true])
->addColumn('createBy', 'integer', ['signed' => false])
->addColumn('create', 'integer')
->addIndex(['stocktakeNumber'], ['unique' => true])
->addIndex(['status'])
->addIndex(['warehouseLocationId'])
->create();
// 2. Individual Stocktake Items
$stocktakeItem = $this->table('WarehouseStocktakeItem');
$stocktakeItem->addColumn('stocktakeId', 'integer', ['signed' => true])
->addColumn('articleId', 'integer', ['signed' => false])
->addColumn('warehouseItemId', 'integer', ['null' => true, 'signed' => false])
->addColumn('countedQuantity', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0])
->addColumn('rack', 'string', ['limit' => 50, 'null' => true])
->addColumn('shelf', 'string', ['limit' => 50, 'null' => true])
->addColumn('note', 'text', ['null' => true])
->addColumn('scannedAt', 'integer', ['null' => true])
->addColumn('scannedBy', 'integer', ['null' => true, 'signed' => false])
->addColumn('createBy', 'integer', ['signed' => false])
->addColumn('create', 'integer')
->addIndex(['stocktakeId'])
->addIndex(['articleId'])
->create();
// 3. Activity Log
$stocktakeLog = $this->table('WarehouseStocktakeLog');
$stocktakeLog->addColumn('stocktakeId', 'integer', ['signed' => true])
->addColumn('stocktakeItemId', 'integer', ['null' => true, 'signed' => true])
->addColumn('action', 'string', ['limit' => 50])
->addColumn('details', 'text', ['null' => true])
->addColumn('userId', 'integer', ['signed' => false])
->addColumn('create', 'integer')
->addIndex(['stocktakeId'])
->create();
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$this->table('WarehouseStocktakeLog')->drop()->save();
$this->table('WarehouseStocktakeItem')->drop()->save();
$this->table('WarehouseStocktake')->drop()->save();
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class WarehouseCategorySetPrefixes extends AbstractMigration
{
public function up(): void
{
$table = $this->table('WarehouseCategory');
if (!$table->hasColumn('articleNumberPrefix')) {
$table->addColumn('articleNumberPrefix', 'string', ['limit' => 4, 'null' => true, 'after' => 'description'])
->update();
}
if ($this->getEnvironment() == "thetool") {
$prefixes = [
1 => '1901', // Dienstleistungen
3 => '9980', // EStmk Shop
4 => '1400', // GPON OLTs und Bridges
21 => '9990', // Import nicht erfolgreich
5 => '1700', // Kabel-TV und Zubehör
6 => '0700', // Kupferverkabelung und Schränke
7 => '0400', // LWL Aussen- und Universalkabel
8 => '0600', // LWL Boxen, Muffen und Gehäuse
9 => '0900', // LWL Leitungsbau
10 => '0500', // LWL Pigtails und Kupplungen
11 => '0800', // LWL Splitter, Filter und Dämpfer
12 => '1600', // Netzteile, USV, Akkus
13 => '0300', // Patchkabel Kupfer
14 => '0200', // Patchkabel LWL Multimode
15 => '0100', // Patchkabel LWL Singlemode
16 => '1000', // Richtfunk und WLAN
17 => '1100', // Router und Zubehör
18 => '1300', // SFP und Konverter
19 => '1200', // Switches und Zubehör
20 => '1500', // Telefonie und Zubehör
2 => '1800', // Elektromaterial etc. (no articles, assign next free)
];
foreach ($prefixes as $categoryId => $prefix) {
$this->execute("UPDATE WarehouseCategory SET articleNumberPrefix = '{$prefix}' WHERE id = {$categoryId}");
}
}
}
public function down(): void
{
$table = $this->table('WarehouseCategory');
if ($table->hasColumn('articleNumberPrefix')) {
$table->removeColumn('articleNumberPrefix')->update();
}
}
}