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

@@ -23,11 +23,11 @@ class MarkDocumentCancelled
$type_text = '';
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
$type_text .= $alias . '::';
}
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);

View File

@@ -26,11 +26,11 @@ class MarkDocumentReceived
$type_text = '';
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
$type_text .= $alias . '::';
}
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);

View File

@@ -26,11 +26,11 @@ class MarkDocumentSent
$type_text = '';
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
$type_text .= $alias . '::';
}
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);

View File

@@ -31,11 +31,11 @@ class MarkDocumentViewed
$type_text = '';
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
$type_text .= $alias . '::';
}
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);

View File

@@ -19,10 +19,6 @@ class SendDocumentPaymentNotification
return;
}
if (!empty($event->request['mark_paid'])) {
return;
}
$document = $event->document;
$transaction = $document->transactions()->latest()->first();
@@ -33,7 +29,7 @@ class SendDocumentPaymentNotification
// Notify all users assigned to this company
foreach ($document->company->users as $user) {
if (!$user->can('read-notifications')) {
if ($user->cannot('read-notifications')) {
continue;
}

View File

@@ -3,9 +3,12 @@
namespace App\Listeners\Document;
use App\Events\Document\DocumentRecurring as Event;
use App\Traits\Documents;
class SendDocumentRecurringNotification
{
use Documents;
/**
* Handle the event.
*
@@ -15,21 +18,25 @@ class SendDocumentRecurringNotification
public function handle(Event $event)
{
$document = $event->document;
$config = config('type.' . $document->type . '.notification');
$config = config('type.document.' . $document->type . '.notification');
if (empty($config) || empty($config['class'])) {
return;
}
if ($document->parent?->recurring?->auto_send == false) {
return;
}
$notification = $config['class'];
// Notify the customer
if ($config['notify_contact'] && $document->contact && !empty($document->contact_email)) {
if ($this->canNotifyTheContactOfDocument($document)) {
$document->contact->notify(new $notification($document, "{$document->type}_recur_customer"));
}
// Check if should notify users
if (!$config['notify_user']) {
if (! $config['notify_user']) {
return;
}

View File

@@ -3,9 +3,12 @@
namespace App\Listeners\Document;
use App\Events\Document\DocumentReminded as Event;
use App\Traits\Documents;
class SendDocumentReminderNotification
{
use Documents;
/**
* Handle the event.
*
@@ -18,13 +21,13 @@ class SendDocumentReminderNotification
$notification = $event->notification;
// Notify the customer
if ($document->contact && !empty($document->contact_email)) {
if ($this->canNotifyTheContactOfDocument($document)) {
$document->contact->notify(new $notification($document, "{$document->type}_remind_customer"));
}
// Notify all users assigned to this company
foreach ($document->company->users as $user) {
if (!$user->can('read-notifications')) {
if ($user->cannot('read-notifications')) {
continue;
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Listeners\Document;
use App\Events\Document\DocumentViewed as Event;
use App\Traits\Documents;
class SendDocumentViewNotification
{
use Documents;
/**
* Handle the event.
*
* @param $event
* @return array
*/
public function handle(Event $event)
{
$document = $event->document;
$config = config('type.document.' . $document->type . '.notification');
if (empty($config) || empty($config['class'])) {
return;
}
// Check if should notify users
if (! $config['notify_user']) {
return;
}
$notification = $config['class'];
// Notify all users assigned to this company
foreach ($document->company->users as $user) {
if ($user->cannot('read-notifications')) {
continue;
}
$user->notify(new $notification($document, "{$document->type}_view_admin"));
}
}
}

View File

@@ -53,7 +53,7 @@ class SettingFieldCreated
$company = Company::find($document->company_id);
foreach ($files as $key => $value) {
// Upload attachment
// Upload attachment
$media = $this->getMedia($value, 'settings');
$company->attachMedia($media, Str::snake($real_key));