diff --git a/application/WarehouseArticlePacket/WarehouseArticlePacketController.php b/application/WarehouseArticlePacket/WarehouseArticlePacketController.php index 2cd57ce95..a9c34461c 100644 --- a/application/WarehouseArticlePacket/WarehouseArticlePacketController.php +++ b/application/WarehouseArticlePacket/WarehouseArticlePacketController.php @@ -7,6 +7,7 @@ class WarehouseArticlePacketController extends TTCrud { // @formatter:off protected array $columns = [ ['key' => 'title', 'text' => 'Titel', 'required' => true], + ['key' => 'externalArticleNumber', 'text' => 'Artikel Nummer Trio', 'required' => true], ['key' => 'description', 'text' => 'Beschreibung', 'required' => true], ['key' => 'category', 'text' => 'Kategorie', 'required' => true], ['key' => 'overrideSellPrice', 'text' => 'Überschriebener Verkaufspreis', 'required' => false, 'modal' => ['type' => 'number'], 'table' => false], diff --git a/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php b/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php index fce43e62f..5c98ee963 100644 --- a/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php +++ b/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php @@ -3,6 +3,7 @@ class WarehouseArticlePacketModel extends TTCrudBaseModel { public int $id; public string $title; + public string $externalArticleNumber; public string $description; public string $category; public ?float $overrideSellPrice; diff --git a/application/WarehouseEShopOrder/WarehouseEShopOrderController.php b/application/WarehouseEShopOrder/WarehouseEShopOrderController.php index b89668015..a555c49d1 100644 --- a/application/WarehouseEShopOrder/WarehouseEShopOrderController.php +++ b/application/WarehouseEShopOrder/WarehouseEShopOrderController.php @@ -166,10 +166,10 @@ class WarehouseEShopOrderController extends TTCrud { $articlePacket = $item->articlePacketId ? array_search($item->articlePacketId, array_column($articlePackets, 'id')) : null; $articleExtRef = $articleDistributor[array_search($item->articleId, array_column($articleDistributor, 'articleId'))]; - $articleExtRef = $articleExtRef->externalArticleNumber ?? null; + $articleExtRef = $item->articleId ? $articleExtRef->externalArticleNumber : (!empty($articlePacket->externalArticleNumber) ? $articlePacket->externalArticleNumber : null); $articleTitle = $item->articleId ? $articles[$article]->title : $articlePackets[$articlePacket]->title; $quantity = $item->quantity; - $body .= $item->articleId ? "$quantity x $articleExtRef ($articleTitle)\n" : "$quantity x $articleTitle\n"; + $body .= $articleExtRef !== null ? "$quantity x $articleExtRef ($articleTitle)\n" : "$quantity x $articleTitle\n"; } $body .= "\n\n"; $body .= "CSV der Bestellung ist im Anhang.\n\n"; diff --git a/db/migrations/20250507160000_warehouse_modify_21.php b/db/migrations/20250507160000_warehouse_modify_21.php new file mode 100644 index 000000000..04cc451ee --- /dev/null +++ b/db/migrations/20250507160000_warehouse_modify_21.php @@ -0,0 +1,28 @@ +getEnvironment() == "thetool") { + $WarehouseArticlePacket = $this->table("WarehouseArticlePacket"); + if (!$WarehouseArticlePacket->hasColumn("externalArticleNumber")) { + $WarehouseArticlePacket + ->addColumn("externalArticleNumber", "string", ["limit" => 255, "null" => true]) + ->update(); + } + } + } + + public function down(): void { + if ($this->getEnvironment() == "thetool") { + $WarehouseArticlePacket = $this->table("WarehouseArticlePacket"); + if ($WarehouseArticlePacket->hasColumn("externalArticleNumber")) { + $WarehouseArticlePacket + ->removeColumn("externalArticleNumber") + ->update(); + } + } + } +}