Fixed sale suspending / unsuspending (adapt db scripts)

Cleanup old code
More code review
Update item_quantities database model (composite pk)

git-svn-id: svn+ssh://svn.code.sf.net/p/opensourcepos/code/@120 c3eb156b-1dc0-44e1-88ae-e38439141b53
This commit is contained in:
jekkos
2014-08-19 19:55:46 +00:00
parent 249274e5f5
commit 4ca452ef12
16 changed files with 197 additions and 191 deletions

View File

@@ -146,7 +146,6 @@ CREATE TABLE `ospos_items` (
`allow_alt_description` tinyint(1) NOT NULL,
`is_serialized` tinyint(1) NOT NULL,
`deleted` int(1) NOT NULL DEFAULT '0',
`stock_type` enum('sale_stock','warehouse') NOT NULL DEFAULT 'warehouse',
`custom1` VARCHAR(25) NOT NULL,
`custom2` VARCHAR(25) NOT NULL,
`custom3` VARCHAR(25) NOT NULL,
@@ -231,11 +230,10 @@ CREATE TABLE `ospos_item_kit_items` (
--
CREATE TABLE IF NOT EXISTS `ospos_item_quantities` (
`item_quantity_id` int(11) NOT NULL AUTO_INCREMENT,
`item_id` int(11) NOT NULL,
`location_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
PRIMARY KEY (`item_quantity_id`),
PRIMARY KEY (`item_id`,`location_id`),
KEY `item_id` (`item_id`),
KEY `location_id` (`location_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
@@ -369,6 +367,7 @@ CREATE TABLE `ospos_receivings_items` (
`quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0',
`item_cost_price` decimal(15,2) NOT NULL,
`item_unit_price` decimal(15,2) NOT NULL,
`item_location` int(11) NOT NULL,
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
PRIMARY KEY (`receiving_id`,`item_id`,`line`),
KEY `item_id` (`item_id`)
@@ -449,9 +448,12 @@ CREATE TABLE `ospos_sales_items` (
`quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00',
`item_cost_price` decimal(15,2) NOT NULL,
`item_unit_price` decimal(15,2) NOT NULL,
`item_location` int(11) NOT NULL,
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
PRIMARY KEY (`sale_id`,`item_id`,`line`),
KEY `item_id` (`item_id`)
KEY `sale_id` (`sale_id`),
KEY `item_id` (`item_id`),
KEY `item_location` (`item_location`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@@ -475,6 +477,7 @@ CREATE TABLE `ospos_sales_items_taxes` (
`name` varchar(255) NOT NULL,
`percent` decimal(15,2) NOT NULL,
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
KEY `sale_id` (`sale_id`),
KEY `item_id` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -493,7 +496,8 @@ CREATE TABLE `ospos_sales_payments` (
`sale_id` int(10) NOT NULL,
`payment_type` varchar(40) NOT NULL,
`payment_amount` decimal(15,2) NOT NULL,
PRIMARY KEY (`sale_id`,`payment_type`)
PRIMARY KEY (`sale_id`,`payment_type`),
KEY `sale_id` (`sale_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@@ -539,8 +543,10 @@ CREATE TABLE `ospos_sales_suspended_items` (
`quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00',
`item_cost_price` decimal(15,2) NOT NULL,
`item_unit_price` decimal(15,2) NOT NULL,
`item_location` int(11) NOT NULL,
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
PRIMARY KEY (`sale_id`,`item_id`,`line`),
KEY `sale_id` (`sale_id`),
KEY `item_id` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -731,7 +737,8 @@ ALTER TABLE `ospos_sales`
--
ALTER TABLE `ospos_sales_items`
ADD CONSTRAINT `ospos_sales_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`);
ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`),
ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
--
-- Constraints for table `ospos_sales_items_taxes`
@@ -758,7 +765,8 @@ ALTER TABLE `ospos_sales_suspended`
--
ALTER TABLE `ospos_sales_suspended_items`
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`);
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`),
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
--
-- Constraints for table `ospos_sales_suspended_items_taxes`