Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/brkcvn/akaunting into cod…
Browse files Browse the repository at this point in the history
…e-clean
  • Loading branch information
brkcvn committed Sep 7, 2022
2 parents ccc566c + 513f451 commit f7694c2
Show file tree
Hide file tree
Showing 76 changed files with 1,015 additions and 696 deletions.
2 changes: 1 addition & 1 deletion app/Abstracts/View/Components/Contacts/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function getSummaryItems($type, $summaryItems)
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(),
];
Expand Down
2 changes: 1 addition & 1 deletion app/Abstracts/View/Components/Documents/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public function getSummaryItems($type, $summaryItems)

$items[] = [
'title' => $title,
'href' => $href,
//'href' => $href,
'amount' => $amount,
'tooltip' => $tooltip,
];
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/Api/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
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
{
Expand All @@ -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');
}

/**
Expand Down
8 changes: 1 addition & 7 deletions app/Http/Controllers/Modals/DocumentTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,7 @@ public function store(Document $document, Request $request)
$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)]);

Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Wizard/Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public function update(Currency $currency, Request $request)
{
$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 {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Livewire/Report/Pin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Pin extends Component

public $pinned = false;

public $reportId = null;
public $report;

public function render(): View
{
Expand All @@ -38,7 +38,7 @@ public function render(): View
continue;
}

if (in_array($this->reportId, $pins)) {
if (in_array($this->report->id, $pins)) {
$this->pinned = true;

break;
Expand Down
9 changes: 6 additions & 3 deletions app/Jobs/Banking/UpdateReconciliation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ public function handle(): Reconciliation
$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();
}
}
Expand Down
9 changes: 9 additions & 0 deletions app/Models/Auth/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,29 @@ public function getLineActionsAttribute()
'icon' => 'edit',
'url' => route('roles.roles.edit', $this->id),
'permission' => 'update-roles-roles',
'attributes' => [
'id' => 'index-line-actions-edit-role-' . $this->id,
],
];

$actions[] = [
'title' => trans('general.duplicate'),
'icon' => 'file_copy',
'url' => route('roles.roles.duplicate', $this->id),
'permission' => 'create-roles-roles',
'attributes' => [
'id' => 'index-line-actions-duplicate-role-' . $this->id,
],
];

$actions[] = [
'type' => 'delete',
'icon' => 'delete',
'route' => 'roles.roles.destroy',
'permission' => 'delete-roles-roles',
'attributes' => [
'id' => 'index-line-actions-delete-role-' . $this->id,
],
'model' => $this,
];

Expand Down
9 changes: 9 additions & 0 deletions app/Models/Auth/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ public function getLineActionsAttribute()
'icon' => 'edit',
'url' => route('users.edit', $this->id),
'permission' => 'update-auth-users',
'attributes' => [
'id' => 'index-line-actions-show-user-' . $this->id,
],
];

if ($this->hasPendingInvitation()) {
Expand All @@ -334,6 +337,9 @@ public function getLineActionsAttribute()
'icon' => 'replay',
'url' => route('users.invite', $this->id),
'permission' => 'update-auth-users',
'attributes' => [
'id' => 'index-line-actions-resend-user-' . $this->id,
],
];
}

Expand All @@ -342,6 +348,9 @@ public function getLineActionsAttribute()
'icon' => 'delete',
'route' => 'users.destroy',
'permission' => 'delete-auth-users',
'attributes' => [
'id' => 'index-line-actions-delete-user-' . $this->id,
],
'model' => $this,
];

Expand Down
9 changes: 9 additions & 0 deletions app/Models/Banking/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,19 @@ public function getLineActionsAttribute()
'icon' => 'visibility',
'url' => route('accounts.show', $this->id),
'permission' => 'read-banking-accounts',
'attributes' => [
'id' => 'index-line-actions-show-account-' . $this->id,
],
];

$actions[] = [
'title' => trans('general.edit'),
'icon' => 'edit',
'url' => route('accounts.edit', $this->id),
'permission' => 'update-banking-accounts',
'attributes' => [
'id' => 'index-line-actions-edit-account-' . $this->id,
],
];

$actions[] = [
Expand All @@ -185,6 +191,9 @@ public function getLineActionsAttribute()
'route' => 'accounts.destroy',
'permission' => 'delete-banking-accounts',
'model' => $this,
'attributes' => [
'id' => 'index-line-actions-delete-account-' . $this->id,
],
];

return $actions;
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Banking/Reconciliation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Reconciliation extends Model
protected $casts = [
'closing_balance' => 'double',
'reconciled' => 'boolean',
'transactions' => 'array',
];

/**
Expand Down Expand Up @@ -56,13 +57,19 @@ public function getLineActionsAttribute()
'icon' => 'edit',
'url' => route('reconciliations.edit', $this->id),
'permission' => 'update-banking-reconciliations',
'attributes' => [
'id' => 'index-line-actions-edit-reconciliation-' . $this->id,
],
];

$actions[] = [
'type' => 'delete',
'icon' => 'delete',
'route' => 'reconciliations.destroy',
'permission' => 'delete-banking-reconciliations',
'attributes' => [
'id' => 'index-line-actions-delete-reconciliation-' . $this->id,
],
'model' => $this,
];

Expand Down
22 changes: 14 additions & 8 deletions app/Models/Banking/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public function getLineActionsAttribute()
'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) {}
Expand All @@ -468,7 +468,7 @@ public function getLineActionsAttribute()
'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,
],
];
}
Expand All @@ -482,7 +482,7 @@ public function getLineActionsAttribute()
'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,
],
];
}
Expand All @@ -496,7 +496,7 @@ public function getLineActionsAttribute()
'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) . '\')',
],
];
Expand All @@ -516,7 +516,7 @@ public function getLineActionsAttribute()
'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',
],
];
Expand All @@ -529,7 +529,7 @@ public function getLineActionsAttribute()
'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',
],
];
Expand All @@ -549,7 +549,7 @@ public function getLineActionsAttribute()
'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) . '")',
],
];
Expand All @@ -564,7 +564,7 @@ public function getLineActionsAttribute()
'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) . '")',
],
];
Expand All @@ -583,6 +583,9 @@ public function getLineActionsAttribute()
'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,
];
}
Expand All @@ -595,6 +598,9 @@ public function getLineActionsAttribute()
'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) {}
}
Expand Down
12 changes: 12 additions & 0 deletions app/Models/Banking/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,27 +246,39 @@ public function getLineActionsAttribute()
'icon' => 'visibility',
'url' => route('transfers.show', $this->id),
'permission' => 'read-banking-transfers',
'attributes' => [
'id' => 'index-line-actions-show-transfer-' . $this->id,
],
];

$actions[] = [
'title' => trans('general.edit'),
'icon' => 'edit',
'url' => route('transfers.edit', $this->id),
'permission' => 'update-banking-transfers',
'attributes' => [
'id' => 'index-line-actions-edit-transfer-' . $this->id,
],
];

$actions[] = [
'title' => trans('general.duplicate'),
'icon' => 'file_copy',
'url' => route('transfers.duplicate', $this->id),
'permission' => 'update-banking-transfers',
'attributes' => [
'id' => 'index-line-actions-duplicate-transfer-' . $this->id,
],
];

$actions[] = [
'type' => 'delete',
'icon' => 'delete',
'route' => 'transfers.destroy',
'permission' => 'delete-banking-transfers',
'attributes' => [
'id' => 'index-line-actions-delete-transfer-' . $this->id,
],
'model' => $this,
];

Expand Down
11 changes: 10 additions & 1 deletion app/Models/Common/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function boot()
{
parent::boot();

try {
try {
// TODO will optimize..
static::retrieved(function($model) {
$model->setCommonSettingsAsAttributes();
Expand Down Expand Up @@ -550,6 +550,9 @@ public function getLineActionsAttribute()
'icon' => 'settings_ethernet',
'url' => route('companies.switch', $this->id),
'permission' => 'read-common-companies',
'attributes' => [
'id' => 'index-line-actions-switch-company-' . $this->id,
],
];
}

Expand All @@ -558,13 +561,19 @@ public function getLineActionsAttribute()
'icon' => 'edit',
'url' => route('companies.edit', $this->id),
'permission' => 'update-common-companies',
'attributes' => [
'id' => 'index-line-actions-edit-company-' . $this->id,
],
];

$actions[] = [
'type' => 'delete',
'icon' => 'delete',
'route' => 'companies.destroy',
'permission' => 'delete-common-companies',
'attributes' => [
'id' => 'index-line-actions-delete-company-' . $this->id,
],
'model' => $this,
];

Expand Down
Loading

0 comments on commit f7694c2

Please sign in to comment.