1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 00:41:34 +02:00

Merge pull request #4414 from turbo124/v5-stable

Fixes for sending email user
This commit is contained in:
David Bomba 2020-12-02 14:36:28 +11:00 committed by GitHub
commit e26263f9ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 98742 additions and 98059 deletions

View File

@ -77,6 +77,8 @@ class BaseMailerJob implements ShouldQueue
Config::set('mail.driver', 'gmail');
Config::set('services.gmail.token', $user->oauth_user_token->access_token);
Config::set('mail.from.address', $user->email);
Config::set('mail.from.name', $user->present()->name());
(new MailServiceProvider(app()))->register();
}

View File

@ -77,7 +77,7 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
try {
$mail_obj = (new EntityPaidObject($this->payment))->build();
$mail_obj->from = [$this->user->email, $this->user->present()->name()];
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
//send email
Mail::to($this->user->email)

View File

@ -81,7 +81,7 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
$this->setMailDriver();
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build();
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
try {
Mail::to($this->user->email)

View File

@ -81,7 +81,7 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
$this->setMailDriver();
$mail_obj = (new EntityViewedObject($this->invitation, $this->entity_type))->build();
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
//send email
try {

View File

@ -91,7 +91,7 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
unset($methods[$key]);
$mail_obj = (new PaymentFailureObject($this->client, $this->message, $this->amount, $this->company))->build();
$mail_obj->from = [$this->company->owner()->email, $this->company->owner()->present()->name()];
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
//send email
try {

View File

@ -199,8 +199,9 @@ class Import implements ShouldQueue
}
$this->setInitialCompanyLedgerBalances();
Mail::to($this->user)->send(new MigrationCompleted());
Mail::to($this->user)
->send(new MigrationCompleted());
/*After a migration first some basic jobs to ensure the system is up to date*/
VersionCheck::dispatch();

View File

@ -34,7 +34,7 @@ class EntityNotificationMailer extends Mailable
*/
public function build()
{
return $this->from($this->mail_obj->from[0], $this->mail_obj->from[1])
return $this->from(config('mail.from.address'), config('mail.from.name'))
->subject($this->mail_obj->subject)
->markdown($this->mail_obj->markdown, $this->mail_obj->data)
->withSwiftMessage(function ($message) {

View File

@ -43,9 +43,9 @@ class BouncedEmail extends Mailable implements ShouldQueue
$entity_type = class_basename(lcfirst($this->invitation->getEntityType()));
$subject = ctrans("texts.notification_{$entity_type}_bounced_subject", ['invoice' => $invoice->number]);
return
$this->from($invitation->user->email)
$this->from(config('mail.from.name'), config('mail.from.address'))
->text()
->subject($subject);

View File

@ -30,13 +30,15 @@ class DownloadInvoices extends Mailable
*/
public function build()
{
return $this->subject(ctrans('texts.download_files'))
->markdown(
'email.admin.download_files',
[
'url' => $this->file_path,
'logo' => $this->company->present()->logo,
]
);
return $this->from(config('mail.from.name'), config('mail.from.address'))
->subject(ctrans('texts.download_files'))
->markdown(
'email.admin.download_files',
[
'url' => $this->file_path,
'logo' => $this->company->present()->logo,
]
);
}
}

View File

@ -27,6 +27,8 @@ class ExistingMigration extends Mailable
*/
public function build()
{
return $this->view('email.migration.existing');
return $this->from(config('mail.from.name'), config('mail.from.address'))
->view('email.migration.existing');
}
}

View File

@ -27,6 +27,6 @@ class InvoiceWasPaid extends Mailable
*/
public function build()
{
return $this->view('email.invoices.paid');
return $this->from(config('mail.from.address'), config('mail.from.name'))->view('email.invoices.paid');
}
}

View File

@ -28,7 +28,8 @@ class MigrationCompleted extends Mailable
public function build()
{
$data['settings'] = auth()->user()->company()->settings;
return $this->view('email.migration.completed', $data);
return $this->from(config('mail.from.name'), config('mail.from.address'))
->view('email.migration.completed', $data);
}
}

View File

@ -31,7 +31,8 @@ class MigrationFailed extends Mailable
*/
public function build()
{
return $this->from('noreply@invoiceninja.com')
->view('email.migration.failed');
return $this->from(config('mail.from.name'), config('mail.from.address'))
->view('email.migration.failed');
}
}

View File

@ -27,6 +27,6 @@ class QuoteWasApproved extends Mailable
*/
public function build()
{
return $this->view('email.quotes.approved');
return $this->from(config('mail.from.address'), config('mail.from.name'))->view('email.quotes.approved');
}
}

View File

