diff --git a/application/models/receiving.php b/application/models/receiving.php index 48ae9dca1..da28232d1 100644 --- a/application/models/receiving.php +++ b/application/models/receiving.php @@ -105,7 +105,7 @@ class Receiving extends CI_Model ".$this->db->dbprefix('items').".item_id, ".$this->db->dbprefix('receivings').".supplier_id, quantity_purchased, item_cost_price, item_unit_price, discount_percent, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) as subtotal, ".$this->db->dbprefix('receivings_items').".line as line, serialnumber, ".$this->db->dbprefix('receivings_items').".description as description, - ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100),2) as total, + (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) as total, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) - (item_cost_price*quantity_purchased) as profit FROM ".$this->db->dbprefix('receivings_items')." INNER JOIN ".$this->db->dbprefix('receivings')." ON ".$this->db->dbprefix('receivings_items').'.receiving_id='.$this->db->dbprefix('receivings').'.receiving_id'." diff --git a/application/models/sale.php b/application/models/sale.php index fb9a72a8d..f649afe6e 100644 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -211,8 +211,8 @@ class Sale extends CI_Model ".$this->db->dbprefix('items').".item_id, supplier_id, quantity_purchased, item_cost_price, item_unit_price, SUM(percent) as item_tax_percent, discount_percent, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) as subtotal, ".$this->db->dbprefix('sales_items').".line as line, serialnumber, ".$this->db->dbprefix('sales_items').".description as description, - ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*(1+(SUM(percent)/100)),2) as total, - ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*(SUM(percent)/100),2) as tax, + (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*(1+(SUM(percent)/100)) as total, + (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*(SUM(percent)/100) as tax, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) - (item_cost_price*quantity_purchased) as profit FROM ".$this->db->dbprefix('sales_items')." INNER JOIN ".$this->db->dbprefix('sales')." ON ".$this->db->dbprefix('sales_items').'.sale_id='.$this->db->dbprefix('sales').'.sale_id'." diff --git a/database/.database.sql.swp b/database/.database.sql.swp new file mode 100644 index 000000000..c1feb4c71 Binary files /dev/null and b/database/.database.sql.swp differ diff --git a/database/database.sql b/database/database.sql index 9fd71e79b..eaad159a7 100644 --- a/database/database.sql +++ b/database/database.sql @@ -89,7 +89,7 @@ INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`) V CREATE TABLE `ospos_giftcards` ( `giftcard_id` int(11) NOT NULL AUTO_INCREMENT, `giftcard_number` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `value` double(15,2) NOT NULL, + `value` decimal(15,2) NOT NULL, `deleted` int(1) NOT NULL DEFAULT '0', `person_id` INT NOT NULL, PRIMARY KEY (`giftcard_id`), @@ -136,10 +136,10 @@ CREATE TABLE `ospos_items` ( `supplier_id` int(11) DEFAULT NULL, `item_number` varchar(255) DEFAULT NULL, `description` varchar(255) NOT NULL, - `cost_price` double(15,2) NOT NULL, - `unit_price` double(15,2) NOT NULL, - `quantity` double(15,2) NOT NULL DEFAULT '0.00', - `reorder_level` double(15,2) NOT NULL DEFAULT '0.00', + `cost_price` decimal(15,2) NOT NULL, + `unit_price` decimal(15,2) NOT NULL, + `quantity` decimal(15,2) NOT NULL DEFAULT '0.00', + `reorder_level` decimal(15,2) NOT NULL DEFAULT '0.00', `location` varchar(255) NOT NULL, `item_id` int(10) NOT NULL AUTO_INCREMENT, `allow_alt_description` tinyint(1) NOT NULL, @@ -174,7 +174,7 @@ CREATE TABLE `ospos_items` ( CREATE TABLE `ospos_items_taxes` ( `item_id` int(10) NOT NULL, `name` varchar(255) NOT NULL, - `percent` double(15,3) NOT NULL, + `percent` decimal(15,2) NOT NULL, PRIMARY KEY (`item_id`,`name`,`percent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -210,7 +210,7 @@ CREATE TABLE `ospos_item_kits` ( CREATE TABLE `ospos_item_kit_items` ( `item_kit_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, - `quantity` double(15,2) NOT NULL, + `quantity` decimal(15,2) NOT NULL, PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`), KEY `ospos_item_kit_items_ibfk_2` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -345,10 +345,10 @@ CREATE TABLE `ospos_receivings_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL, - `quantity_purchased` int(10) NOT NULL DEFAULT '0', + `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, - `item_unit_price` double(15,2) NOT NULL, - `discount_percent` int(11) NOT NULL DEFAULT '0', + `item_unit_price` decimal(15,2) NOT NULL, + `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', PRIMARY KEY (`receiving_id`,`item_id`,`line`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -393,10 +393,10 @@ CREATE TABLE `ospos_sales_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` double(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', `item_cost_price` decimal(15,2) NOT NULL, - `item_unit_price` double(15,2) NOT NULL, - `discount_percent` int(11) NOT NULL DEFAULT '0', + `item_unit_price` decimal(15,2) NOT NULL, + `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', PRIMARY KEY (`sale_id`,`item_id`,`line`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -417,7 +417,7 @@ CREATE TABLE `ospos_sales_items_taxes` ( `item_id` int(10) NOT NULL, `line` int(3) NOT NULL DEFAULT '0', `name` varchar(255) NOT NULL, - `percent` double(15,3) NOT NULL, + `percent` decimal(15,2) NOT NULL, PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -480,10 +480,10 @@ CREATE TABLE `ospos_sales_suspended_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` double(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', `item_cost_price` decimal(15,2) NOT NULL, - `item_unit_price` double(15,2) NOT NULL, - `discount_percent` int(11) NOT NULL DEFAULT '0', + `item_unit_price` decimal(15,2) NOT NULL, + `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', PRIMARY KEY (`sale_id`,`item_id`,`line`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -504,7 +504,7 @@ CREATE TABLE `ospos_sales_suspended_items_taxes` ( `item_id` int(10) NOT NULL, `line` int(3) NOT NULL DEFAULT '0', `name` varchar(255) NOT NULL, - `percent` double(15,3) NOT NULL, + `percent` decimal(15,2) NOT NULL, PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;