Set Currency Code on Transfers as well and set currency code as not null field

This commit is contained in:
johnny@pittpc.com 2021-02-14 18:26:52 -05:00
parent 6f46f2ec87
commit 1ef8925774
2 changed files with 12 additions and 12 deletions

20
db.sql
View File

@ -26,7 +26,7 @@ CREATE TABLE `accounts` (
`account_id` int(11) NOT NULL AUTO_INCREMENT,
`account_name` varchar(200) NOT NULL,
`opening_balance` decimal(15,2) NOT NULL DEFAULT 0.00,
`account_curency_code` varchar(200) DEFAULT NULL,
`account_curency_code` varchar(200) NOT NULL,
`account_notes` text DEFAULT NULL,
`account_created_at` datetime NOT NULL,
`account_updated_at` datetime DEFAULT NULL,
@ -174,7 +174,7 @@ CREATE TABLE `clients` (
`client_email` varchar(200) DEFAULT NULL,
`client_website` varchar(200) DEFAULT NULL,
`client_referral` varchar(200) DEFAULT NULL,
`client_currency_code` varchar(200) DEFAULT NULL,
`client_currency_code` varchar(200) NOT NULL,
`client_net_terms` int(10) NOT NULL,
`client_notes` text DEFAULT NULL,
`client_created_at` datetime NOT NULL,
@ -317,7 +317,7 @@ CREATE TABLE `expenses` (
`expense_id` int(11) NOT NULL AUTO_INCREMENT,
`expense_description` text DEFAULT NULL,
`expense_amount` decimal(15,2) NOT NULL,
`expense_currency_code` varchar(200) DEFAULT NULL,
`expense_currency_code` varchar(200) NOT NULL,
`expense_date` date NOT NULL,
`expense_reference` varchar(200) DEFAULT NULL,
`expense_payment_method` varchar(200) DEFAULT NULL,
@ -422,7 +422,7 @@ CREATE TABLE `invoices` (
`invoice_date` date NOT NULL,
`invoice_due` date NOT NULL,
`invoice_amount` decimal(15,2) DEFAULT NULL,
`invoice_currency_code` varchar(200) DEFAULT NULL,
`invoice_currency_code` varchar(200) NOT NULL,
`invoice_note` text DEFAULT NULL,
`invoice_url_key` varchar(200) DEFAULT NULL,
`invoice_created_at` datetime NOT NULL,
@ -552,7 +552,7 @@ CREATE TABLE `payments` (
`payment_id` int(11) NOT NULL AUTO_INCREMENT,
`payment_date` date NOT NULL,
`payment_amount` decimal(15,2) NOT NULL,
`payment_currency_code` varchar(10) DEFAULT NULL,
`payment_currency_code` varchar(10) NOT NULL,
`payment_method` varchar(200) DEFAULT NULL,
`payment_reference` varchar(200) DEFAULT NULL,
`payment_created_at` datetime NOT NULL,
@ -596,7 +596,7 @@ CREATE TABLE `products` (
`product_name` varchar(200) NOT NULL,
`product_description` text DEFAULT NULL,
`product_cost` decimal(15,2) NOT NULL,
`product_currency_code` varchar(200) DEFAULT NULL,
`product_currency_code` varchar(200) NOT NULL,
`product_created_at` datetime NOT NULL,
`product_updated_at` datetime DEFAULT NULL,
`product_archived_at` datetime DEFAULT NULL,
@ -622,7 +622,7 @@ CREATE TABLE `quotes` (
`quote_status` varchar(200) NOT NULL,
`quote_date` date NOT NULL,
`quote_amount` decimal(15,2) DEFAULT NULL,
`quote_currency_code` varchar(200) DEFAULT NULL,
`quote_currency_code` varchar(200) NOT NULL,
`quote_note` text DEFAULT NULL,
`quote_url_key` varchar(200) DEFAULT NULL,
`quote_created_at` datetime NOT NULL,
@ -674,7 +674,7 @@ CREATE TABLE `recurring` (
`recurring_next_date` date NOT NULL,
`recurring_status` int(1) NOT NULL,
`recurring_amount` decimal(15,2) DEFAULT NULL,
`recurring_currency_code` varchar(200) DEFAULT NULL,
`recurring_currency_code` varchar(200) NOT NULL,
`recurring_note` text DEFAULT NULL,
`recurring_created_at` datetime NOT NULL,
`recurring_updated_at` datetime DEFAULT NULL,
@ -697,7 +697,7 @@ CREATE TABLE `revenues` (
`revenue_id` int(11) NOT NULL AUTO_INCREMENT,
`revenue_date` date NOT NULL,
`revenue_amount` decimal(15,2) NOT NULL,
`revenue_currency_code` varchar(200) DEFAULT NULL,
`revenue_currency_code` varchar(200) NOT NULL,
`revenue_payment_method` varchar(200) DEFAULT NULL,
`revenue_reference` varchar(200) DEFAULT NULL,
`revenue_description` varchar(200) DEFAULT NULL,
@ -980,4 +980,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-02-14 18:04:43
-- Dump completed on 2021-02-14 18:26:14

View File

@ -1507,10 +1507,10 @@ if(isset($_POST['add_transfer'])){
$account_to = intval($_POST['account_to']);
$notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']));
mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$date', expense_amount = '$amount', vendor_id = 0, category_id = 0, account_id = $account_from, expense_created_at = NOW(), company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$date', expense_amount = '$amount', expense_currency_code = '$config_default_currency', vendor_id = 0, category_id = 0, account_id = $account_from, expense_created_at = NOW(), company_id = $session_company_id");
$expense_id = mysqli_insert_id($mysqli);
mysqli_query($mysqli,"INSERT INTO revenues SET revenue_date = '$date', revenue_amount = '$amount', account_id = $account_to, category_id = 0, revenue_created_at = NOW(), company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO revenues SET revenue_date = '$date', revenue_amount = '$amount', revenue_currency_code = '$config_default_currency', account_id = $account_to, category_id = 0, revenue_created_at = NOW(), company_id = $session_company_id");
$revenue_id = mysqli_insert_id($mysqli);
mysqli_query($mysqli,"INSERT INTO transfers SET expense_id = $expense_id, revenue_id = $revenue_id, transfer_notes = '$notes', transfer_created_at = NOW(), company_id = $session_company_id");