From: Steve Sutton Date: Wed, 29 Nov 2017 18:25:56 +0000 (-0500) Subject: Updating the database tables. X-Git-Tag: v1.0.0^2~219 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=564afc30965957abb7514239c2e274ee62995b5f;p=WP-Plugins%2Fglm-member-db-billing.git Updating the database tables. New db structure for the plugin. --- diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql index c73a34d..a2b3be0 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -9,66 +9,135 @@ -- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES **** -- +-- Billing Accounts +CREATE TABLE {prefix}accounts ( + id INT NOT NULL AUTO_INCREMENT, + ref_dest INT NOT NULL, -- reference to member id + anniversary_date DATE NOT NULL, -- anniversary date - used for main invoice generation + payment_data TEXT NULL, -- stored payment data + email TINYTEXT NULL, -- billing email + PRIMARY KEY (id) +); + +---- + -- transactions CREATE TABLE {prefix}transactions ( id INT NOT NULL AUTO_INCREMENT, - invoice_id INT NOT NULL, - transaction_time TIMESTAMP NOT NULL, - transaction_date DATE NOT NULL, - ref_dest_name INT, - ref_dest INT, - account INT, - account_number INT NOT NULL, - billing_type INT NOT NULL, - amount DECIMAL(8, 2) NOT NULL, - balance DECIMAL(8, 2) NOT NULL, - payment_method INT, - payment_data TEXT, - paid BOOLEAN DEFAULT '0', - invoice TEXT, - notes TINYTEXT, + type INT NOT NULL, -- type of transaction (payment,invoice,etc) + type_id INT NOT NULL, -- reference to type id + transaction_time DATETIME NOT NULL, -- datetime for the transaction + current_invoice_total DECIMAL(8, 2) NOT NULL, -- invoice total + current_payment_total DECIMAL(8, 2) NOT NULL, -- payment total PRIMARY KEY (id) ); ---- --- payment_types -CREATE TABLE {prefix}payment_types ( +-- Invoices +CREATE TABLE {prefix}invoices ( id INT NOT NULL AUTO_INCREMENT, - name TINYTEXT NOT NULL, - qcode TINYTEXT NULL, - category TEXT NOT NULL, - amount DECIMAL(8, 2), - notes TINYTEXT NULL, - dynamic_amount BOOLEAN DEFAULT '0', + transaction_time DATETIME NOT NULL, -- datetime for the invoice + account INT NOT NULL, -- ref to account id + amount_total DECIMAL(8, 2) NOT NULL, -- total amount for invoice + balance DECIMAL(8, 2) NOT NULL, -- balance for this invoice + due_date DATE NOT NULL, -- Due date for this invoice + paid BOOLEAN DEFAULT '0', -- true/false if invoice is paid + notes TINYTEXT, -- notes for this invoice + recurring BOOLEAN DEFAULT '0', -- true/false if recurring + recurrence INT NULL DEFAULT 0, -- recurrence type PRIMARY KEY (id) ); ---- --- ref_account -CREATE TABLE {prefix}ref_account ( +-- Line Item Types +CREATE TABLE {prefix}invoice_types ( id INT NOT NULL AUTO_INCREMENT, - ref_type INT NOT NULL, - ref_dest INT NOT NULL, - payment_type INT NOT NULL, - billing_period TINYTEXT NOT NULL, - invoice_date DATE NOT NULL, - processed_date DATE NOT NULL, - notification_pref TINYTEXT NULL, - PRIMARY KEY (id), - INDEX(ref_type), - INDEX(ref_dest), - INDEX(payment_type) + name TINYTEXT NOT NULL, -- name + parent INT NOT NULL DEFAULT 0, -- 0 if top level otherwise ref to another line_item_type as it's parent + amount DECIMAL(8,2) NOT NULL DEFAULT '0.00', -- amount + recurring BOOLEAN DEFAULT '0', -- true/false if recurring + recurrence INT NULL DEFAULT 0, -- recurrence type + PRIMARY KEY (id) +); + +---- + +-- Line Items +CREATE TABLE {prefix}line_items ( + id INT NOT NULL AUTO_INCREMENT, + invoice INT NOT NULL, -- reference to invoice + line_item_type INT NOT NULL, -- reference to line item type + name TEXT NOT NULL, -- line item name + amount DECIMAL(8,2) DEFAULT '0.00', -- line item amount per item + quantity INT DEFAULT 1, -- quantity + recurring BOOLEAN DEFAULT '0', -- true/false if recurring + recurrence INT NULL DEFAULT 0, -- recurrence type + PRIMARY KEY (id) +); + +---- + +-- payments +CREATE TABLE {prefix}payments ( + id INT NOT NULL AUTO_INCREMENT, + transaction_time DATETIME NOT NULL, -- datetime of payment + account INT NOT NULL, -- ref to account + amount DECIMAL(8, 2) NOT NULL, -- payment amount + payment_method TINYTEXT NOT NULL, -- payment method + payment_data TINYTEXT NULL, -- additional payment info + PRIMARY KEY (id) +); + +---- + +-- Notification Types +CREATE TABLE {prefix}notification_types ( + id INT NOT NULL AUTO_INCREMENT, + from_replyto TINYTEXT NOT NULL, -- from reply-to headers + subject TINYTEXT NOT NULL, -- Subject + message TEXT NOT NULL, -- Message + send_by_date BOOLEAN NULL DEFAULT '0', -- true/false send by date based on due date + send_by_action BOOLEAN NULL DEFAULT '0', -- send notice based on an action + send_action INT NULL DEFAULT 0, -- (create invoice or receive payment) + send_date_number INT NULL DEFAULT 0, -- number to apply to send by date + send_date_period INT NULL DEFAULT 0, -- (days,weeks,months,years) + send_date_when INT NULL DEFAULT 0, -- (before or after) + PRIMARY KEY (id) +); + +---- + +-- Notifications +CREATE TABLE {prefix}notifications ( + id INT NOT NULL AUTO_INCREMENT, + notification_type INT NOT NULL, -- ref to notification type + account INT NOT NULL, -- ref to account + from_replyto TINYTEXT NOT NULL, -- from reply-to header + subject TEXT NOT NULL, -- subject + message TEXT NOT NULL, -- message + date_sent DATETIME NOT NULL, -- Date the notice was sent + email_sent TINYTEXT NOT NULL, -- email used + PRIMARY KEY (id) +); + +---- + +-- Gateway Settings +CREATE TABLE {prefix}gateway_settings ( + id INT NOT NULL AUTO_INCREMENT, + name TEXT NOT NULL, + login_id TINYTEXT NOT NULL, + transaction_key TINYTEXT NOT NULL, + PRIMARY KEY (id) ); ---- --- Management Options +-- Settings CREATE TABLE {prefix}settings ( id INT NOT NULL AUTO_INCREMENT, - billing_period TINYTEXT NOT NULL, - invoice_date DATE NOT NULL, company_logo TINYTEXT NULL, company_logo_height INT NULL, company_name TINYTEXT NULL, @@ -81,14 +150,12 @@ CREATE TABLE {prefix}settings ( company_phone TINYTEXT NULL, company_email TINYTEXT NULL, company_url TINYTEXT NULL, - notification_from TINYTEXT NULL, - notification_message TEXT NULL, PRIMARY KEY (id) ); ---- --- Set default billing settings entry +-- Set default billing Settings entry INSERT INTO {prefix}settings ( id ) VALUES diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 5aaba3f..1ab11c9 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -14,6 +14,6 @@ */ $glmMembersBillingDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 4), + '0.0.1' => array('version' => '0.0.1', 'tables' => 10), );