Merge branch 'master' of https://github.com/brkcvn/akaunting into code-clean
This commit is contained in:
@@ -282,7 +282,7 @@ abstract class Index extends Component
|
||||
foreach ($totals as $key => $total) {
|
||||
$items[] = [
|
||||
'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key),
|
||||
'href' => route($route, ['search' => 'status:' . $key]),
|
||||
//'href' => route($route, ['search' => 'status:' . $key]),
|
||||
'amount' => money($total, setting('default.currency'), true)->formatForHumans(),
|
||||
'tooltip' => money($total, setting('default.currency'), true)->format(),
|
||||
];
|
||||
|
||||
@@ -397,7 +397,7 @@ abstract class Index extends Component
|
||||
|
||||
$items[] = [
|
||||
'title' => $title,
|
||||
'href' => $href,
|
||||
//'href' => $href,
|
||||
'amount' => $amount,
|
||||
'tooltip' => $tooltip,
|
||||
];
|
||||
|
||||
@@ -6,6 +6,8 @@ use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Setting\Setting as Request;
|
||||
use App\Http\Resources\Setting\Setting as Resource;
|
||||
use App\Models\Setting\Setting;
|
||||
use Laratrust\Middleware\LaratrustMiddleware;
|
||||
|
||||
|
||||
class Settings extends ApiController
|
||||
{
|
||||
@@ -15,9 +17,10 @@ class Settings extends ApiController
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-settings')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-settings-settings')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable', 'destroy');
|
||||
// We've added base 3 permission then get all setting thsi permissions
|
||||
$this->middleware('permission:create-settings-company|create-settings-defaults|create-settings-localisation')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-settings-company|read-settings-defaults|read-settings-localisation')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-settings-company|update-settings-defaults|update-settings-localisation')->only('update', 'enable', 'disable', 'destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,13 +113,7 @@ class DocumentTransactions extends Controller
|
||||
$response = $this->ajaxDispatch(new CreateBankingDocumentTransaction($document, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$route = config('type.document.' . $document->type . '.route.prefix');
|
||||
|
||||
if ($alias = config('type.document.' . $document->type . '.alias')) {
|
||||
$route = $alias . '.' . $route;
|
||||
}
|
||||
|
||||
$response['redirect'] = route($route . '.show', $document->id);
|
||||
$response['redirect'] = url()->previous();
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ class Currencies extends Controller
|
||||
{
|
||||
$response = $this->ajaxDispatch(new UpdateCurrency($currency, $request));
|
||||
|
||||
$currency->default = setting('default.currency') == $currency->code;
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.updated', ['type' => $currency->name]);
|
||||
} else {
|
||||
|
||||
@@ -13,7 +13,7 @@ class Pin extends Component
|
||||
|
||||
public $pinned = false;
|
||||
|
||||
public $reportId = null;
|
||||
public $report;
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class Pin extends Component
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($this->reportId, $pins)) {
|
||||
if (in_array($this->report->id, $pins)) {
|
||||
$this->pinned = true;
|
||||
|
||||
break;
|
||||
|
||||
@@ -15,19 +15,22 @@ class UpdateReconciliation extends Job implements ShouldUpdate
|
||||
$reconcile = (int) $this->request->get('reconcile');
|
||||
$transactions = $this->request->get('transactions');
|
||||
|
||||
$this->model->transactions = $transactions;
|
||||
$this->model->reconciled = $reconcile;
|
||||
$this->model->save();
|
||||
|
||||
if ($transactions) {
|
||||
foreach ($transactions as $key => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
$transaction_reconcile = $reconcile;
|
||||
|
||||
if (empty($value) || $value === 'false') {
|
||||
$transaction_reconcile = 0;
|
||||
}
|
||||
|
||||
$t = explode('_', $key);
|
||||
|
||||
$transaction = Transaction::find($t[1]);
|
||||
$transaction->reconciled = $reconcile;
|
||||
$transaction->reconciled = $transaction_reconcile;
|
||||
$transaction->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ class Role extends LaratrustRole
|
||||
'icon' => 'edit',
|
||||
'url' => route('roles.roles.edit', $this->id),
|
||||
'permission' => 'update-roles-roles',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-role-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -50,6 +53,9 @@ class Role extends LaratrustRole
|
||||
'icon' => 'file_copy',
|
||||
'url' => route('roles.roles.duplicate', $this->id),
|
||||
'permission' => 'create-roles-roles',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-duplicate-role-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -57,6 +63,9 @@ class Role extends LaratrustRole
|
||||
'icon' => 'delete',
|
||||
'route' => 'roles.roles.destroy',
|
||||
'permission' => 'delete-roles-roles',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-role-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -326,6 +326,9 @@ class User extends Authenticatable implements HasLocalePreference
|
||||
'icon' => 'edit',
|
||||
'url' => route('users.edit', $this->id),
|
||||
'permission' => 'update-auth-users',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-show-user-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->hasPendingInvitation()) {
|
||||
@@ -334,6 +337,9 @@ class User extends Authenticatable implements HasLocalePreference
|
||||
'icon' => 'replay',
|
||||
'url' => route('users.invite', $this->id),
|
||||
'permission' => 'update-auth-users',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-resend-user-' . $this->id,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -342,6 +348,9 @@ class User extends Authenticatable implements HasLocalePreference
|
||||
'icon' => 'delete',
|
||||
'route' => 'users.destroy',
|
||||
'permission' => 'delete-auth-users',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-user-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -170,6 +170,9 @@ class Account extends Model
|
||||
'icon' => 'visibility',
|
||||
'url' => route('accounts.show', $this->id),
|
||||
'permission' => 'read-banking-accounts',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-show-account-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -177,6 +180,9 @@ class Account extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route('accounts.edit', $this->id),
|
||||
'permission' => 'update-banking-accounts',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-account-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -185,6 +191,9 @@ class Account extends Model
|
||||
'route' => 'accounts.destroy',
|
||||
'permission' => 'delete-banking-accounts',
|
||||
'model' => $this,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-account-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
return $actions;
|
||||
|
||||
@@ -28,6 +28,7 @@ class Reconciliation extends Model
|
||||
protected $casts = [
|
||||
'closing_balance' => 'double',
|
||||
'reconciled' => 'boolean',
|
||||
'transactions' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -56,6 +57,9 @@ class Reconciliation extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route('reconciliations.edit', $this->id),
|
||||
'permission' => 'update-banking-reconciliations',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-reconciliation-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -63,6 +67,9 @@ class Reconciliation extends Model
|
||||
'icon' => 'delete',
|
||||
'route' => 'reconciliations.destroy',
|
||||
'permission' => 'delete-banking-reconciliations',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-reconciliation-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -455,7 +455,7 @@ class Transaction extends Model
|
||||
'url' => route($prefix. '.show', $this->id),
|
||||
'permission' => 'read-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-show-' . $this->id,
|
||||
'id' => 'index-line-actions-show-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
@@ -468,7 +468,7 @@ class Transaction extends Model
|
||||
'url' => route($prefix. '.edit', $this->id),
|
||||
'permission' => 'update-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-edit-' . $this->id,
|
||||
'id' => 'index-line-actions-edit-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -482,7 +482,7 @@ class Transaction extends Model
|
||||
'url' => route($prefix. '.duplicate', $this->id),
|
||||
'permission' => 'create-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-duplicate-' . $this->id,
|
||||
'id' => 'index-line-actions-duplicate-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -496,7 +496,7 @@ class Transaction extends Model
|
||||
'icon' => 'sensors',
|
||||
'permission' => 'create-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-transactions-more-actions-connect-' . $this->id,
|
||||
'id' => 'index-line-actions-connect-' . $this->type . '-' . $this->id,
|
||||
'@click' => 'onConnectTransactions(\'' . route('transactions.dial', $this->id) . '\')',
|
||||
],
|
||||
];
|
||||
@@ -516,7 +516,7 @@ class Transaction extends Model
|
||||
'url' => route($prefix. '.print', $this->id),
|
||||
'permission' => 'read-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-print-' . $this->id,
|
||||
'id' => 'index-line-actions-print-' . $this->type . '-' . $this->id,
|
||||
'target' => '_blank',
|
||||
],
|
||||
];
|
||||
@@ -529,7 +529,7 @@ class Transaction extends Model
|
||||
'url' => route($prefix. '.pdf', $this->id),
|
||||
'permission' => 'read-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-pdf-' . $this->id,
|
||||
'id' => 'index-line-actions-pdf-' . $this->type . '-' . $this->id,
|
||||
'target' => '_blank',
|
||||
],
|
||||
];
|
||||
@@ -549,7 +549,7 @@ class Transaction extends Model
|
||||
'url' => route('modals.transactions.share.create', $this->id),
|
||||
'permission' => 'read-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-share-' . $this->id,
|
||||
'id' => 'index-line-actions-share-' . $this->type . '-' . $this->id,
|
||||
'@click' => 'onShareLink("' . route('modals.transactions.share.create', $this->id) . '")',
|
||||
],
|
||||
];
|
||||
@@ -564,7 +564,7 @@ class Transaction extends Model
|
||||
'url' => route('modals.transactions.emails.create', $this->id),
|
||||
'permission' => 'read-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-send-email-' . $this->id,
|
||||
'id' => 'index-line-actions-send-email-' . $this->type . '-' . $this->id,
|
||||
'@click' => 'onEmail("' . route('modals.transactions.emails.create', $this->id) . '")',
|
||||
],
|
||||
];
|
||||
@@ -583,6 +583,9 @@ class Transaction extends Model
|
||||
'text' => ! empty($this->recurring) ? 'transactions' : 'recurring_template',
|
||||
'route' => $prefix. '.destroy',
|
||||
'permission' => 'delete-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
}
|
||||
@@ -595,6 +598,9 @@ class Transaction extends Model
|
||||
'icon' => 'block',
|
||||
'url' => route($prefix. '.end', $this->id),
|
||||
'permission' => 'update-banking-transactions',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-end-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
@@ -246,6 +246,9 @@ class Transfer extends Model
|
||||
'icon' => 'visibility',
|
||||
'url' => route('transfers.show', $this->id),
|
||||
'permission' => 'read-banking-transfers',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-show-transfer-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -253,6 +256,9 @@ class Transfer extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route('transfers.edit', $this->id),
|
||||
'permission' => 'update-banking-transfers',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-transfer-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -260,6 +266,9 @@ class Transfer extends Model
|
||||
'icon' => 'file_copy',
|
||||
'url' => route('transfers.duplicate', $this->id),
|
||||
'permission' => 'update-banking-transfers',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-duplicate-transfer-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -267,6 +276,9 @@ class Transfer extends Model
|
||||
'icon' => 'delete',
|
||||
'route' => 'transfers.destroy',
|
||||
'permission' => 'delete-banking-transfers',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-transfer-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class Company extends Eloquent implements Ownable
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
try {
|
||||
try {
|
||||
// TODO will optimize..
|
||||
static::retrieved(function($model) {
|
||||
$model->setCommonSettingsAsAttributes();
|
||||
@@ -550,6 +550,9 @@ class Company extends Eloquent implements Ownable
|
||||
'icon' => 'settings_ethernet',
|
||||
'url' => route('companies.switch', $this->id),
|
||||
'permission' => 'read-common-companies',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-switch-company-' . $this->id,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -558,6 +561,9 @@ class Company extends Eloquent implements Ownable
|
||||
'icon' => 'edit',
|
||||
'url' => route('companies.edit', $this->id),
|
||||
'permission' => 'update-common-companies',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-company-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -565,6 +571,9 @@ class Company extends Eloquent implements Ownable
|
||||
'icon' => 'delete',
|
||||
'route' => 'companies.destroy',
|
||||
'permission' => 'delete-common-companies',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-company-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -291,6 +291,9 @@ class Contact extends Model
|
||||
'icon' => 'visibility',
|
||||
'url' => route($prefix . '.show', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-show-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
@@ -300,6 +303,9 @@ class Contact extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route($prefix . '.edit', $this->id),
|
||||
'permission' => 'update-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
@@ -309,6 +315,9 @@ class Contact extends Model
|
||||
'icon' => 'file_copy',
|
||||
'url' => route($prefix . '.duplicate', $this->id),
|
||||
'permission' => 'create-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-duplicate-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
@@ -319,6 +328,9 @@ class Contact extends Model
|
||||
'title' => $translation_prefix,
|
||||
'route' => $prefix . '.destroy',
|
||||
'permission' => 'delete-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
@@ -129,6 +129,9 @@ class Dashboard extends Model
|
||||
'icon' => 'settings_ethernet',
|
||||
'url' => route('dashboards.switch', $this->id),
|
||||
'permission' => 'read-common-dashboards',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-switch-dashboard-' . $this->id,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -137,6 +140,9 @@ class Dashboard extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route('dashboards.edit', $this->id),
|
||||
'permission' => 'update-common-dashboards',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-dashboard-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -144,6 +150,9 @@ class Dashboard extends Model
|
||||
'icon' => 'delete',
|
||||
'route' => 'dashboards.destroy',
|
||||
'permission' => 'delete-common-dashboards',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-dashboard-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -174,6 +174,9 @@ class Item extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route('items.edit', $this->id),
|
||||
'permission' => 'update-common-items',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-item-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -181,6 +184,9 @@ class Item extends Model
|
||||
'icon' => 'file_copy',
|
||||
'url' => route('items.duplicate', $this->id),
|
||||
'permission' => 'create-common-items',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-duplicate-item-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -188,6 +194,9 @@ class Item extends Model
|
||||
'icon' => 'delete',
|
||||
'route' => 'items.destroy',
|
||||
'permission' => 'delete-common-items',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-item-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -488,18 +488,6 @@ class Document extends Model
|
||||
return $actions;
|
||||
}
|
||||
|
||||
try {
|
||||
$actions[] = [
|
||||
'title' => trans('general.show'),
|
||||
'icon' => 'visibility',
|
||||
'url' => route($prefix . '.show', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-show-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
try {
|
||||
if (! $this->reconciled) {
|
||||
$actions[] = [
|
||||
@@ -508,7 +496,7 @@ class Document extends Model
|
||||
'url' => route($prefix . '.edit', $this->id),
|
||||
'permission' => 'update-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-edit-' . $this->id,
|
||||
'id' => 'index-line-actions-edit-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -521,12 +509,26 @@ class Document extends Model
|
||||
'url' => route($prefix . '.duplicate', $this->id),
|
||||
'permission' => 'create-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-duplicate-' . $this->id,
|
||||
'id' => 'index-line-actions-duplicate-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
if ($this->status != 'cancelled') {
|
||||
if ((empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
|
||||
try {
|
||||
$actions[] = [
|
||||
'type' => 'button',
|
||||
'title' => trans('invoices.add_payment'),
|
||||
'icon' => 'paid',
|
||||
'url' => route('modals.documents.document.transactions.create', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
|
||||
'@click' => 'onPayment("' . $this->id . '")',
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
} else {
|
||||
try {
|
||||
$actions[] = [
|
||||
'title' => trans('general.print'),
|
||||
@@ -534,7 +536,22 @@ class Document extends Model
|
||||
'url' => route($prefix . '.print', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-print-' . $this->id,
|
||||
'id' => 'index-line-actions-print-' . $this->type . '-' . $this->id,
|
||||
'target' => '_blank',
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
if (($actions[1]['icon'] != 'print') && ($actions[2]['icon'] != 'print')) {
|
||||
try {
|
||||
$actions[] = [
|
||||
'title' => trans('general.print'),
|
||||
'icon' => 'print',
|
||||
'url' => route($prefix . '.print', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-print-' . $this->type . '-' . $this->id,
|
||||
'target' => '_blank',
|
||||
],
|
||||
];
|
||||
@@ -548,7 +565,7 @@ class Document extends Model
|
||||
'url' => route($prefix . '.pdf', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-pdf-' . $this->id,
|
||||
'id' => 'index-line-actions-pdf-' . $this->type . '-' . $this->id,
|
||||
'target' => '_blank',
|
||||
],
|
||||
];
|
||||
@@ -568,14 +585,14 @@ class Document extends Model
|
||||
'url' => route('modals.'. $prefix . '.share.create', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-share-link-' . $this->id,
|
||||
'id' => 'index-line-actions-share-link-' . $this->type . '-' . $this->id,
|
||||
'@click' => 'onShareLink("' . route('modals.'. $prefix . '.share.create', $this->id) . '")',
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
try {
|
||||
if (! empty($this->contact) && $this->contact->email && $this->type == 'invoice') {
|
||||
if (! empty($this->contact) && $this->contact->email && ($this->type == 'invoice')) {
|
||||
$actions[] = [
|
||||
'type' => 'button',
|
||||
'title' => trans('invoices.send_mail'),
|
||||
@@ -583,8 +600,8 @@ class Document extends Model
|
||||
'url' => route('modals.'. $prefix . '.emails.create', $this->id),
|
||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-send-email-' . $this->id,
|
||||
'@click' => 'onEmail("' . route('modals.'. $prefix . '.emails.create', $this->id) . '")',
|
||||
'id' => 'index-line-actions-send-email-' . $this->type . '-' . $this->id,
|
||||
'@click' => 'onEmail("' . route('modals.'. $prefix . '.emails.create', $this->id) . '")',
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -603,7 +620,7 @@ class Document extends Model
|
||||
'url' => route($prefix . '.cancelled', $this->id),
|
||||
'permission' => 'update-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-more-actions-cancel-' . $this->id,
|
||||
'id' => 'index-line-actions-cancel-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
@@ -620,6 +637,9 @@ class Document extends Model
|
||||
'title' => $translation_prefix,
|
||||
'route' => $prefix . '.destroy',
|
||||
'permission' => 'delete-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
@@ -630,6 +650,9 @@ class Document extends Model
|
||||
'icon' => 'block',
|
||||
'url' => route($prefix. '.end', $this->id),
|
||||
'permission' => 'update-' . $group . '-' . $permission_prefix,
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-end-' . $this->type . '-' . $this->id,
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
@@ -240,6 +240,9 @@ class Category extends Model
|
||||
'icon' => 'create',
|
||||
'url' => route('categories.edit', $this->id),
|
||||
'permission' => 'update-settings-categories',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-category-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->isTransferCategory()) {
|
||||
@@ -251,6 +254,9 @@ class Category extends Model
|
||||
'icon' => 'delete',
|
||||
'route' => 'categories.destroy',
|
||||
'permission' => 'delete-settings-categories',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-category-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -197,6 +197,9 @@ class Currency extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route('currencies.edit', $this->id),
|
||||
'permission' => 'update-settings-currencies',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-currency-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -204,6 +207,9 @@ class Currency extends Model
|
||||
'icon' => 'delete',
|
||||
'route' => 'currencies.destroy',
|
||||
'permission' => 'delete-settings-currencies',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-currency-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -150,6 +150,9 @@ class Tax extends Model
|
||||
'icon' => 'edit',
|
||||
'url' => route('taxes.edit', $this->id),
|
||||
'permission' => 'update-settings-taxes',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-edit-tax-' . $this->id,
|
||||
],
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
@@ -157,6 +160,9 @@ class Tax extends Model
|
||||
'icon' => 'delete',
|
||||
'route' => 'taxes.destroy',
|
||||
'permission' => 'delete-settings-taxes',
|
||||
'attributes' => [
|
||||
'id' => 'index-line-actions-delete-tax-' . $this->id,
|
||||
],
|
||||
'model' => $this,
|
||||
];
|
||||
|
||||
|
||||
@@ -51,6 +51,18 @@ trait Transactions
|
||||
return Str::endsWith($type, '-transfer');
|
||||
}
|
||||
|
||||
public function isDocumentTransaction(): bool
|
||||
{
|
||||
$document_id = $this->document_id ?? $this->transaction->document_id ?? $this->model->document_id ?? null;
|
||||
|
||||
return ! empty($document_id);
|
||||
}
|
||||
|
||||
public function isNotDocumentTransaction(): bool
|
||||
{
|
||||
return ! $this->isDocumentTransaction();
|
||||
}
|
||||
|
||||
public function isNotTransferTransaction(): bool
|
||||
{
|
||||
return ! $this->isTransferTransaction();
|
||||
|
||||
@@ -103,6 +103,7 @@ class Scripts extends Component
|
||||
'name' => trans('general.name'),
|
||||
'code' => trans('currencies.code'),
|
||||
'rate' => trans('currencies.rate'),
|
||||
'default' => trans('currencies.default'),
|
||||
'enabled' => trans('general.enabled'),
|
||||
'actions' => trans('general.actions') ,
|
||||
'yes' => trans('general.yes'),
|
||||
@@ -162,7 +163,15 @@ class Scripts extends Component
|
||||
|
||||
protected function getCurrencies()
|
||||
{
|
||||
return Currency::all();
|
||||
$currencies = collect();
|
||||
|
||||
Currency::all()->each(function ($currency) use (&$currencies) {
|
||||
$currency->default = setting('default.currency') == $currency->code;
|
||||
|
||||
$currencies->push($currency);
|
||||
});
|
||||
|
||||
return $currencies;
|
||||
}
|
||||
|
||||
protected function getCurrencyCodes()
|
||||
|
||||
Reference in New Issue
Block a user