Topic: stock_id and item_code relationships
Updated the Wiki with the stock_id and item_code table relationships.
Item Coding:
Any combination of numbers and letter is fine as long as it is in the Item Short Label field (item_code / stock_id)
The table item_codes is used to store normal items (stock_id = item_code)
It is also used to store foreign items (stock_id need not be the same as item_code), a flag for is_foreign is set
In any case, the id field should be unique and will be an auto generated unsigned integer value
The combination of stock_id and item_code should be unique
item_code and stock_id are VARCHAR(20)
Vendor and PO searches are by item_code and warehouse lookups use stock_id
Hence "stock_id" is "our" inventory code and "item_code" is for "vendor/account" based reference.
All bought out items come into foreign items type with their own UPC/EAN/ISBN type numbering
All items must first be entered as Normal Items and then assign them as foreign items if needed.
Foreign Item's data cannot be entered if it does not exist as a normal item in the table.
Apart from the item_codes table, the item_code field is used in Goods Receipt Notes (grn_items) and in the purch_order_details tables.
Hence item_code is limited to the accounting side. Definitely your vendors are not going to understand your own item references (stock_id). Hence you need to use their reference numbers (item_code) when interacting with them. Although your stock_id referencing may be similar to those from your vendors, yours may/can have some prefixed characters to denote the vendor you are referring to, to alleviate the condition when the same part number straddles across vendors possibly denoting even eniterly different items.
Please note that there is no reference to any stock_id where item_code is used except in the item_codes lookup table.