The Inventory Allocation functionality in my Inventory Management system is designed to distribute units from inventory to a number of partners. There's way to many business rules associated with this piece to describe here, but I wanted to at least give a high-level picture.
<?php
-- Table structure for table ia
CREATE TABLE ia (
ia_id int(10) unsigned NOT NULL auto_increment,
date date NOT NULL default '0000-00-00',
closed tinyint(1) NOT NULL default '0',
locked tinyint(1) NOT NULL default '0',
total_weight int(10) default '0',
total_served int(10) default '0',
PRIMARY KEY (ia_id),
KEY IDX_ia_date (date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table ia_unit
CREATE TABLE ia_unit (
ia_unit_id int(10) unsigned NOT NULL auto_increment,
ia_id int(10) unsigned NOT NULL default '0',
category_id int(10) unsigned NOT NULL default '0',