ALTER TABLE `main_category` ADD `image` MEDIUMTEXT NOT NULL AFTER `order_sort`;

# 20210824 #
ALTER TABLE `item_zone` ADD `dine_in_status` CHAR(1) NOT NULL DEFAULT 'Y' COMMENT '[Y]es , [N]o' AFTER `with_service_charge`, ADD INDEX (`dine_in_status`);


# 20210824 #
ALTER TABLE `sell` ADD `bill_out_at` DATETIME NULL DEFAULT NULL AFTER `created_at`;
ALTER TABLE `sell_history` ADD `bill_out_at` DATETIME NULL DEFAULT NULL AFTER `created_at`;


# 20210907 #
ALTER TABLE `sell` ADD `table_type` CHAR(1) NOT NULL DEFAULT 'D' COMMENT '[D]INE-IN, [T]AKEAWAY' AFTER `bill_out_at`;


# 20210913 #
ALTER TABLE `sell` CHANGE `iva` `iva` DECIMAL(9,2) UNSIGNED NULL DEFAULT NULL COMMENT 'TAX';
ALTER TABLE `sell_history` CHANGE `iva` `iva` DECIMAL(9,2) UNSIGNED NULL DEFAULT NULL COMMENT 'TAX';

ALTER TABLE `item_zone` ADD `max_time` INT(11) NULL DEFAULT NULL COMMENT 'Maximum table time (In minutes)' AFTER `dine_in_status`;


# 20210921 #
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'serial_key', 'SERIAL KEY', '2', '', '1', 'store_details');

ALTER TABLE `configuration` CHANGE `val` `val` VARCHAR(500) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;

UPDATE `configuration` SET `sort_order` = '2' WHERE `configuration`.`id` = 15;
UPDATE `configuration` SET `sort_order` = '3' WHERE `configuration`.`id` = 1;
UPDATE `configuration` SET `sort_order` = '4' WHERE `configuration`.`id` = 12;
UPDATE `configuration` SET `sort_order` = '5' WHERE `configuration`.`id` = 13;
UPDATE `configuration` SET `sort_order` = '6' WHERE `configuration`.`id` = 4;
UPDATE `configuration` SET `sort_order` = '7' WHERE `configuration`.`id` = 11;
UPDATE `configuration` SET `sort_order` = '8' WHERE `configuration`.`id` = 3;
UPDATE `configuration` SET `sort_order` = '9' WHERE `configuration`.`id` = 2;
UPDATE `configuration` SET `sort_order` = '10' WHERE `configuration`.`id` = 14;
UPDATE `configuration` SET `sort_order` = '11' WHERE `configuration`.`id` = 16;
UPDATE `configuration` SET `sort_order` = '12' WHERE `configuration`.`id` = 8;
UPDATE `configuration` SET `sort_order` = '13' WHERE `configuration`.`id` = 9;
UPDATE `configuration` SET `sort_order` = '14' WHERE `configuration`.`id` = 10;
UPDATE `configuration` SET `sort_order` = '15' WHERE `configuration`.`id` = 7;


# 20210923 #
ALTER TABLE `t` ADD `image` VARCHAR(255) NOT NULL AFTER `id`;


# 20210927 #
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'is_first_sync', 'FIRST SYNC', '4', '0', '16', 'store_details');
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'extra_code', 'EXTRA CODE', '4', NULL, '17', 'store_details');


# 20211103 #
ALTER TABLE `xreport_banknotes` ADD `banknote_value` DECIMAL(9,2) UNSIGNED NOT NULL AFTER `banknotes_id`;


# 20211227 #
CREATE TABLE `section_printers` ( `id` INT(11) NOT NULL , `section_id` INT(11) NOT NULL , `printer_id` INT(11) NOT NULL , PRIMARY KEY (`id`), INDEX (`section_id`), INDEX (`printer_id`)) ENGINE = InnoDB;

