Allow empty tax category id (#4285) (#4288)

This commit is contained in:
jekkos
2025-07-29 23:59:23 +02:00
committed by GitHub
parent 9cd2f685ff
commit e08367aaae
4 changed files with 34 additions and 3 deletions

View File

@@ -635,10 +635,10 @@ class Items extends Secure_Controller
$item_data['reorder_level'] = 0;
}
$tax_category_id = intval($this->request->getPost('tax_category_id'));
$tax_category_id = $this->request->getPost('tax_category_id');
if (!isset($tax_category_id)) {
$item_data['tax_category_id'] = '';
$item_data['tax_category_id'] = null;
} else {
$item_data['tax_category_id'] = empty($this->request->getPost('tax_category_id')) ? null : intval($this->request->getPost('tax_category_id'));
}

View File

@@ -4,7 +4,7 @@ namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class MissingConfigKeys extends Migration
class Migration_MissingConfigKeys extends Migration
{
/**
* Perform a migration step.

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class Migration_NullableTaxCategoryId extends Migration
{
/**
* Perform a migration step.
*/
public function up(): void
{
error_log('Migrating config table');
helper('migration');
execute_script(APPPATH . 'Database/Migrations/sqlscripts/3.4.2_missing_config_keys.sql');
error_log('Migrating config table');
}
/**
* Revert a migration step.
*/
public function down(): void
{
}
}

View File

@@ -0,0 +1,3 @@
-- Migration to make tax_category_id nullable in ospos_items
ALTER TABLE ospos_items
MODIFY COLUMN tax_category_id INT NULL;