Merge branch 'akaunting:master' into button-loading

This commit is contained in:
Burak Civan
2022-06-16 18:35:14 +03:00
committed by GitHub
128 changed files with 4246 additions and 14911 deletions

View File

@ -2,7 +2,7 @@
namespace App\Abstracts;
use Akaunting\Apexcharts\Charts as Apexcharts;
use Akaunting\Apexcharts\Chart;
use App\Events\Report\DataLoaded;
use App\Events\Report\DataLoading;
use App\Events\Report\FilterApplying;
@ -14,7 +14,6 @@ use App\Exports\Common\Reports as Export;
use App\Models\Common\Report as Model;
use App\Models\Document\Document;
use App\Models\Setting\Category;
use App\Traits\Charts;
use App\Traits\DateTime;
use App\Traits\SearchString;
use App\Traits\Translations;
@ -24,7 +23,7 @@ use Illuminate\Support\Str;
abstract class Report
{
use Charts, DateTime, SearchString, Translations;
use DateTime, SearchString, Translations;
public $model;
@ -176,7 +175,7 @@ abstract class Report
public function getBarChart($table_key)
{
$chart = new Apexcharts();
$chart = new Chart();
if (empty($this->chart)) {
return $chart;
@ -194,7 +193,7 @@ abstract class Report
public function getDonutChart($table_key)
{
$chart = new Apexcharts();
$chart = new Chart();
if (empty($this->chart)) {
return $chart;

View File

@ -975,7 +975,7 @@ abstract class Show extends Component
$backgroundColor = setting($this->getSettingKey($type, 'color'), '#55588b');
return $backgroundColor;
return $this->convertClasstoHex($backgroundColor);
}
protected function getTextDocumentTitle($type, $textDocumentTitle)

View File

@ -276,7 +276,7 @@ abstract class Template extends Component
$backgroundColor = setting($this->getSettingKey($type, 'color'), '#55588b');
return $backgroundColor;
return $this->convertClasstoHex($backgroundColor);
}
protected function getTextDocumentTitle($type, $textDocumentTitle)

View File

@ -299,6 +299,9 @@ abstract class Show extends Component
/** @var bool */
public $hideRecurringMessage;
/** @var bool */
public $hideCreated;
/**
* Create a new component instance.
*
@ -327,7 +330,7 @@ abstract class Show extends Component
string $routeDocumentShow = '', string $routeTransactionShow = '', string $textButtonAddNew = '',
bool $hideSchedule = false, bool $hideChildren = false, bool $hideAttachment = false, $attachment = [],
array $connectTranslations = [], string $textRecurringType = '', bool $hideRecurringMessage = false
array $connectTranslations = [], string $textRecurringType = '', bool $hideRecurringMessage = false, bool $hideCreated = false
) {
$this->type = $type;
$this->transaction = $transaction;
@ -461,6 +464,7 @@ abstract class Show extends Component
$this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType);
$this->hideRecurringMessage = $hideRecurringMessage;
$this->hideCreated = $hideCreated;
}
protected function getTransactionTemplate($type, $transactionTemplate)

View File

@ -5,7 +5,7 @@ namespace App\BulkActions\Sales;
use App\Abstracts\BulkAction;
use App\Events\Document\DocumentCancelled;
use App\Events\Document\DocumentCreated;
use App\Events\Document\DocumentSent;
use App\Events\Document\DocumentMarkedSent;
use App\Events\Document\PaymentReceived;
use App\Exports\Sales\Invoices as Export;
use App\Jobs\Document\DeleteDocument;
@ -58,7 +58,7 @@ class Invoices extends BulkAction
continue;
}
event(new DocumentSent($invoice));
event(new DocumentMarkedSent($invoice));
}
}

View File

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

View File

@ -220,7 +220,7 @@ class Invoices extends Controller
*/
public function markSent(Document $invoice)
{
event(new \App\Events\Document\DocumentSent($invoice));
event(new \App\Events\Document\DocumentMarkedSent($invoice));
$message = trans('documents.messages.marked_sent', ['type' => trans_choice('general.invoices', 1)]);

View File

@ -27,7 +27,13 @@ class Favorites extends Component
foreach ($favorites as $favorite) {
$favorite['active'] = false;
$favorite['url'] = $this->getUrl($favorite);
try {
$favorite['url'] = $this->getUrl($favorite);
} catch (\Exception $e) {
continue;
}
$favorite['id'] = $this->getId($favorite);
if ($this->isActive($favorite['url'])) {

View File

@ -2,7 +2,8 @@
namespace App\Listeners\Document;
use App\Events\Document\DocumentSent as Event;
use App\Events\Document\DocumentMarkedSent;
use App\Events\Document\DocumentSent;
use App\Jobs\Document\CreateDocumentHistory;
use App\Traits\Jobs;
@ -10,13 +11,7 @@ class MarkDocumentSent
{
use Jobs;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
public function handle(DocumentMarkedSent|DocumentSent $event): void
{
if ($event->document->status != 'partial') {
$event->document->status = 'sent';
@ -24,6 +19,11 @@ class MarkDocumentSent
$event->document->save();
}
$this->dispatch(new CreateDocumentHistory($event->document, 0, $this->getDescription($event)));
}
public function getDescription(DocumentMarkedSent|DocumentSent $event): string
{
$type_text = '';
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
@ -34,12 +34,8 @@ class MarkDocumentSent
$type = trans_choice($type_text, 1);
$this->dispatch(
new CreateDocumentHistory(
$event->document,
0,
trans('documents.messages.marked_sent', ['type' => $type])
)
);
$message = ($event instanceof DocumentMarkedSent) ? 'marked_sent' : 'email_sent';
return trans('documents.messages.' . $message, ['type' => $type]);
}
}

View File

@ -480,7 +480,7 @@ class Transaction extends Model
'permission' => 'create-banking-transactions',
'attributes' => [
'id' => 'index-transactions-more-actions-connect-' . $this->id,
'@click' => 'onConnect(\'' . route('transactions.dial', $this->id) . '\')',
'@click' => 'onConnectTransactions(\'' . route('transactions.dial', $this->id) . '\')',
],
];

View File

@ -179,24 +179,29 @@ class Document extends Model
return $query->whereDate('due_at', '=', $date);
}
public function scopeStatus(Builder $query, string $status): Builder
{
return $query->where($this->qualifyColumn('status'), '=', $status);
}
public function scopeAccrued(Builder $query): Builder
{
return $query->whereNotIn('status', ['draft', 'cancelled']);
return $query->whereNotIn($this->qualifyColumn('status'), ['draft', 'cancelled']);
}
public function scopePaid(Builder $query): Builder
{
return $query->where('status', '=', 'paid');
return $query->where($this->qualifyColumn('status'), '=', 'paid');
}
public function scopeNotPaid(Builder $query): Builder
{
return $query->where('status', '<>', 'paid');
return $query->where($this->qualifyColumn('status'), '<>', 'paid');
}
public function scopeFuture(Builder $query): Builder
{
return $query->whereIn('status', $this->getDocumentStatusesForFuture());
return $query->whereIn($this->qualifyColumn('status'), $this->getDocumentStatusesForFuture());
}
public function scopeType(Builder $query, string $type): Builder
@ -244,14 +249,14 @@ class Document extends Model
public function getSentAtAttribute(string $value = null)
{
$sent = $this->histories()->where('status', 'sent')->first();
$sent = $this->histories()->where('document_histories.status', 'sent')->first();
return $sent->created_at ?? null;
}
public function getReceivedAtAttribute(string $value = null)
{
$received = $this->histories()->where('status', 'received')->first();
$received = $this->histories()->where('document_histories.status', 'received')->first();
return $received->created_at ?? null;
}

View File

@ -57,6 +57,9 @@ class Event extends Provider
'App\Listeners\Document\CreateDocumentTransaction',
'App\Listeners\Document\SendDocumentPaymentNotification',
],
'App\Events\Document\DocumentMarkedSent' => [
'App\Listeners\Document\MarkDocumentSent',
],
'App\Events\Document\DocumentSent' => [
'App\Listeners\Document\MarkDocumentSent',
],

View File

@ -2,7 +2,7 @@
namespace App\Traits;
use Akaunting\Apexcharts\Charts as Apexcharts;
use Akaunting\Apexcharts\Chart;
trait Charts
{
@ -54,7 +54,7 @@ trait Charts
$labels[$id] = $this->donut['labels'][$id];
}
$chart = new Apexcharts();
$chart = new Chart();
$chart->setType('donut')
->setWidth($width)
@ -75,7 +75,7 @@ trait Charts
public function getBarChart($name, $width = '100%', $height = 160)
{
$chart = new Apexcharts();
$chart = new Chart();
$chart->setType('bar')
->setWidth($width)

View File

@ -3,11 +3,14 @@
namespace App\Traits;
use Throwable;
use Illuminate\Support\Arr;
trait Translations
{
public function findTranslation($keys, $number = 2)
{
$keys = Arr::wrap($keys);
try {
foreach ($keys as $key) {
if (is_array($key)) {

View File

@ -752,4 +752,111 @@ trait ViewComponents
return '';
}
protected function convertClasstoHex($class)
{
$colors = [
'gray' => '#6b7280',
'gray-50' => '#f9fafb',
'gray-100' => '#f3f4f6',
'gray-200' => '#e5e7eb',
'gray-300' => '#d1d5db',
'gray-400' => '#9ca3af',
'gray-500' => '#6b7280',
'gray-600' => '#4b5563',
'gray-700' => '#374151',
'gray-800' => '#1f2937',
'gray-900' => '#111827',
'red' => '#cc0000',
'red-50' => '#fcf2f2',
'red-100' => '#fae6e6',
'red-200' => '#f2bfbf',
'red-300' => '#eb9999',
'red-400' => '#db4d4d',
'red-500' => '#cc0000',
'red-600' => '#b80000',
'red-700' => '#990000',
'red-800' => '#7a0000',
'red-900' => '#640000',
'yellow' => '#eab308',
'yellow-50' => '#fefce8',
'yellow-100' => '#fef9c3',
'yellow-200' => '#fef08a',
'yellow-300' => '#fde047',
'yellow-400' => '#facc15',
'yellow-500' => '#eab308',
'yellow-600' => '#ca8a04',
'yellow-700' => '#a16207',
'yellow-800' => '#854d0e',
'yellow-900' => '#713f12',
'green' => '#6ea152',
'green-50' => '#f8faf6',
'green-100' => '#f1f6ee',
'green-200' => '#dbe8d4',
'green-300' => '#c5d9ba',
'green-400' => '#9abd86',
'green-500' => '#6ea152',
'green-600' => '#63914a',
'green-700' => '#53793e',
'green-800' => '#426131',
'green-900' => '#364f28',
'blue' => '#006ea6',
'blue-50' => '#f2f8fb',
'blue-100' => '#e6f1f6',
'blue-200' => '#bfdbe9',
'blue-300' => '#99c5db',
'blue-400' => '#4d9ac1',
'blue-500' => '#006ea6',
'blue-600' => '#006395',
'blue-700' => '#00537d',
'blue-800' => '#004264',
'blue-900' => '#003651',
'indigo' => '#6366f1',
'indigo-50' => '#eef2ff',
'indigo-100' => '#e0e7ff',
'indigo-200' => '#c7d2fe',
'indigo-300' => '#a5b4fc',
'indigo-400' => '#818cf8',
'indigo-500' => '#6366f1',
'indigo-600' => '#4f46e5',
'indigo-700' => '#4338ca',
'indigo-800' => '#3730a3',
'indigo-900' => '#312e81',
'purple' => '#55588b',
'purple-50' => '#f7f7f9',
'purple-100' => '#eeeef3',
'purple-200' => '#d5d5e2',
'purple-300' => '#bbbcd1',
'purple-400' => '#888aae',
'purple-500' => '#55588b',
'purple-600' => '#4d4f7d',
'purple-700' => '#404268',
'purple-800' => '#333553',
'purple-900' => '#2a2b44',
'pink' => '#ec4899',
'pink-50' => '#fdf2f8',
'pink-100' => '#fce7f3',
'pink-200' => '#fbcfe8',
'pink-300' => '#f9a8d4',
'pink-400' => '#f472b6',
'pink-500' => '#ec4899',
'pink-600' => '#db2777',
'pink-700' => '#be185d',
'pink-800' => '#9d174d',
'pink-900' => '#831843',
];
if (Arr::exists($colors, $class)) {
return $colors[$class];
}
return $class;
}
}

View File

@ -200,7 +200,15 @@ class DeleteButton extends Component
$page = '';
if (! empty($this->route)) {
$page = explode('.', $this->route)[0];
if (! is_array($this->route)) {
$string = $this->route;
}
if (is_array($this->route)) {
$string = $this->route[0];
}
$page = explode('.', $string)[0];
} elseif (! empty($this->url)) {
$page = explode('/', $this->url)[1];
}

View File

@ -4,11 +4,12 @@ namespace App\View\Components;
use App\Abstracts\View\Component;
use App\Traits\DateTime;
use App\Traits\Translations;
use Illuminate\Support\Str;
class SearchString extends Component
{
use DateTime;
use DateTime, Translations;
public $filters;
@ -203,16 +204,16 @@ class SearchString extends Component
$values = [
[
'key' => 0,
'value' => empty($options['translation']) ? trans('general.no') : trans($options['translation'][0]),
'value' => empty($options['translation']) ? trans('general.no') : $this->findTranslation($options['translation'][0], 1),
],
[
'key' => 1,
'value' => empty($options['translation']) ? trans('general.yes') : trans($options['translation'][1]),
'value' => empty($options['translation']) ? trans('general.yes') : $this->findTranslation($options['translation'][1], 1),
],
];
} else if (isset($options['values'])) {
foreach ($options['values'] as $key => $value) {
$values[$key] = trans($value);
$values[$key] = $this->findTranslation($value, 1);
}
} else if ($search = request()->get('search', false)) {
$fields = explode(' ', $search);

View File

@ -2,7 +2,7 @@
namespace App\Widgets;
use Akaunting\Apexcharts\Charts as Apexcharts;
use Akaunting\Apexcharts\Chart;
use App\Abstracts\Widget;
use App\Models\Banking\Transaction;
use App\Traits\Currencies;
@ -55,7 +55,7 @@ class CashFlow extends Widget
],
];
$chart = new Apexcharts();
$chart = new Chart();
$chart->setType('line')
->setOptions($options)

View File

@ -6,7 +6,7 @@ use App\Abstracts\Widget;
use App\Utilities\Recurring;
use App\Models\Document\Document;
use App\Models\Banking\Transaction;
use Akaunting\Apexcharts\Charts as Apexcharts;
use Akaunting\Apexcharts\Chart;
use App\Traits\Currencies;
use App\Traits\DateTime;
use App\Utilities\Date;
@ -39,7 +39,7 @@ class ProfitLoss extends Widget
$colors = $this->getColors();
$chart = new Apexcharts();
$chart = new Chart();
$options = [
'legend' => [