ALTER TABLE `section_printers` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT;

# 20220216 #
ALTER TABLE `operation` ADD `section_id` INT(11) NOT NULL AFTER `print_num`;
ALTER TABLE `operation` ADD `user_id` INT(11) NOT NULL AFTER `section_id`;
ALTER TABLE `operation_history` ADD `section_id` INT(11) NOT NULL AFTER `print_num`, ADD `user_id` INT(11) NOT NULL AFTER `section_id`;

# 20220218 #
ALTER TABLE `product` ADD `countdown` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `availability`;
ALTER TABLE `product` ADD `has_countdown` CHAR(1) NOT NULL DEFAULT 'N' COMMENT '[Y]es, [N]one' AFTER `availability`;

# 20220301 #
ALTER TABLE `category` ADD `availability_time_from` TIME NULL DEFAULT NULL AFTER `order_sort`, ADD `availability_time_to` TIME NULL DEFAULT NULL AFTER `availability_time_from`;

# 20220307 #
checklist
checklist_log

# 20220314 #
ALTER TABLE `discount_history` ADD `sync_status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '[0] NOT SYNC , [1] SYNCED' AFTER `new_amount`, ADD INDEX (`sync_status`);

# 20220322 #
ALTER TABLE `checklist` ADD `day` CHAR(10) NOT NULL AFTER `id`, ADD INDEX (`day`);
ALTER TABLE `checklist` ADD `is_primary` TINYINT(1) NOT NULL DEFAULT '0' AFTER `textTime`;

# 20220401 #
ALTER TABLE `product` ADD `sku` VARCHAR(128) NULL DEFAULT NULL AFTER `barcode`, ADD INDEX (`sku`);

# 20220405 #
tutorial
tutorial_modules

# 20220516 #
INSERT INTO `tutorial_modules` (`id`, `name`, `function_name`, `sort_order`, `type`, `status`) VALUES (NULL, 'ALL SALES', 'myAllSales1', '9', 'pos', 'A');
INSERT INTO `tutorial_modules` (`id`, `name`, `function_name`, `sort_order`, `type`, `status`) VALUES (NULL, 'ALL SALES 2', 'myAllSales2', '10', 'pos', 'A');
INSERT INTO `tutorial_modules` (`id`, `name`, `function_name`, `sort_order`, `type`, `status`) VALUES (NULL, 'SEARCH SALES', 'mySearchSales', '11', 'pos', 'A');
INSERT INTO `tutorial_modules` (`id`, `name`, `function_name`, `sort_order`, `type`, `status`) VALUES (NULL, 'PENDING SALES', 'myPendingSales', '12', 'pos', 'D');

# 20220520 #
ALTER TABLE user ADD auto_logout CHAR(1) NOT NULL DEFAULT 'Y' COMMENT '[N]o , [Y]es' AFTER image, ADD INDEX (auto_logout);

# 20220603 #
ALTER TABLE `t` ADD `code` VARCHAR(50) NOT NULL AFTER `name`;

# 20220607 #
ALTER TABLE `t` ADD `with_limit` CHAR(3) NOT NULL DEFAULT 'NO' COMMENT '[YES] , [NO] ' AFTER `with_pin`, ADD `payment_limit` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0' AFTER `with_limit`, ADD INDEX (`with_limit`);

# 20220608 #
CREATE TABLE `t_transaction_history` ( `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT , `store_id` INT(11) UNSIGNED NOT NULL , `t_id` INT(11) UNSIGNED NOT NULL , `type` CHAR(1) NOT NULL COMMENT '[A]djustment , [P]ayment' , `operation` CHAR(10) NOT NULL COMMENT '[add] , [minus] ' , `amount` DECIMAL(12,2) UNSIGNED NOT NULL , `balance` DECIMAL(12,2) UNSIGNED NOT NULL , `remarks` MEDIUMTEXT NOT NULL , `sell_id` INT(11) UNSIGNED NOT NULL , `date_created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP , `action_by` INT(11) UNSIGNED NOT NULL , `status` CHAR(1) NOT NULL DEFAULT 'A' COMMENT '[A]ctive , [R]emoved ' , PRIMARY KEY (`id`), INDEX (`store_id`), INDEX (`t_id`), INDEX (`type`), INDEX (`operation`), INDEX (`sell_id`), INDEX (`action_by`), INDEX (`status`)) ENGINE = InnoDB;
ALTER TABLE `t_transaction_history` DROP `store_id`;
ALTER TABLE `t_transaction_history` CHANGE `sell_id` `sell_id` INT(11) UNSIGNED NULL DEFAULT '0';
INSERT INTO `tutorial_modules` (`id`, `name`, `function_name`, `sort_order`, `type`, `status`) VALUES (13, 'SETUP PRINTER', 'myPrinterIntro', 13, 'pos', 'A'), (14, 'ADD PRINTER', 'myPrinterAdd', 14, 'pos', 'A'), (15, 'PRINTERS', 'myPrinterList', 15, 'pos', 'A'), (16, 'SECTIONS', 'mySectionList', 16, 'pos', 'A'), (17, 'SECTION EDIT', 'mySectionEdit', 17, 'pos', 'A'), (18, 'PRE-INVOICE', 'myPrinterInvoice', 18, 'pos', 'A'), (19, 'PRE-INVOICE 2', 'myPrinterInvoice2', 19, 'pos', 'A'), (20, 'PRINTERS 2', 'myPrinterList2', 20, 'pos', 'A'), (21, 'USERS TUTORIAL', 'myUsers', 21, 'pos', 'D');

# 20220613 #
UPDATE `tutorial_modules` SET `status` = 'D' WHERE `tutorial_modules`.`id` = 8;
UPDATE `tutorial_modules` SET `status` = 'D' WHERE `tutorial_modules`.`id` = 9;
UPDATE `tutorial_modules` SET `status` = 'D' WHERE `tutorial_modules`.`id` = 10;
UPDATE `tutorial_modules` SET `status` = 'D' WHERE `tutorial_modules`.`id` = 11;
UPDATE `tutorial_modules` SET `status` = 'D' WHERE `tutorial_modules`.`id` = 12;

# 20220621 #
UPDATE `tutorial_modules` SET `status` = 'A' WHERE `tutorial_modules`.`id` = 23;
INSERT INTO `tutorial_modules` (`id`, `name`, `function_name`, `sort_order`, `type`, `status`) VALUES (NULL, 'USERS TUTORIAL 2', 'myUsers2', '24', 'pos', 'A');
INSERT INTO `tutorial_modules` (`id`, `name`, `function_name`, `sort_order`, `type`, `status`) VALUES (NULL, 'USERS TUTORIAL 3', 'myUsers3', '25', 'pos', 'A');
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'show_invoice_footer', 'SHOW INVOICE FOOTER', '4', '1', '18', 'store_details');
UPDATE `autoload_configuration` SET `name` = 'Default Printer for X and Z Module' WHERE `autoload_configuration`.`id` = 5;

# 20220623 #
ALTER TABLE `operation` ADD `print_q` SMALLINT(4) UNSIGNED NOT NULL AFTER `q`;

# 20220624 #
ALTER TABLE `discount` ADD `disc_type` CHAR(1) NOT NULL DEFAULT 'P' COMMENT 'Discount by [P]ercentage, [V]alue' AFTER `name`, ADD `disc_value` DECIMAL(12,2) NULL DEFAULT '0' COMMENT 'Discount by Value' AFTER `disc_type`, ADD INDEX (`disc_type`);
ALTER TABLE `discount` CHANGE `rate` `rate` FLOAT NULL DEFAULT NULL COMMENT 'Discount by Percentage';

# 20220708 -#
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'toggle_service_charge', 'TOGGLE SERVICE CHARGE', '4', 'Y', '19', 'store_details');

# 20220715 #
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'system_version', 'SYSTEM VERSION', '2', '', '20', 'store_details');

# 20220906 #
INSERT INTO `configuration`(`id`,`short`,`name`,`kind`,`val`,`sort_order`,`type`) VALUES ( NULL,'smtp_server','SMTP MAIL SERVER','1','server.hibax.com','99','smtp');
INSERT INTO `configuration`(`id`,`short`,`name`,`kind`,`val`,`sort_order`,`type`) VALUES ( NULL,'smtp_username','SMTP MAIL USERNAME','1','pos@trackerteer.com','99','smtp');
INSERT INTO `configuration`(`id`,`short`,`name`,`kind`,`val`,`sort_order`,`type`) VALUES ( NULL,'smtp_password','SMTP MAIL PASSWORD','1','Tr4ck3r@2021!','99','smtp');
INSERT INTO `configuration`(`id`,`short`,`name`,`kind`,`val`,`sort_order`,`type`) VALUES ( NULL,'smtp_port','SMTP PORT','1','465','99','smtp');

# 20220909 #
ALTER TABLE t ADD open_cash_drawer CHAR(3) NOT NULL DEFAULT 'YES' COMMENT '[YES] , [NO]' AFTER payment_limit, ADD INDEX (open_cash_drawer);
CREATE TABLE system_update_logs ( id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT , system_version INT(11) UNSIGNED NOT NULL , description MEDIUMTEXT NOT NULL , PRIMARY KEY (id), INDEX (system_version)) ENGINE = InnoDB;

# 20220915 #
INSERT INTO `autoload_configuration` (`id`, `short`, `name`, `value`) VALUES (NULL, 'GRAVYBABY', 'Gravybaby POS', 'FALSE');

# 20221003 #
ALTER TABLE `t` ADD `category` VARCHAR(100) NOT NULL AFTER `code`, ADD INDEX (`category`);

# 20221007 #
INSERT INTO `autoload_configuration` (`id`, `short`, `name`, `value`) VALUES (NULL, 'LED_SCREEN_DISPLAY', 'LED SCREEN DISPLAY', 'FALSE');

# 20221123 -#
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'logo_image', 'BILLS IMAGE LOGO', '2', '', '100', 'store_details');

# 20221124 #
ALTER TABLE `user` ADD INDEX(`printer_id`);
ALTER TABLE `user` ADD `printer_id_order` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' AFTER `printer_id`, ADD INDEX (`printer_id_order`);

# 20230217 #
ALTER TABLE `operation_option` ADD `price_out` FLOAT NOT NULL DEFAULT '0' AFTER `product_id`;
ALTER TABLE `operation_option_history` ADD `price_out` FLOAT NOT NULL DEFAULT '0' AFTER `product_id`;

# 20230907 - Customer Module #

ALTER TABLE `sell` ADD `customer_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `user_id`, ADD INDEX (`customer_id`);
ALTER TABLE `sell_history` ADD `customer_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `user_id`, ADD INDEX (`customer_id`);

ALTER TABLE `sell` ADD `cash_back_rebate` DECIMAL(9,2) UNSIGNED NOT NULL AFTER `discount_promotion`;
ALTER TABLE `sell_history` ADD `cash_back_rebate` DECIMAL(9,2) UNSIGNED NOT NULL AFTER `discount_promotion`;

CREATE TABLE `customer` (
  `id` int(11) UNSIGNED NOT NULL,
  `store_id` int(11) UNSIGNED NOT NULL,
  `customer_no` varchar(50) NOT NULL COMMENT 'Auto Generated',
  `barcode` varchar(50) NOT NULL,
  `first_name` varchar(150) NOT NULL,
  `last_name` varchar(150) NOT NULL,
  `phone_number` varchar(150) NOT NULL,
  `birthday` date NOT NULL,
  `join_date` date NOT NULL,
  `email` varchar(150) NOT NULL,
  `remarks` mediumtext NOT NULL,
  `balance` decimal(12,2) UNSIGNED NOT NULL COMMENT 'Cashback Rebate',
  `status` char(1) NOT NULL DEFAULT 'A' COMMENT '[A]ctive , [D]isabled , [R]emoved',
  `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `added_by` int(11) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `customer`
  ADD PRIMARY KEY (`id`),
  ADD KEY `store_id` (`store_id`),
  ADD KEY `status` (`status`),
  ADD KEY `added_by` (`added_by`);


