diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index cbb75ee2291f..1d0e3b0ca559 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -28,6 +28,7 @@ class CompanySettings extends BaseSettings public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented public $enable_client_portal_tasks = false; //@ben to implement + public $show_all_tasks_client_portal = 'all'; // all, uninvoiced, invoiced public $enable_client_portal_password = false; //@implemented public $enable_client_portal = true; //@implemented public $enable_client_portal_dashboard = false; // @TODO There currently is no dashboard so this is pending @@ -268,6 +269,7 @@ class CompanySettings extends BaseSettings public $hide_empty_columns_on_pdf = false; public static $casts = [ + 'show_all_tasks_client_portal' => 'string', 'entity_send_time' => 'int', 'shared_invoice_credit_counter' => 'bool', 'reply_to_name' => 'string', diff --git a/app/Http/Controllers/StripeConnectController.php b/app/Http/Controllers/StripeConnectController.php index d01a2f6a8206..ceb2aa4c39f3 100644 --- a/app/Http/Controllers/StripeConnectController.php +++ b/app/Http/Controllers/StripeConnectController.php @@ -1,5 +1,4 @@ gateway_key = 'd14dd26a47cecc30fdd65700bfb67b34'; $company_gateway->fees_and_limits = $fees_and_limits; $company_gateway->setConfig([]); + $company_gateway->token_billing = 'always'; // $company_gateway->save(); $payload = [ diff --git a/app/Http/Controllers/StripeController.php b/app/Http/Controllers/StripeController.php index 3976c183e12b..0c3647d76bd1 100644 --- a/app/Http/Controllers/StripeController.php +++ b/app/Http/Controllers/StripeController.php @@ -29,7 +29,6 @@ class StripeController extends BaseController } - return response()->json(['message' => 'Unauthorized'], 403); } @@ -44,7 +43,6 @@ class StripeController extends BaseController return response()->json(['message' => 'Processing'], 200); } - return response()->json(['message' => 'Unauthorized'], 403); } diff --git a/app/Http/Controllers/WePayController.php b/app/Http/Controllers/WePayController.php index b68bc0b72cfd..cd09d4dbcc4e 100644 --- a/app/Http/Controllers/WePayController.php +++ b/app/Http/Controllers/WePayController.php @@ -1,5 +1,4 @@ update_details = false; $cg->config = encrypt(config('ninja.testvars.checkout')); $cg->fees_and_limits = $fees_and_limits; + $cg->token_billing = 'always'; $cg->save(); } diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 6b9451b4877d..9e66f6dacbab 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -55,8 +55,15 @@ class QueryLogging //nlog($request->method().' - '.urldecode($request->url()).": $count queries - ".$time); // if($count > 50) //nlog($queries); + $ip = ''; - LightLogs::create(new DbQuery($request->method(), urldecode($request->url()), $count, $time, request()->ip())) + if(request()->header('Cf-Connecting-Ip')) + $ip = request()->header('Cf-Connecting-Ip'); + else{ + $ip = request()->ip(); + } + + LightLogs::create(new DbQuery($request->method(), urldecode($request->url()), $count, $time, $ip)) ->batch(); } diff --git a/app/Jobs/Cron/RecurringInvoicesCron.php b/app/Jobs/Cron/RecurringInvoicesCron.php index 8ced88244634..21df692fdef6 100644 --- a/app/Jobs/Cron/RecurringInvoicesCron.php +++ b/app/Jobs/Cron/RecurringInvoicesCron.php @@ -43,7 +43,7 @@ class RecurringInvoicesCron nlog("Sending recurring invoices ".Carbon::now()->format('Y-m-d h:i:s')); if (! config('ninja.db.multi_db_enabled')) { - $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '<=', now()) + $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '<=', now()->toDateTimeString()) ->whereNotNull('next_send_date') ->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('remaining_cycles', '!=', '0') @@ -64,7 +64,7 @@ class RecurringInvoicesCron foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); - $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '<=', now()) + $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '<=', now()->toDateTimeString()) ->whereNotNull('next_send_date') ->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('remaining_cycles', '!=', '0') diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index f9cd2e68cfea..7704940a94aa 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -55,7 +55,7 @@ class ReminderJob implements ShouldQueue { nlog("Sending invoice reminders " . now()->format('Y-m-d h:i:s')); - Invoice::whereDate('next_send_date', '<=', now()) + Invoice::whereDate('next_send_date', '<=', now()->toDateTimeString()) ->where('is_deleted', 0) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) diff --git a/app/PaymentDrivers/WePay/Setup.php b/app/PaymentDrivers/WePay/Setup.php index 3498751bf5f6..b6e062b9904c 100644 --- a/app/PaymentDrivers/WePay/Setup.php +++ b/app/PaymentDrivers/WePay/Setup.php @@ -1,5 +1,4 @@ save(); + $this->setExchangeRate($payment); + $payment->invoices()->attach($this->invoice->id, [ 'amount' => $payment->amount, ]); @@ -70,6 +74,7 @@ class MarkPaid extends AbstractService $this->invoice->next_send_date = null; $this->invoice->service() + ->setExchangeRate() ->updateBalance($payment->amount * -1) ->updatePaidToDate($payment->amount) ->setStatus(Invoice::STATUS_PAID) @@ -96,4 +101,22 @@ class MarkPaid extends AbstractService return $this->invoice; } + + private function setExchangeRate(Payment $payment) + { + + $client_currency = $payment->client->getSetting('currency_id'); + $company_currency = $payment->client->company->settings->currency_id; + + if ($company_currency != $client_currency) { + + $exchange_rate = new CurrencyApi(); + + $payment->exchange_rate = $exchange_rate->exchangeRate($client_currency, $company_currency, Carbon::parse($payment->date)); + $payment->exchange_currency_id = $client_currency; + $payment->save(); + + } + + } }