mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-03-16 06:01:27 -04:00
Merge pull request #1397 from RuleDomain/tax-category-cleanup
Improve tax category maintenance.
This commit is contained in:
@@ -637,6 +637,7 @@ class Config extends Secure_Controller
|
||||
);
|
||||
|
||||
$success = $this->Appconfig->batch_save($batch_save_data) ? TRUE : FALSE;
|
||||
$delete_rejected = FALSE;
|
||||
|
||||
if($customer_sales_tax_support)
|
||||
{
|
||||
@@ -674,7 +675,16 @@ class Config extends Secure_Controller
|
||||
{
|
||||
if(!in_array($category['tax_category_id'], $not_to_delete))
|
||||
{
|
||||
$this->Tax->delete_tax_category($category['tax_category_id']);
|
||||
$usg1 = $this->Tax->get_tax_category_usage($category['tax_category_id']);
|
||||
$usg2 = $this->Item->get_tax_category_usage($category['tax_category_id']);
|
||||
if(($usg1 + $usg2) == 0)
|
||||
{
|
||||
$this->Tax->delete_tax_category($category['tax_category_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$delete_rejected = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -683,9 +693,20 @@ class Config extends Secure_Controller
|
||||
|
||||
$success &= $this->db->trans_status();
|
||||
|
||||
$message = "";
|
||||
if($success && $delete_rejected)
|
||||
{
|
||||
$message = $this->lang->line('config_tax_category_used');
|
||||
$success = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully');
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'success' => $success,
|
||||
'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
|
||||
'message' => $message
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ $lang["config_table_configuration"] = "Table Configuration";
|
||||
$lang["config_takings_printer"] = "Takings Printer";
|
||||
$lang["config_tax"] = "Tax";
|
||||
$lang["config_tax_category"] = "Tax Category";
|
||||
$lang["config_tax_category_used"] = "Tax category cannot be deleted because it is being used.";
|
||||
$lang["config_tax_configuration"] = "Tax Configuration";
|
||||
$lang["config_tax_decimals"] = "Tax Decimals";
|
||||
$lang["config_tax_included"] = "Tax Included";
|
||||
|
||||
@@ -52,6 +52,14 @@ class Item extends CI_Model
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function get_tax_category_usage($tax_category_id)
|
||||
{
|
||||
$this->db->from('items');
|
||||
$this->db->where('tax_category_id', $tax_category_id);
|
||||
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
/*
|
||||
Get number of rows
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,14 @@ class Tax extends CI_Model
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function get_tax_category_usage($tax_category_id)
|
||||
{
|
||||
$this->db->from('tax_code_rates');
|
||||
$this->db->where('rate_tax_category_id', $tax_category_id);
|
||||
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
/**
|
||||
Gets information about a particular tax_code
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,13 @@ foreach($tax_categories as $tax_category => $category)
|
||||
</div>
|
||||
<span class="add_tax_category glyphicon glyphicon-plus" style="padding-top: 0.5em;"></span>
|
||||
<span> </span>
|
||||
<span class="remove_tax_category glyphicon glyphicon-minus" style="padding-top: 0.5em;"></span>
|
||||
<?php
|
||||
if($tax_category_id > 0) {
|
||||
?>
|
||||
<span class="remove_tax_category glyphicon glyphicon-minus" style="padding-top: 0.5em;"></span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user