diff --git a/VERSION.txt b/VERSION.txt index f810c24459..c850dd977c 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.18 \ No newline at end of file +5.5.19 \ No newline at end of file diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 92a0ae31a2..31c90f38e3 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -436,9 +436,12 @@ class CompanySettings extends BaseSettings public $auto_archive_invoice_cancelled = false; - public $vendor_portal_enable_uploads=false; + public $vendor_portal_enable_uploads = false; + + public $send_email_on_mark_paid = false; public static $casts = [ + 'send_email_on_mark_paid' => 'bool', 'vendor_portal_enable_uploads' => 'bool', 'besr_id' => 'string', 'qr_iban' => 'string', diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index a2695f0c6d..ea6b7d56f0 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -900,6 +900,10 @@ class BaseController extends Controller return redirect('/')->with(['signup' => 'true']); } + $canvas_path_array = parse_url(config('ninja.app_url')); + + $canvas_path = (array_key_exists('path', $canvas_path_array)) ? $canvas_path_array['path'] : ''; + $data = []; //pass report errors bool to front end @@ -910,6 +914,7 @@ class BaseController extends Controller $data['build'] = request()->has('build') ? request()->input('build') : ''; $data['login'] = request()->has('login') ? request()->input('login') : 'false'; $data['signup'] = request()->has('signup') ? request()->input('signup') : 'false'; + $data['canvas_path'] = $canvas_path; if (request()->session()->has('login')) { $data['login'] = 'true'; diff --git a/app/Http/Livewire/SubscriptionPlanSwitch.php b/app/Http/Livewire/SubscriptionPlanSwitch.php index c1ea73efeb..aac8816624 100644 --- a/app/Http/Livewire/SubscriptionPlanSwitch.php +++ b/app/Http/Livewire/SubscriptionPlanSwitch.php @@ -56,6 +56,7 @@ class SubscriptionPlanSwitch extends Component */ public $total; + public $hide_button = false; /** * @var array */ @@ -139,12 +140,20 @@ class SubscriptionPlanSwitch extends Component public function handlePaymentNotRequired() { - return $this->target->service()->createChangePlanCredit([ + $this->hide_button = true; + + $response = $this->target->service()->createChangePlanCredit([ 'recurring_invoice' => $this->recurring_invoice, 'subscription' => $this->subscription, 'target' => $this->target, 'hash' => $this->hash, ]); + + $this->hide_button = true; + + $this->dispatchBrowserEvent('redirectRoute', ['route' => $response]); + + // return redirect($response); } public function render() diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index 1cf9476d4e..72b07d70d0 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -80,9 +80,9 @@ class AdjustProductInventory implements ShouldQueue $p->in_stock_quantity -= $item->quantity; $p->saveQuietly(); - if ($p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold) { + if ($this->company->stock_notification && $p->stock_notification && $p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold) { $this->notifyStockLevels($p, 'product'); - } elseif ($this->company->stock_notification_threshold && $p->in_stock_quantity <= $this->company->stock_notification_threshold) { + } elseif ($this->company->stock_notification && $p->stock_notification && $this->company->inventory_notification_threshold && $p->in_stock_quantity <= $this->company->inventory_notification_threshold) { $this->notifyStocklevels($p, 'company'); } } diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index cac419fb3e..78d233d357 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -14,8 +14,10 @@ namespace App\Jobs\Util; use App\DataMapper\InvoiceItem; use App\Events\Invoice\InvoiceWasEmailed; use App\Jobs\Entity\EmailEntity; +use App\Jobs\Ninja\TransactionLog; use App\Libraries\MultiDB; use App\Models\Invoice; +use App\Models\TransactionEvent; use App\Utils\Ninja; use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesReminders; @@ -201,10 +203,20 @@ class ReminderJob implements ShouldQueue $client = $invoice->client; $client = $client->fresh(); - nlog('adjusting client balance and invoice balance by '.($invoice->balance - $temp_invoice_balance)); + nlog('adjusting client balance and invoice balance by #'.$invoice->number.' '.($invoice->balance - $temp_invoice_balance)); $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}"); + $transaction = [ + 'invoice' => $invoice->transaction_event(), + 'payment' => [], + 'client' => $client->transaction_event(), + 'credit' => [], + 'metadata' => ['setLateFee'], + ]; + + TransactionLog::dispatch(TransactionEvent::CLIENT_STATUS, $transaction, $invoice->company->db); + return $invoice; } } diff --git a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php index b561733347..860b590602 100644 --- a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php +++ b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php @@ -74,6 +74,9 @@ class UpdatePaymentMethods { $sources = $customer->sources; + if(!property_exists($sources, 'data')) + return; + foreach ($sources->data as $method) { $token_exists = ClientGatewayToken::where([ 'gateway_customer_reference' => $customer->id, diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index eea48ba397..fd818c7264 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -88,6 +88,7 @@ class ApplyPayment extends AbstractService $this->invoice ->client + ->fresh() ->service() ->updateBalance($amount_paid) ->save(); diff --git a/app/Services/Invoice/ApplyPaymentAmount.php b/app/Services/Invoice/ApplyPaymentAmount.php index 564d84f37b..3e5db3db72 100644 --- a/app/Services/Invoice/ApplyPaymentAmount.php +++ b/app/Services/Invoice/ApplyPaymentAmount.php @@ -17,6 +17,7 @@ use App\Factory\PaymentFactory; use App\Jobs\Invoice\InvoiceWorkflowSettings; use App\Jobs\Payment\EmailPayment; use App\Libraries\Currency\Conversion\CurrencyApi; +use App\Models\Client; use App\Models\Invoice; use App\Models\Payment; use App\Services\AbstractService; @@ -87,11 +88,13 @@ class ApplyPaymentAmount extends AbstractService $this->invoice ->client + ->fresh() ->service() ->updateBalance($payment->amount * -1) ->updatePaidToDate($payment->amount) ->save(); + if ($this->invoice->client->getSetting('client_manual_payment_notification')) { $payment->service()->sendEmail(); } diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index ccfd3e25cd..1cfe1b5bdd 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -92,6 +92,9 @@ class MarkPaid extends AbstractService $payment->service()->applyNumber()->save(); + if($payment->company->getSetting('send_email_on_mark_paid')) + $payment->service()->sendEmail(); + $this->setExchangeRate($payment); /* Create a payment relationship to the invoice entity */ diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index a8b6d17b24..d95d7365bd 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -69,6 +69,7 @@ class MarkSent extends AbstractService $client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); $client->balance += $adjustment; $client->save(); + }, 1); $this->invoice->markInvitationsSent(); diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 7f74fcb9be..a79ccd9ab0 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -477,10 +477,14 @@ class SubscriptionService nlog($response); - if($credit) - return $this->handleRedirect('/client/credits/'.$credit->hashed_id); - else - return $this->handleRedirect('/client/credits'); + if($credit){ + // return $this->handleRedirect('/client/credits/'.$credit->hashed_id); + return '/client/credits/'.$credit->hashed_id; + } + else{ + // return $this->handleRedirect('/client/credits'); + return '/client/credits'; + } } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 635fc002e9..c4d6cf6fe0 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -160,7 +160,7 @@ class HtmlEngine $data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.invoice_date')]; if($this->entity->project) { - $data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project_name')]; + $data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project')]; $data['$invoice.project'] = &$data['$project.name']; } diff --git a/config/ninja.php b/config/ninja.php index 299e67c668..7caef91200 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.5.18', - 'app_tag' => '5.5.18', + 'app_version' => '5.5.19', + 'app_tag' => '5.5.19', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index f66926c193..186f03091a 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -21,7 +21,7 @@ diff --git a/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php b/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php index 3a5b764ec5..032ec9a4e3 100644 --- a/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php @@ -15,7 +15,7 @@ @if(!array_key_exists('filled', $field)) @component('portal.ninja2020.components.general.card-element', ['title' => $field['label']]) @if($field['name'] == 'client_country_id' || $field['name'] == 'client_shipping_country_id') - + @foreach($countries as $country) @@ -25,7 +25,7 @@ @endforeach @else - + @endif @if(session()->has('validation_errors') && array_key_exists($field['name'], session('validation_errors'))) diff --git a/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php b/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php index 7d53d6c5ca..8d3c0301d5 100644 --- a/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php @@ -1,3 +1,4 @@ + @@ -62,6 +63,7 @@ @elseif($amount <= 0) + {{ ctrans('texts.total') }}: {{ \App\Utils\Number::formatMoney($amount, $subscription->company) }} @@ -69,12 +71,20 @@ - - {{ ctrans('texts.click_to_continue') }} + + @if($hide_button) {{ ctrans('texts.loading') }} @else {{ ctrans('texts.click_to_continue') }} @endif - @endif + + + \ No newline at end of file