ALTER TABLE `customer`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;


CREATE TABLE `customer_birthday_discount_history` (
  `id` int(11) UNSIGNED NOT NULL,
  `store_id` int(11) UNSIGNED NOT NULL,
  `customer_id` int(11) UNSIGNED NOT NULL,
  `year` year(4) NOT NULL,
  `sell_id` int(11) UNSIGNED NOT NULL,
  `status` char(1) NOT NULL DEFAULT 'A' COMMENT '[A]ctive, [C]ancelled',
  `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `added_by` int(11) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `customer_birthday_discount_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `store_id` (`store_id`),
  ADD KEY `customer_id` (`customer_id`),
  ADD KEY `sell_id` (`sell_id`),
  ADD KEY `added_by` (`added_by`),
  ADD KEY `status` (`status`);


ALTER TABLE `customer_birthday_discount_history`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;

CREATE TABLE `customer_transaction_history` (
  `id` int(11) UNSIGNED NOT NULL,
  `store_id` int(11) UNSIGNED NOT NULL,
  `customer_id` int(11) UNSIGNED NOT NULL,
  `type` char(1) NOT NULL COMMENT '[R]ebate , [P]ayment , [C]ancelled',
  `operation` char(10) NOT NULL COMMENT '[add] , [minus]',
  `amount` decimal(12,2) UNSIGNED NOT NULL,
  `balance` decimal(12,2) UNSIGNED NOT NULL,
  `remarks` mediumtext NOT NULL,
  `sell_id` int(11) UNSIGNED NOT NULL,
  `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `action_by` int(11) UNSIGNED NOT NULL,
  `status` char(1) NOT NULL DEFAULT 'A' COMMENT ' [A]ctive , [R]emoved'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `customer_transaction_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `store_id` (`store_id`),
  ADD KEY `customer_id` (`customer_id`),
  ADD KEY `type` (`type`),
  ADD KEY `sell_id` (`sell_id`),
  ADD KEY `action_by` (`action_by`),
  ADD KEY `status` (`status`);


ALTER TABLE `customer_transaction_history`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;

# 20230912 #
ALTER TABLE `banknotes` CHANGE `id` `id` INT(1) UNSIGNED NOT NULL AUTO_INCREMENT;

# 20230913 - START CUSTOMER MODULE #

INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'store_id', 'STORE ID', '4', '', '1', 'store_details');
CREATE TABLE `stores` ( `store_id` INT(11) NOT NULL , `store_code` VARCHAR(100) NOT NULL , `store_name` VARCHAR(255) NOT NULL , `store_address` VARCHAR(500) NOT NULL , `store_phone` VARCHAR(120) NOT NULL , `store_service_charge` DECIMAL(12,2) NOT NULL , `store_tax_percent` DECIMAL(12,2) NOT NULL , `store_tax_vat` VARCHAR(255) NOT NULL , `store_sst_id` VARCHAR(255) NOT NULL , `status` CHAR(1) NOT NULL COMMENT '[A]ctive , [D]isabled' , PRIMARY KEY (`store_id`), INDEX (`status`)) ENGINE = InnoDB;

INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'with_membership_module', 'WITH MEMBERSHIP MODULE', '2', '', '21', 'store_details');
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'cashback_rebate_percentage', 'CASHBACK REBATE PERCENTAGE', '2', '', '22', 'store_details');

