-- -------------------------------------------------------------
-- TablePlus 6.7.0(634)
--
-- https://tableplus.com/
--
-- Database: sx_db_1751480457
-- Generation Time: 2025-09-12 12:29:48.3610
-- -------------------------------------------------------------


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


CREATE TABLE `charges` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `refid` bigint(20) unsigned DEFAULT NULL,
  `external_id` varchar(255) DEFAULT NULL,
  `synced` tinyint(1) NOT NULL DEFAULT 0,
  `title` varchar(255) DEFAULT NULL,
  `fields` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`fields`)),
  `amount` decimal(19,4) NOT NULL,
  `billingaccount` bigint(20) unsigned DEFAULT NULL,
  `billingitem` bigint(20) unsigned DEFAULT NULL,
  `billto` bigint(20) unsigned DEFAULT NULL,
  `chargedate` date DEFAULT NULL,
  `chargetype` varchar(255) DEFAULT NULL,
  `class` bigint(20) unsigned DEFAULT NULL,
  `createddate` date DEFAULT NULL,
  `currency` bigint(20) unsigned DEFAULT NULL,
  `department` bigint(20) unsigned DEFAULT NULL,
  `description` text DEFAULT NULL,
  `invoice` bigint(20) unsigned DEFAULT NULL,
  `invoiceline` text DEFAULT NULL,
  `location` bigint(20) unsigned DEFAULT NULL,
  `project` bigint(20) unsigned DEFAULT NULL,
  `projecttask` bigint(20) unsigned DEFAULT NULL,
  `quantity` double(8,2) DEFAULT NULL,
  `rate` decimal(19,4) DEFAULT NULL,
  `rule` text DEFAULT NULL,
  `runid` varchar(255) DEFAULT NULL,
  `salesorder` bigint(20) unsigned DEFAULT NULL,
  `salesorderline` bigint(20) unsigned DEFAULT NULL,
  `stage` text DEFAULT NULL,
  `subscriptionline` bigint(20) unsigned DEFAULT NULL,
  `timerecord` bigint(20) unsigned DEFAULT NULL,
  `transaction` bigint(20) unsigned DEFAULT NULL,
  `transactionline` bigint(20) unsigned DEFAULT NULL,
  `use` varchar(255) DEFAULT NULL,
  `subsidiary` bigint(20) unsigned DEFAULT NULL,
  `formid` bigint(20) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `charges_external_id_unique` (`external_id`),
  KEY `charges_formid_foreign` (`formid`),
  KEY `charges_refid_index` (`refid`),
  CONSTRAINT `charges_formid_foreign` FOREIGN KEY (`formid`) REFERENCES `entry_forms` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;