Fixes a couple of problems with sales tax migration plus a couple of other problems.

This commit is contained in:
Steve Ireland
2019-02-04 21:35:41 -05:00
parent 069715fe4a
commit 2f710e80e7
10 changed files with 75 additions and 18 deletions

View File

@@ -117,7 +117,7 @@ class Suppliers extends Persons
'agency_name' => $this->input->post('agency_name'),
'category' => $this->input->post('category'),
'account_number' => $this->input->post('account_number') == '' ? NULL : $this->input->post('account_number'),
'tax_id' => $this->input->post('tax_id') == '' ? NULL : $this->input->post('tax_id')
'tax_id' => $this->input->post('tax_id')
);
if($this->Supplier->save_supplier($person_data, $supplier_data, $supplier_id))

View File

@@ -36,17 +36,19 @@ class Migration_IndiaGST extends CI_Migration
}
$count_of_sales_taxes_entries = $this->get_count_of_sales_taxes_entries();
if($count_of_sales_taxes_entries > 0)
{
$this->migrate_sales_taxes_data();
}
$this->drop_backups();
error_log('Migrating tax configuration completed');
}
public function down()
{
$this->drop_backups();
}
private function get_count_of_tax_code_entries()
@@ -60,7 +62,7 @@ class Migration_IndiaGST extends CI_Migration
private function get_count_of_sales_taxes_entries()
{
$this->db->select('COUNT(*) as count');
$this->db->from('sales_taxes');
$this->db->from('sales_taxes_backup');
return $this->db->get()->row()->count;
}
@@ -143,9 +145,9 @@ class Migration_IndiaGST extends CI_Migration
private function drop_backups()
{
$this->db->query('DROP TABLE IF EXISTS' . $this->db->dbprefix('tax_codes_backup'));
$this->db->query('DROP TABLE IF EXISTS' . $this->db->dbprefix('sales_taxes_backup'));
$this->db->query('DROP TABLE IF EXISTS' . $this->db->dbprefix('tax_code_rates_backup'));
$this->db->query('DROP TABLE IF EXISTS ' . $this->db->dbprefix('tax_codes_backup'));
$this->db->query('DROP TABLE IF EXISTS ' . $this->db->dbprefix('sales_taxes_backup'));
$this->db->query('DROP TABLE IF EXISTS ' . $this->db->dbprefix('tax_code_rates_backup'));
}
}
?>

View File

@@ -0,0 +1,24 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Migration_IndiaGST1 extends CI_Migration
{
public function __construct()
{
parent::__construct();
}
public function up()
{
execute_script(APPPATH . 'migrations/sqlscripts/3.3.0_indiagst1.sql');
error_log('Fix definition of Supplier.Tax Id');
error_log('Definition of Supplier.Tax Id corrected');
}
public function down()
{
}
}
?>

View File

@@ -0,0 +1,20 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Migration_IndiaGST2 extends CI_Migration
{
public function __construct()
{
parent::__construct();
}
public function up()
{
execute_script(APPPATH . 'migrations/sqlscripts/3.3.0_indiagst2.sql');
}
public function down()
{
}
}
?>

View File

@@ -148,6 +148,3 @@ ALTER TABLE `ospos_expenses`
INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('default_receivings_discount_type', '0'),
('default_receivings_discount', '0');
ALTER TABLE `ospos_suppliers`
CHANGE COLUMN `tax_id` `tax_id` VARCHAR(32) NULL;

View File

@@ -74,7 +74,7 @@ CREATE TABLE IF NOT EXISTS `ospos_tax_jurisdictions` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
ALTER TABLE `ospos_suppliers`
ADD COLUMN `tax_id` varchar(32) NOT NULL DEFAULT '' AFTER `account_number`;
ADD COLUMN `tax_id` varchar(32) DEFAULT NULL AFTER `account_number`;
ALTER TABLE `ospos_tax_categories`
ADD COLUMN `deleted` int(1) NOT NULL DEFAULT 0 AFTER `tax_group_sequence`;

View File

@@ -0,0 +1,6 @@
UPDATE `ospos_suppliers`
SET `tax_id` = ''
WHERE `tax_id`IS NULL;
ALTER TABLE `ospos_suppliers`
CHANGE COLUMN `tax_id` `tax_id` varchar(32) NOT NULL DEFAULT '';

View File

@@ -0,0 +1,5 @@
-- This is to cleanup any orphaned tax migration tables
DROP TABLE IF EXISTS `ospos_tax_codes_backup`;
DROP TABLE IF EXISTS `ospos_sales_taxes_backup`;
DROP TABLE IF EXISTS `ospos_tax_code_rates_backup`;

View File

@@ -16,6 +16,8 @@ class Summary_sales_taxes extends Summary_report
protected function _where(array $inputs)
{
$this->db->where('sales.sale_status = ' . COMPLETED);
if(empty($this->config->item('date_or_time_format')))
{
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
@@ -28,17 +30,16 @@ class Summary_sales_taxes extends Summary_report
public function getData(array $inputs)
{
$where = '';
$where = 'WHERE sale_status = ' . COMPLETED . ' ';
if(empty($this->config->item('date_or_time_format')))
{
$where .= 'WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
$where .= 'AND DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date'])
. ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where .= 'WHERE sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
$where .= 'AND sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
}
$query = $this->db->query("SELECT reporting_authority, jurisdiction_name, tax_category, tax_rate,

View File

@@ -16,6 +16,8 @@ class Summary_taxes extends Summary_report
protected function _where(array $inputs)
{
$this->db->where('sales.sale_status = ' . COMPLETED);
if(empty($this->config->item('date_or_time_format')))
{
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
@@ -28,15 +30,15 @@ class Summary_taxes extends Summary_report
public function getData(array $inputs)
{
$where = '';
$where = 'WHERE sale_status = ' . COMPLETED . ' ';
if(empty($this->config->item('date_or_time_format')))
{
$where .= 'WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
$where .= 'AND DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where .= 'WHERE sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
$where .= 'AND sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
}
if($this->config->item('tax_included'))