Migrated from GitLab wiki

rob
2026-06-29 09:04:54 +00:00
parent 7a428e300f
commit 2dd05a1750
+148
@@ -0,0 +1,148 @@
**Table Name - IContainer**
**Table Schema**
```
+--------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| location_id | int(11) | YES | MUL | NULL | |
| parent_id | int(11) | YES | MUL | NULL | |
| address_id | int(11) | YES | MUL | NULL | |
| user_id | int(11) | YES | MUL | NULL | |
| shipment_id | int(11) | YES | MUL | NULL | |
| identifier | varchar(64) | YES | | NULL | |
| deletedAt | datetime | YES | | NULL | |
| lft | int(11) | NO | | NULL | |
| rgt | int(11) | NO | | NULL | |
| root | int(11) | YES | | NULL | |
| lvl | int(11) | NO | | NULL | |
| createdAt | datetime | NO | | NULL | |
| updatedAt | datetime | NO | | NULL | |
| discr | varchar(255) | NO | | NULL | |
| cartonNumber | varchar(32) | YES | | NULL | |
| description | varchar(1024) | YES | | NULL | |
+--------------+---------------+------+-----+---------+----------------+
```
```
CREATE TABLE `IContainer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`location_id` int(11) DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
`address_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`shipment_id` int(11) DEFAULT NULL,
`identifier` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`deletedAt` datetime DEFAULT NULL,
`lft` int(11) NOT NULL,
`rgt` int(11) NOT NULL,
`root` int(11) DEFAULT NULL,
`lvl` int(11) NOT NULL,
`createdAt` datetime NOT NULL,
`updatedAt` datetime NOT NULL,
`discr` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`cartonNumber` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
`description` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `IDX_227F3E0A64D218E` (`location_id`),
KEY `IDX_227F3E0A727ACA70` (`parent_id`),
KEY `IDX_227F3E0AF5B7AF75` (`address_id`),
KEY `IDX_227F3E0AA76ED395` (`user_id`),
KEY `IDX_227F3E0A7BE036FC` (`shipment_id`),
CONSTRAINT `FK_227F3E0A64D218E` FOREIGN KEY (`location_id`) REFERENCES `IContainer` (`id`),
CONSTRAINT `FK_227F3E0A727ACA70` FOREIGN KEY (`parent_id`) REFERENCES `IContainer` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK_227F3E0A7BE036FC` FOREIGN KEY (`shipment_id`) REFERENCES `Shipment` (`id`),
CONSTRAINT `FK_227F3E0AA76ED395` FOREIGN KEY (`user_id`) REFERENCES `User` (`id`),
CONSTRAINT `FK_227F3E0AF5B7AF75` FOREIGN KEY (`address_id`) REFERENCES `Address` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6280 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
```
- id - incremental value as database reference for location.
- location_id - location where the shipment is located. reference to location `id`.
- parent_id - parent location reference to location `id`. Parent Tree
- address_id - location address reference to table `Address`
- user_id - Stock location added to user's Cart reference table to `User`
- shipment_id - Stock is on shipment. Reference to table `Shipment`
- identifier - Location Identifier. This is what we show to the system as location name.
- deletedAt - if not NULL, this means the location is not active
- lft - Tree Left
- rgt - Tree Right
- root - Tree Root. This is currently used to distinguish between system generated location for shipments and physical stock locations.
- lvl - Tree Level. Values (0,1,2,3)
- createdAt - timestamp when the location is created
- updatedAt - timestamp when the location is updated
- discr - these are type of locations. Discriminator Map
| Value | Description | Location Type |
| ------ | ------ | ------ |
| location | currently use by the system for the auto generated customerorders. Which means stocks allocated to a customer order | Non Pickable |
| pick-location | pickable location inside the warehouse | Pickable |
| qc-location | stock is in quality control locations | Non Pickable |
| warehouse | stock location is in the warehouse | Non Pickable |
| stock | The container representing all stock the company has | Non Pickable |
| bs-location | location is back stock. | Non Pickable |
| shipment | stock location is for shipment | Non Pickable |
| user | stock location is user cart | Pickable |
| carton | stock is for shipment and location is in the package? | Non Pickable |
- cartonNumber - reference to shipment package.
- description - Description of the location
As Per @tim
> lft/right/root/lvl/parent_id are all related to the library used to model the tree-like structure. See their docs here:
>
> https://github.com/timdev/DoctrineExtensions/blob/fix/allow-decorated-entitymanagers/doc/tree.md
>
> The model used is called "nested set" and it's one way to model a hierarchy in an SQL database.
**Location Tree**
![location-tree](uploads/3405b7acdd470faa59d0a8e32d0266b5/location-tree.png)
**For the new implementation**
We can now add locations like the tree above. First level is 'Stocks' representing all stocks the company has. Right now, our system only supports 1 Warehouse at the moment so every locations that we add will be under Warehouse.
Add New Locations Rules:
1. Warehouse as a default parent location
2. If location type pickable then discrimator map is 'pick-location' otherwise it will be on type 'qc-location'. The 'qc-location' allocating correctly when move items on non pickable locations.
2. Added ability to add location description.
**SKU Widget Enhancement/Fixes**
There are several discrepancies on the total stocks and allocations scenario. To address the issues we implemented the following:
1. We should list down all locations even stocks on retail shipments and retail direct orders or B2B Direct orders shipments.
2. Allocations should list down consolidated retail shipments, direct orders and non-pickable stocks allocation.
**Moving of stocks**
- By default we prevented moving of stocks in locations 'Stocks' and 'Warehouse'.
Additional features also added to edit location name and description except locations 'Stocks', 'Warehouse' and 'Picking Area'. Picking area is systems default pickable location it is hardcoded anywhere in the code. As per Rob, we should get rid of this location moving forward.