diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 8801eda1a129..81772a8beed4 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -71,6 +71,7 @@ class BaseController extends Controller 'company.clients.gateway_tokens', 'company.clients.documents', 'company.products', + 'company.products.documents', 'company.recurring_invoices', 'company.invoices.invitations.contact', 'company.invoices.invitations.company', @@ -92,6 +93,7 @@ class BaseController extends Controller 'company.tasks', 'company.projects', 'company.designs', + 'company.documents', 'company.webhooks', 'company.tokens_hashed', ]; @@ -202,7 +204,7 @@ class BaseController extends Controller $query->with( [ 'company' => function ($query) use ($updated_at) { - $query->whereNotNull('updated_at'); + $query->whereNotNull('updated_at')->with('documents'); }, 'company.clients' => function ($query) use ($updated_at) { $query->where('clients.updated_at', '>=', $updated_at)->with('contacts', 'gateway_tokens','documents'); @@ -217,7 +219,7 @@ class BaseController extends Controller $query->whereNotNull('updated_at'); }, 'company.products' => function ($query) use ($updated_at) { - $query->where('updated_at', '>=', $updated_at); + $query->where('updated_at', '>=', $updated_at)->with('documents'); }, 'company.recurring_invoices'=> function ($query) use ($updated_at) { $query->where('updated_at', '>=', $updated_at)->with('company'); diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 97cdf2b47193..32302359ad29 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -700,7 +700,7 @@ class InvoiceController extends BaseController } break; case 'email': - //check query paramater for email_type and set the template else use calculateTemplate + //check query parameter for email_type and set the template else use calculateTemplate if (request()->has('email_type') && property_exists($invoice->company->settings, request()->input('email_type'))) { $this->reminder_template = $invoice->client->getSetting(request()->input('email_type')); } else { diff --git a/app/Jobs/User/UserEmailChanged.php b/app/Jobs/User/UserEmailChanged.php index 6c3cb939b036..8043d4e2232c 100644 --- a/app/Jobs/User/UserEmailChanged.php +++ b/app/Jobs/User/UserEmailChanged.php @@ -92,6 +92,7 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue 'button' => ctrans('texts.account_login'), 'signature' => $this->company->owner()->signature, 'logo' => $this->company->present()->logo(), + 'settings' => $this->settings, ]; } } diff --git a/app/Jobs/Util/SendFailedEmails.php b/app/Jobs/Util/SendFailedEmails.php index e9975213e0ef..329ed566c00b 100644 --- a/app/Jobs/Util/SendFailedEmails.php +++ b/app/Jobs/Util/SendFailedEmails.php @@ -56,7 +56,7 @@ class SendFailedEmails implements ShouldQueue private function processEmails() { - \Log::error('processing emails'); + //\Log::error('processing emails'); //info("process emails"); //@todo check that the quota is available for the job diff --git a/app/Mail/Admin/EntitySentObject.php b/app/Mail/Admin/EntitySentObject.php index 5ebcf6a19c64..4367acda86c7 100644 --- a/app/Mail/Admin/EntitySentObject.php +++ b/app/Mail/Admin/EntitySentObject.php @@ -84,6 +84,8 @@ class EntitySentObject 'button' => ctrans("texts.view_{$this->entity_type}"), 'signature' => $settings->email_signature, 'logo' => $this->company->present()->logo(), + 'settings' => $settings, + ]; } } diff --git a/app/Mail/Admin/EntityViewedObject.php b/app/Mail/Admin/EntityViewedObject.php index e491e1566696..367c3f2de2a2 100644 --- a/app/Mail/Admin/EntityViewedObject.php +++ b/app/Mail/Admin/EntityViewedObject.php @@ -84,6 +84,8 @@ class EntityViewedObject 'button' => ctrans("texts.view_{$this->entity_type}"), 'signature' => $settings->email_signature, 'logo' => $this->company->present()->logo(), + 'settings' => $settings, + ]; return $data; diff --git a/app/Mail/Admin/PaymentFailureObject.php b/app/Mail/Admin/PaymentFailureObject.php index 08077206bfdd..12e041740f05 100644 --- a/app/Mail/Admin/PaymentFailureObject.php +++ b/app/Mail/Admin/PaymentFailureObject.php @@ -76,6 +76,8 @@ class PaymentFailureObject ), 'signature' => $signature, 'logo' => $this->company->present()->logo(), + 'settings' => $this->client->getMergedSettings(), + ]; return $data; diff --git a/app/Notifications/Admin/EntitySentNotification.php b/app/Notifications/Admin/EntitySentNotification.php index ec5680a4582a..dead3b4eae8f 100644 --- a/app/Notifications/Admin/EntitySentNotification.php +++ b/app/Notifications/Admin/EntitySentNotification.php @@ -1,4 +1,13 @@ ctrans('texts.view_'.$this->entity_string), 'logo' => $this->entity->company->present()->logo(), 'signature' => $this->settings->email_signature, + 'settings' => $this->settings, ]; diff --git a/app/Notifications/ClientContactRequestCancellation.php b/app/Notifications/ClientContactRequestCancellation.php index 25c2fcce0ddc..927b07e25802 100644 --- a/app/Notifications/ClientContactRequestCancellation.php +++ b/app/Notifications/ClientContactRequestCancellation.php @@ -1,4 +1,13 @@ [ InvoicePaidActivity::class, + CreateInvoicePdf::class, ], InvoiceWasViewed::class => [ InvoiceViewedActivity::class, @@ -238,6 +239,7 @@ class EventServiceProvider extends ServiceProvider ], InvoiceWasDeleted::class => [ InvoiceDeletedActivity::class, + CreateInvoicePdf::class, ], InvoiceWasArchived::class => [ InvoiceArchivedActivity::class, @@ -247,6 +249,7 @@ class EventServiceProvider extends ServiceProvider ], InvoiceWasReversed::class => [ InvoiceReversedActivity::class, + CreateInvoicePdf::class, ], InvoiceWasCancelled::class => [ InvoiceCancelledActivity::class, diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 9e027a98f381..a7e52f7d63ce 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -206,6 +206,9 @@ class InvoiceService if($this->invoice->balance == 0) $this->setStatus(Invoice::STATUS_PAID); + if($this->invoice->balance > 0 && $this->invoice->balance < $this->invoice->amount) + $this->setStatus(Invoice::STATUS_PARTIAL); + return $this; } diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index ed6c69d316c2..341e3c746595 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -73,6 +73,8 @@ class UpdateInvoicePayment $pivot_invoice->pivot->amount = $paid_amount; $pivot_invoice->pivot->save(); + $this->payment->applied += $paid_amount; + $invoice->service() //caution what if we amount paid was less than partial - we wipe it! ->clearPartial() ->updateBalance($paid_amount * -1) @@ -82,6 +84,8 @@ class UpdateInvoicePayment event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars())); }); + + $this->payment->save(); return $this->payment; } diff --git a/app/Utils/ClientPortal/CustomMessage/CustomMessage.php b/app/Utils/ClientPortal/CustomMessage/CustomMessage.php index 649370b62f0f..ca298cf3a701 100644 --- a/app/Utils/ClientPortal/CustomMessage/CustomMessage.php +++ b/app/Utils/ClientPortal/CustomMessage/CustomMessage.php @@ -1,4 +1,13 @@
+ +
+
+ {{ ctrans('texts.subtotal') }} +
+
+ {{ App\Utils\Number::formatMoney($total['invoice_totals'], $client) }} +
+
+ {{ ctrans('texts.gateway_fees') }} +
+
+ {{ App\Utils\Number::formatMoney($total['fee_total'], $client) }} +
+
+ {{ ctrans('texts.total') }} +
+
+ {{ App\Utils\Number::formatMoney($total['amount_with_fee'], $client) }} +
+
+ @if($token)