Merge pull request #4680 from turbo124/v5-develop

Refactor notifications to be more specific, ie. Invoice -> Reminder 1
This commit is contained in:
David Bomba 2021-01-14 07:48:07 +11:00 committed by GitHub
commit 1dc932b85e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 167 additions and 115 deletions

View File

@ -30,7 +30,7 @@ class CompanySettings extends BaseSettings
public $enable_client_portal_tasks = false; //@ben to implement public $enable_client_portal_tasks = false; //@ben to implement
public $enable_client_portal_password = false; //@implemented public $enable_client_portal_password = false; //@implemented
public $enable_client_portal = true; //@implemented public $enable_client_portal = true; //@implemented
public $enable_client_portal_dashboard = true; // @TODO There currently is no dashboard so this is pending public $enable_client_portal_dashboard = false; // @TODO There currently is no dashboard so this is pending
public $signature_on_pdf = false; //@implemented public $signature_on_pdf = false; //@implemented
public $document_email_attachment = false; //@TODO I assume this is 3rd party attachments on the entity to be included public $document_email_attachment = false; //@TODO I assume this is 3rd party attachments on the entity to be included
@ -634,6 +634,7 @@ class CompanySettings extends BaseSettings
'$product.description', '$product.description',
'$product.unit_cost', '$product.unit_cost',
'$product.quantity', '$product.quantity',
'$product.discount',
'$product.tax', '$product.tax',
'$product.line_total', '$product.line_total',
], ],
@ -642,6 +643,7 @@ class CompanySettings extends BaseSettings
'$task.description', '$task.description',
'$task.rate', '$task.rate',
'$task.hours', '$task.hours',
'$task.discount',
'$task.tax', '$task.tax',
'$task.line_total', '$task.line_total',
], ],

View File

@ -27,6 +27,7 @@ class CreditWasEmailed
public $event_vars; public $event_vars;
public $template;
/** /**
* Create a new event instance. * Create a new event instance.
* *
@ -34,10 +35,11 @@ class CreditWasEmailed
* @param Company $company * @param Company $company
* @param array $event_vars * @param array $event_vars
*/ */
public function __construct(CreditInvitation $invitation, Company $company, array $event_vars) public function __construct(CreditInvitation $invitation, Company $company, array $event_vars, string $template)
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
$this->company = $company; $this->company = $company;
$this->event_vars = $event_vars; $this->event_vars = $event_vars;
$this->template = $template;
} }
} }

View File

@ -31,6 +31,8 @@ class InvoiceWasEmailed
public $event_vars; public $event_vars;
public $template;
/** /**
* Create a new event instance. * Create a new event instance.
* *
@ -38,10 +40,11 @@ class InvoiceWasEmailed
* @param Company $company * @param Company $company
* @param array $event_vars * @param array $event_vars
*/ */
public function __construct(InvoiceInvitation $invitation, Company $company, array $event_vars) public function __construct(InvoiceInvitation $invitation, Company $company, array $event_vars, string $template)
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
$this->company = $company; $this->company = $company;
$this->event_vars = $event_vars; $this->event_vars = $event_vars;
$this->template = $template;
} }
} }

View File

@ -29,6 +29,7 @@ class QuoteWasEmailed
public $event_vars; public $event_vars;
public $template;
/** /**
* Create a new event instance. * Create a new event instance.
* *
@ -37,10 +38,11 @@ class QuoteWasEmailed
* @param Company $company * @param Company $company
* @param array $event_vars * @param array $event_vars
*/ */
public function __construct(QuoteInvitation $invitation, Company $company, array $event_vars) public function __construct(QuoteInvitation $invitation, Company $company, array $event_vars, string $template)
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
$this->company = $company; $this->company = $company;
$this->event_vars = $event_vars; $this->event_vars = $event_vars;
$this->template = $template;
} }
} }

View File