ALTER TABLE `sell` ADD `birth_month_discount` DECIMAL(9,2) NOT NULL DEFAULT '0' AFTER `discount_promotion`;
ALTER TABLE `sell_history` ADD `birth_month_discount` DECIMAL(9,2) NOT NULL DEFAULT '0' AFTER `discount_promotion`;

# END CUSTOMER MODULE #

# 20230913 #

ALTER TABLE product ADD sell_by_weight CHAR(3) NOT NULL DEFAULT 'NO' COMMENT '[YES] , [NO]' AFTER price_out, ADD INDEX (sell_by_weight);

ALTER TABLE operation ADD weight DECIMAL(9,3) NOT NULL COMMENT 'Sold by weight' AFTER print_q;
ALTER TABLE operation_history ADD weight DECIMAL(9,3) NOT NULL COMMENT 'Sold by weight' AFTER stock_id;

# 20230914 - change operation weight to sold_by_weight #

ALTER TABLE `operation` CHANGE `weight` `sold_by_weight` CHAR(3) NOT NULL DEFAULT 'NO' COMMENT '[YES], [NO]';
ALTER TABLE `operation_history` CHANGE `weight` `sold_by_weight` CHAR(3) NOT NULL DEFAULT 'NO' COMMENT '[YES], [NO]';

INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'invoice_print_qty', 'INVOICE PRINT QTY', '2', '1', '12', 'store_details');

# 20230914 - charm #

ALTER TABLE `operation` ADD `sbw_print_q` FLOAT NULL COMMENT 'Sold by Weight print_q' AFTER `print_q`;

# 20230914 - QUEUEING NUMBER #

INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'queue_number', 'RECEIPT QUEUE NUMBER', '2', '300', '12', 'store_details');
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'queue_number_limit', 'RECEIPT QUEUE NUMBER LIMIT', '2', '305', '12', 'store_details');
INSERT INTO `configuration` (`id`, `short`, `name`, `kind`, `val`, `sort_order`, `type`) VALUES (NULL, 'queue_base_number', 'RECEIPT QUEUE BASE NUMBER', '2', '300', '12', 'store_details');
ALTER TABLE `sell` ADD `queue_number` INT(11) NULL DEFAULT NULL AFTER `id`;
ALTER TABLE `sell_history` ADD `queue_number` INT(11) NULL DEFAULT NULL AFTER `id`;

# 20230919 - PRINT CONFIG #
INSERT INTO `autoload_configuration` (`id`, `short`, `name`, `value`) VALUES (NULL, 'DISABLED_PRINT', 'DISABLED PRINT ON ORDER/BILL/SUMMARY/INVOICE', 'FALSE');

