diff --git a/app/Http/Controllers/WePayController.php b/app/Http/Controllers/WePayController.php index e44103c12596..aca370b4ecc6 100644 --- a/app/Http/Controllers/WePayController.php +++ b/app/Http/Controllers/WePayController.php @@ -40,7 +40,10 @@ class WePayController extends BaseController $company = Company::where('company_key', $hash['company_key'])->firstOrFail(); $data['user_id'] = $user->id; - $data['company'] = $company; + $data['user_company'] = $company; + + // $data['company_key'] = $company->company_key; + // $data['db'] = $company->db; $wepay_driver = new WePayPaymentDriver(new CompanyGateway, null, null); diff --git a/app/Http/Requests/Client/StoreClientRequest.php b/app/Http/Requests/Client/StoreClientRequest.php index 48e4d095c36d..0f77f3348ef2 100644 --- a/app/Http/Requests/Client/StoreClientRequest.php +++ b/app/Http/Requests/Client/StoreClientRequest.php @@ -158,6 +158,10 @@ class StoreClientRequest extends Request unset($input['number']); } + if (array_key_exists('name', $input)) { + $input['name'] = strip_tags($input['name']); + } + $this->replace($input); } diff --git a/app/Http/Requests/Client/UpdateClientRequest.php b/app/Http/Requests/Client/UpdateClientRequest.php index cf0da48a6926..c95f3592331f 100644 --- a/app/Http/Requests/Client/UpdateClientRequest.php +++ b/app/Http/Requests/Client/UpdateClientRequest.php @@ -112,6 +112,10 @@ class UpdateClientRequest extends Request $input['settings'] = $this->filterSaveableSettings($input['settings']); } + if (array_key_exists('name', $input)) { + $input['name'] = strip_tags($input['name']); + } + $this->replace($input); } diff --git a/app/Http/Requests/Company/StoreCompanyRequest.php b/app/Http/Requests/Company/StoreCompanyRequest.php index da6b9b141f9d..f60ca455e93e 100644 --- a/app/Http/Requests/Company/StoreCompanyRequest.php +++ b/app/Http/Requests/Company/StoreCompanyRequest.php @@ -65,15 +65,15 @@ class StoreCompanyRequest extends Request $input['google_analytics_key'] = $input['google_analytics_url']; } - $company_settings = CompanySettings::defaults(); + // $company_settings = CompanySettings::defaults(); //@todo this code doesn't make sense as we never return $company_settings anywhere //@deprecated??? - if (array_key_exists('settings', $input) && ! empty($input['settings'])) { - foreach ($input['settings'] as $key => $value) { - $company_settings->{$key} = $value; - } - } + // if (array_key_exists('settings', $input) && ! empty($input['settings'])) { + // foreach ($input['settings'] as $key => $value) { + // $company_settings->{$key} = $value; + // } + // } if (array_key_exists('portal_domain', $input)) { $input['portal_domain'] = strtolower($input['portal_domain']); diff --git a/app/Http/Requests/User/StoreUserRequest.php b/app/Http/Requests/User/StoreUserRequest.php index dfd752d1e09c..57d8baf4b465 100644 --- a/app/Http/Requests/User/StoreUserRequest.php +++ b/app/Http/Requests/User/StoreUserRequest.php @@ -85,6 +85,14 @@ class StoreUserRequest extends Request ]; } + if (array_key_exists('first_name', $input)) { + $input['first_name'] = strip_tags($input['first_name']); + } + + if (array_key_exists('last_name', $input)) { + $input['last_name'] = strip_tags($input['last_name']); + } + $this->replace($input); } diff --git a/app/Http/Requests/User/UpdateUserRequest.php b/app/Http/Requests/User/UpdateUserRequest.php index 42fa3f66e82e..2e2a95bb7f7b 100644 --- a/app/Http/Requests/User/UpdateUserRequest.php +++ b/app/Http/Requests/User/UpdateUserRequest.php @@ -49,6 +49,14 @@ class UpdateUserRequest extends Request $input['email'] = trim($input['email']); } + if (array_key_exists('first_name', $input)) { + $input['first_name'] = strip_tags($input['first_name']); + } + + if (array_key_exists('last_name', $input)) { + $input['last_name'] = strip_tags($input['last_name']); + } + $this->replace($input); } } diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index 72b07d70d075..49cba52cecfb 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -37,7 +37,7 @@ class AdjustProductInventory implements ShouldQueue public array $old_invoice; - public function __construct(Company $company, Invoice $invoice, ?array $old_invoice = []) + public function __construct(Company $company, Invoice $invoice, $old_invoice = []) { $this->company = $company; $this->invoice = $invoice; diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index d4b840c547d3..e0ef5317e617 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -91,7 +91,8 @@ class TemplateEmail extends Mailable if (strlen($settings->bcc_email) > 1) { if (Ninja::isHosted()) { $bccs = explode(',', str_replace(' ', '', $settings->bcc_email)); - $this->bcc(reset($bccs)); //remove whitespace if any has been inserted. + $this->bcc(array_slice($bccs, 0, 2)); + //$this->bcc(reset($bccs)); //remove whitespace if any has been inserted. } else { $this->bcc(explode(',', str_replace(' ', '', $settings->bcc_email))); }//remove whitespace if any has been inserted. @@ -116,11 +117,6 @@ class TemplateEmail extends Mailable 'whitelabel' => $this->client->user->account->isPaid() ? true : false, 'logo' => $this->company->present()->logo($settings), ]); - // ->withSymfonyMessage(function ($message) use ($company) { - // $message->getHeaders()->addTextHeader('Tag', $company->company_key); - // $message->invitation = $this->invitation; - //}); - // ->tag($company->company_key); /*In the hosted platform we need to slow things down a little for Storage to catch up.*/ diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index 426f96717f71..62193cfcc95d 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -53,6 +53,8 @@ class ACH public function authorizeView(array $data) { + $data['gateway'] = $this->forte; + return render('gateways.forte.ach.authorize', $data); } @@ -81,7 +83,7 @@ class ACH $this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data); $this->forte->payment_hash->save(); - $data['gateway'] = $this; + $data['gateway'] = $this->forte; return render('gateways.forte.ach.pay', $data); } diff --git a/app/PaymentDrivers/WePay/ACH.php b/app/PaymentDrivers/WePay/ACH.php index 5773978b1864..a4703e47875e 100644 --- a/app/PaymentDrivers/WePay/ACH.php +++ b/app/PaymentDrivers/WePay/ACH.php @@ -41,6 +41,7 @@ class ACH public function authorizeView($data) { $data['gateway'] = $this->wepay_payment_driver; + $data['country_code'] = $this->wepay_payment_driver->client ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2; return render('gateways.wepay.authorize.bank_transfer', $data); } diff --git a/app/PaymentDrivers/WePay/Setup.php b/app/PaymentDrivers/WePay/Setup.php index ade6c25676f5..d5e6156219b2 100644 --- a/app/PaymentDrivers/WePay/Setup.php +++ b/app/PaymentDrivers/WePay/Setup.php @@ -27,7 +27,7 @@ class Setup { /* 'user_id', - 'company', + 'user_company', */ return render('gateways.wepay.signup.index', $data); diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index a04aa04fe9a9..6454919238de 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -33,17 +33,29 @@ class DeletePayment public function run() { - if ($this->payment->is_deleted) { - return $this->payment; - } - return $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment - ->updateCreditables() //return the credits first - ->adjustInvoices() - ->updateClient() - ->deletePaymentables() - ->cleanupPayment() - ->save(); + \DB::connection(config('database.default'))->transaction(function () { + + + if ($this->payment->is_deleted) { + return $this->payment; + } + + $this->payment = Payment::withTrashed()->where('id', $this->payment->id)->lockForUpdate()->first(); + + $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment + ->updateCreditables() //return the credits first + ->adjustInvoices() + ->updateClient() + ->deletePaymentables() + ->cleanupPayment() + ->save(); + + + }, 2); + + return $this->payment; + } private function cleanupPayment() diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index 1c94970f8424..a3ba8bd67038 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -114,6 +114,22 @@ class Helpers return ''; } + // 04-10-2022 Return Early if no reserved keywords are present, this is a very expenseive process + $string_hit = false; + + foreach ( [':MONTH',':YEAR',':QUARTER',':WEEK'] as $string ) + { + + if(stripos($value, $string) !== FALSE) { + $string_hit = true; + } + + } + + if(!$string_hit) + return $value; + // 04-10-2022 Return Early if no reserved keywords are present, this is a very expenseive process + Carbon::setLocale($entity->locale()); $replacements = [ diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index 30c8a58f7b33..5579207fc897 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -421,7 +421,6 @@ trait GeneratesCounter $check_counter = 1; do { - nlog($counter); $number = $this->padCounter($counter, $padding); diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index 9a4bd3b6c29f..055b7698bf09 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -264,7 +264,8 @@ trait MakesInvoiceValues * @return array */ public function transformLineItems($items, $table_type = '$product') :array - { + { //$start = microtime(true); + $entity = $this->client ? $this->client : $this->company; $data = []; @@ -274,6 +275,8 @@ trait MakesInvoiceValues $locale_info = localeconv(); + $entity_currency = $entity->currency(); + foreach ($items as $key => $item) { if ($table_type == '$product' && $item->type_id != 1) { if ($item->type_id != 4 && $item->type_id != 6 && $item->type_id != 5) { @@ -297,13 +300,13 @@ trait MakesInvoiceValues $data[$key][$table_type.'.notes'] = Helpers::processReservedKeywords($item->notes, $entity); $data[$key][$table_type.'.description'] = Helpers::processReservedKeywords($item->notes, $entity); - $data[$key][$table_type.".{$_table_type}1"] = $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}1", $item->custom_value1, $entity); - $data[$key][$table_type.".{$_table_type}2"] = $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}2", $item->custom_value2, $entity); - $data[$key][$table_type.".{$_table_type}3"] = $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}3", $item->custom_value3, $entity); - $data[$key][$table_type.".{$_table_type}4"] = $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}4", $item->custom_value4, $entity); + $data[$key][$table_type.".{$_table_type}1"] = strlen($item->custom_value1) > 1 ? $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}1", $item->custom_value1, $entity) : ''; + $data[$key][$table_type.".{$_table_type}2"] = strlen($item->custom_value1) > 2 ? $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}2", $item->custom_value2, $entity) : ''; + $data[$key][$table_type.".{$_table_type}3"] = strlen($item->custom_value1) > 3 ? $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}3", $item->custom_value3, $entity) : ''; + $data[$key][$table_type.".{$_table_type}4"] = strlen($item->custom_value1) > 4 ? $helpers->formatCustomFieldValue($this->company->custom_fields, "{$_table_type}4", $item->custom_value4, $entity) : ''; if ($item->quantity > 0 || $item->cost > 0) { - $data[$key][$table_type.'.quantity'] = Number::formatValueNoTrailingZeroes($item->quantity, $entity->currency()); + $data[$key][$table_type.'.quantity'] = Number::formatValueNoTrailingZeroes($item->quantity, $entity_currency); $data[$key][$table_type.'.unit_cost'] = Number::formatMoneyNoRounding($item->cost, $entity); @@ -357,6 +360,8 @@ trait MakesInvoiceValues $data[$key]['task_id'] = property_exists($item, 'task_id') ? $item->task_id : ''; } + //nlog(microtime(true) - $start); + return $data; } diff --git a/database/migrations/2022_10_05_205645_add_indexes_to_client_hash.php b/database/migrations/2022_10_05_205645_add_indexes_to_client_hash.php new file mode 100644 index 000000000000..09658b6e71ed --- /dev/null +++ b/database/migrations/2022_10_05_205645_add_indexes_to_client_hash.php @@ -0,0 +1,41 @@ +index([\DB::raw('client_hash(20)')]); + }); + + + Schema::table('client_contacts', function (Blueprint $table) { + $table->index([\DB::raw('contact_key(20)')]); + $table->index('email'); + }); + + Schema::table('vendor_contacts', function (Blueprint $table) { + $table->index([\DB::raw('contact_key(20)')]); + $table->index('email'); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + } +}; diff --git a/database/schema/mysql-schema.dump b/database/schema/mysql-schema.dump index bb4351fe5ebd..1513db183e2b 100644 --- a/database/schema/mysql-schema.dump +++ b/database/schema/mysql-schema.dump @@ -41,6 +41,12 @@ CREATE TABLE `accounts` ( `hosted_client_count` int(10) unsigned DEFAULT NULL, `hosted_company_count` int(10) unsigned DEFAULT NULL, `inapp_transaction_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `set_react_as_default_ap` tinyint(1) NOT NULL DEFAULT 0, + `is_flagged` tinyint(1) NOT NULL DEFAULT 0, + `is_verified_account` tinyint(1) NOT NULL DEFAULT 0, + `account_sms_verification_code` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `account_sms_verification_number` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `account_sms_verified` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `accounts_payment_id_index` (`payment_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -75,6 +81,8 @@ CREATE TABLE `activities` ( `recurring_invoice_id` int(10) unsigned DEFAULT NULL, `recurring_expense_id` int(10) unsigned DEFAULT NULL, `recurring_quote_id` int(10) unsigned DEFAULT NULL, + `purchase_order_id` int(10) unsigned DEFAULT NULL, + `vendor_contact_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `activities_vendor_id_company_id_index` (`vendor_id`,`company_id`), KEY `activities_project_id_company_id_index` (`project_id`,`company_id`), @@ -88,6 +96,10 @@ CREATE TABLE `activities` ( KEY `activities_expense_id_company_id_index` (`expense_id`,`company_id`), KEY `activities_client_contact_id_company_id_index` (`client_contact_id`,`company_id`), KEY `activities_company_id_foreign` (`company_id`), + KEY `activities_quote_id_company_id_index` (`quote_id`,`company_id`), + KEY `activities_recurring_invoice_id_company_id_index` (`recurring_invoice_id`,`company_id`), + KEY `activities_purchase_order_id_company_id_index` (`purchase_order_id`,`company_id`), + KEY `activities_vendor_contact_id_company_id_index` (`vendor_contact_id`,`company_id`), CONSTRAINT `activities_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -210,6 +222,8 @@ CREATE TABLE `client_contacts` ( KEY `client_contacts_company_id_index` (`company_id`), KEY `client_contacts_client_id_index` (`client_id`), KEY `client_contacts_user_id_index` (`user_id`), + KEY `client_contacts_contact_key(20)_index` (`contact_key`(20)), + KEY `client_contacts_email_index` (`email`), CONSTRAINT `client_contacts_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -321,6 +335,7 @@ CREATE TABLE `clients` ( KEY `clients_size_id_foreign` (`size_id`), KEY `clients_company_id_index` (`company_id`), KEY `clients_user_id_index` (`user_id`), + KEY `clients_client_hash(20)_index` (`client_hash`(20)), CONSTRAINT `clients_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clients_industry_id_foreign` FOREIGN KEY (`industry_id`) REFERENCES `industries` (`id`), CONSTRAINT `clients_size_id_foreign` FOREIGN KEY (`size_id`) REFERENCES `sizes` (`id`) @@ -393,6 +408,13 @@ CREATE TABLE `companies` ( `markdown_email_enabled` tinyint(1) NOT NULL DEFAULT 0, `stop_on_unpaid_recurring` tinyint(1) NOT NULL DEFAULT 0, `use_quote_terms_on_conversion` tinyint(1) NOT NULL DEFAULT 0, + `enable_applying_payments` tinyint(1) NOT NULL DEFAULT 0, + `track_inventory` tinyint(1) NOT NULL DEFAULT 0, + `inventory_notification_threshold` int(11) NOT NULL DEFAULT 0, + `stock_notification` tinyint(1) NOT NULL DEFAULT 1, + `enabled_expense_tax_rates` int(10) unsigned NOT NULL DEFAULT 0, + `invoice_task_project` tinyint(1) NOT NULL DEFAULT 0, + `report_include_deleted` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `companies_company_key_unique` (`company_key`), KEY `companies_industry_id_foreign` (`industry_id`), @@ -833,12 +855,14 @@ DROP TABLE IF EXISTS `failed_jobs`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `failed_jobs` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `uuid` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `connection` text COLLATE utf8mb4_unicode_ci NOT NULL, `queue` text COLLATE utf8mb4_unicode_ci NOT NULL, `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `failed_at` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `gateway_types`; @@ -1009,6 +1033,8 @@ CREATE TABLE `invoices` ( KEY `invoices_company_id_deleted_at_index` (`company_id`,`deleted_at`), KEY `invoices_client_id_index` (`client_id`), KEY `invoices_company_id_index` (`company_id`), + KEY `invoices_recurring_id_index` (`recurring_id`), + KEY `invoices_status_id_balance_index` (`status_id`,`balance`), CONSTRAINT `invoices_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoices_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -1054,6 +1080,7 @@ CREATE TABLE `licenses` ( `is_claimed` tinyint(1) DEFAULT NULL, `transaction_reference` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `product_id` int(10) unsigned DEFAULT NULL, + `recurring_invoice_id` bigint(20) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `licenses_license_key_unique` (`license_key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -1092,6 +1119,7 @@ CREATE TABLE `payment_hashes` ( `updated_at` timestamp(6) NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `payment_hashes_payment_id_foreign` (`payment_id`), + KEY `payment_hashes_hash_index` (`hash`), CONSTRAINT `payment_hashes_payment_id_foreign` FOREIGN KEY (`payment_id`) REFERENCES `payments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1152,6 +1180,7 @@ CREATE TABLE `paymentables` ( `deleted_at` timestamp(6) NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `paymentables_payment_id_foreign` (`payment_id`), + KEY `paymentables_paymentable_id_index` (`paymentable_id`), CONSTRAINT `paymentables_payment_id_foreign` FOREIGN KEY (`payment_id`) REFERENCES `payments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1193,8 +1222,10 @@ CREATE TABLE `payments` ( `custom_value2` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `custom_value3` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `custom_value4` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `idempotency_key` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `payments_company_id_number_unique` (`company_id`,`number`), + UNIQUE KEY `payments_company_id_idempotency_key_unique` (`company_id`,`idempotency_key`), KEY `payments_company_id_deleted_at_index` (`company_id`,`deleted_at`), KEY `payments_client_contact_id_foreign` (`client_contact_id`), KEY `payments_company_gateway_id_foreign` (`company_gateway_id`), @@ -1202,6 +1233,8 @@ CREATE TABLE `payments` ( KEY `payments_company_id_index` (`company_id`), KEY `payments_client_id_index` (`client_id`), KEY `payments_status_id_index` (`status_id`), + KEY `payments_transaction_reference_index` (`transaction_reference`), + KEY `payments_idempotency_key_index` (`idempotency_key`), CONSTRAINT `payments_client_contact_id_foreign` FOREIGN KEY (`client_contact_id`) REFERENCES `client_contacts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `payments_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `payments_company_gateway_id_foreign` FOREIGN KEY (`company_gateway_id`) REFERENCES `company_gateways` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -1238,10 +1271,14 @@ CREATE TABLE `products` ( `created_at` timestamp(6) NULL DEFAULT NULL, `updated_at` timestamp(6) NULL DEFAULT NULL, `is_deleted` tinyint(1) NOT NULL DEFAULT 0, + `in_stock_quantity` int(11) NOT NULL DEFAULT 0, + `stock_notification` tinyint(1) NOT NULL DEFAULT 1, + `stock_notification_threshold` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `products_company_id_deleted_at_index` (`company_id`,`deleted_at`), KEY `products_user_id_foreign` (`user_id`), KEY `products_company_id_index` (`company_id`), + KEY `pro_co_us_up_index` (`company_id`,`user_id`,`assigned_user_id`,`updated_at`), CONSTRAINT `products_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `products_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -1280,6 +1317,118 @@ CREATE TABLE `projects` ( CONSTRAINT `projects_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `purchase_order_invitations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `purchase_order_invitations` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `company_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `vendor_contact_id` int(10) unsigned NOT NULL, + `purchase_order_id` bigint(20) unsigned NOT NULL, + `key` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, + `transaction_reference` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `message_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `email_error` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `signature_base64` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `signature_date` datetime DEFAULT NULL, + `sent_date` datetime DEFAULT NULL, + `viewed_date` datetime DEFAULT NULL, + `opened_date` datetime DEFAULT NULL, + `created_at` timestamp(6) NULL DEFAULT NULL, + `updated_at` timestamp(6) NULL DEFAULT NULL, + `deleted_at` timestamp(6) NULL DEFAULT NULL, + `email_status` enum('delivered','bounced','spam') COLLATE utf8mb4_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `vendor_purchase_unique` (`vendor_contact_id`,`purchase_order_id`), + KEY `purchase_order_invitations_user_id_foreign` (`user_id`), + KEY `purchase_order_invitations_company_id_foreign` (`company_id`), + KEY `vendor_purchase_company_index` (`deleted_at`,`purchase_order_id`,`company_id`), + KEY `purchase_order_invitations_purchase_order_id_index` (`purchase_order_id`), + KEY `purchase_order_invitations_key_index` (`key`), + KEY `purchase_order_invitations_message_id_index` (`message_id`), + CONSTRAINT `purchase_order_invitations_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `purchase_order_invitations_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `purchase_order_invitations_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `purchase_order_invitations_vendor_contact_id_foreign` FOREIGN KEY (`vendor_contact_id`) REFERENCES `vendor_contacts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `purchase_orders`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `purchase_orders` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `client_id` int(10) unsigned DEFAULT NULL, + `user_id` int(10) unsigned NOT NULL, + `assigned_user_id` int(10) unsigned DEFAULT NULL, + `company_id` int(10) unsigned NOT NULL, + `status_id` int(10) unsigned NOT NULL, + `project_id` int(10) unsigned DEFAULT NULL, + `vendor_id` int(10) unsigned DEFAULT NULL, + `recurring_id` int(10) unsigned DEFAULT NULL, + `design_id` int(10) unsigned DEFAULT NULL, + `invoice_id` int(10) unsigned DEFAULT NULL, + `number` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `discount` double(8,2) NOT NULL DEFAULT 0.00, + `is_amount_discount` tinyint(1) NOT NULL DEFAULT 0, + `po_number` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `date` date DEFAULT NULL, + `last_sent_date` datetime DEFAULT NULL, + `due_date` date DEFAULT NULL, + `is_deleted` tinyint(1) NOT NULL DEFAULT 0, + `line_items` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `backup` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `footer` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `public_notes` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `private_notes` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `terms` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `tax_name1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `tax_rate1` decimal(20,6) NOT NULL DEFAULT 0.000000, + `tax_name2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `tax_rate2` decimal(20,6) NOT NULL DEFAULT 0.000000, + `tax_name3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `tax_rate3` decimal(20,6) NOT NULL DEFAULT 0.000000, + `total_taxes` decimal(20,6) NOT NULL DEFAULT 0.000000, + `uses_inclusive_taxes` tinyint(1) NOT NULL DEFAULT 0, + `reminder1_sent` date DEFAULT NULL, + `reminder2_sent` date DEFAULT NULL, + `reminder3_sent` date DEFAULT NULL, + `reminder_last_sent` date DEFAULT NULL, + `custom_value1` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `custom_value2` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `custom_value3` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `custom_value4` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `next_send_date` datetime DEFAULT NULL, + `custom_surcharge1` decimal(20,6) DEFAULT NULL, + `custom_surcharge2` decimal(20,6) DEFAULT NULL, + `custom_surcharge3` decimal(20,6) DEFAULT NULL, + `custom_surcharge4` decimal(20,6) DEFAULT NULL, + `custom_surcharge_tax1` tinyint(1) NOT NULL DEFAULT 0, + `custom_surcharge_tax2` tinyint(1) NOT NULL DEFAULT 0, + `custom_surcharge_tax3` tinyint(1) NOT NULL DEFAULT 0, + `custom_surcharge_tax4` tinyint(1) NOT NULL DEFAULT 0, + `exchange_rate` decimal(20,6) NOT NULL DEFAULT 1.000000, + `balance` decimal(20,6) NOT NULL, + `partial` decimal(20,6) DEFAULT NULL, + `amount` decimal(20,6) NOT NULL, + `paid_to_date` decimal(20,6) NOT NULL DEFAULT 0.000000, + `partial_due_date` datetime DEFAULT NULL, + `last_viewed` datetime DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `expense_id` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `purchase_orders_user_id_foreign` (`user_id`), + KEY `purchase_orders_company_id_deleted_at_index` (`company_id`,`deleted_at`), + KEY `purchase_orders_client_id_index` (`client_id`), + KEY `purchase_orders_company_id_index` (`company_id`), + KEY `purchase_orders_expense_id_index` (`expense_id`), + CONSTRAINT `purchase_orders_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `purchase_orders_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `purchase_orders_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `quote_invitations`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -1388,6 +1537,7 @@ CREATE TABLE `quotes` ( KEY `quotes_company_id_deleted_at_index` (`company_id`,`deleted_at`), KEY `quotes_client_id_index` (`client_id`), KEY `quotes_company_id_index` (`company_id`), + KEY `quotes_company_id_updated_at_index` (`company_id`,`updated_at`), CONSTRAINT `quotes_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `quotes_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `quotes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -1447,6 +1597,7 @@ CREATE TABLE `recurring_expenses` ( `last_sent_date` datetime DEFAULT NULL, `next_send_date` datetime DEFAULT NULL, `remaining_cycles` int(11) DEFAULT NULL, + `next_send_date_client` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `recurring_expenses_company_id_number_unique` (`company_id`,`number`), KEY `recurring_expenses_company_id_deleted_at_index` (`company_id`,`deleted_at`), @@ -1555,6 +1706,7 @@ CREATE TABLE `recurring_invoices` ( `exchange_rate` decimal(13,6) NOT NULL DEFAULT 1.000000, `paid_to_date` decimal(20,6) NOT NULL DEFAULT 0.000000, `subscription_id` int(10) unsigned DEFAULT NULL, + `next_send_date_client` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `recurring_invoices_company_id_number_unique` (`company_id`,`number`), KEY `recurring_invoices_company_id_deleted_at_index` (`company_id`,`deleted_at`), @@ -1676,6 +1828,27 @@ CREATE TABLE `recurring_quotes` ( CONSTRAINT `recurring_quotes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `schedulers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schedulers` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `paused` tinyint(1) NOT NULL DEFAULT 0, + `is_deleted` tinyint(1) NOT NULL DEFAULT 0, + `repeat_every` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, + `start_from` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `scheduled_run` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `company_id` bigint(20) unsigned NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `action_name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, + `action_class` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, + `parameters` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `schedulers_action_name_index` (`action_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `sizes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -1917,9 +2090,10 @@ CREATE TABLE `users` ( `created_at` timestamp(6) NULL DEFAULT NULL, `updated_at` timestamp(6) NULL DEFAULT NULL, `deleted_at` timestamp(6) NULL DEFAULT NULL, - `oauth_user_refresh_token` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `oauth_user_refresh_token` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `last_confirmed_email_address` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `has_password` tinyint(1) NOT NULL DEFAULT 0, + `oauth_user_token_expiry` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `users_email_unique` (`email`), UNIQUE KEY `users_oauth_user_id_oauth_provider_id_unique` (`oauth_user_id`,`oauth_provider_id`), @@ -1972,6 +2146,8 @@ CREATE TABLE `vendor_contacts` ( KEY `vendor_contacts_user_id_foreign` (`user_id`), KEY `vendor_contacts_vendor_id_index` (`vendor_id`), KEY `vendor_contacts_company_id_email_deleted_at_index` (`company_id`,`email`,`deleted_at`), + KEY `vendor_contacts_contact_key(20)_index` (`contact_key`(20)), + KEY `vendor_contacts_email_index` (`email`), CONSTRAINT `vendor_contacts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `vendor_contacts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `vendor_contacts_vendor_id_foreign` FOREIGN KEY (`vendor_id`) REFERENCES `vendors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -2182,3 +2358,35 @@ INSERT INTO `migrations` VALUES (128,'2022_05_08_004937_heal_stripe_gateway_conf INSERT INTO `migrations` VALUES (129,'2022_05_16_224917_add_auto_bill_tries_to_invoices_table',1); INSERT INTO `migrations` VALUES (130,'2022_05_18_055442_update_custom_value_four_columns',1); INSERT INTO `migrations` VALUES (131,'2022_05_23_050754_drop_redundant_column_show_production_description_dropdown',1); +INSERT INTO `migrations` VALUES (132,'2022_04_14_121548_forte_payment_gateway',2); +INSERT INTO `migrations` VALUES (133,'2022_05_18_162152_create_scheduled_jobs_table',2); +INSERT INTO `migrations` VALUES (134,'2022_05_18_162443_create_schedulers_table',2); +INSERT INTO `migrations` VALUES (135,'2022_05_28_234651_create_purchase_orders_table',2); +INSERT INTO `migrations` VALUES (136,'2022_05_30_181109_drop_scheduled_jobs_table',2); +INSERT INTO `migrations` VALUES (137,'2022_05_30_184320_add_job_related_fields_to_schedulers_table',2); +INSERT INTO `migrations` VALUES (138,'2022_05_31_101504_inventory_management_schema',2); +INSERT INTO `migrations` VALUES (139,'2022_06_01_215859_set_recurring_client_timestamp',2); +INSERT INTO `migrations` VALUES (140,'2022_06_01_224339_create_purchase_order_invitations_table',2); +INSERT INTO `migrations` VALUES (141,'2022_06_10_030503_set_account_flag_for_react',2); +INSERT INTO `migrations` VALUES (142,'2022_06_16_025156_add_react_switching_flag',2); +INSERT INTO `migrations` VALUES (143,'2022_06_17_082627_change_refresh_token_column_size',2); +INSERT INTO `migrations` VALUES (144,'2022_06_21_104350_fixes_for_description_in_pdf_designs',2); +INSERT INTO `migrations` VALUES (145,'2022_06_22_090547_set_oauth_expiry_column',2); +INSERT INTO `migrations` VALUES (146,'2022_06_24_141018_upgrade_failed_jobs_table',2); +INSERT INTO `migrations` VALUES (147,'2022_06_30_000126_add_flag_to_accounts_table',2); +INSERT INTO `migrations` VALUES (148,'2022_07_06_080127_add_purchase_order_to_expense',2); +INSERT INTO `migrations` VALUES (149,'2022_07_09_235510_add_index_to_payment_hash',2); +INSERT INTO `migrations` VALUES (150,'2022_07_18_033756_fixes_for_date_formats_table_react',2); +INSERT INTO `migrations` VALUES (151,'2022_07_21_023805_add_hebrew_language',2); +INSERT INTO `migrations` VALUES (152,'2022_07_26_091216_add_sms_verification_to_hosted_account',2); +INSERT INTO `migrations` VALUES (153,'2022_07_28_232340_enabled_expense_tax_rates_to_companies_table',2); +INSERT INTO `migrations` VALUES (154,'2022_07_29_091235_correction_for_companies_table_types',2); +INSERT INTO `migrations` VALUES (155,'2022_08_11_011534_licenses_table_for_self_host',2); +INSERT INTO `migrations` VALUES (156,'2022_08_24_215917_invoice_task_project_companies_table',2); +INSERT INTO `migrations` VALUES (157,'2022_08_26_232500_add_email_status_column_to_purchase_order_invitations_table',2); +INSERT INTO `migrations` VALUES (158,'2022_08_28_210111_add_index_to_payments_table',2); +INSERT INTO `migrations` VALUES (159,'2022_09_05_024719_update_designs_for_tech_template',2); +INSERT INTO `migrations` VALUES (160,'2022_09_07_101731_add_reporting_option_to_companies_table',2); +INSERT INTO `migrations` VALUES (161,'2022_09_21_012417_add_threeds_to_braintree',2); +INSERT INTO `migrations` VALUES (162,'2022_09_30_235337_add_idempotency_key_to_payments',2); +INSERT INTO `migrations` VALUES (163,'2022_10_05_205645_add_indexes_to_client_hash',2); diff --git a/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php b/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php index f898d9aaa6f8..3f0fe3077525 100644 --- a/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php +++ b/resources/views/portal/ninja2020/gateways/wepay/signup/index.blade.php @@ -7,7 +7,7 @@ We Pay - @livewire('wepay-signup', ['user_id' => $user_id, 'company' => $company]) + @livewire('wepay-signup', ['user_id' => $user_id, 'company' => $user_company]) @endsection