diff --git a/application/controllers/Items.php b/application/controllers/Items.php
index da0ce601d..373aad6b5 100644
--- a/application/controllers/Items.php
+++ b/application/controllers/Items.php
@@ -197,7 +197,7 @@ class Items extends Secure_Controller
$item_info->reorder_level = 1;
$item_info->item_type = '0'; // standard
$item_info->stock_type = '0'; // stock
- $item_info->tax_category_id = 0;
+ $item_info->tax_category_id = 1; // Standard
}
$data['item_info'] = $item_info;
diff --git a/application/controllers/Taxes.php b/application/controllers/Taxes.php
index e8e429b6b..022b2c854 100644
--- a/application/controllers/Taxes.php
+++ b/application/controllers/Taxes.php
@@ -77,12 +77,13 @@ class Taxes extends Secure_Controller
{
$tax_code_info = $this->Tax->get_info($tax_code);
- $default_tax_category_id = 0; // Tax category id is always the default tax category
+ $default_tax_category_id = 1; // Tax category id is always the default tax category
$default_tax_category = $this->Tax->get_tax_category($default_tax_category_id);
$tax_rate_info = $this->Tax->get_rate_info($tax_code, $default_tax_category_id);
$data['rounding_options'] = Rounding_mode::get_rounding_options();
+ $data['html_rounding_options'] = $this->get_html_rounding_options();
if ($tax_code == -1)
{
@@ -93,7 +94,7 @@ class Taxes extends Secure_Controller
$data['state'] = '';
$data['tax_rate'] = '0.0000';
$data['rate_tax_code'] = '';
- $data['rate_tax_category_id'] = '0';
+ $data['rate_tax_category_id'] = 1;
$data['tax_category'] = '';
$data['add_tax_category'] = '';
$data['rounding_code'] = '0';
@@ -149,7 +150,7 @@ class Taxes extends Secure_Controller
$tax_rate_data = array(
'rate_tax_code' => $this->input->post('tax_code'),
- 'rate_tax_category_id' => 0,
+ 'rate_tax_category_id' => 1,
'tax_rate' => parse_decimals($this->input->post('tax_rate')),
'rounding_code' => $this->input->post('rounding_code')
);
diff --git a/application/language/en/common_lang.php b/application/language/en/common_lang.php
index 17bd58e9a..0031c51c7 100644
--- a/application/language/en/common_lang.php
+++ b/application/language/en/common_lang.php
@@ -58,6 +58,7 @@ $lang["common_searched_for"] = "Searched for";
$lang["common_state"] = "State";
$lang["common_submit"] = "Submit";
$lang["common_total_spent"] = "Total Spent";
+$lang["common_unknown"] = "Unknown";
$lang["common_view_recent_sales"] = "View Recent Sales";
$lang["common_website"] = "website";
$lang["common_welcome"] = "Welcome";
diff --git a/application/libraries/Tax_lib.php b/application/libraries/Tax_lib.php
index 964d09721..8e52b2345 100644
--- a/application/libraries/Tax_lib.php
+++ b/application/libraries/Tax_lib.php
@@ -179,7 +179,7 @@ class Tax_lib
*/
public function apply_sales_tax(&$item, &$city, &$state, &$sales_tax_code, $register_mode, $sale_id, &$sales_taxes)
{
- $tax_code = $this->get_applicable_tax_mode($register_mode, $city, $state, $sales_tax_code);
+ $tax_code = $this->get_applicable_tax_code($register_mode, $city, $state, $sales_tax_code);
// If tax code cannot be determined or the price is zero then skip this item
if($tax_code != '' && $item['price'] != 0)
@@ -261,9 +261,9 @@ class Tax_lib
}
}
- public function get_applicable_tax_mode($register_mode, $city, $state, $sales_tax_code)
+ public function get_applicable_tax_code($register_mode, $city, $state, $sales_tax_code)
{
- if($register_mode == "SALE")
+ if($register_mode == "sale")
{
$tax_code = $this->CI->config->config['default_origin_tax_code']; // overrides customer assigned code
}
diff --git a/application/models/Tax.php b/application/models/Tax.php
index 0386d8f17..23d233760 100644
--- a/application/models/Tax.php
+++ b/application/models/Tax.php
@@ -59,7 +59,7 @@ class Tax extends CI_Model
{
$this->db->from('tax_codes');
$this->db->join('tax_code_rates',
- 'tax_code = rate_tax_code and rate_tax_category_id = 0', 'LEFT');
+ 'tax_code = rate_tax_code and rate_tax_category_id = 1', 'LEFT');
$this->db->join('tax_categories',
'rate_tax_category_id = tax_category_id');
$this->db->where('tax_code', $tax_code);
@@ -290,7 +290,7 @@ class Tax extends CI_Model
public function delete_tax_rate_exceptions($tax_code)
{
$this->db->where('rate_tax_code', $tax_code);
- $this->db->where('rate_tax_category_id !=', 0);
+ $this->db->where('rate_tax_category_id !=', 1);
return $this->db->delete('tax_code_rates');
}
@@ -302,7 +302,7 @@ class Tax extends CI_Model
{
$this->db->from('tax_codes');
$this->db->join('tax_code_rates',
- 'tax_code = rate_tax_code and rate_tax_category_id = 0', 'LEFT');
+ 'tax_code = rate_tax_code and rate_tax_category_id = 1', 'LEFT');
if (!empty($search))
{
$this->db->like('tax_code', $search);
@@ -376,7 +376,7 @@ class Tax extends CI_Model
$suggestions = array();
$this->db->from('tax_categories');
- $this->db->where('tax_category_id !=', 0);
+ $this->db->where('tax_category_id !=', 1);
if (!empty($search))
{
$this->db->like('tax_category', '%'.$search.'%');
@@ -430,7 +430,7 @@ class Tax extends CI_Model
$this->db->from('tax_code_rates');
$this->db->join('tax_categories', 'rate_tax_category_id = tax_category_id');
$this->db->where('rate_tax_code', $tax_code);
- $this->db->where('rate_tax_category_id !=', 0);
+ $this->db->where('rate_tax_category_id !=', 1);
$this->db->order_by('tax_category', 'asc');
return $this->db->get()->result_array();
diff --git a/application/models/enums/Rounding_mode.php b/application/models/enums/Rounding_mode.php
index 46f75cb01..603b24054 100644
--- a/application/models/enums/Rounding_mode.php
+++ b/application/models/enums/Rounding_mode.php
@@ -40,6 +40,7 @@ class Rounding_mode
{
$CI =& get_instance();
$CI->load->helper('language');
+ $x = '';
foreach (Rounding_mode::get_rounding_options() as $option => $label)
{
$x .= "";
@@ -49,7 +50,7 @@ class Rounding_mode
public static function round_number($rounding_mode, $amount, $decimals)
{
- if($rounding_mode != Rounding_mode::ROUND_UP)
+ if($rounding_mode == Rounding_mode::ROUND_UP)
{
$fig = (int) str_pad('1', $decimals, '0');
$rounded_total = (ceil($amount * $fig) / $fig);
diff --git a/application/views/taxes/form.php b/application/views/taxes/form.php
index 44e73495d..894e5dd73 100644
--- a/application/views/taxes/form.php
+++ b/application/views/taxes/form.php
@@ -150,63 +150,67 @@
+
\ No newline at end of file
+
diff --git a/database/3.0.2_to_3.1.0.sql b/database/3.0.2_to_3.1.0.sql
index 4f6d661b2..c6d564a79 100644
--- a/database/3.0.2_to_3.1.0.sql
+++ b/database/3.0.2_to_3.1.0.sql
@@ -169,11 +169,6 @@ CREATE TABLE IF NOT EXISTS `ospos_tax_categories` (
PRIMARY KEY (`tax_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-INSERT INTO `ospos_tax_categories` ( `tax_category_id`,`tax_category`, `tax_group_sequence` ) VALUES
- (0, 'Standard', 10),
- (1, 'Service', 12),
- (2, 'Alcohol', 11);
-
ALTER TABLE `ospos_items`
ADD COLUMN `tax_category_id` int(10) NOT NULL DEFAULT 0;
@@ -244,17 +239,33 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`) VALUES
UPDATE ospos_items SET receiving_quantity = 1 WHERE receiving_quantity = 0;
--- fix tax category maintenance
-
-ALTER TABLE `ospos_tax_categories`
- MODIFY COLUMN `tax_category_id` int(10) NOT NULL AUTO_INCREMENT;
-
-- long alternate description
ALTER TABLE `ospos_sales_items`
MODIFY COLUMN `description` varchar(255) DEFAULT NULL;
-- fix tax category maintenance
-
+
+DELETE FROM `ospos_tax_categories` where tax_category_id in (0, 1, 2, 3);
+
ALTER TABLE `ospos_tax_categories`
MODIFY COLUMN `tax_category_id` int(10) NOT NULL AUTO_INCREMENT;
+
+INSERT INTO `ospos_tax_categories` ( `tax_category_id`,`tax_category`, `tax_group_sequence` ) VALUES
+ (1, 'Standard', 10),
+ (2, 'Service', 12),
+ (3, 'Alcohol', 11);
+
+ALTER TABLE `ospos_items`
+ MODIFY COLUMN `tax_category_id` int(10) NOT NULL DEFAULT 1;
+
+UPDATE `ospos_items` SET `tax_category_id` = 1 WHERE `tax_category_id` = 0;
+
+-- If you have added any tax codes, the following will correct the rate_tax_category_id on the tax_code_rates table,
+-- but you might need to add more UPDATE statements depending on how may tax codes and/or tax categories you've added
+
+UPDATE `ospos_tax_code_rates` SET rate_tax_category_id = 4 WHERE rate_tax_category_id = 3;
+UPDATE `ospos_tax_code_rates` SET rate_tax_category_id = 3 WHERE rate_tax_category_id = 2;
+UPDATE `ospos_tax_code_rates` SET rate_tax_category_id = 2 WHERE rate_tax_category_id = 1;
+UPDATE `ospos_tax_code_rates` SET rate_tax_category_id = 1 WHERE rate_tax_category_id = 0;
+
diff --git a/database/database.sql b/database/database.sql
index 2f33a7ec6..1fa42fac6 100644
--- a/database/database.sql
+++ b/database/database.sql
@@ -217,7 +217,7 @@ CREATE TABLE `ospos_items` (
`is_serialized` tinyint(1) NOT NULL,
`stock_type` TINYINT(2) NOT NULL DEFAULT 0,
`item_type` TINYINT(2) NOT NULL DEFAULT 0,
- `tax_category_id` int(10) NOT NULL DEFAULT 0,
+ `tax_category_id` int(10) NOT NULL DEFAULT 1,
`deleted` int(1) NOT NULL DEFAULT '0',
`custom1` VARCHAR(25) NOT NULL,
`custom2` VARCHAR(25) NOT NULL,
@@ -821,9 +821,9 @@ CREATE TABLE IF NOT EXISTS `ospos_tax_categories` (
--
INSERT INTO `ospos_tax_categories` ( `tax_category_id`,`tax_category`, `tax_group_sequence` ) VALUES
- (0, 'Standard', 10),
- (1, 'Service', 12),
- (2, 'Alcohol', 11);
+ (1, 'Standard', 10),
+ (2, 'Service', 12),
+ (3, 'Alcohol', 11);
-- --------------------------------------------------------
diff --git a/database/tables.sql b/database/tables.sql
index 7c65e6255..84637e45b 100644
--- a/database/tables.sql
+++ b/database/tables.sql
@@ -821,9 +821,9 @@ CREATE TABLE IF NOT EXISTS `ospos_tax_categories` (
--
INSERT INTO `ospos_tax_categories` ( `tax_category_id`,`tax_category`, `tax_group_sequence` ) VALUES
- (0, 'Standard', 10),
- (1, 'Service', 12),
- (2, 'Alcohol', 11);
+ (1, 'Standard', 10),
+ (2, 'Service', 12),
+ (3, 'Alcohol', 11);
-- --------------------------------------------------------