I am trying to make an inventory system for a company, when user will enter item to an inventory there is no problem as the table is shown below, however how do i know how many item left when some of the item is sold ? for example I purchased 100 bags and Mr Y purchased 20 bags, how will system show 80 bags left ? Any help would be appreceated. Thanks
CREATE TABLE `inventory` (
`inv_id` int(11) NOT NULL AUTO_INCREMENT,
`inv_reference_no` varchar(40) NOT NULL,
`inv_part_no` varchar(100) NOT NULL,
`inv_category_id` int(11) NOT NULL,
`inv_product_name` varchar(200) NOT NULL,
`inv_quantity` int(11) NOT NULL,
`inv_description` varchar(500) NOT NULL,
`inv_cost_price` float(12,2) NOT NULL,
`inv_cost_sub_total` float(14,2) NOT NULL,
`inv_product_type` enum('cons','serv','stock') NOT NULL,
`inv_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`inv_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8
You can add field say “in_stock” in you table which will store the quantity of products left.
Or you can decrement your quantity field everytime any item is purchased.
Hope it helps