@ -59,7 +59,7 @@ class SupportMessageSent extends Mailable
$subject = "Customer MSG {$user->present()->name} - [{$plan} - DB:{$company->db}]";
return $this->from(config('mail.from.address')) //todo this needs to be fixed to handle the hosted version
return $this->from(config('mail.from.address'), config('mail.from.name')) //todo this needs to be fixed to handle the hosted version
->subject($subject)
->markdown('email.support.message', [
'message' => $this->message,

View File

@ -52,7 +52,7 @@ class TemplateEmail extends Mailable
$company = $this->client->company;
$this->from($this->user->email, $this->user->present()->name());
$this->from(config('mail.from.address'), config('mail.from.name'));
if (strlen($settings->reply_to_email) > 1) {
$this->replyTo($settings->reply_to_email, $settings->reply_to_email);

View File

@ -36,7 +36,7 @@ class TestMailServer extends Mailable
*/
public function build()
{
return $this->from($this->from_email) //todo this needs to be fixed to handle the hosted version
return $this->from(config('mail.from.address'), config('mail.from.name'))
->subject(ctrans('texts.email'))
->markdown('email.support.message', [
'message' => $this->message,

View File

@ -34,7 +34,7 @@ class UserNotificationMailer extends Mailable
*/
public function build()
{
return $this->from($this->mail_obj->from[0], $this->mail_obj->from[1]) //todo
return $this->from(config('mail.from.address'), config('mail.from.name'))
->subject($this->mail_obj->subject)
->markdown($this->mail_obj->markdown, $this->mail_obj->data)
->withSwiftMessage(function ($message) {

View File

@ -111,14 +111,15 @@ class CreditCard
private function processSuccessfulPayment()
{
$stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
$data = [
'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method,
'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)),
'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->server_response->amount, $this->stripe->client->currency()->precision),
'transaction_reference' => $this->stripe->payment_hash->data->server_response->id,
'transaction_reference' => optional($this->stripe->payment_hash->data->payment_intent->charges->data[0])->id,
];
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]);
$this->stripe->payment_hash->save();

View File

@ -172,7 +172,7 @@ class StripePaymentDriver extends BaseDriver
* Processes the gateway response for credit card authorization.
*
* @param Request $request The returning request object
* @return Factory|View
* @return Factory|View
*/
public function authorizeResponse($request)
{
@ -189,7 +189,7 @@ class StripePaymentDriver extends BaseDriver
* Process the payment with gateway.
*
* @param array $data
* @return Factory|View|void
* @return Factory|View|void
*/
public function processPaymentView(array $data)
{
@ -209,7 +209,7 @@ class StripePaymentDriver extends BaseDriver
->route('client.profile.edit', ['client_contact' => auth()->user()->hashed_id])
->with('missing_required_fields', $this->required_fields);
}
return $this->payment_method->paymentResponse($request);
}
@ -279,7 +279,7 @@ class StripePaymentDriver extends BaseDriver
}
if (!$customer) {
throw new Exception('Unable to create gateway customer');
throw new \Exception('Unable to create gateway customer');
}
return $customer;
@ -289,37 +289,48 @@ class StripePaymentDriver extends BaseDriver
{
$this->init();
$response = $this->stripe
->refunds
->create(['charge' => $payment->transaction_reference, 'amount' => $amount]);
/** Response from Stripe SDK/API. */
$response = null;
// $response = $this->gateway
// ->refund(['transactionReference' => $payment->transaction_reference, 'amount' => $amount, 'currency' => $payment->client->getCurrencyCode()])
// ->send();
try {
$response = $this->stripe
->refunds
->create(['charge' => $payment->transaction_reference, 'amount' => $this->convertToStripeAmount($amount, $this->client->currency()->precision)]);
if ($response->status == $response::STATUS_SUCCEEDED) {
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),
], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->client);
if ($response->status == $response::STATUS_SUCCEEDED) {
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->client);
return [
'transaction_reference' => $response->charge,
'transaction_response' => json_encode($response),
'success' => $response->status == $response::STATUS_SUCCEEDED ? true : false,
'description' => $response->metadata,
'code' => $response,
];
}
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
return [
'transaction_reference' => $response->charge,
'transaction_reference' => null,
'transaction_response' => json_encode($response),
'success' => $response->status == $response::STATUS_SUCCEEDED ? true : false,
'description' => $response->metadata,
'code' => $response,
'success' => false,
'description' => $response->failure_reason,
'code' => 422,
];
} catch (\Exception $e) {
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
info($e->getMessage());
return [
'transaction_reference' => null,
'transaction_response' => json_encode($response),
'success' => false,
'description' => $e->getMessage(),
'code' => 422,
];
}
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),
], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
return [
'transaction_reference' => null,
'transaction_response' => json_encode($response),
'success' => false,
'description' => $response->failure_reason,
'code' => 422,
];
}
public function verificationView(ClientGatewayToken $payment_method)
@ -395,8 +406,8 @@ class StripePaymentDriver extends BaseDriver
* https://stripe.com/docs/api/payment_methods/detach
*
* @param ClientGatewayToken $token
* @return void
*/
* @return void
*/
public function detach(ClientGatewayToken $token)
{
$stripe = new StripeClient(
@ -411,7 +422,7 @@ class StripePaymentDriver extends BaseDriver
], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_STRIPE, $this->client);
}
}
public function getCompanyGatewayId(): int
{
return $this->company_gateway->id;

View File

@ -73,16 +73,18 @@ class RefundPayment
{
if ($this->refund_data['gateway_refund'] !== false && $this->total_refund > 0) {
if ($this->payment->company_gateway) {
$response = $this->payment->company_gateway->driver($this->payment->client)->refund($this->payment, $this->total_refund);
if ($response['success'] == false) {
throw new PaymentRefundFailed();
}
$this->payment->refunded += $this->total_refund;
$this->createActivity($this->payment);
if ($response['success'] == false) {
$this->payment->save();
throw new PaymentRefundFailed();
}
}
} else {
$this->payment->refunded += $this->total_refund;

View File

@ -292,8 +292,17 @@ class Design extends BaseDesign
$elements = [];
// Some of column can be aliased. This is simple workaround for these.
$aliases = [
'$task.product_key' => '$task.service',
];
foreach ($this->context['pdf_variables']["{$type}_columns"] as $column) {
$elements[] = ['element' => 'th', 'content' => $column . '_label'];
if (array_key_exists($column, $aliases)) {
$elements[] = ['element' => 'th', 'content' => $aliases[$column] . '_label'];
} else {
$elements[] = ['element' => 'th', 'content' => $column . '_label'];
}
}
return $elements;
@ -322,7 +331,7 @@ class Design extends BaseDesign
$element['elements'][] = ['element' => 'td', 'content' => $row['delivery_note.product_key']];
$element['elements'][] = ['element' => 'td', 'content' => $row['delivery_note.notes']];
$element['elements'][] = ['element' => 'td', 'content' => $row['delivery_note.quantity']];
$elements[] = $element;
}

View File

@ -14,6 +14,7 @@ namespace App\Services\PdfMaker\Designs\Utilities;
use App\Models\Task;
use App\Utils\Traits\MakesHash;
use Carbon\Carbon;
use DOMDocument;
use DOMXPath;
use Exception;
@ -249,11 +250,18 @@ trait DesignHelpers
}
foreach ($_logs as $log) {
$logs[] = sprintf(
'%s - %s',
\Carbon\Carbon::createFromTimestamp($log[0])->format($task->client->date_format() . ' h:i:s'),
\Carbon\Carbon::createFromTimestamp($log[1])->format($task->client->date_format() . ' h:i:s')
);
$start = Carbon::createFromTimestamp($log[0]);
$finish = Carbon::createFromTimestamp($log[1]);
if ($start->isSameDay($finish)) {
$logs[] = sprintf('%s: %s - %s', $start->format($this->entity->client->date_format()), $start->format('h:i:s'), $finish->format('h:i:s'));
} else {
$logs[] = sprintf(
'%s - %s',
$start->format($this->entity->client->date_format() . ' h:i:s'),
$finish->format($this->entity->client->date_format() . ' h:i:s')
);
}
}
return $logs;

View File

@ -316,6 +316,7 @@ class HtmlEngine
$data['$task.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$task.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$task.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
$data['$task.service'] = ['value' => '', 'label' => ctrans('texts.service')];
if ($this->settings->signature_on_pdf) {
$data['$contact.signature'] = ['value' => $this->invitation->signature_base64, 'label' => ctrans('texts.signature')];

View File

@ -132,7 +132,7 @@ trait AppSetup
if (is_null($position)) {
$words_count > 1 ? $env[] = "{$property}=" . '"' . $value . '"' . "\n" : $env[] = "{$property}=" . $value . "\n";
} else if ($words_count > 1) {
} elseif ($words_count > 1) {
$env[$position] = "{$property}=" . '"' . $value . '"' . "\n"; // If value of variable is more than one word, surround with quotes.
} else {
$env[$position] = "{$property}=" . $value . "\n"; // Just a normal variable update, with prexisting keys.

View File

@ -23,6 +23,7 @@ return [
'date_time_format' => 'Y-m-d H:i',
'daily_email_limit' => 300,
'error_email' => env('ERROR_EMAIL', ''),
'mailer' => env('MAIL_MAILER',''),
'company_id' => 0,
'hash_salt' => env('HASH_SALT', ''),
'currency_converter_api_key' => env('OPENEXCHANGE_APP_ID', ''),

View File

@ -3,9 +3,9 @@ const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
"version.json": "399f70d54a0cf071e6e83bb5382fcdf5",
"version.json": "32afcc2282ccf7746c00708ef0601017",
"favicon.ico": "51636d3a390451561744c42188ccd628",
"main.dart.js": "abbefac6e42c6ac8c46c784c474498bc",
"main.dart.js": "93b0d3c3a17ae9148c1dfd198f6b450e",
"/": "23224b5e03519aaa87594403d54412cf",
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
"assets/AssetManifest.json": "ea09ed4b9b8b6c83d6896248aac7c527",

196570
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"app_name":"invoiceninja_flutter","version":"5.0.26","build_number":"26"}
{"app_name":"invoiceninja_flutter","version":"5.0.27","build_number":"27"}

View File

@ -3214,7 +3214,7 @@ return [
'checkout_com' => 'Checkout.com',
'footer_label' => 'Copyright © :year Invoice Ninja. All rights reserved.',
'footer_label' => 'Copyright © :year :company. All rights reserved.',
'credit_card_invalid' => 'Provided credit card number is not valid.',
'month_invalid' => 'Provided month is not valid.',
@ -3311,4 +3311,6 @@ return [
'billing_country' => 'Billing Country',
'shipping_country' => 'Shipping Country',
'service' => 'Service',
];

View File

@ -1,7 +1,7 @@
<footer class="bg-white px-4 py-5 shadow px-4 sm:px-6 md:px-8 flex justify-center border border-gray-200 justify-between items-center" x-data="{ privacy: false, tos: false }">
<section>
<span class="text-xs md:text-sm text-gray-700">{{ ctrans('texts.footer_label', ['year' => date('Y')]) }}</span>
<span class="text-xs md:text-sm text-gray-700">{{ ctrans('texts.footer_label', ['company' => auth('contact')->user() ? (auth('contact')->user()->user->account->isPaid() ? auth('contact')->user()->company->present()->name() : 'Invoice Ninja') : 'Invoice Ninja', 'year' => date('Y')]) }}</span>
<div class="flex items-center space-x-2">
@if(strlen($client->getSetting('client_portal_privacy_policy')) > 1)
<a x-on:click="privacy = true; tos = false" href="#" class="button-link text-sm primary-color flex items-center">{{ __('texts.privacy_policy')}}</a>

View File

@ -14,6 +14,8 @@
</a>
@endforeach
</nav>
@if(!auth('contact')->user()->user->account->isPaid())
<div class="flex-shrink-0 flex bg-primary p-4 justify-center">
<div class="flex items-center">
<a href="https://www.facebook.com/invoiceninja/">
@ -38,6 +40,7 @@
</a>
</div>
</div>
@endif
</div>
<div class="flex-shrink-0 w-14"></div>
</div>

View File

@ -20,6 +20,8 @@
</a>
@endforeach
</nav>
@if(!auth('contact')->user()->user->account->isPaid())
<div class="flex-shrink-0 flex bg-primary p-4 justify-center">
<div class="flex items-center">
<a href="https://www.facebook.com/invoiceninja/">
@ -44,6 +46,7 @@
</a>
</div>
</div>
@endif
</div>
<div class="flex-shrink-0 w-14"></div>
</div>

View File

@ -2,8 +2,6 @@
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<!-- Source: https://github.com/invoiceninja/invoiceninja -->
<!-- Error: {{ session('error') }} -->
@if (config('services.analytics.tracking_id'))
@ -32,8 +30,15 @@
</script>
@endif
<!-- Title -->
<title>@yield('meta_title', 'Invoice Ninja') {{ config('app.name') }}</title>
@auth()
<title>@yield('meta_title', '') {{ auth('contact')->user()->user->account->isPaid() ? auth('contact')->user()->company->present()->name() : 'Invoice Ninja' }}</title>
@endauth
@guest
<title>@yield('meta_title', '') {{ config('app.name') }}</title>
@endguest
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -2,8 +2,6 @@
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<!-- Source: https://github.com/invoiceninja/invoiceninja -->
<!-- Error: {{ session('error') }} -->
@if (config('services.analytics.tracking_id'))
@ -33,7 +31,13 @@
@endif
<!-- Title -->
<title>@yield('meta_title', 'Invoice Ninja') | {{ config('app.name') }}</title>
@auth()
<title>@yield('meta_title', '') {{ auth('contact')->user()->user->account->isPaid() ? auth('contact')->user()->company->present()->name() : 'Invoice Ninja' }}</title>
@endauth
@guest
<title>@yield('meta_title', '') {{ config('app.name') }}</title>
@endguest
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">