Merge branch 'master' of github.com:akaunting/akaunting

This commit is contained in:
Cüneyt Şentürk 2023-03-06 13:57:14 +03:00
commit f2b73d83d8
16 changed files with 224 additions and 105 deletions

View File

@ -31,7 +31,7 @@ class Bills extends BulkAction
], ],
'cancelled' => [ 'cancelled' => [
'icon' => 'cancel', 'icon' => 'cancel',
'name' => 'general.cancel', 'name' => 'documents.actions.cancel',
'message' => 'bulk_actions.message.cancelled', 'message' => 'bulk_actions.message.cancelled',
'permission' => 'update-purchases-bills', 'permission' => 'update-purchases-bills',
], ],

View File

@ -31,7 +31,7 @@ class Invoices extends BulkAction
], ],
'cancelled' => [ 'cancelled' => [
'icon' => 'cancel', 'icon' => 'cancel',
'name' => 'general.cancel', 'name' => 'documents.actions.cancel',
'message' => 'bulk_actions.message.cancelled', 'message' => 'bulk_actions.message.cancelled',
'permission' => 'update-sales-invoices', 'permission' => 'update-sales-invoices',
], ],

View File

@ -0,0 +1,20 @@
<?php
namespace App\Events\Document;
use App\Abstracts\Event;
class DocumentSending extends Event
{
public $document;
/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}

View File

@ -10,6 +10,7 @@ use App\Imports\Sales\Invoices as Import;
use App\Jobs\Document\CreateDocument; use App\Jobs\Document\CreateDocument;
use App\Jobs\Document\DeleteDocument; use App\Jobs\Document\DeleteDocument;
use App\Jobs\Document\DuplicateDocument; use App\Jobs\Document\DuplicateDocument;
use App\Jobs\Document\SendDocument;
use App\Jobs\Document\UpdateDocument; use App\Jobs\Document\UpdateDocument;
use App\Models\Document\Document; use App\Models\Document\Document;
use App\Notifications\Sale\Invoice as Notification; use App\Notifications\Sale\Invoice as Notification;
@ -260,12 +261,17 @@ class Invoices extends Controller
return redirect()->back(); return redirect()->back();
} }
// Notify the customer $response = $this->ajaxDispatch(new SendDocument($invoice));
$invoice->contact->notify(new Notification($invoice, 'invoice_new_customer', true));
event(new \App\Events\Document\DocumentSent($invoice)); if ($response['success']) {
$message = trans('documents.messages.email_sent', ['type' => trans_choice('general.invoices', 1)]);
flash(trans('documents.messages.email_sent', ['type' => trans_choice('general.invoices', 1)]))->success(); flash($message)->success();
} else {
$message = $response['message'];
flash($message)->error()->important();
}
return redirect()->back(); return redirect()->back();
} }

View File

@ -0,0 +1,26 @@
<?php
namespace App\Jobs\Document;
use App\Abstracts\Job;
use App\Events\Document\DocumentSending;
use App\Events\Document\DocumentSent;
use App\Models\Document\Document;
class SendDocument extends Job
{
public function __construct(Document $document)
{
$this->document = $document;
}
public function handle(): void
{
event(new DocumentSending($document));
// Notify the customer
$invoice->contact->notify(new Notification($invoice, 'invoice_new_customer', true));
event(new DocumentSent($document));
}
}

View File

