From 3838147bb96c37c55ede87dedb7800308660f95e Mon Sep 17 00:00:00 2001 From: jekkos Date: Fri, 4 Jul 2014 21:01:47 +0000 Subject: [PATCH] All database types used in amount calculations changes to decimal(15,2) Removed round() statements in sale temp table, precision is defined by datatypes Removed round() statement in receiving temp table, precision is defined by datatypes git-svn-id: svn+ssh://svn.code.sf.net/p/opensourcepos/code/@105 c3eb156b-1dc0-44e1-88ae-e38439141b53 --- application/models/receiving.php | 2 +- application/models/sale.php | 4 ++-- database/.database.sql.swp | Bin 0 -> 16384 bytes database/database.sql | 36 +++++++++++++++---------------- 4 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 database/.database.sql.swp 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 0000000000000000000000000000000000000000..c1feb4c716a36f1e1a5d9c012d307f054676dab4 GIT binary patch literal 16384 zcmeI2TWlj&8OKixY`3&atL};w@N&4xwv;$_5^rwW1vi<^8WJb9oh=L6wa4S*WEy*B zIy26Nh2A7Uf+7kpAeD!uQiVVi#7m*A009CX3TP{+gb*)0&~g#&R;mPu7WkjJk27}c zgjNF0C_lxX^PSuOeDj@)r=B@qSf*3y34-fZLf(7*cgiVzcvc|fF1ER;8a$!@)nbae zrH-1p@l0RCd+Y+owpD%8&_s!isTxxZwWCW+Q;o5PXo_{wVBUwcad)e4iE(1AK&-&v z3LGO7<5}w=efPWGNsr&QHh9+9GFBi~AXXq&AXXq&AXXq&AXXq&;D25LQ#(TLMK7** zdh%)K|8-se|Lt6to%^5ZO8=LWexGyyh*N-D&Z|!P15WxUyV75A(%s{RqfUd|{Qq>) z&p7!nccnYG!FIu>!FIu>!FIu>!FIu>!FIu>!FIu>u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?b@8mU26k^IRBPpP~CJgPZO2)m#=KUr~zTlPwh^1eX(hH$??uEYDE6JMP7)MqiP zs7@F`*jYWdO3x#%V81g&Q0=^MW!%#3e0H*PCQHVnocv* zBXm5I%~H{%naSDlDZ0AMjnAouIZIorB(^s2k#_}mH%wET9UI%;-cD;9T6@=W&$PmL zx?3ehL(((+227TB^L)ys9PKKVJn`z+1tWu~&W=dwlMFO=Qf8dEjCJ_{}F=SY63B9y}CNM1eG>JveEUR5x? zi&zR6d(U;k)|gd$G#(2GqiS>vtS%a?QPsp zukOM6*Dv$H-L;Ng_`(YC)Oe zWAqgtiFBbZ(E^P)km%j{hwOc{;zRVi%g2V(KKg0pT^fA62Uq#v`dT>$SJpXk4STV> zlj_woH{Ci12?VSm{5dlAxm)yJ^}6ZZ^$w!zK@=TC%fp7iE~ku&*EN43Wt!eJJ&!e9xzaada~c6WH;ac?&cpyEqUOn&(ta#~tv&?(@muDBM Veb3{`$GTU=wjW?c=NXNV{{Ri1gb4ru literal 0 HcmV?d00001 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;