akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -0,0 +1,52 @@
<?php
namespace App\Notifications\Auth;
use App\Models\Auth\UserInvitation;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class Invitation extends Notification
{
/**
* The password reset token.
*
* @var UserInvitation
*/
public $invitation;
/**
* Create a notification instance.
*
* @param UserInvitation $invitation
*/
public function __construct($invitation)
{
$this->invitation = $invitation;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line(trans('auth.invitation.message_1'))
->action(trans('auth.invitation.button'), route('register', $this->invitation->token))
->line(trans('auth.invitation.message_2'));
}
}

View File

@ -0,0 +1,121 @@
<?php
namespace App\Notifications\Banking;
use App\Abstracts\Notification;
use App\Models\Banking\Transaction as Model;
use App\Models\Setting\EmailTemplate;
use App\Traits\Transactions;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
class Transaction extends Notification
{
use Transactions;
/**
* The transaction model.
*
* @var object
*/
public $transaction;
/**
* The email template.
*
* @var EmailTemplate
*/
public $template;
/**
* Should attach pdf or not.
*
* @var bool
*/
public $attach_pdf;
/**
* Create a notification instance.
*/
public function __construct(Model $transaction = null, string $template_alias = null, bool $attach_pdf = false)
{
parent::__construct();
$this->transaction = $transaction;
$this->template = EmailTemplate::alias($template_alias)->first();
$this->attach_pdf = $attach_pdf;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*/
public function toMail($notifiable): MailMessage
{
$message = $this->initMailMessage();
// Attach the PDF file
if ($this->attach_pdf) {
$message->attach($this->storeTransactionPdfAndGetPath($this->transaction), [
'mime' => 'application/pdf',
]);
}
return $message;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable): array
{
return [
'template_alias' => $this->template->alias,
'title' => trans('notifications.menu.' . $this->template->alias . '.title'),
'description' => trans('notifications.menu.' . $this->template->alias . '.description', $this->getTagsBinding()),
'transaction_id' => $this->transaction->id,
'contact_name' => $this->transaction->contact->name,
'amount' => $this->transaction->amount,
'transaction_date' => company_date($this->transaction->paid_at),
];
}
public function getTags(): array
{
return [
'{payment_amount}',
'{payment_date}',
'{payment_guest_link}',
'{payment_admin_link}',
'{payment_portal_link}',
'{contact_name}',
'{company_name}',
'{company_email}',
'{company_tax_number}',
'{company_phone}',
'{company_address}',
];
}
public function getTagsReplacement(): array
{
return [
money($this->transaction->amount, $this->transaction->currency_code, true),
company_date($this->transaction->paid_at),
URL::signedRoute('signed.payments.show', [$this->transaction->id]),
route('transactions.show', $this->transaction->id),
route('portal.payments.show', $this->transaction->id),
$this->transaction->contact->name,
$this->transaction->company->name,
$this->transaction->company->email,
$this->transaction->company->tax_number,
$this->transaction->company->phone,
nl2br(trim($this->transaction->company->address)),
];
}
}

View File

@ -51,7 +51,7 @@ class ExportCompleted extends Notification implements ShouldQueue
public function toMail($notifiable)
{
return (new MailMessage)
->subject(trans('notifications.export.completed.subject'))
->subject(trans('notifications.export.completed.title'))
->line(trans('notifications.export.completed.description'))
->action(trans('general.download'), $this->download_url);
}
@ -65,6 +65,11 @@ class ExportCompleted extends Notification implements ShouldQueue
public function toArray($notifiable)
{
return [
'title' => trans('notifications.menu.export_completed.title'),
'description' => trans('notifications.menu.export_completed.description', [
'type' => $this->translation,
'url' => $this->download_url,
]),
'translation' => $this->translation,
'file_name' => $this->file_name,
'download_url' => $this->download_url,

View File

@ -50,7 +50,7 @@ class ExportFailed extends Notification implements ShouldQueue
public function toMail($notifiable)
{
return (new MailMessage)
->subject(trans('notifications.export.failed.subject'))
->subject(trans('notifications.export.failed.title'))
->line(trans('notifications.export.failed.description'))
->line($this->message);
}
@ -64,6 +64,10 @@ class ExportFailed extends Notification implements ShouldQueue
public function toArray($notifiable)
{
return [
'title' => trans('notifications.menu.export_failed.title'),
'description' => trans('notifications.menu.export_failed.description', [
'issues' => $this->message,
]),
'message' => $this->message,
];
}

View File

@ -48,7 +48,7 @@ class ImportCompleted extends Notification implements ShouldQueue
$dashboard_url = route('dashboard', ['company_id' => company_id()]);
return (new MailMessage)
->subject(trans('notifications.import.completed.subject'))
->subject(trans('notifications.import.completed.title'))
->line(trans('notifications.import.completed.description'))
->action(trans_choice('general.dashboards', 1), $dashboard_url);
}
@ -62,6 +62,11 @@ class ImportCompleted extends Notification implements ShouldQueue
public function toArray($notifiable)
{
return [
'title' => trans('notifications.menu.import_completed.title'),
'description' => trans('notifications.menu.import_completed.description', [
'type' => $this->translation,
'count' => $this->total_rows,
]),
'translation' => $this->translation,
'total_rows' => $this->total_rows,
];

View File

@ -50,7 +50,7 @@ class ImportFailed extends Notification implements ShouldQueue
public function toMail($notifiable)
{
$message = (new MailMessage)
->subject(trans('notifications.import.failed.subject'))
->subject(trans('notifications.import.failed.title'))
->line(trans('notifications.import.failed.description'));
foreach ($this->errors as $error) {
@ -69,6 +69,10 @@ class ImportFailed extends Notification implements ShouldQueue
public function toArray($notifiable)
{
return [
'title' => trans('notifications.menu.import_failed.title'),
'description' => trans('notifications.menu.import_failed.description', [
'issues' => $this->errors,
]),
'errors' => $this->errors,
];
}

View File

@ -62,11 +62,11 @@ class UpdateFailed extends Notification
*/
public function toMail($notifiable)
{
$subject = trans('notifications.update.mail.subject', [
$subject = trans('notifications.update.mail.title', [
'domain' => request()->getHttpHost(),
]);
$message = trans('notifications.update.mail.message', [
$message = trans('notifications.update.mail.description', [
'alias' => $this->getAliasName(),
'current_version' => $this->event->old,
'new_version' => $this->event->new,
@ -88,7 +88,7 @@ class UpdateFailed extends Notification
*/
public function toSlack($notifiable)
{
$message = trans('notifications.update.slack.message', [
$message = trans('notifications.update.slack.description', [
'domain' => request()->getHttpHost(),
]);

View File

@ -3,9 +3,13 @@
namespace App\Notifications\Portal;
use App\Abstracts\Notification;
use App\Models\Common\EmailTemplate;
use App\Models\Banking\Transaction;
use App\Models\Setting\EmailTemplate;
use App\Models\Document\Document;
use App\Traits\Documents;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
class PaymentReceived extends Notification
{
@ -21,14 +25,14 @@ class PaymentReceived extends Notification
/**
* The payment transaction.
*
* @var string
* @var Transaction
*/
public $transaction;
/**
* The email template.
*
* @var \App\Models\Common\EmailTemplate
* @var EmailTemplate
*/
public $template;
@ -41,13 +45,8 @@ class PaymentReceived extends Notification
/**
* Create a notification instance.
*
* @param object $invoice
* @param object $transaction
* @param object $template_alias
* @param object $attach_pdf
*/
public function __construct($invoice = null, $transaction = null, $template_alias = null, $attach_pdf = false)
public function __construct(Document $invoice = null, Transaction $transaction = null, string $template_alias = null, bool $attach_pdf = false)
{
parent::__construct();
@ -61,11 +60,10 @@ class PaymentReceived extends Notification
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
public function toMail($notifiable): MailMessage
{
$message = $this->initMessage();
$message = $this->initMailMessage();
// Attach the PDF file
if ($this->attach_pdf) {
@ -81,12 +79,13 @@ class PaymentReceived extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
public function toArray($notifiable): array
{
return [
'template_alias' => $this->template->alias,
'title' => trans('notifications.menu.' . $this->template->alias . '.title'),
'description' => trans('notifications.menu.' . $this->template->alias . '.description', $this->getTagsBinding()),
'invoice_id' => $this->invoice->id,
'invoice_number' => $this->invoice->document_number,
'customer_name' => $this->invoice->contact_name,
@ -97,7 +96,7 @@ class PaymentReceived extends Notification
];
}
public function getTags()
public function getTags(): array
{
return [
'{invoice_number}',
@ -119,7 +118,7 @@ class PaymentReceived extends Notification
];
}
public function getTagsReplacement()
public function getTagsReplacement(): array
{
return [
$this->invoice->document_number,

View File

@ -3,31 +3,31 @@
namespace App\Notifications\Purchase;
use App\Abstracts\Notification;
use App\Models\Common\EmailTemplate;
use App\Models\Setting\EmailTemplate;
use App\Models\Document\Document;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Str;
class Bill extends Notification
{
/**
* The bill model.
*
* @var object
* @var Document
*/
public $bill;
/**
* The email template.
*
* @var \App\Models\Common\EmailTemplate
* @var EmailTemplate
*/
public $template;
/**
* Create a notification instance.
*
* @param object $bill
* @param object $template_alias
*/
public function __construct($bill = null, $template_alias = null)
public function __construct(Document $bill = null, string $template_alias = null)
{
parent::__construct();
@ -39,11 +39,10 @@ class Bill extends Notification
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
public function toMail($notifiable): MailMessage
{
$message = $this->initMessage();
$message = $this->initMailMessage();
return $message;
}
@ -52,12 +51,13 @@ class Bill extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
public function toArray($notifiable): array
{
return [
'template_alias' => $this->template->alias,
'title' => trans('notifications.menu.' . $this->template->alias . '.title'),
'description' => trans('notifications.menu.' . $this->template->alias . '.description', $this->getTagsBinding()),
'bill_id' => $this->bill->id,
'bill_number' => $this->bill->document_number,
'vendor_name' => $this->bill->contact_name,
@ -68,7 +68,7 @@ class Bill extends Notification
];
}
public function getTags()
public function getTags(): array
{
return [
'{bill_number}',
@ -86,7 +86,7 @@ class Bill extends Notification
];
}
public function getTagsReplacement()
public function getTagsReplacement(): array
{
return [
$this->bill->document_number,

View File

@ -3,9 +3,10 @@
namespace App\Notifications\Purchase;
use App\Abstracts\Notification;
use App\Models\Common\EmailTemplate;
use App\Models\Setting\EmailTemplate;
use App\Traits\Transactions;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
class Payment extends Notification
{
@ -21,7 +22,7 @@ class Payment extends Notification
/**
* The email template.
*
* @var \App\Models\Common\EmailTemplate
* @var EmailTemplate
*/
public $template;
@ -78,6 +79,8 @@ class Payment extends Notification
{
return [
'template_alias' => $this->template->alias,
'title' => trans('notifications.menu.' . $this->template->alias . '.title'),
'description' => trans('notifications.menu.' . $this->template->alias . '.description', $this->getTagsBinding()),
'payment_id' => $this->payment->id,
'vendor_name' => $this->payment->contact->name,
'amount' => $this->payment->amount,

View File

@ -3,9 +3,12 @@
namespace App\Notifications\Sale;
use App\Abstracts\Notification;
use App\Models\Common\EmailTemplate;
use App\Models\Setting\EmailTemplate;
use App\Models\Document\Document;
use App\Traits\Documents;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
class Invoice extends Notification
{
@ -21,7 +24,7 @@ class Invoice extends Notification
/**
* The email template.
*
* @var \App\Models\Common\EmailTemplate
* @var EmailTemplate
*/
public $template;
@ -34,29 +37,29 @@ class Invoice extends Notification
/**
* Create a notification instance.
*
* @param object $invoice
* @param object $template_alias
* @param object $attach_pdf
*/
public function __construct($invoice = null, $template_alias = null, $attach_pdf = false)
public function __construct(Document $invoice = null, string $template_alias = null, bool $attach_pdf = false, array $custom_mail = [])
{
parent::__construct();
$this->invoice = $invoice;
$this->template = EmailTemplate::alias($template_alias)->first();
$this->attach_pdf = $attach_pdf;
$this->custom_mail = $custom_mail;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
public function toMail($notifiable): MailMessage
{
$message = $this->initMessage();
if (!empty($this->custom_mail['to'])) {
$notifiable->email = $this->custom_mail['to'];
}
$message = $this->initMailMessage();
// Attach the PDF file
if ($this->attach_pdf) {
@ -72,12 +75,13 @@ class Invoice extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
public function toArray($notifiable): array
{
return [
'template_alias' => $this->template->alias,
'title' => trans('notifications.menu.' . $this->template->alias . '.title'),
'description' => trans('notifications.menu.' . $this->template->alias . '.description', $this->getTagsBinding()),
'invoice_id' => $this->invoice->id,
'invoice_number' => $this->invoice->document_number,
'customer_name' => $this->invoice->contact_name,
@ -88,7 +92,7 @@ class Invoice extends Notification
];
}
public function getTags()
public function getTags(): array
{
return [
'{invoice_number}',
@ -108,7 +112,7 @@ class Invoice extends Notification
];
}
public function getTagsReplacement()
public function getTagsReplacement(): array
{
return [
$this->invoice->document_number,

View File

@ -1,121 +0,0 @@
<?php
namespace App\Notifications\Sale;
use App\Abstracts\Notification;
use App\Models\Common\EmailTemplate;
use App\Traits\Transactions;
use Illuminate\Support\Facades\URL;
class Revenue extends Notification
{
use Transactions;
/**
* The revenue model.
*
* @var object
*/
public $revenue;
/**
* The email template.
*
* @var \App\Models\Common\EmailTemplate
*/
public $template;
/**
* Should attach pdf or not.
*
* @var bool
*/
public $attach_pdf;
/**
* Create a notification instance.
*
* @param object $revenue
* @param object $template_alias
* @param object $attach_pdf
*/
public function __construct($revenue = null, $template_alias = null, $attach_pdf = false)
{
parent::__construct();
$this->revenue = $revenue;
$this->template = EmailTemplate::alias($template_alias)->first();
$this->attach_pdf = $attach_pdf;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$message = $this->initMessage();
// Attach the PDF file
if ($this->attach_pdf) {
$message->attach($this->storeTransactionPdfAndGetPath($this->revenue), [
'mime' => 'application/pdf',
]);
}
return $message;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'template_alias' => $this->template->alias,
'revenue_id' => $this->revenue->id,
'customer_name' => $this->revenue->contact->name,
'amount' => $this->revenue->amount,
'revenue_date' => company_date($this->revenue->paid_at),
];
}
public function getTags()
{
return [
'{revenue_amount}',
'{revenue_date}',
'{revenue_guest_link}',
'{revenue_admin_link}',
'{revenue_portal_link}',
'{customer_name}',
'{company_name}',
'{company_email}',
'{company_tax_number}',
'{company_phone}',
'{company_address}',
];
}
public function getTagsReplacement()
{
return [
money($this->revenue->amount, $this->revenue->currency_code, true),
company_date($this->revenue->paid_at),
URL::signedRoute('signed.payments.show', [$this->revenue->id]),
route('revenues.show', $this->revenue->id),
route('portal.payments.show', $this->revenue->id),
$this->revenue->contact->name,
$this->revenue->company->name,
$this->revenue->company->email,
$this->revenue->company->tax_number,
$this->revenue->company->phone,
nl2br(trim($this->revenue->company->address)),
];
}
}