mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-08 08:57:50 -04:00
Add missing language element for rounding code "Unknown" and eliminate duplicate statements in upgrade statement, and fix issue with 0 tax_category_id
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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')
|
||||
);
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 .= "<option value='$option'>".$label."</option>";
|
||||
@@ -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);
|
||||
|
||||
@@ -150,63 +150,67 @@
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
//validation and submit handling
|
||||
$(document).ready(function() {
|
||||
//validation and submit handling
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#add_tax_category").autocomplete({
|
||||
source: '<?php echo site_url("taxes/suggest_tax_categories"); ?>',
|
||||
minChars: 0,
|
||||
autoFocus: false,
|
||||
delay: 10,
|
||||
appendTo: ".modal-content",
|
||||
select: function (e, ui) {
|
||||
if ($("#tax_category_id" + ui.item.value).length == 1) {
|
||||
$("#tax_category_id" + ui.item.value).val(parseFloat($("#tax_category_id" + ui.item.value).val()) + 1);
|
||||
$('#tax_code_form').validate($.extend({
|
||||
submitHandler: function (form) {
|
||||
$(form).ajaxSubmit({
|
||||
success: function (response) {
|
||||
dialog_support.hide();
|
||||
table_support.handle_submit('<?php echo site_url('taxes'); ?>', response);
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
},
|
||||
rules: {
|
||||
tax_code: "required",
|
||||
tax_rate: "required"
|
||||
},
|
||||
messages: {
|
||||
tax_code: "<?php echo $this->lang->line('taxes_tax_code_required'); ?>",
|
||||
tax_rate: "<?php echo $this->lang->line('taxes_tax_rate_required'); ?>"
|
||||
}
|
||||
else {
|
||||
$("#tax_code_rates").append("<tr>" +
|
||||
"<td><a href='#' onclick='return delete_tax_code_rate_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>" +
|
||||
"<td>" + ui.item.label + "</td>" +
|
||||
"<td><input class='form-control input-sm' id='exception_tax_rate_" + ui.item.value + "' name=exception_tax_rate[" + ui.item.value + "] value=''/></td>" +
|
||||
"<td><select id='exception_rounding_code_" + ui.item.value + "' class='form-control input-sm' name=exception_rounding_code[" + ui.item.value +
|
||||
"] aria-invalid='false'><?php echo Taxes::get_html_rounding_options(); ?></select></td>" +
|
||||
"</tr>");
|
||||
}, form_support.error));
|
||||
|
||||
|
||||
$("#add_tax_category").autocomplete({
|
||||
source: '<?php echo site_url("taxes/suggest_tax_categories"); ?>',
|
||||
minChars: 0,
|
||||
autoFocus: false,
|
||||
delay: 10,
|
||||
appendTo: ".modal-content",
|
||||
select: function (e, ui) {
|
||||
|
||||
var rounding_options = "<?php echo $html_rounding_options; ?>";
|
||||
|
||||
if ($("#tax_category_id" + ui.item.value).length == 1) {
|
||||
$("#tax_category_id" + ui.item.value).val(parseFloat($("#tax_category_id" + ui.item.value).val()) + 1);
|
||||
} else {
|
||||
$("#tax_code_rates").append("<tr>" +
|
||||
"<td><a href='#' onclick='return delete_tax_code_rate_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>" +
|
||||
"<td>" + ui.item.label + "</td>" +
|
||||
"<td><input class='form-control input-sm' id='exception_tax_rate_" + ui.item.value + "' name=exception_tax_rate[" + ui.item.value + "] value=''/></td>" +
|
||||
"<td><select id='exception_rounding_code_" + ui.item.value + "' class='form-control input-sm' name=exception_rounding_code[" + ui.item.value +
|
||||
"] aria-invalid='false'>" + rounding_options + "</select></td>" +
|
||||
"</tr>");
|
||||
}
|
||||
$("#add_tax_category").val("");
|
||||
return false;
|
||||
}
|
||||
$("#add_tax_category").val("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#tax_code_form').validate($.extend({
|
||||
submitHandler: function (form) {
|
||||
$(form).ajaxSubmit({
|
||||
success: function (response) {
|
||||
dialog_support.hide();
|
||||
table_support.handle_submit('<?php echo site_url('taxes'); ?>', response);
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
},
|
||||
rules: {
|
||||
tax_code: "required",
|
||||
tax_rate: "required"
|
||||
},
|
||||
messages: {
|
||||
tax_code: "<?php echo $this->lang->line('taxes_tax_code_required'); ?>",
|
||||
tax_rate: "<?php echo $this->lang->line('taxes_tax_rate_required'); ?>"
|
||||
}
|
||||
}, form_support.error));
|
||||
|
||||
});
|
||||
|
||||
function delete_tax_code_rate_row(link) {
|
||||
$(link).parent().parent().remove();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user