@ -37,7 +37,7 @@ class CloneQuoteToInvoiceFactory
$invoice->due_date = null; $invoice->due_date = null;
$invoice->partial_due_date = null; $invoice->partial_due_date = null;
$invoice->number = null; $invoice->number = null;
$invoice->date = now()->format('Y-m-d');
return $invoice; return $invoice;
} }
} }

View File

@ -22,6 +22,6 @@ class DashboardController extends Controller
*/ */
public function index() public function index()
{ {
return redirect()->route('client.invoices.index'); return $this->render('dashboard.index');
} }
} }

View File

@ -51,6 +51,7 @@ class InvitationController extends Controller
->with('contact.client') ->with('contact.client')
->firstOrFail(); ->firstOrFail();
/* Return early if we have the correct client_hash embedded */ /* Return early if we have the correct client_hash embedded */
if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) { if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) {

View File

@ -32,6 +32,7 @@ use App\Transformers\CompanyTransformer;
use App\Transformers\CompanyUserTransformer; use App\Transformers\CompanyUserTransformer;
use App\Utils\Ninja; use App\Utils\Ninja;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\Utils\Traits\SavesDocuments;
use App\Utils\Traits\Uploadable; use App\Utils\Traits\Uploadable;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -47,6 +48,7 @@ class CompanyController extends BaseController
use DispatchesJobs; use DispatchesJobs;
use MakesHash; use MakesHash;
use Uploadable; use Uploadable;
use SavesDocuments;
protected $entity_type = Company::class; protected $entity_type = Company::class;
@ -402,14 +404,17 @@ class CompanyController extends BaseController
*/ */
public function update(UpdateCompanyRequest $request, Company $company) public function update(UpdateCompanyRequest $request, Company $company)
{ {
if ($request->hasFile('company_logo') || (is_array($request->input('settings')) && !array_key_exists('company_logo', $request->input('settings')))) { if ($request->hasFile('company_logo') || (is_array($request->input('settings')) && !array_key_exists('company_logo', $request->input('settings'))))
$this->removeLogo($company); $this->removeLogo($company);
}
$company = $this->company_repo->save($request->all(), $company); $company = $this->company_repo->save($request->all(), $company);
$company->saveSettings($request->input('settings'), $company); $company->saveSettings($request->input('settings'), $company);
if ($request->has('documents'))
$this->saveDocuments($request->input('documents'), $company, false);
$this->uploadLogo($request->file('company_logo'), $company, $company); $this->uploadLogo($request->file('company_logo'), $company, $company);
return $this->itemResponse($company); return $this->itemResponse($company);

View File

@ -1,38 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers;
use Illuminate\Http\Response;
class DashboardController extends BaseController
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth:user');
}
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
// dd(json_decode(auth()->user()->permissions(),true));
return view('dashboard.index');
}
}

View File

@ -140,15 +140,13 @@ class EmailController extends BaseController
$entity_obj->save(); $entity_obj->save();
/*Only notify the admin ONCE, not once per contact/invite*/ /*Only notify the admin ONCE, not once per contact/invite*/
// $invitation = $entity_obj->invitations->first();
// EntitySentMailer::dispatch($invitation, $entity_string, $entity_obj->user, $invitation->company);
if ($entity_obj instanceof Invoice) { if ($entity_obj instanceof Invoice) {
$this->entity_type = Invoice::class; $this->entity_type = Invoice::class;
$this->entity_transformer = InvoiceTransformer::class; $this->entity_transformer = InvoiceTransformer::class;
if ($entity_obj->invitations->count() >= 1) { if ($entity_obj->invitations->count() >= 1) {
$entity_obj->entityEmailEvent($entity_obj->invitations->first(), 'invoice'); $entity_obj->entityEmailEvent($entity_obj->invitations->first(), 'invoice', $template);
} }
} }
@ -157,7 +155,7 @@ class EmailController extends BaseController
$this->entity_transformer = QuoteTransformer::class; $this->entity_transformer = QuoteTransformer::class;
if ($entity_obj->invitations->count() >= 1) { if ($entity_obj->invitations->count() >= 1) {
event(new QuoteWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars())); event(new QuoteWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars(), 'quote'));
} }
} }
@ -166,7 +164,7 @@ class EmailController extends BaseController
$this->entity_transformer = CreditTransformer::class; $this->entity_transformer = CreditTransformer::class;
if ($entity_obj->invitations->count() >= 1) { if ($entity_obj->invitations->count() >= 1) {
event(new CreditWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars())); event(new CreditWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars(), 'credit'));
} }
} }