# 20230920 - 
ALTER TABLE `xreport_banknotes` CHANGE `banknotes_id` `banknotes_id` INT(1) UNSIGNED NOT NULL;

# 20230922 - PRODUCT BUILD [S]ingle (x 1) or [M]ultiple #
INSERT INTO `autoload_configuration` (`id`, `short`, `name`, `value`) VALUES (NULL, 'PRODUCT_BUILD', 'PRODUCT BUILD', 'M');

# 20231113 
INSERT INTO `autoload_configuration` (`id`, `short`, `name`, `value`) VALUES (NULL, 'PRINT_ORDER', 'PRINT ORDER', 'GROUP');

# 20231129 - PER ITEM DISCOUNT
ALTER TABLE `operation` ADD `original_price` DECIMAL(9,2) UNSIGNED NOT NULL AFTER `price_out`;
ALTER TABLE `operation_history` ADD `original_price` DECIMAL(9,2) UNSIGNED NOT NULL AFTER `price_out`;

# 20231201 - PER ITEM DISCOUNT - SAVE DISCOUNT NAME
ALTER TABLE `operation` ADD `discount_name` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `original_price`;
ALTER TABLE `operation_history` ADD `discount_name` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `original_price`;

# 20231211
ALTER TABLE `discount_history` ADD `operation_id` INT(11) UNSIGNED NULL DEFAULT '0' COMMENT 'For per product discount' AFTER `sell_id`;

