mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-04 15:37:55 -05:00
Fixes a couple of problems with sales tax migration plus a couple of other problems.
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
24
application/migrations/20190213210000_indiagst1.php
Normal file
24
application/migrations/20190213210000_indiagst1.php
Normal 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()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
20
application/migrations/20190220210000_indiagst2.php
Normal file
20
application/migrations/20190220210000_indiagst2.php
Normal 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()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -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;
|
||||
@@ -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`;
|
||||
|
||||
6
application/migrations/sqlscripts/3.3.0_indiagst1.sql
Normal file
6
application/migrations/sqlscripts/3.3.0_indiagst1.sql
Normal 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 '';
|
||||
5
application/migrations/sqlscripts/3.3.0_indiagst2.sql
Normal file
5
application/migrations/sqlscripts/3.3.0_indiagst2.sql
Normal 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`;
|
||||
@@ -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,
|
||||
|
||||
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user