View File

@ -426,10 +426,9 @@ class ExpenseController extends BaseController
*/ */
public function destroy(DestroyExpenseRequest $request, Expense $expense) public function destroy(DestroyExpenseRequest $request, Expense $expense)
{ {
//may not need these destroy routes as we are using actions to 'archive/delete' $this->expense_repo->delete($expense);
$expense->delete();
return response()->json([], 200); return $this->itemResponse($expense->fresh());
} }
/** /**

View File

@ -50,7 +50,7 @@ class StoreClientRequest extends Request
//$rules['name'] = 'required|min:1'; //$rules['name'] = 'required|min:1';
$rules['id_number'] = 'unique:clients,id_number,'.$this->id.',id,company_id,'.$this->company_id; $rules['id_number'] = 'unique:clients,id_number,'.$this->id.',id,company_id,'.$this->company_id;
$rules['settings'] = new ValidClientGroupSettingsRule(); $rules['settings'] = new ValidClientGroupSettingsRule();
$rules['contacts.*.email'] = 'nullable|distinct'; $rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
$rules['contacts.*.password'] = [ $rules['contacts.*.password'] = [
'nullable', 'nullable',
'sometimes', 'sometimes',

View File

@ -54,7 +54,7 @@ class UpdateClientRequest extends Request
//$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id; //$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id;
$rules['id_number'] = 'unique:clients,id_number,'.$this->id.',id,company_id,'.$this->company_id; $rules['id_number'] = 'unique:clients,id_number,'.$this->id.',id,company_id,'.$this->company_id;
$rules['settings'] = new ValidClientGroupSettingsRule(); $rules['settings'] = new ValidClientGroupSettingsRule();
$rules['contacts.*.email'] = 'nullable|distinct'; $rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
$rules['contacts.*.password'] = [ $rules['contacts.*.password'] = [
'nullable', 'nullable',
'sometimes', 'sometimes',

View File

@ -39,9 +39,9 @@ class StoreUserRequest extends Request
$rules['last_name'] = 'required|string|max:100'; $rules['last_name'] = 'required|string|max:100';
if (config('ninja.db.multi_db_enabled')) { if (config('ninja.db.multi_db_enabled')) {
$rules['email'] = [new ValidUserForCompany(), Rule::unique('users')]; $rules['email'] = ['email', new ValidUserForCompany(), Rule::unique('users')];
} else { } else {
$rules['email'] = Rule::unique('users'); $rules['email'] = ['email',Rule::unique('users')];
} }

View File

@ -35,7 +35,7 @@ class UpdateUserRequest extends Request
]; ];
if (isset($input['email'])) { if (isset($input['email'])) {
$rules['email'] = ['email:rfc,dns', 'sometimes', new UniqueUserRule($this->user, $input['email'])]; $rules['email'] = ['email', 'sometimes', new UniqueUserRule($this->user, $input['email'])];
} }
return $rules; return $rules;

View File

@ -21,6 +21,8 @@ use Illuminate\View\View;
*/ */
class PortalComposer class PortalComposer
{ {
public $settings;
/** /**
* Bind data to the view. * Bind data to the view.
* *
@ -45,13 +47,15 @@ class PortalComposer
return []; return [];
} }
$this->settings = auth()->user()->client->getMergedSettings();
$data['sidebar'] = $this->sidebarMenu(); $data['sidebar'] = $this->sidebarMenu();
$data['header'] = []; $data['header'] = [];
$data['footer'] = []; $data['footer'] = [];
$data['countries'] = TranslationHelper::getCountries(); $data['countries'] = TranslationHelper::getCountries();
$data['company'] = auth()->user()->company; $data['company'] = auth()->user()->company;
$data['client'] = auth()->user()->client; $data['client'] = auth()->user()->client;
$data['settings'] = auth()->user()->client->getMergedSettings(); $data['settings'] = $this->settings;
$data['currencies'] = TranslationHelper::getCurrencies(); $data['currencies'] = TranslationHelper::getCurrencies();
$data['multiple_contacts'] = session()->get('multiple_contacts'); $data['multiple_contacts'] = session()->get('multiple_contacts');
@ -63,7 +67,9 @@ class PortalComposer
{ {
$data = []; $data = [];
// $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'activity']; if($this->settings->enable_client_portal_dashboard == TRUE)
$data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'activity'];
$data[] = ['title' => ctrans('texts.invoices'), 'url' => 'client.invoices.index', 'icon' => 'file-text']; $data[] = ['title' => ctrans('texts.invoices'), 'url' => 'client.invoices.index', 'icon' => 'file-text'];
$data[] = ['title' => ctrans('texts.recurring_invoices'), 'url' => 'client.recurring_invoices.index', 'icon' => 'file']; $data[] = ['title' => ctrans('texts.recurring_invoices'), 'url' => 'client.recurring_invoices.index', 'icon' => 'file'];
$data[] = ['title' => ctrans('texts.payments'), 'url' => 'client.payments.index', 'icon' => 'credit-card']; $data[] = ['title' => ctrans('texts.payments'), 'url' => 'client.payments.index', 'icon' => 'credit-card'];

View File

@ -39,6 +39,7 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
public $settings; public $settings;
public $template;
/** /**
* Create a new job instance. * Create a new job instance.
* *
@ -47,7 +48,7 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
* @param $user * @param $user
* @param $company * @param $company
*/ */
public function __construct($invitation, $entity_type, $user, $company) public function __construct($invitation, $entity_type, $user, $company, $template)
{ {
$this->company = $company; $this->company = $company;
@ -60,6 +61,8 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
$this->entity_type = $entity_type; $this->entity_type = $entity_type;
$this->settings = $invitation->contact->client->getMergedSettings(); $this->settings = $invitation->contact->client->getMergedSettings();
$this->template = $template;
} }
/** /**
@ -69,6 +72,8 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
nlog("entity sent mailer");
/*If we are migrating data we don't want to fire these notification*/ /*If we are migrating data we don't want to fire these notification*/
if ($this->company->is_disabled) { if ($this->company->is_disabled) {
return true; return true;
@ -80,7 +85,7 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
//if we need to set an email driver do it now //if we need to set an email driver do it now
$this->setMailDriver(); $this->setMailDriver();
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build(); $mail_obj = (new EntitySentObject($this->invitation, $this->entity_type, $this->template))->build();
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')]; $mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
try { try {

View File

@ -216,7 +216,7 @@ class SendReminders implements ShouldQueue
if ($this->checkSendSetting($invoice, $template)) { if ($this->checkSendSetting($invoice, $template)) {
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars())); event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars(), $template));
} }
$invoice->last_sent_date = now(); $invoice->last_sent_date = now();

View File

@ -94,10 +94,7 @@ class SendRecurring implements ShouldQueue
nlog("last send date = " . $this->recurring_invoice->last_sent_date); nlog("last send date = " . $this->recurring_invoice->last_sent_date);
$this->recurring_invoice->save(); $this->recurring_invoice->save();
//this is duplicated!!
// if ($invoice->invitations->count() > 0)
// event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars()));
} }
public function failed($exception = null) public function failed($exception = null)