@ -3,6 +3,7 @@
namespace App\Jobs\Document; namespace App\Jobs\Document;
use App\Abstracts\Job; use App\Abstracts\Job;
use App\Events\Document\DocumentSending;
use App\Events\Document\DocumentSent; use App\Events\Document\DocumentSent;
use App\Models\Document\Document; use App\Models\Document\Document;
@ -18,6 +19,8 @@ class SendDocumentAsCustomMail extends Job
{ {
$document = Document::find($this->request->get('document_id')); $document = Document::find($this->request->get('document_id'));
event(new DocumentSending($document));
$custom_mail = $this->request->only(['to', 'subject', 'body']); $custom_mail = $this->request->only(['to', 'subject', 'body']);
if ($this->request->get('user_email', false)) { if ($this->request->get('user_email', false)) {

View File

@ -0,0 +1,71 @@
<?php
namespace App\Listeners\Update\V30;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Traits\Categories;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class Version3013 extends Listener
{
use Categories;
const ALIAS = 'core';
const VERSION = '3.0.13';
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
if ($this->skipThisUpdate($event)) {
return;
}
Log::channel('stdout')->info('Updating to 3.0.13 version...');
DB::transaction(function () {
$types = $this->getTypesByAllowedTranslations();
foreach ($types as $type => $translations) {
DB::table('categories')->whereIn('type', $translations)->update(['type' => $type]);
}
});
Log::channel('stdout')->info('Done!');
}
protected function getTypesByAllowedTranslations(): array
{
$types = $this->getCategoryTypes(false);
$lang_codes = array_keys(language()->allowed());
foreach ($types as $type => $trans_name) {
$translations_for_type = [];
foreach ($lang_codes as $lang_code) {
$translation = trans_choice($trans_name, 1, locale: $lang_code);
if ($translation === $trans_name) {
continue;
}
$translations_for_type[] = $translation;
}
$types[$type] = $translations_for_type;
}
/**
* Example: en-GB es-ES
* 'income' => ['Income', 'Ingresos']
*/
return $types;
}
}

View File

@ -614,7 +614,7 @@ class Document extends Model
if (! in_array($this->status, ['cancelled', 'draft'])) { if (! in_array($this->status, ['cancelled', 'draft'])) {
try { try {
$actions[] = [ $actions[] = [
'title' => trans('general.cancel'), 'title' => trans('documents.actions.cancel'),
'icon' => 'cancel', 'icon' => 'cancel',
'url' => route($prefix . '.cancelled', $this->id), 'url' => route($prefix . '.cancelled', $this->id),
'permission' => 'update-' . $group . '-' . $permission_prefix, 'permission' => 'update-' . $group . '-' . $permission_prefix,

View File

@ -21,6 +21,7 @@ class Event extends Provider
'App\Listeners\Update\V30\Version305', 'App\Listeners\Update\V30\Version305',
'App\Listeners\Update\V30\Version307', 'App\Listeners\Update\V30\Version307',
'App\Listeners\Update\V30\Version309', 'App\Listeners\Update\V30\Version309',
'App\Listeners\Update\V30\Version3013',
], ],
'Illuminate\Auth\Events\Login' => [ 'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login', 'App\Listeners\Auth\Login',

View File

@ -7,7 +7,7 @@ use Illuminate\Support\Str;
trait Categories trait Categories
{ {
public function getCategoryTypes(): array public function getCategoryTypes(bool $translate = true): array
{ {
$types = []; $types = [];
$configs = config('type.category'); $configs = config('type.category');
@ -21,7 +21,7 @@ trait Categories
$name = $attr['alias'] . '::' . $name; $name = $attr['alias'] . '::' . $name;
} }
$types[$type] = trans_choice($name, 1); $types[$type] = $translate ? trans_choice($name, 1) : $name;
} }
return $types; return $types;

View File

@ -156,20 +156,4 @@ return [
*/ */
'middleware' => explode(',', env('API_MIDDLEWARE', 'api')), 'middleware' => explode(',', env('API_MIDDLEWARE', 'api')),
/*
|--------------------------------------------------------------------------
| Rate Limit (Throttle)
|--------------------------------------------------------------------------
|
| Consumers of your API can be limited to the amount of requests they can
| make. You can create your own throttles or simply change the default
| throttles.
|
*/
'rate_limit' => [
Limit::perMinute(env('API_RATE_LIMIT', 60)),
],
]; ];

View File

@ -10,6 +10,10 @@ return [
'billing' => 'Billing', 'billing' => 'Billing',
'advanced' => 'Advanced', 'advanced' => 'Advanced',
'actions' => [
'cancel' => 'Cancel',
],
'invoice_detail' => [ 'invoice_detail' => [
'marked' => '<b>You</b> marked this invoice as', 'marked' => '<b>You</b> marked this invoice as',
'services' => 'Services', 'services' => 'Services',

View File

@ -61,6 +61,7 @@
</br> </br>
<div class="flex flex-row">
@if (! empty($transaction->contact) && $transaction->contact->email) @if (! empty($transaction->contact) && $transaction->contact->email)
<x-button id="show-slider-actions-transaction-send-email-{{ $document->type }}-{{ $transaction->id }}" class="text-purple mt-1" override="class" @click="onEmailViaTemplate('{{ route($transactionEmailRoute, $transaction->id) }}', '{{ $transactionEmailTemplate }}')"> <x-button id="show-slider-actions-transaction-send-email-{{ $document->type }}-{{ $transaction->id }}" class="text-purple mt-1" override="class" @click="onEmailViaTemplate('{{ route($transactionEmailRoute, $transaction->id) }}', '{{ $transactionEmailTemplate }}')">
<x-button.hover color="to-purple"> <x-button.hover color="to-purple">
@ -77,7 +78,7 @@
</x-tooltip> </x-tooltip>
@endif @endif
<span> - </span> <span class="mt-1 mr-2 ml-2"> - </span>
<x-button <x-button
@click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')" @click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')"
@ -90,7 +91,7 @@
</x-button.hover> </x-button.hover>
</x-button> </x-button>
<span> - </span> <span class="mt-1 mr-2 ml-2"> - </span>
@php @php
$message = trans('general.delete_confirm', [ $message = trans('general.delete_confirm', [
@ -110,6 +111,7 @@
override="class" override="class"
/> />
</div> </div>
</div>
@endforeach @endforeach
@else @else
<div class="my-2"> <div class="my-2">

View File

@ -44,6 +44,7 @@
</br> </br>
<div class="flex flex-row">
@if (! empty($transaction->contact) && $transaction->contact->email) @if (! empty($transaction->contact) && $transaction->contact->email)
<x-button id="show-slider-actions-transaction-send-email-{{ $document->type }}-{{ $transaction->id }}" class="text-purple mt-1" override="class" @click="onEmailViaTemplate('{{ route($transactionEmailRoute, $transaction->id) }}', '{{ $transactionEmailTemplate }}')"> <x-button id="show-slider-actions-transaction-send-email-{{ $document->type }}-{{ $transaction->id }}" class="text-purple mt-1" override="class" @click="onEmailViaTemplate('{{ route($transactionEmailRoute, $transaction->id) }}', '{{ $transactionEmailTemplate }}')">
<x-button.hover color="to-purple"> <x-button.hover color="to-purple">
@ -60,7 +61,7 @@
</x-tooltip> </x-tooltip>
@endif @endif
<span> - </span> <span class="mt-1 mr-2 ml-2"> - </span>
<x-button <x-button
@click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')" @click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')"
@ -73,7 +74,7 @@
</x-button.hover> </x-button.hover>
</x-button> </x-button>
<span> - </span> <span class="mt-1 mr-2 ml-2"> - </span>
@php @php
$message = trans('general.delete_confirm', [ $message = trans('general.delete_confirm', [
@ -93,6 +94,7 @@
override="class" override="class"
/> />
</div> </div>
</div>
@endforeach @endforeach
@else @else
<div class="my-2"> <div class="my-2">

View File

@ -113,7 +113,7 @@
<x-dropdown.divider /> <x-dropdown.divider />
<x-dropdown.link href="{{ route($cancelledRoute, $document->id) }}" id="show-more-actions-cancel-{{ $document->type }}"> <x-dropdown.link href="{{ route($cancelledRoute, $document->id) }}" id="show-more-actions-cancel-{{ $document->type }}">
{{ trans('general.cancel') }} {{ trans('documents.actions.cancel') }}
</x-dropdown.link> </x-dropdown.link>
@endcan @endcan
@endif @endif

View File

@ -10,7 +10,7 @@
value="{{ $signedUrl }}" value="{{ $signedUrl }}"
ref="clone" ref="clone"
@click="onCopyLink()" @click="onCopyLink()"
style="appearance: none; background-color: whitesmoke; border: none; font-size: 16px;" style="appearance: none; background-color: whitesmoke; cursor:pointer; border: none; font-size: 16px;"
/> />
<x-form.input.hidden name="hidden-share" value="{{ $signedUrl }}" /> <x-form.input.hidden name="hidden-share" value="{{ $signedUrl }}" />