diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 5a9d5fc..1211c5d 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -94,6 +94,46 @@ } } }, + "warehousemgmt_stockshelf": { + "name": "warehousemgmt_stockshelf", + "fields": { + "warehousemgmt_stockshelf_id": { + "name": "warehousemgmt_stockshelf_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "warehousemgmt_stockshelf_name": { + "name": "warehousemgmt_stockshelf_name", + "type": "VARCHAR(255)", + "null": false + }, + "warehousemgmt_stockshelf_location": { + "name": "warehousemgmt_stockshelf_location", + "type": "INT", + "null": false, + "foreignTable": "warehousemgmt_stocklocation", + "foreignKey": "warehousemgmt_stocklocation_id" + }, + "warehousemgmt_stockshelf_x": { + "name": "warehousemgmt_stockshelf_x", + "type": "INT", + "null": false + }, + "warehousemgmt_stockshelf_y": { + "name": "warehousemgmt_stockshelf_y", + "type": "INT", + "null": false + }, + "warehousemgmt_stockshelf_z": { + "description": "Height", + "name": "warehousemgmt_stockshelf_z", + "type": "INT", + "null": false + } + } + }, "warehousemgmt_lot": { "name": "warehousemgmt_lot", "fields": { diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 5c9e8d6..600ee61 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -19,6 +19,8 @@ use Modules\WarehouseManagement\Models\Stock; use Modules\WarehouseManagement\Models\StockMapper; use Modules\WarehouseManagement\Models\StockLocation; use Modules\WarehouseManagement\Models\StockLocationMapper; +use Modules\WarehouseManagement\Models\StockShelf; +use Modules\WarehouseManagement\Models\StockShelfMapper; /** * WarehouseManagement api controller class. @@ -46,9 +48,13 @@ final class ApiController extends Controller $stock->type = 1; StockMapper::create($stock); - $stockLocation = new StockLocation($new->number . '-1'); + $stockLocation = new StockLocation($stock->name . '-1'); $stockLocation->stock = $stock->getId(); StockLocationMapper::create($stockLocation); + + $stockShelf = new StockShelf($stockLocation->name . '-1'); + $stockShelf->location = $stockLocation->getId(); + StockShelfMapper::create($stockShelf); } public function eventBillUpdateInternal( diff --git a/Models/StockLocation.php b/Models/StockLocation.php index afbccfd..57f1625 100644 --- a/Models/StockLocation.php +++ b/Models/StockLocation.php @@ -34,7 +34,7 @@ class StockLocation public string $name = ''; - public $stock = 0; + public int | Stock $stock = 0; public int $x = 0; diff --git a/Models/StockMovement.php b/Models/StockMovement.php index 91a4b26..160e917 100644 --- a/Models/StockMovement.php +++ b/Models/StockMovement.php @@ -14,6 +14,9 @@ declare(strict_types=1); namespace Modules\WarehouseManagement\Models; +use Modules\Admin\Models\Account; +use Modules\Admin\Models\NullAccount; + /** * Warehouse class. * @@ -64,6 +67,12 @@ class StockMovement */ public \DateTimeImmutable $createdAt; + public function __construct() + { + $this->createdBy = new NullAccount(); + $this->createdAt = new \DateTimeImmutable('now'); + } + /** * Get ID. * diff --git a/Models/StockShelf.php b/Models/StockShelf.php new file mode 100644 index 0000000..d2ce756 --- /dev/null +++ b/Models/StockShelf.php @@ -0,0 +1,54 @@ +name = $name; + } + + public function getId() : int + { + return $this->id; + } +} diff --git a/Models/StockShelfMapper.php b/Models/StockShelfMapper.php new file mode 100644 index 0000000..e99b5e2 --- /dev/null +++ b/Models/StockShelfMapper.php @@ -0,0 +1,72 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'warehousemgmt_stockshelf_id' => ['name' => 'warehousemgmt_stockshelf_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_stockshelf_name' => ['name' => 'warehousemgmt_stockshelf_name', 'type' => 'string', 'internal' => 'name'], + 'warehousemgmt_stockshelf_location' => ['name' => 'warehousemgmt_stockshelf_location', 'type' => 'int', 'internal' => 'location'], + 'warehousemgmt_stockshelf_x' => ['name' => 'warehousemgmt_stockshelf_x', 'type' => 'int', 'internal' => 'x'], + 'warehousemgmt_stockshelf_y' => ['name' => 'warehousemgmt_stockshelf_y', 'type' => 'int', 'internal' => 'y'], + 'warehousemgmt_stockshelf_z' => ['name' => 'warehousemgmt_stockshelf_z', 'type' => 'int', 'internal' => 'z'], + ]; + + /** + * Belongs to. + * + * @var array + * @since 1.0.0 + */ + protected static array $belongsTo = [ + 'location' => [ + 'mapper' => StockMapper::class, + 'external' => 'warehousemgmt_stockshelf_location', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'warehousemgmt_stockshelf'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'warehousemgmt_stockshelf_id'; +}