Fixes for System Log Filter types

This commit is contained in:
David Bomba 2021-09-06 13:07:11 +10:00
parent d575fac950
commit 79ef62fefb
3 changed files with 23 additions and 16 deletions

View File

@ -34,11 +34,6 @@ class SystemLogFilters extends QueryFilters
return $this->builder->where('event_id', $event_id);
}
public function client_id(int $client_id) :Builder
{
return $this->builder->where('client_id', $client_id);
}
/**
* Filter based on search text.
*

View File

@ -30,6 +30,7 @@ use App\Providers\MailServiceProvider;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use Dacastro4\LaravelGmail\Facade\LaravelGmail;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
@ -118,10 +119,18 @@ class NinjaMailerJob implements ShouldQueue
nlog("error failed with {$e->getMessage()}");
if($this->nmo->entity)
$this->entityEmailFailed($e->getMessage());
$message = $e->getMessage();
if(Ninja::isHosted())
if($e instanceof ClientException) { //postmark specific failure
$response = $e->getResponse();
$message = $response->Message;
}
if($this->nmo->entity)
$this->entityEmailFailed($message);
if(Ninja::isHosted() && (!$e instanceof ClientException)) // Don't send postmark failures to Sentry
app('sentry')->captureException($e);
}
}
@ -241,6 +250,7 @@ class NinjaMailerJob implements ShouldQueue
private function logMailError($errors, $recipient_object)
{
SystemLogger::dispatch(
$errors,
SystemLog::CATEGORY_MAIL,
@ -249,19 +259,18 @@ class NinjaMailerJob implements ShouldQueue
$recipient_object,
$this->nmo->company
);
}
public function failed($exception = null)
{
nlog('mailer job failed');
nlog($exception->getMessage());
$job_failure = new EmailFailure($this->nmo->company->company_key);
$job_failure->string_metric5 = 'failed_email';
$job_failure->string_metric6 = substr($exception->getMessage(), 0, 150);
$job_failure->string_metric6 = substr($errors, 0, 150);
LightLogs::create($job_failure)
->batch();
}
public function failed($exception = null)
{
}
}

View File

@ -301,7 +301,10 @@ trait MakesInvoiceValues
$data[$key][$table_type . ".{$_table_type}3"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}3", $item->custom_value3, $this->client);
$data[$key][$table_type . ".{$_table_type}4"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}4", $item->custom_value4, $this->client);
$data[$key][$table_type.'.quantity'] = Number::formatValue($item->quantity, $this->client->currency());
//$data[$key][$table_type.'.quantity'] = Number::formatValue($item->quantity, $this->client->currency());
//change quantity from localized number, to decimal format with no trailing zeroes 06/09/21
$data[$key][$table_type.'.quantity'] = rtrim($item->quantity, "0");
$data[$key][$table_type.'.unit_cost'] = Number::formatMoney($item->cost, $this->client);
$data[$key][$table_type.'.cost'] = Number::formatMoney($item->cost, $this->client);