View File

@ -66,7 +66,7 @@ class ReminderJob implements ShouldQueue
}); });
if ($invoice->invitations->count() > 0) { if ($invoice->invitations->count() > 0) {
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars())); event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars(), $reminder_template));
} }
} else { } else {
$invoice->next_send_date = null; $invoice->next_send_date = null;

View File

@ -66,6 +66,9 @@ class UploadFile implements ShouldQueue
*/ */
public function handle() : ?Document public function handle() : ?Document
{ {
if(!$this->file)
return null;
$path = self::PROPERTIES[$this->type]['path']; $path = self::PROPERTIES[$this->type]['path'];
if ($this->company) { if ($this->company) {

View File

@ -51,7 +51,7 @@ class CreditEmailedNotification implements ShouldQueue
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
unset($methods[$key]); unset($methods[$key]);
EntitySentMailer::dispatch($event->invitation, 'credit', $user, $event->invitation->company); EntitySentMailer::dispatch($event->invitation, 'credit', $user, $event->invitation->company, $event->template);
$first_notification_sent = false; $first_notification_sent = false;
} }

View File

@ -36,8 +36,26 @@ class CreateInvoicePdf implements ShouldQueue
{ {
MultiDB::setDb($event->company->db); MultiDB::setDb($event->company->db);
$event->invoice->invitations->each(function ($invitation) { if(isset($event->invoice))
CreateEntityPdf::dispatch($invitation); {
}); $event->invoice->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
});
}
if(isset($event->quote))
{
$event->quote->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
});
}
if(isset($event->credit))
{
$event->credit->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
});
}
} }
} }