# 20231214
ALTER TABLE `operation` ADD `discount_id` INT(11) NOT NULL DEFAULT '0' AFTER `discount_name`, ADD INDEX (`discount_id`);

# 20240212 - [NO] DEFAULT — SKIP SELECTING TABLE FOR ONLINE POS
INSERT INTO `autoload_configuration` (`id`, `short`, `name`, `value`) VALUES (NULL, 'SKIP_SELECTING_TABLE', 'SKIP SELECTING TABLE [Y]es OR [N]o', 'N');

# 20240620

CREATE TABLE `store_tax` ( `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT , `tax_name` VARCHAR(50) NOT NULL , `tax_percent` DECIMAL(12,2) NOT NULL , `status` CHAR(1) NOT NULL DEFAULT 'A' COMMENT '[A]ctive , [D]isabled , [R]emoved' , PRIMARY KEY (`id`), INDEX (`status`)) ENGINE = InnoDB;

ALTER TABLE `product` ADD `tax_percent` DECIMAL(12,2) NOT NULL AFTER `price_out`;

ALTER TABLE `product` ADD `tax_id` INT(11) NOT NULL AFTER `price_out`, ADD INDEX (`tax_id`);

ALTER TABLE `operation` ADD `iva` DECIMAL(12,2) UNSIGNED NOT NULL AFTER `original_price`;

ALTER TABLE `operation` ADD `tax_percent` DECIMAL(12,2) UNSIGNED NOT NULL AFTER `iva`;

ALTER TABLE `operation_history` ADD `iva` DECIMAL(12,2) UNSIGNED NOT NULL AFTER `original_price`;

ALTER TABLE `operation_history` ADD `tax_percent` DECIMAL(12,2) UNSIGNED NOT NULL AFTER `iva`;

ALTER TABLE `store_tax` CHANGE `tax_percent` `tax_percent` DECIMAL(12,4) NOT NULL;

ALTER TABLE `product` CHANGE `tax_percent` `tax_percent` DECIMAL(12,4) NOT NULL;

ALTER TABLE `operation` CHANGE `tax_percent` `tax_percent` DECIMAL(12,4) UNSIGNED NOT NULL;

ALTER TABLE `operation_history` CHANGE `tax_percent` `tax_percent` DECIMAL(12,4) UNSIGNED NOT NULL;

ALTER TABLE `operation` ADD `is_cancelled_first` CHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' COMMENT 'Item canceled first before canceling invoice.' AFTER `user_id`;

ALTER TABLE `operation_history` ADD `is_cancelled_first` CHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' COMMENT 'Item canceled first before canceling invoice.' AFTER `user_id`;

ALTER TABLE `operation` ADD `discounted_iva` DECIMAL(12,2) UNSIGNED NULL DEFAULT NULL COMMENT 'Updated after payment if whole transaction discount applied' AFTER `iva`;

ALTER TABLE `operation` ADD `discounted_price` DECIMAL(9,2) UNSIGNED NULL DEFAULT NULL COMMENT 'Updated after payment if whole transaction discount applied' AFTER `original_price`;

ALTER TABLE `operation_history` ADD `discounted_iva` DECIMAL(12,2) UNSIGNED NULL DEFAULT NULL COMMENT 'Updated after payment if whole transaction discount applied' AFTER `iva`;

ALTER TABLE `operation_history` ADD `discounted_price` DECIMAL(9,2) UNSIGNED NULL DEFAULT NULL COMMENT 'Updated after payment if whole transaction discount applied' AFTER `original_price`;




