mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
commit
58c6cb415e
@ -1 +1 @@
|
||||
5.0.23
|
||||
5.0.24
|
@ -175,7 +175,7 @@ class CompanySettings extends BaseSettings
|
||||
public $email_template_reminder3 = ''; //@implemented
|
||||
public $email_template_reminder_endless = ''; //@implemented
|
||||
public $email_signature = ''; //@implemented
|
||||
public $enable_email_markup = true; //@TODO
|
||||
public $enable_email_markup = true; //@TODO -
|
||||
|
||||
public $email_subject_custom1 = ''; //@TODO
|
||||
public $email_subject_custom2 = ''; //@TODO
|
||||
@ -185,35 +185,35 @@ class CompanySettings extends BaseSettings
|
||||
public $email_template_custom2 = ''; //@TODO
|
||||
public $email_template_custom3 = ''; //@TODO
|
||||
|
||||
public $enable_reminder1 = false; //@partially implmemented
|
||||
public $enable_reminder2 = false; //@partially implmemented
|
||||
public $enable_reminder3 = false; //@partially implmemented
|
||||
public $enable_reminder_endless = false; //@partially implmemented
|
||||
public $enable_reminder1 = false; //@implmemented
|
||||
public $enable_reminder2 = false; //@implmemented
|
||||
public $enable_reminder3 = false; //@implmemented
|
||||
public $enable_reminder_endless = false; //@implmemented
|
||||
|
||||
public $num_days_reminder1 = 0;//@partially implmemented
|
||||
public $num_days_reminder2 = 0;//@partially implmemented
|
||||
public $num_days_reminder3 = 0;//@partially implmemented
|
||||
public $num_days_reminder1 = 0;//@implmemented
|
||||
public $num_days_reminder2 = 0;//@implmemented
|
||||
public $num_days_reminder3 = 0;//@implmemented
|
||||
|
||||
public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||
public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||
public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
||||
public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
|
||||
public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
|
||||
public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
|
||||
|
||||
public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders
|
||||
public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders @TODO
|
||||
|
||||
public $late_fee_amount1 = 0; //@TODO
|
||||
public $late_fee_amount2 = 0; //@TODO
|
||||
public $late_fee_amount3 = 0; //@TODO
|
||||
public $late_fee_amount1 = 0; //@implemented
|
||||
public $late_fee_amount2 = 0; //@implemented
|
||||
public $late_fee_amount3 = 0; //@implemented
|
||||
|
||||
public $late_fee_percent1 = 0; //@TODO
|
||||
public $late_fee_percent2 = 0; //@TODO
|
||||
public $late_fee_percent3 = 0; //@TODO
|
||||
public $late_fee_percent1 = 0; //@implemented
|
||||
public $late_fee_percent2 = 0; //@implemented
|
||||
public $late_fee_percent3 = 0; //@implemented
|
||||
|
||||
public $endless_reminder_frequency_id = '0'; //@implemented
|
||||
public $late_fee_endless_amount = 0; //@TODO
|
||||
public $late_fee_endless_percent = 0; //@TODO
|
||||
public $late_fee_endless_amount = 0; //@implemented
|
||||
public $late_fee_endless_percent = 0; //@implemented
|
||||
|
||||
public $client_online_payment_notification = true; //@todo implement in notifications
|
||||
public $client_manual_payment_notification = true; //@todo implement in notifications
|
||||
public $client_online_payment_notification = true; //@todo implement in notifications check this bool prior to sending payment notification to client
|
||||
public $client_manual_payment_notification = true; //@todo implement in notifications check this bool prior to sending manual payment notification to client
|
||||
|
||||
/* Company Meta data that we can use to build sub companies*/
|
||||
|
||||
@ -232,26 +232,26 @@ class CompanySettings extends BaseSettings
|
||||
public $id_number = ''; //@implemented
|
||||
|
||||
public $page_size = 'A4'; //Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
|
||||
public $font_size = 9;
|
||||
public $font_size = 9; //@implemented
|
||||
public $primary_font = 'Roboto';
|
||||
public $secondary_font = 'Roboto';
|
||||
public $primary_color = '#4caf50';
|
||||
public $secondary_color = '#2196f3';
|
||||
|
||||
public $hide_paid_to_date = false; //@TODO where?
|
||||
public $embed_documents = false; //@TODO
|
||||
public $embed_documents = false; //@TODO where?
|
||||
public $all_pages_header = false; //@implemented
|
||||
public $all_pages_footer = false; //@implemented
|
||||
public $pdf_variables = ''; //@implemented
|
||||
|
||||
public $portal_custom_head = ''; //@TODO
|
||||
public $portal_custom_css = ''; //@TODO
|
||||
public $portal_custom_footer = ''; //@TODO
|
||||
public $portal_custom_js = ''; //@TODO
|
||||
public $portal_custom_head = ''; //@TODO @BEN
|
||||
public $portal_custom_css = ''; //@TODO @BEN
|
||||
public $portal_custom_footer = ''; //@TODO @BEN
|
||||
public $portal_custom_js = ''; //@TODO @BEN
|
||||
|
||||
public $client_can_register = false; //@implemented
|
||||
public $client_portal_terms = ''; //@TODO
|
||||
public $client_portal_privacy_policy = ''; //@TODO
|
||||
public $client_portal_terms = ''; //@TODO @BEN
|
||||
public $client_portal_privacy_policy = ''; //@TODO @BEN
|
||||
public $client_portal_enable_uploads = false; //@implemented
|
||||
public $client_portal_allow_under_payment = false; //@implemented
|
||||
public $client_portal_under_payment_minimum = 0; //@implemented
|
||||
@ -511,6 +511,7 @@ class CompanySettings extends BaseSettings
|
||||
|
||||
/**
|
||||
* Provides class defaults on init.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public static function defaults(): stdClass
|
||||
@ -543,6 +544,7 @@ class CompanySettings extends BaseSettings
|
||||
* set new properties to the object prior to being returned.
|
||||
*
|
||||
* @param $settings
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public static function setProperties($settings): stdClass
|
||||
@ -551,14 +553,19 @@ class CompanySettings extends BaseSettings
|
||||
|
||||
foreach ($company_settings as $key => $value) {
|
||||
if (! property_exists($settings, $key)) {
|
||||
$settings->{ $key} = self::castAttribute($key, $company_settings->{ $key});
|
||||
$settings->{$key} = self::castAttribute($key, $company_settings->{$key});
|
||||
}
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public static function notificationDefaults()
|
||||
/**
|
||||
* Stubs the notification defaults
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public static function notificationDefaults() :stdClass
|
||||
{
|
||||
$notification = new stdClass;
|
||||
$notification->email = ['all_notifications'];
|
||||
@ -566,7 +573,12 @@ class CompanySettings extends BaseSettings
|
||||
return $notification;
|
||||
}
|
||||
|
||||
private static function getEntityVariableDefaults()
|
||||
/**
|
||||
* Defines entity variables for PDF generation
|
||||
*
|
||||
* @return stdClass The stdClass of PDF variables
|
||||
*/
|
||||
private static function getEntityVariableDefaults() :stdClass
|
||||
{
|
||||
$variables = [
|
||||
'client_details' => [
|
||||
|
@ -11,8 +11,15 @@
|
||||
|
||||
namespace App\Events\Payment;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
@ -20,7 +27,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
*/
|
||||
class PaymentWasEmailed
|
||||
{
|
||||
use SerializesModels;
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Payment
|
||||
|
@ -11,15 +11,23 @@
|
||||
|
||||
namespace App\Events\Payment;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasEmailedAndFailed.
|
||||
* Class PaymentWasEmailedAndFailed.
|
||||
*/
|
||||
class PaymentWasEmailedAndFailed
|
||||
{
|
||||
use SerializesModels;
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Payment
|
||||
@ -39,7 +47,7 @@ class PaymentWasEmailedAndFailed
|
||||
* @param array $errors
|
||||
* @param array $event_vars
|
||||
*/
|
||||
public function __construct(Payment $payment, $company, array $errors, array $event_vars)
|
||||
public function __construct(Payment $payment, Company $company, array $errors, array $event_vars)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
protected $dontReport = [
|
||||
PDOException::class,
|
||||
Swift_TransportException::class,
|
||||
//Swift_TransportException::class,
|
||||
MaxAttemptsExceededException::class,
|
||||
CommandNotFoundException::class,
|
||||
];
|
||||
|
@ -218,7 +218,7 @@ class BaseController extends Controller
|
||||
$query->whereNotNull('updated_at');
|
||||
},
|
||||
'company.credits'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents',);
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
|
||||
},
|
||||
'company.designs'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('company');
|
||||
@ -227,7 +227,7 @@ class BaseController extends Controller
|
||||
$query->where('updated_at', '>=', $updated_at);
|
||||
},
|
||||
'company.expenses'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('documents' );
|
||||
$query->where('updated_at', '>=', $updated_at)->with('documents');
|
||||
},
|
||||
'company.groups' => function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at);
|
||||
@ -236,7 +236,7 @@ class BaseController extends Controller
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
|
||||
},
|
||||
'company.payments'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('paymentables','documents', );
|
||||
$query->where('updated_at', '>=', $updated_at)->with('paymentables','documents');
|
||||
},
|
||||
'company.payment_terms'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at);
|
||||
@ -248,7 +248,7 @@ class BaseController extends Controller
|
||||
$query->where('updated_at', '>=', $updated_at)->with('documents' );
|
||||
},
|
||||
'company.quotes'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents',);
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
|
||||
},
|
||||
'company.recurring_invoices'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
|
||||
@ -260,7 +260,7 @@ class BaseController extends Controller
|
||||
$query->where('updated_at', '>=', $updated_at);
|
||||
},
|
||||
'company.vendors'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('contacts','documents' );
|
||||
$query->where('updated_at', '>=', $updated_at)->with('contacts','documents');
|
||||
},
|
||||
'company.expense_categories'=> function ($query) use ($updated_at) {
|
||||
$query->where('updated_at', '>=', $updated_at);
|
||||
|
@ -729,6 +729,7 @@ class InvoiceController extends BaseController
|
||||
$invoice->service()->touchReminder($this->reminder_template)->save();
|
||||
|
||||
$invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) {
|
||||
info("firing email");
|
||||
EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template);
|
||||
|
||||
});
|
||||
|
@ -39,7 +39,8 @@ class StoreExpenseRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
$rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
|
||||
$rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id);
|
||||
// $rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
|
||||
$rules['contacts.*.email'] = 'nullable|distinct';
|
||||
//$rules['number'] = new UniqueExpenseNumberRule($this->all());
|
||||
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||
|
@ -42,9 +42,8 @@ class UpdateExpenseRequest extends Request
|
||||
//$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id;
|
||||
$rules['contacts.*.email'] = 'nullable|distinct';
|
||||
|
||||
if ($this->input('number')) {
|
||||
$rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.$this->expense->company_id;
|
||||
}
|
||||
if(isset($this->number))
|
||||
$rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->expense->id);
|
||||
|
||||
return $this->globalRules($rules);
|
||||
}
|
||||
|
@ -33,9 +33,8 @@ class UpdateProjectRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
if ($this->input('number')) {
|
||||
$rules['number'] = 'unique:projects,number,'.$this->id.',id,company_id,'.$this->project->company_id;
|
||||
}
|
||||
if(isset($this->number))
|
||||
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id)->ignore($this->project->id);
|
||||
|
||||
return $this->globalRules($rules);
|
||||
}
|
||||
@ -44,6 +43,9 @@ class UpdateProjectRequest extends Request
|
||||
{
|
||||
$input = $this->decodePrimaryKeys($this->all());
|
||||
|
||||
if(isset($input['client_id']))
|
||||
unset($input['client_id']);
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use App\Jobs\Company\CreateCompanyPaymentTerms;
|
||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||
use App\Jobs\Company\CreateCompanyToken;
|
||||
use App\Jobs\User\CreateUser;
|
||||
use App\Jobs\Util\VersionCheck;
|
||||
use App\Models\Account;
|
||||
use App\Models\User;
|
||||
use App\Notifications\Ninja\NewAccountCreated;
|
||||
@ -93,6 +94,8 @@ class CreateAccount
|
||||
|
||||
$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja();
|
||||
|
||||
VersionCheck::dispatchNow();
|
||||
|
||||
LightLogs::create(new AnalyticsAccountCreated())
|
||||
->increment()
|
||||
->batch();
|
||||
|
@ -116,13 +116,13 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
|
||||
$this->invitation->contact->client
|
||||
)
|
||||
);
|
||||
} catch (Swift_TransportException $e) {
|
||||
} catch (\Exception $e) {
|
||||
$this->failed($e);
|
||||
$this->entityEmailFailed($e->getMessage());
|
||||
$this->logMailError($e->getMessage(), $this->entity->client);
|
||||
}
|
||||
|
||||
if (count(Mail::failures()) > 0) {
|
||||
$this->logMailError(Mail::failures(), $this->entity->client);
|
||||
} else {
|
||||
if (count(Mail::failures()) == 0) {
|
||||
$this->entityEmailSucceeded();
|
||||
}
|
||||
|
||||
@ -130,19 +130,6 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
|
||||
$this->entity->service()->markSent()->save();
|
||||
}
|
||||
|
||||
public function failed($exception = null)
|
||||
{
|
||||
info('the job failed');
|
||||
|
||||
$job_failure = new EmailInvoiceFailure();
|
||||
$job_failure->string_metric5 = $this->entity_string;
|
||||
$job_failure->string_metric6 = $exception->getMessage();
|
||||
|
||||
LightLogs::create($job_failure)
|
||||
->batch();
|
||||
|
||||
}
|
||||
|
||||
private function resolveEntityString() :string
|
||||
{
|
||||
if($this->invitation instanceof InvoiceInvitation)
|
||||
|
@ -94,9 +94,15 @@ class ZipInvoices extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
$this->setMailDriver();
|
||||
|
||||
Mail::to($this->email)
|
||||
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company));
|
||||
try {
|
||||
Mail::to($this->email)
|
||||
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company));
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->failed($e);
|
||||
|
||||
}
|
||||
|
||||
UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1));
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,10 @@
|
||||
namespace App\Jobs\Mail;
|
||||
|
||||
use App\DataMapper\Analytics\EmailFailure;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Libraries\Google\Google;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\User;
|
||||
use App\Providers\MailServiceProvider;
|
||||
use App\Utils\Ninja;
|
||||
@ -75,7 +77,7 @@ class BaseMailerJob implements ShouldQueue
|
||||
}
|
||||
|
||||
public function logMailError($errors, $recipient_object)
|
||||
{info(print_r($errors,1));
|
||||
{
|
||||
SystemLogger::dispatch(
|
||||
$errors,
|
||||
SystemLog::CATEGORY_MAIL,
|
||||
|
@ -90,15 +90,9 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
|
||||
} catch (Swift_TransportException $e) {
|
||||
$this->failed($e->getMessage());
|
||||
//$this->entityEmailFailed($e->getMessage());
|
||||
}
|
||||
|
||||
if (count(Mail::failures()) > 0) {
|
||||
$this->logMailError(Mail::failures(), $this->payment->client);
|
||||
} else {
|
||||
// $this->entityEmailSucceeded();
|
||||
} catch (\Exception $e) {
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->payment->client);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,13 +88,15 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build();
|
||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||
|
||||
//send email
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
try {
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
}catch(\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->entity->client);
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->entity->client);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -89,12 +89,15 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||
|
||||
//send email
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
try{
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->entity->client);
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->invoice->client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ use App\Models\Company;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\User;
|
||||
use App\Providers\MailServiceProvider;
|
||||
use Dacastro4\LaravelGmail\Services\Message\Mail;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@ -77,12 +76,16 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
|
||||
$this->setMailDriver();
|
||||
|
||||
//send email
|
||||
Mail::to($this->to_user->email)
|
||||
->send($this->mailable);
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
$this->logMailError(Mail::failures(), $this->to_user);
|
||||
try {
|
||||
Mail::to($this->to_user->email)
|
||||
->send($this->mailable);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->to_user);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -100,13 +100,17 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj->from = [$this->company->owner()->email, $this->company->owner()->present()->name()];
|
||||
|
||||
//send email
|
||||
Mail::to($company_user->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->client);
|
||||
try {
|
||||
Mail::to($company_user->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->client);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Jobs\Payment;
|
||||
|
||||
@ -64,6 +73,7 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
if($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
@ -76,13 +86,18 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
||||
|
||||
Mail::to($this->contact->email, $this->contact->present()->name())
|
||||
->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client));
|
||||
try{
|
||||
|
||||
if (count(Mail::failures()) > 0) {
|
||||
event(new PaymentWasEmailedAndFailed($this->payment, Mail::failures(), Ninja::eventVars()));
|
||||
$mail = Mail::to($this->contact->email, $this->contact->present()->name());
|
||||
$mail->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client));
|
||||
|
||||
}catch(\Exception $e) {
|
||||
|
||||
info("mailing failed with message " . $e->getMessage());
|
||||
event(new PaymentWasEmailedAndFailed($this->payment, $this->company, Mail::failures(), Ninja::eventVars()));
|
||||
$this->failed($e);
|
||||
return $this->logMailError($e->getMessage(), $this->payment->client);
|
||||
|
||||
return $this->logMailError(Mail::failures());
|
||||
}
|
||||
|
||||
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars()));
|
||||
@ -90,17 +105,5 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
public function failed($exception = null)
|
||||
{
|
||||
info('the job failed');
|
||||
|
||||
$job_failure = new EmailInvoiceFailure();
|
||||
$job_failure->string_metric5 = 'payment';
|
||||
$job_failure->string_metric6 = $exception->getMessage();
|
||||
|
||||
LightLogs::create($job_failure)
|
||||
->batch();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,16 +72,21 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj->data = $this->getData();
|
||||
|
||||
//Send email via a Mailable class
|
||||
//
|
||||
try {
|
||||
Mail::to($this->old_email)
|
||||
->send(new UserNotificationMailer($mail_obj));
|
||||
|
||||
Mail::to($this->new_email)
|
||||
->send(new UserNotificationMailer($mail_obj));
|
||||
|
||||
//Catch errors and report.
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->company);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->company->owner());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getData()
|
||||
|
@ -57,15 +57,6 @@ class PaymentCreatedActivity implements ShouldQueue
|
||||
$fields->company_id = $payment->company_id;
|
||||
$fields->activity_type_id = Activity::CREATE_PAYMENT;
|
||||
|
||||
/*todo tests fail for this for some reason?*/
|
||||
// foreach ($invoices as $invoice) { //todo we may need to add additional logic if in the future we apply payments to other entity Types, not just invoices
|
||||
// $fields->invoice_id = $invoice->id;
|
||||
|
||||
// InvoiceWorkflowSettings::dispatchNow($invoice);
|
||||
|
||||
// $this->activity_repo->save($fields, $invoice, $event->event_vars);
|
||||
// }
|
||||
|
||||
if (count($invoices) == 0) {
|
||||
$this->activity_repo->save($fields, $payment, $event->event_vars);
|
||||
}
|
||||
|
57
app/Listeners/Payment/PaymentEmailFailureActivity.php
Normal file
57
app/Listeners/Payment/PaymentEmailFailureActivity.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Listeners\Payment;
|
||||
|
||||
use App\Jobs\Mail\EntityPaidMailer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Notifications\Admin\NewPaymentNotification;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class PaymentEmailFailureActivity implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return bool
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
info("i failed emailing {$payment->number}");
|
||||
// info(print_r($event->errors,1));
|
||||
|
||||
}
|
||||
}
|
||||
|
55
app/Listeners/Payment/PaymentEmailedActivity.php
Normal file
55
app/Listeners/Payment/PaymentEmailedActivity.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Listeners\Payment;
|
||||
|
||||
use App\Jobs\Mail\EntityPaidMailer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Notifications\Admin\NewPaymentNotification;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class PaymentEmailedActivity implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return bool
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
info("i succeeded in emailing payment {$payment->number}");
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,15 @@ class TemplateEmail extends Mailable
|
||||
|
||||
$company = $this->client->company;
|
||||
|
||||
$message = $this->from($this->user->email, $this->user->present()->name())//todo this needs to be fixed to handle the hosted version
|
||||
->subject($this->build_email->getSubject())
|
||||
$this->from($this->user->email, $this->user->present()->name());
|
||||
|
||||
if(strlen($settings->reply_to_email) > 1)
|
||||
$this->replyTo($settings->reply_to_email, $settings->reply_to_email);
|
||||
|
||||
if(strlen($settings->bcc_email) > 1)
|
||||
$this->bcc($settings->bcc_email, $settings->bcc_email);
|
||||
|
||||
$this->subject($this->build_email->getSubject())
|
||||
->text('email.template.plain', [
|
||||
'body' => $this->build_email->getBody(),
|
||||
'footer' => $this->build_email->getFooter(),
|
||||
@ -78,10 +85,10 @@ class TemplateEmail extends Mailable
|
||||
//conditionally attach files
|
||||
if ($settings->pdf_email_attachment !== false && ! empty($this->build_email->getAttachments())) {
|
||||
foreach ($this->build_email->getAttachments() as $file) {
|
||||
$message->attach($file);
|
||||
$this->attach($file);
|
||||
}
|
||||
}
|
||||
|
||||
return $message;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class CompanyGateway extends BaseModel
|
||||
'require_billing_address',
|
||||
'require_shipping_address',
|
||||
'require_client_name',
|
||||
'require_zip',
|
||||
'require_postal_code',
|
||||
'require_client_phone',
|
||||
'require_contact_name',
|
||||
'update_details',
|
||||
|
@ -51,6 +51,8 @@ use App\Events\Misc\InvitationWasViewed;
|
||||
use App\Events\Payment\PaymentWasArchived;
|
||||
use App\Events\Payment\PaymentWasCreated;
|
||||
use App\Events\Payment\PaymentWasDeleted;
|
||||
use App\Events\Payment\PaymentWasEmailed;
|
||||
use App\Events\Payment\PaymentWasEmailedAndFailed;
|
||||
use App\Events\Payment\PaymentWasRefunded;
|
||||
use App\Events\Payment\PaymentWasRestored;
|
||||
use App\Events\Payment\PaymentWasUpdated;
|
||||
@ -129,6 +131,8 @@ use App\Listeners\Invoice\InvoiceViewedActivity;
|
||||
use App\Listeners\Invoice\UpdateInvoiceActivity;
|
||||
use App\Listeners\Invoice\UpdateInvoiceInvitations;
|
||||
use App\Listeners\Misc\InvitationViewedListener;
|
||||
use App\Listeners\Payment\PaymentEmailFailureActivity;
|
||||
use App\Listeners\Payment\PaymentEmailedActivity;
|
||||
use App\Listeners\Payment\PaymentNotification;
|
||||
use App\Listeners\Payment\PaymentRestoredActivity;
|
||||
use App\Listeners\Quote\QuoteApprovedActivity;
|
||||
@ -310,6 +314,12 @@ class EventServiceProvider extends ServiceProvider
|
||||
InvitationWasViewed::class => [
|
||||
InvitationViewedListener::class,
|
||||
],
|
||||
PaymentWasEmailed::class => [
|
||||
PaymentEmailedActivity::class,
|
||||
],
|
||||
PaymentWasEmailedAndFailed::class => [
|
||||
PaymentEmailFailureActivity::class,
|
||||
],
|
||||
CompanyDocumentsDeleted::class => [
|
||||
DeleteCompanyDocuments::class,
|
||||
],
|
||||
|
@ -75,7 +75,8 @@ class MarkPaid extends AbstractService
|
||||
->applyNumber()
|
||||
->save();
|
||||
|
||||
EmailPayment::dispatch($payment, $payment->company, $payment->client->primary_contact()->first());
|
||||
if($this->invoice->client->getSetting('client_manual_payment_notification'))
|
||||
EmailPayment::dispatch($payment, $payment->company, $payment->client->primary_contact()->first());
|
||||
|
||||
/* Update Invoice balance */
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||
|
@ -53,6 +53,7 @@ class CompanyGatewayTransformer extends EntityTransformer
|
||||
'require_shipping_address' => (bool) $company_gateway->require_shipping_address,
|
||||
'require_client_name' => (bool) $company_gateway->require_client_name,
|
||||
'require_zip' => (bool) $company_gateway->require_zip,
|
||||
'require_postal_code' => (bool) $company_gateway->require_postal_code,
|
||||
'require_client_phone' => (bool) $company_gateway->require_client_phone,
|
||||
'require_contact_name' => (bool) $company_gateway->require_contact_name,
|
||||
'require_contact_email' => (bool) $company_gateway->require_contact_email,
|
||||
|
@ -12,7 +12,7 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/').'/',
|
||||
'app_domain' => env('APP_DOMAIN', ''),
|
||||
'app_version' => '5.0.23',
|
||||
'app_version' => '5.0.24',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CompanyGatewayRenameColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('company_gateways', function(Blueprint $table){
|
||||
$table->renameColumn('require_zip', 'require_postal_code');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user