View File

@ -51,7 +51,7 @@ class InvoiceEmailedNotification implements ShouldQueue
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
unset($methods[$key]); unset($methods[$key]);
EntitySentMailer::dispatch($event->invitation, 'invoice', $user, $event->invitation->company); EntitySentMailer::dispatch($event->invitation, 'invoice', $user, $event->invitation->company, $event->template);
$first_notification_sent = false; $first_notification_sent = false;
} }

View File

@ -51,7 +51,7 @@ class QuoteEmailedNotification implements ShouldQueue
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
unset($methods[$key]); unset($methods[$key]);
EntitySentMailer::dispatch($event->invitation, 'quote', $user, $event->invitation->company); EntitySentMailer::dispatch($event->invitation, 'quote', $user, $event->invitation->company, $event->template);
$first_notification_sent = false; $first_notification_sent = false;
} }
@ -60,4 +60,4 @@ class QuoteEmailedNotification implements ShouldQueue
$user->notify($notification); $user->notify($notification);
} }
} }
} }

View File

@ -28,17 +28,26 @@ class EntitySentObject
public $settings; public $settings;
public function __construct($invitation, $entity_type) public $template;
private $template_subject;
private $template_body;
public function __construct($invitation, $entity_type, $template)
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
$this->entity_type = $entity_type; $this->entity_type = $entity_type;
$this->entity = $invitation->{$entity_type}; $this->entity = $invitation->{$entity_type};
$this->contact = $invitation->contact; $this->contact = $invitation->contact;
$this->company = $invitation->company; $this->company = $invitation->company;
$this->template = $template;
} }
public function build() public function build()
{ {
$this->setTemplate();
$mail_obj = new stdClass; $mail_obj = new stdClass;
$mail_obj->amount = $this->getAmount(); $mail_obj->amount = $this->getAmount();
$mail_obj->subject = $this->getSubject(); $mail_obj->subject = $this->getSubject();
@ -49,6 +58,47 @@ class EntitySentObject
return $mail_obj; return $mail_obj;
} }
private function setTemplate()
{
nlog($this->template);
switch ($this->template) {
case 'invoice':
$this->template_subject = "texts.notification_invoice_sent_subject";
$this->template_body = "texts.notification_invoice_sent";
break;
case 'reminder1':
$this->template_subject = "texts.notification_invoice_reminder1_sent_subject";
$this->template_body = "texts.notification_invoice_sent";
break;
case 'reminder2':
$this->template_subject = "texts.notification_invoice_reminder2_sent_subject";
$this->template_body = "texts.notification_invoice_sent";
break;
case 'reminder3':
$this->template_subject = "texts.notification_invoice_reminder3_sent_subject";
$this->template_body = "texts.notification_invoice_sent";
break;
case 'reminder_endless':
$this->template_subject = "texts.notification_invoice_reminder_endless_sent_subject";
$this->template_body = "texts.notification_invoice_sent";
break;
case 'quote':
$this->template_subject = "texts.notification_quote_sent_subject";
$this->template_body = "texts.notification_quote_sent";
break;
case 'credit':
$this->template_subject = "texts.notification_credit_sent_subject";
$this->template_body = "texts.notification_credit_sent";
break;
default:
$this->template_subject = "texts.notification_invoice_sent_subject";
$this->template_body = "texts.notification_invoice_sent";
break;
}
}
private function getAmount() private function getAmount()
{ {
return Number::formatMoney($this->entity->amount, $this->entity->client); return Number::formatMoney($this->entity->amount, $this->entity->client);
@ -58,7 +108,7 @@ class EntitySentObject
{ {
return return
ctrans( ctrans(
"texts.notification_{$this->entity_type}_sent_subject", $this->template_subject,
[ [
'client' => $this->contact->present()->name(), 'client' => $this->contact->present()->name(),
'invoice' => $this->entity->number, 'invoice' => $this->entity->number,
@ -73,7 +123,7 @@ class EntitySentObject
return [ return [
'title' => $this->getSubject(), 'title' => $this->getSubject(),
'message' => ctrans( 'message' => ctrans(
"texts.notification_{$this->entity_type}_sent", $this->template_body,
[ [
'amount' => $this->getAmount(), 'amount' => $this->getAmount(),
'client' => $this->contact->present()->name(), 'client' => $this->contact->present()->name(),

View File

@ -52,7 +52,6 @@ class Credit extends BaseModel
'terms', 'terms',
'public_notes', 'public_notes',
'private_notes', 'private_notes',
'invoice_type_id',
'tax_name1', 'tax_name1',
'tax_rate1', 'tax_rate1',
'tax_name2', 'tax_name2',

View File

@ -63,7 +63,6 @@ class Invoice extends BaseModel
'terms', 'terms',
'public_notes', 'public_notes',
'private_notes', 'private_notes',
'invoice_type_id',
'tax_name1', 'tax_name1',
'tax_rate1', 'tax_rate1',
'tax_name2', 'tax_name2',
@ -434,12 +433,11 @@ class Invoice extends BaseModel
return $this->calc()->getTotal(); return $this->calc()->getTotal();
} }
public function entityEmailEvent($invitation, $reminder_template, $template)
public function entityEmailEvent($invitation, $reminder_template)
{ {
switch ($reminder_template) { switch ($reminder_template) {
case 'invoice': case 'invoice':
event(new InvoiceWasEmailed($invitation, $invitation->company, Ninja::eventVars())); event(new InvoiceWasEmailed($invitation, $invitation->company, Ninja::eventVars(), $template));
break; break;
case 'reminder1': case 'reminder1':
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(), Activity::INVOICE_REMINDER1_SENT)); event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(), Activity::INVOICE_REMINDER1_SENT));

View File

@ -52,7 +52,6 @@ class Quote extends BaseModel
'public_notes', 'public_notes',
'private_notes', 'private_notes',
'project_id', 'project_id',
'invoice_type_id',
'tax_name1', 'tax_name1',
'tax_rate1', 'tax_rate1',
'tax_name2', 'tax_name2',

View File

@ -226,6 +226,7 @@ class EventServiceProvider extends ServiceProvider
], ],
CreditWasUpdated::class => [ CreditWasUpdated::class => [
UpdatedCreditActivity::class, UpdatedCreditActivity::class,
CreateInvoicePdf::class,
], ],
CreditWasEmailedAndFailed::class => [ CreditWasEmailedAndFailed::class => [
], ],
@ -334,6 +335,7 @@ class EventServiceProvider extends ServiceProvider
], ],
QuoteWasUpdated::class => [ QuoteWasUpdated::class => [
QuoteUpdatedActivity::class, QuoteUpdatedActivity::class,
CreateInvoicePdf::class,
], ],
QuoteWasEmailed::class => [ QuoteWasEmailed::class => [
QuoteEmailActivity::class, QuoteEmailActivity::class,

View File

@ -66,7 +66,7 @@ class TriggeredActions extends AbstractService
}); });
if ($this->invoice->invitations->count() > 0) { if ($this->invoice->invitations->count() > 0) {
event(new InvoiceWasEmailed($this->invoice->invitations->first(), $this->invoice->company, Ninja::eventVars())); event(new InvoiceWasEmailed($this->invoice->invitations->first(), $this->invoice->company, Ninja::eventVars(), 'invoice'));
} }
} }
} }

View File

@ -34,7 +34,7 @@ class GetQuotePdf extends AbstractService
$invitation = $this->quote->invitations->where('client_contact_id', $this->contact->id)->first(); $invitation = $this->quote->invitations->where('client_contact_id', $this->contact->id)->first();
$path = $this->quote->client->invoice_filepath(); $path = $this->quote->client->quote_filepath();
$file_path = $path.$this->quote->number.'.pdf'; $file_path = $path.$this->quote->number.'.pdf';

View File

@ -58,9 +58,9 @@ class QuoteService
return $this; return $this;
} }
$convert_quote = new ConvertQuote($this->quote->client); $convert_quote = (new ConvertQuote($this->quote->client))->run($this->quote);
$this->invoice = $convert_quote->run($this->quote); $this->invoice = $convert_quote;
$this->quote->fresh(); $this->quote->fresh();
@ -96,9 +96,7 @@ class QuoteService
public function markSent() :self public function markSent() :self
{ {
$mark_sent = new MarkSent($this->quote->client, $this->quote); $this->quote = (new MarkSent($this->quote->client, $this->quote))->run();
$this->quote = $mark_sent->run();
return $this; return $this;
} }

