ALTER TABLE `car_driver_tepic`.`BANK_CARD` 
ADD COLUMN `balance` DOUBLE NULL DEFAULT 0 AFTER `id_location`;

CREATE TABLE `BANK_CARD_KARDEX` (
  `id` char(36) NOT NULL,
  `id_bank_card` char(36) NOT NULL,
  `amount` double NOT NULL,
  `amount_before` double NOT NULL,
  `amount_after` double NOT NULL,
  `type` enum('EXPENSE','INCOME','INITIAL_BALANCE','EXPENSE_RETURN','INCOME_RETURN') NOT NULL,
  `description` varchar(200) NOT NULL,
  `id_location` varchar(50) NOT NULL,
  `created_by` char(36) NOT NULL,
  `created_on` datetime DEFAULT CURRENT_TIMESTAMP,
  `last_updated_by` char(36) DEFAULT NULL,
  `last_updated_on` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `bank_card_kardex_user_created_by_id_fk` (`created_by`),
  KEY `bank_card_kardex_user_last_updated_by_id_fk` (`last_updated_by`),
  CONSTRAINT `bank_card_kardex_user_created_by_id_fk` FOREIGN KEY (`created_by`) REFERENCES `car_driver_user` (`id`) ON UPDATE CASCADE,
  CONSTRAINT `bank_card_kardex_user_last_updated_by_id_fk` FOREIGN KEY (`last_updated_by`) REFERENCES `car_driver_user` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `car_driver_tepic`.`SALE` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `total_to_pay`,
ADD COLUMN `estatus` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;


ALTER TABLE `car_driver_tepic`.`EXPENSE` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `id_expense_type`,
ADD COLUMN `deposit_status` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;

ALTER TABLE `car_driver_tepic`.`SANCTION` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `estatus`;

ALTER TABLE `car_driver_tepic`.`SANCTION` 
ADD COLUMN `deposit_status` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;


ALTER TABLE `car_driver_tepic`.`EXPENSE_COMPANY` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `id_expense_type`,
ADD COLUMN `deposit_status` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;

ALTER TABLE `car_driver_tepic`.`TAXES` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `id_location`,
ADD COLUMN `deposit_status` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;


ALTER TABLE `car_driver_tepic`.`INVOICE` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `authorize`,
ADD COLUMN `deposit_status` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;

ALTER TABLE `car_driver_tepic`.`SERVICE_ORDER` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `pay_user`,
ADD COLUMN `deposit_status` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;

ALTER TABLE `car_driver_tepic`.`PAYMENT_CLIENT` 
ADD COLUMN `id_bank_card` CHAR(36) NULL DEFAULT NULL AFTER `descuento_pago_comment`,
ADD COLUMN `deposit_status` ENUM('PENDING', 'AUTHORIZED') NULL DEFAULT 'AUTHORIZED' AFTER `id_bank_card`;
