diff --git a/admin/database_updates.php b/admin/database_updates.php index 6d52b604..f9a93e4e 100644 --- a/admin/database_updates.php +++ b/admin/database_updates.php @@ -4394,10 +4394,16 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { } - // if (CURRENT_DATABASE_VERSION == '2.4.4') { - // // Insert queries here required to update to DB version 2.4.5 - // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.5'"); + if (CURRENT_DATABASE_VERSION == '2.4.4') { + // Gateway fee expense now uses the actual fee from Stripe's balance transaction + mysqli_query($mysqli, "ALTER TABLE `payment_providers` DROP `payment_provider_expense_percentage_fee`, DROP `payment_provider_expense_flat_fee`"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.5'"); + } + + // if (CURRENT_DATABASE_VERSION == '2.4.5') { + // // Insert queries here required to update to DB version 2.4.6 + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.6'"); // } } else { diff --git a/admin/modals/payment_provider/payment_provider_add.php b/admin/modals/payment_provider/payment_provider_add.php index db79d3a5..987deff8 100644 --- a/admin/modals/payment_provider/payment_provider_add.php +++ b/admin/modals/payment_provider/payment_provider_add.php @@ -16,11 +16,6 @@ ob_start(); + Should havea seperate account created off the payment provider's name e.g. Stripe
@@ -107,6 +103,10 @@ ob_start();
+
+ Payment Processing Fee Expenses get reconciled nighly via the cron +
+
@@ -136,6 +136,7 @@ ob_start(); ?>
+ Payment Privider name e.g. Stripe
@@ -166,29 +167,8 @@ ob_start();
-
- -
- -
-
- -
- -
- See here for the latest Stripe Fees. -
- -
- -
-
- -
- -
- See here for the latest Stripe Fees. -
+ Processing Fee, Credit Card Fee etc + diff --git a/admin/modals/payment_provider/payment_provider_edit.php b/admin/modals/payment_provider/payment_provider_edit.php index a10bca72..26030f84 100644 --- a/admin/modals/payment_provider/payment_provider_edit.php +++ b/admin/modals/payment_provider/payment_provider_edit.php @@ -14,12 +14,11 @@ $account_id = intval($row['payment_provider_account']); $threshold = floatval($row['payment_provider_threshold']); $vendor_id = intval($row['payment_provider_expense_vendor']); $category_id = intval($row['payment_provider_expense_category']); -$percent_fee = floatval($row['payment_provider_expense_percentage_fee']) * 100; -$flat_fee = floatval($row['payment_provider_expense_flat_fee']); -// Generate the HTML form content using output buffering. ob_start(); + ?> + + Should havea seperate account created off the payment provider's name e.g. Stripe
@@ -106,6 +106,10 @@ ob_start();
+
+ Payment Processing Fee Expenses get reconciled nighly via the cron +
+
@@ -130,6 +134,7 @@ ob_start(); ?>
+ Payment Privider name e.g. Stripe
@@ -160,28 +165,7 @@ ob_start();
-
- -
- -
-
- -
- -
- See here for the latest Stripe Fees. -
- -
- -
-
- -
- -
- See here for the latest Stripe Fees. + Processing Fee, Credit Card Fee etc
diff --git a/admin/payment_providers.php b/admin/payment_providers.php index 6bc2622a..882d79ad 100644 --- a/admin/payment_providers.php +++ b/admin/payment_providers.php @@ -54,9 +54,6 @@ $num_rows = mysqli_num_rows($sql); Expense Category - - Expensed Fee - Saved Payment Methods @@ -72,10 +69,13 @@ $num_rows = mysqli_num_rows($sql); $provider_description = escapeHtml($row['payment_provider_description']); $account_name = escapeHtml($row['account_name']); $threshold = floatval($row['payment_provider_threshold']); + if (!$threshold) { + $threshold = "Not Enforced"; + } else { + $threshold = numfmt_format_currency($currency_format, $threshold, $session_company_currency); + } $vendor_name = escapeHtml($row['vendor_name'] ?? "Expense Disabled"); $category = escapeHtml($row['category_name']); - $percent_fee = floatval($row['payment_provider_expense_percentage_fee']) * 100; - $flat_fee = floatval($row['payment_provider_expense_flat_fee']); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('saved_payment_id') AS saved_payment_count FROM client_saved_payment_methods WHERE saved_payment_provider_id = $provider_id")); $saved_payment_count = intval($row['saved_payment_count']); @@ -90,10 +90,9 @@ $num_rows = mysqli_num_rows($sql); - + - % + diff --git a/admin/post/payment_provider.php b/admin/post/payment_provider.php index d8a05761..7a66caf5 100644 --- a/admin/post/payment_provider.php +++ b/admin/post/payment_provider.php @@ -17,8 +17,6 @@ if (isset($_POST['add_payment_provider'])) { $account = intval($_POST['account']); $expense_vendor = intval($_POST['expense_vendor']) ?? 0; $expense_category = intval($_POST['expense_category']) ?? 0; - $percentage_fee = floatval($_POST['percentage_fee']) / 100 ?? 0; - $flat_fee = floatval($_POST['flat_fee']) ?? 0; // Check to ensure provider isn't added twice $sql = mysqli_query($mysqli, "SELECT 1 FROM payment_providers WHERE payment_provider_name = '$provider' LIMIT 1"); @@ -27,7 +25,7 @@ if (isset($_POST['add_payment_provider'])) { redirect(); } - mysqli_query($mysqli,"INSERT INTO payment_providers SET payment_provider_name = '$provider', payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category, payment_provider_expense_percentage_fee = $percentage_fee, payment_provider_expense_flat_fee = $flat_fee"); + mysqli_query($mysqli,"INSERT INTO payment_providers SET payment_provider_name = '$provider', payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category"); $provider_id = mysqli_insert_id($mysqli); @@ -51,10 +49,8 @@ if (isset($_POST['edit_payment_provider'])) { $account = intval($_POST['account']); $expense_vendor = intval($_POST['expense_vendor']) ?? 0; $expense_category = intval($_POST['expense_category']) ?? 0; - $percentage_fee = floatval($_POST['percentage_fee']) / 100; - $flat_fee = floatval($_POST['flat_fee']); - mysqli_query($mysqli,"UPDATE payment_providers SET payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category, payment_provider_expense_percentage_fee = $percentage_fee, payment_provider_expense_flat_fee = $flat_fee WHERE payment_provider_id = $provider_id"); + mysqli_query($mysqli,"UPDATE payment_providers SET payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category WHERE payment_provider_id = $provider_id"); logAudit("Payment Provider", "Edit", "$session_name edited Payment Provider $provider"); @@ -71,7 +67,7 @@ if (isset($_GET['delete_payment_provider'])) { $provider_id = intval($_GET['delete_payment_provider']); // When deleted it cascades deletes - // all Recurring paymentes related to payment provider + // all Recurring payments related to payment provider // Delete all Saved Cards related // Delete Client Payment Provider Releation diff --git a/db.sql b/db.sql index b9b8b8e8..4ea84512 100644 --- a/db.sql +++ b/db.sql @@ -1,9 +1,9 @@ /*M!999999\- enable the sandbox mode */ --- MariaDB dump 10.19 Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.11.18-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: localhost Database: itflow_dev -- ------------------------------------------------------ --- Server version 10.11.14-MariaDB-0+deb12u2 +-- Server version 10.11.18-MariaDB-0+deb12u1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -962,6 +962,132 @@ CREATE TABLE `custom_fields` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `custom_hosting_api_keys` +-- + +DROP TABLE IF EXISTS `custom_hosting_api_keys`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `custom_hosting_api_keys` ( + `api_key_id` int(11) NOT NULL AUTO_INCREMENT, + `api_key_name` varchar(200) NOT NULL, + `api_key_url` varchar(250) NOT NULL, + `api_key_token_id` varchar(200) NOT NULL, + `api_key_token_secret` varchar(250) NOT NULL, + `api_key_created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`api_key_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `custom_hosting_networks` +-- + +DROP TABLE IF EXISTS `custom_hosting_networks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `custom_hosting_networks` ( + `network_id` int(11) NOT NULL AUTO_INCREMENT, + `network_name` varchar(200) NOT NULL, + `network` varchar(100) NOT NULL, + `network_mask` varchar(100) NOT NULL, + `gateway` varchar(100) NOT NULL, + `network_start` varchar(100) NOT NULL, + `network_end` varchar(100) NOT NULL, + PRIMARY KEY (`network_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `custom_hosting_plans` +-- + +DROP TABLE IF EXISTS `custom_hosting_plans`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `custom_hosting_plans` ( + `plan_id` int(11) NOT NULL AUTO_INCREMENT, + `plan_name` varchar(250) NOT NULL, + `plan_description` text NOT NULL, + `plan_created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`plan_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `custom_hosting_regions` +-- + +DROP TABLE IF EXISTS `custom_hosting_regions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `custom_hosting_regions` ( + `region_id` int(11) NOT NULL AUTO_INCREMENT, + `region_name` varchar(200) NOT NULL, + `region_created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`region_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `custom_hosting_servers` +-- + +DROP TABLE IF EXISTS `custom_hosting_servers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `custom_hosting_servers` ( + `server_id` int(11) NOT NULL AUTO_INCREMENT, + `server_node` varchar(200) NOT NULL, + `server_storage` varchar(200) NOT NULL, + `server_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `server_region_id` int(11) NOT NULL, + `server_api_key_id` varchar(200) NOT NULL, + PRIMARY KEY (`server_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `custom_hosting_vm_templates` +-- + +DROP TABLE IF EXISTS `custom_hosting_vm_templates`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `custom_hosting_vm_templates` ( + `template_id` int(11) NOT NULL AUTO_INCREMENT, + `template_name` varchar(200) NOT NULL, + `vcpus` int(11) NOT NULL, + `memory` int(11) NOT NULL, + `disk` int(11) NOT NULL, + `template_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `template_plan_id` int(11) NOT NULL, + PRIMARY KEY (`template_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `custom_hosting_vms` +-- + +DROP TABLE IF EXISTS `custom_hosting_vms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `custom_hosting_vms` ( + `vm_id` int(11) NOT NULL AUTO_INCREMENT, + `vm_hostname` varchar(200) NOT NULL, + `vm_ip` varchar(100) NOT NULL, + `vm_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `vm_network_id` int(11) NOT NULL, + `vm_server_id` int(11) NOT NULL, + `vm_template_id` int(11) NOT NULL, + `vm_recurring_invoice_id` int(11) DEFAULT NULL, + `vm_client_id` int(11) NOT NULL, + PRIMARY KEY (`vm_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `custom_links` -- @@ -1508,8 +1634,6 @@ CREATE TABLE `payment_providers` ( `payment_provider_account` int(11) NOT NULL, `payment_provider_expense_vendor` int(11) NOT NULL DEFAULT 0, `payment_provider_expense_category` int(11) NOT NULL DEFAULT 0, - `payment_provider_expense_percentage_fee` decimal(4,4) DEFAULT NULL, - `payment_provider_expense_flat_fee` decimal(15,2) DEFAULT NULL, `payment_provider_created_at` datetime NOT NULL DEFAULT current_timestamp(), `payment_provider_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), PRIMARY KEY (`payment_provider_id`) @@ -2997,4 +3121,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2026-04-04 18:13:53 +-- Dump completed on 2026-07-22 17:26:08 diff --git a/includes/database_version.php b/includes/database_version.php index 53c431bc..5f182ee7 100644 --- a/includes/database_version.php +++ b/includes/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "2.4.4"); +DEFINE("LATEST_DATABASE_VERSION", "2.4.5");