View File

@ -43,7 +43,6 @@ class InvoiceTransformer extends EntityTransformer
'terms' => $invoice->terms ?: '', 'terms' => $invoice->terms ?: '',
'public_notes' => $invoice->public_notes ?: '', 'public_notes' => $invoice->public_notes ?: '',
'is_deleted' => (bool) $invoice->is_deleted, 'is_deleted' => (bool) $invoice->is_deleted,
'invoice_type_id' => (int) $invoice->invoice_type_id,
'tax_name1' => $invoice->tax_name1 ? $invoice->tax_name1 : '', 'tax_name1' => $invoice->tax_name1 ? $invoice->tax_name1 : '',
'tax_rate1' => (float) $invoice->tax_rate1, 'tax_rate1' => (float) $invoice->tax_rate1,
'tax_name2' => $invoice->tax_name2 ? $invoice->tax_name2 : '', 'tax_name2' => $invoice->tax_name2 ? $invoice->tax_name2 : '',

View File

@ -22,9 +22,11 @@ trait SavesDocuments
if ($entity instanceof Company) { if ($entity instanceof Company) {
$account = $entity->account; $account = $entity->account;
$company = $entity; $company = $entity;
$user = auth()->user();
} else { } else {
$account = $entity->company->account; $account = $entity->company->account;
$company = $entity->company; $company = $entity->company;
$user = $entity->user;
} }
if (! $account->hasFeature(Account::FEATURE_DOCUMENTS)) { if (! $account->hasFeature(Account::FEATURE_DOCUMENTS)) {
@ -35,8 +37,8 @@ trait SavesDocuments
$document = UploadFile::dispatchNow( $document = UploadFile::dispatchNow(
$document, $document,
UploadFile::DOCUMENT, UploadFile::DOCUMENT,
$entity->user, $user,
$entity->company, $company,
$entity, $entity,
null, null,
$is_public $is_public
@ -49,9 +51,11 @@ trait SavesDocuments
if ($entity instanceof Company) { if ($entity instanceof Company) {
$account = $entity->account; $account = $entity->account;
$company = $entity; $company = $entity;
$user = auth()->user();
} else { } else {
$account = $entity->company->account; $account = $entity->company->account;
$company = $entity->company; $company = $entity->company;
$user = $entity->user;
} }
if (! $account->hasFeature(Account::FEATURE_DOCUMENTS)) { if (! $account->hasFeature(Account::FEATURE_DOCUMENTS)) {
@ -61,8 +65,8 @@ trait SavesDocuments
$document = UploadFile::dispatchNow( $document = UploadFile::dispatchNow(
$document, $document,
UploadFile::DOCUMENT, UploadFile::DOCUMENT,
$entity->user, $user,
$entity->company, $company,
$entity, $entity,
null, null,
$is_public $is_public

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3,7 +3,7 @@
* *
* @link https://github.com/invoiceninja/invoiceninja source repository * @link https://github.com/invoiceninja/invoiceninja source repository
* *
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* *
* @license https://opensource.org/licenses/AAL * @license https://opensource.org/licenses/AAL
*/ */

View File

@ -3242,7 +3242,7 @@ return [
'checkout_com' => 'Checkout.com', 'checkout_com' => 'Checkout.com',
'footer_label' => 'Copyright © :year :company. All rights reserved.', 'footer_label' => 'Copyright © :year :company.',
'credit_card_invalid' => 'Provided credit card number is not valid.', 'credit_card_invalid' => 'Provided credit card number is not valid.',
'month_invalid' => 'Provided month is not valid.', 'month_invalid' => 'Provided month is not valid.',

View File

@ -8,9 +8,9 @@
@endif @endif
@if(strlen($client->getSetting('client_portal_privacy_policy')) > 1 && strlen($client->getSetting('client_portal_terms')) > 1) @if(strlen($client->getSetting('client_portal_privacy_policy')) > 1 && strlen($client->getSetting('client_portal_terms')) > 1)
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-minus"> <!-- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-minus">
<line x1="5" y1="12" x2="19" y2="12"></line> <line x1="5" y1="12" x2="19" y2="12"></line>
</svg> <!-- Long dash between items. --> </svg> Long dash between items. -->
@endif @endif
@if(strlen($client->getSetting('client_portal_terms')) > 1) @if(strlen($client->getSetting('client_portal_terms')) > 1)

View File

@ -2,7 +2,7 @@
<div class="flex flex-col w-64"> <div class="flex flex-col w-64">
<div class="flex items-center h-16 flex-shrink-0 px-4 bg-primary-darken justify-center"> <div class="flex items-center h-16 flex-shrink-0 px-4 bg-primary-darken justify-center">
<a href="{{ route('client.dashboard') }}"> <a href="{{ route('client.dashboard') }}">
<img class="h-8 w-auto" src="{!! url('') . $settings->company_logo ?: asset('images/invoiceninja-white-logo.png') !!}" alt="{{ config('app.name') }}" /> <img class="h-8 w-auto" src="{!! $settings->company_logo ? url('') . $settings->company_logo : asset('images/invoiceninja-white-logo.png') !!}" alt="{{ config('app.name') }}" />
</a> </a>
</div> </div>
<div class="h-0 flex-1 flex flex-col overflow-y-auto"> <div class="h-0 flex-1 flex flex-col overflow-y-auto">