diff --git a/VERSION.txt b/VERSION.txt index f810c24459ff..c850dd977c51 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 92a0ae31a2cc..31c90f38e32d 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 83b99932aafb..b85683a4a8e8 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -901,6 +901,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 @@ -911,6 +915,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/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index 1cf9476d4ed2..72b07d70d075 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 cac419fb3e71..78d233d357bd 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/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index eea48ba3974e..fd818c726428 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 564d84f37b2a..3e5db3db72d0 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 ccfd3e25cd1c..1cfe1b5bdd48 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 a8b6d17b2481..d95d7365bd6c 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/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 635fc002e99d..c4d6cf6fe0db 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 299e67c66820..7caef9120046 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 f66926c193c2..186f03091ab8 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -21,7 +21,7 @@