diff --git a/app/Abstracts/Http/Controller.php b/app/Abstracts/Http/Controller.php index 4ed55d0a1..f6805027c 100644 --- a/app/Abstracts/Http/Controller.php +++ b/app/Abstracts/Http/Controller.php @@ -37,7 +37,7 @@ abstract class Controller extends BaseController * * @return LengthAwarePaginator */ - public function paginate($items, $perPage = 15, $page = null, $options = []) + public function paginate($items, $perPage = null, $page = null, $options = []) { $perPage = $perPage ?: (int) request('limit', setting('default.list_limit', '25')); diff --git a/app/Exports/Banking/Transactions.php b/app/Exports/Banking/Transactions.php index 78c098a87..aee773b3b 100644 --- a/app/Exports/Banking/Transactions.php +++ b/app/Exports/Banking/Transactions.php @@ -47,7 +47,7 @@ class Transactions extends Export implements WithColumnFormatting public function columnFormats(): array { return [ - 'B' => NumberFormat::FORMAT_DATE_YYYYMMDD, + 'C' => NumberFormat::FORMAT_DATE_YYYYMMDD, ]; } } diff --git a/app/Exports/Purchases/Sheets/BillTransactions.php b/app/Exports/Purchases/Sheets/BillTransactions.php index c70b0e48b..ee1b43e0f 100644 --- a/app/Exports/Purchases/Sheets/BillTransactions.php +++ b/app/Exports/Purchases/Sheets/BillTransactions.php @@ -53,7 +53,7 @@ class BillTransactions extends Export implements WithColumnFormatting public function columnFormats(): array { return [ - 'B' => NumberFormat::FORMAT_DATE_YYYYMMDD, + 'C' => NumberFormat::FORMAT_DATE_YYYYMMDD, ]; } } diff --git a/app/Exports/Sales/Sheets/InvoiceTransactions.php b/app/Exports/Sales/Sheets/InvoiceTransactions.php index 060fd4ce2..42f3e1aa6 100644 --- a/app/Exports/Sales/Sheets/InvoiceTransactions.php +++ b/app/Exports/Sales/Sheets/InvoiceTransactions.php @@ -53,7 +53,7 @@ class InvoiceTransactions extends Export implements WithColumnFormatting public function columnFormats(): array { return [ - 'B' => NumberFormat::FORMAT_DATE_YYYYMMDD, + 'C' => NumberFormat::FORMAT_DATE_YYYYMMDD, ]; } } diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php index 0c7f55bbe..9ae9aa7d6 100644 --- a/app/Http/Controllers/Banking/Accounts.php +++ b/app/Http/Controllers/Banking/Accounts.php @@ -10,9 +10,9 @@ use App\Jobs\Banking\UpdateAccount; use App\Models\Banking\Account; use App\Models\Banking\Transaction; use App\Models\Banking\Transfer; -use App\Utilities\Reports as Utility; +use App\Utilities\Date; +use App\Utilities\Reports; use App\Models\Setting\Currency; -use Date; class Accounts extends Controller { @@ -35,23 +35,27 @@ class Accounts extends Controller */ public function show(Account $account) { - // Handle transactions - $transactions = Transaction::with('account', 'category')->where('account_id', $account->id)->collect('paid_at'); + $transactions = Transaction::with('category', 'contact', 'document')->where('account_id', $account->id)->collect(['paid_at'=> 'desc']); - $transfers = Transfer::with('expense_transaction', 'income_transaction')->get()->filter(function ($transfer) use($account) { - if ($transfer->expense_account->id == $account->id || $transfer->income_account->id == $account->id) { - return true; - } + $transfers = Transfer::with('expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account') + ->whereHas('expense_transaction', fn ($query) => $query->where('account_id', $account->id)) + ->orWhereHas('income_transaction', fn ($query) => $query->where('account_id', $account->id)) + ->collect(['expense_transaction.paid_at' => 'desc']); - return false; - })->sortByDesc(function ($transfer) { - return $transfer->expense_transaction->paid_at; - }); + $incoming_amount = money($account->income_balance, $account->currency_code, true); + $outgoing_amount = money($account->expense_balance, $account->currency_code, true); + $current_amount = money($account->balance, $account->currency_code, true); - $limit = (int) request('limit', setting('default.list_limit', '25')); - $transfers = $this->paginate($transfers, $limit); + $summary_amounts = [ + 'incoming_exact' => $incoming_amount->format(), + 'incoming_for_humans' => $incoming_amount->formatForHumans(), + 'outgoing_exact' => $outgoing_amount->format(), + 'outgoing_for_humans' => $outgoing_amount->formatForHumans(), + 'current_exact' => $current_amount->format(), + 'current_for_humans' => $current_amount->formatForHumans(), + ]; - return view('banking.accounts.show', compact('account', 'transactions', 'transfers')); + return view('banking.accounts.show', compact('account', 'transactions', 'transfers', 'summary_amounts')); } /** @@ -248,7 +252,7 @@ class Accounts extends Controller 'account_id' => $account->id, ]; - $report = Utility::getClassInstance('App\Reports\IncomeExpenseSummary'); + $report = Reports::getClassInstance('App\Reports\IncomeExpenseSummary'); if (empty($report) || empty($report->model)) { $message = trans('accounts.create_report'); diff --git a/app/Http/Controllers/Modules/Tiles.php b/app/Http/Controllers/Modules/Tiles.php index 54d2c2ab6..8af4e94de 100644 --- a/app/Http/Controllers/Modules/Tiles.php +++ b/app/Http/Controllers/Modules/Tiles.php @@ -155,7 +155,7 @@ class Tiles extends Controller $modules = $this->getSearchModules($data); $installed = Module::all()->pluck('enabled', 'alias')->toArray(); - return view('modules.tiles.index', compact('title', 'modules', 'keyword', 'installed')); + return $this->response('modules.tiles.index', compact('modules', 'title', 'keyword', 'installed')); } public function loadMore($type, Request $request) diff --git a/app/Imports/Banking/Transactions.php b/app/Imports/Banking/Transactions.php index 03d86d35a..5bb9deee9 100644 --- a/app/Imports/Banking/Transactions.php +++ b/app/Imports/Banking/Transactions.php @@ -20,6 +20,7 @@ class Transactions extends Import $row['account_id'] = $this->getAccountId($row); $row['category_id'] = $this->getCategoryId($row); $row['contact_id'] = $this->getContactId($row); + $row['currency_code'] = $this->getCurrencyCode($row); $row['document_id'] = $this->getDocumentId($row); return $row; diff --git a/app/Imports/Banking/Transfers.php b/app/Imports/Banking/Transfers.php index 8b267b5d0..a64747696 100644 --- a/app/Imports/Banking/Transfers.php +++ b/app/Imports/Banking/Transfers.php @@ -27,9 +27,11 @@ class Transfers extends Import $row['transferred_at'] = Date::parse($row['transferred_at'])->format('Y-m-d'); $row['from_account_id'] = $this->getFromAccountId($row); $row['to_account_id'] = $this->getToAccountId($row); + $row['from_currency_code'] = $this->getFromCurrencyCode($row); + $row['to_currency_code'] = $this->getToCurrencyCode($row); $row['expense_transaction_id'] = $this->getExpenseTransactionId($row); $row['income_transaction_id'] = $this->getIncomeTransactionId($row); - + return $row; } @@ -124,4 +126,20 @@ class Transfers extends Import return $this->getAccountId($row); } + + private function getFromCurrencyCode($row) + { + $row['currency_code'] = $row['from_currency_code'] ?? null; + $row['currency_rate'] = $row['from_currency_rate'] ?? null; + + return $this->getCurrencyCode($row); + } + + private function getToCurrencyCode($row) + { + $row['currency_code'] = $row['to_currency_code'] ?? null; + $row['currency_rate'] = $row['to_currency_rate'] ?? null; + + return $this->getCurrencyCode($row); + } } diff --git a/app/Imports/Purchases/Sheets/BillTransactions.php b/app/Imports/Purchases/Sheets/BillTransactions.php index 532a85ebe..528d5bb16 100644 --- a/app/Imports/Purchases/Sheets/BillTransactions.php +++ b/app/Imports/Purchases/Sheets/BillTransactions.php @@ -25,6 +25,7 @@ class BillTransactions extends Import $row['account_id'] = $this->getAccountId($row); $row['category_id'] = $this->getCategoryId($row, 'expense'); $row['contact_id'] = $this->getContactId($row, 'vendor'); + $row['currency_code'] = $this->getCurrencyCode($row); $row['document_id'] = $this->getDocumentId($row); $row['number'] = $row['transaction_number']; diff --git a/app/Imports/Purchases/Sheets/Bills.php b/app/Imports/Purchases/Sheets/Bills.php index e66df3aca..f3ea5a549 100644 --- a/app/Imports/Purchases/Sheets/Bills.php +++ b/app/Imports/Purchases/Sheets/Bills.php @@ -28,6 +28,7 @@ class Bills extends Import $row['issued_at'] = $row['billed_at']; $row['category_id'] = $this->getCategoryId($row, 'expense'); $row['contact_id'] = $this->getContactId($row, 'vendor'); + $row['currency_code'] = $this->getCurrencyCode($row); $row['type'] = Model::BILL_TYPE; $row['contact_country'] = !empty($country) ? $country : null; diff --git a/app/Imports/Purchases/Vendors.php b/app/Imports/Purchases/Vendors.php index d70fa9d0c..2e4c6c5c1 100644 --- a/app/Imports/Purchases/Vendors.php +++ b/app/Imports/Purchases/Vendors.php @@ -21,6 +21,7 @@ class Vendors extends Import $row['type'] = 'vendor'; $row['country'] = !empty($country) ? $country : null; + $row['currency_code'] = $this->getCurrencyCode($row); $row['user_id'] = null; return $row; diff --git a/app/Imports/Sales/Customers.php b/app/Imports/Sales/Customers.php index c3b7a8a58..0803f6c1c 100644 --- a/app/Imports/Sales/Customers.php +++ b/app/Imports/Sales/Customers.php @@ -21,6 +21,7 @@ class Customers extends Import $row['type'] = 'customer'; $row['country'] = !empty($country) ? $country : null; + $row['currency_code'] = $this->getCurrencyCode($row); $row['user_id'] = null; return $row; diff --git a/app/Imports/Sales/Sheets/InvoiceTransactions.php b/app/Imports/Sales/Sheets/InvoiceTransactions.php index 64880eaf4..2fb2cf21c 100644 --- a/app/Imports/Sales/Sheets/InvoiceTransactions.php +++ b/app/Imports/Sales/Sheets/InvoiceTransactions.php @@ -25,6 +25,7 @@ class InvoiceTransactions extends Import $row['account_id'] = $this->getAccountId($row); $row['category_id'] = $this->getCategoryId($row, 'income'); $row['contact_id'] = $this->getContactId($row, 'customer'); + $row['currency_code'] = $this->getCurrencyCode($row); $row['document_id'] = $this->getDocumentId($row); $row['number'] = $row['transaction_number']; diff --git a/app/Imports/Sales/Sheets/Invoices.php b/app/Imports/Sales/Sheets/Invoices.php index d6a9797df..e0d52e699 100644 --- a/app/Imports/Sales/Sheets/Invoices.php +++ b/app/Imports/Sales/Sheets/Invoices.php @@ -28,6 +28,7 @@ class Invoices extends Import $row['issued_at'] = $row['invoiced_at']; $row['category_id'] = $this->getCategoryId($row, 'income'); $row['contact_id'] = $this->getContactId($row, 'customer'); + $row['currency_code'] = $this->getCurrencyCode($row); $row['type'] = Model::INVOICE_TYPE; $row['contact_country'] = !empty($country) ? $country : null; diff --git a/app/Traits/Import.php b/app/Traits/Import.php index bec4b881c..2ddd79853 100644 --- a/app/Traits/Import.php +++ b/app/Traits/Import.php @@ -6,17 +6,20 @@ use App\Http\Requests\Banking\Account as AccountRequest; use App\Http\Requests\Common\Contact as ContactRequest; use App\Http\Requests\Common\Item as ItemRequest; use App\Http\Requests\Setting\Category as CategoryRequest; +use App\Http\Requests\Setting\Currency as CurrencyRequest; use App\Http\Requests\Setting\Tax as TaxRequest; use App\Jobs\Banking\CreateAccount; use App\Jobs\Common\CreateContact; use App\Jobs\Common\CreateItem; use App\Jobs\Setting\CreateCategory; +use App\Jobs\Setting\CreateCurrency; use App\Jobs\Setting\CreateTax; use App\Models\Banking\Account; use App\Models\Common\Contact; use App\Models\Common\Item; use App\Models\Document\Document; use App\Models\Setting\Category; +use App\Models\Setting\Currency; use App\Models\Setting\Tax; use App\Traits\Jobs; use Illuminate\Support\Facades\Validator; @@ -74,6 +77,33 @@ trait Import return is_null($id) ? $id : (int) $id; } + public function getCurrencyCode($row) + { + $currency = Currency::where('code', $row['currency_code'])->first(); + + if (!empty($currency)) { + return $currency->code; + } + + $data = [ + 'company_id' => company_id(), + 'code' => $row['currency_code'], + 'name' => isset($row['currency_name']) ? $row['currency_name'] : config('money.' . $row['currency_code'] . '.name'), + 'rate' => isset($row['currency_rate']) ? $row['currency_rate'] : 1, + 'symbol' => isset($row['currency_symbol']) ? $row['currency_symbol'] : config('money.' . $row['currency_code'] . '.symbol'), + 'precision' => isset($row['currency_precision']) ? $row['currency_precision'] : config('money.' . $row['currency_code'] . '.precision'), + 'decimal_mark' => isset($row['currency_decimal_mark']) ? $row['currency_decimal_mark'] : config('money.' . $row['currency_code'] . '.decimal_mark'), + 'created_from' => $row['created_from'], + 'created_by' => $row['created_by'], + ]; + + Validator::validate($data, [(new CurrencyRequest)->rules()]); + + $currency = $this->dispatch(new CreateCurrency($data)); + + return $currency->code; + } + public function getDocumentId($row) { $id = isset($row['document_id']) ? $row['document_id'] : null; diff --git a/app/Utilities/Overrider.php b/app/Utilities/Overrider.php index 1d8147d1a..12dd16dee 100644 --- a/app/Utilities/Overrider.php +++ b/app/Utilities/Overrider.php @@ -2,6 +2,7 @@ namespace App\Utilities; +use Akaunting\Money\Money; use App\Models\Setting\Currency; class Overrider @@ -58,6 +59,9 @@ class Overrider app()->setLocale($locale); } + // Set locale for Money package + Money::setLocale(app()->getLocale()); + // Set app url dynamically if empty if (! config('app.url')) { config(['app.url' => url('/')]); diff --git a/app/View/Components/Contacts/Show/Content.php b/app/View/Components/Contacts/Show/Content.php index f1bd76941..03d278578 100644 --- a/app/View/Components/Contacts/Show/Content.php +++ b/app/View/Components/Contacts/Show/Content.php @@ -74,9 +74,8 @@ class Content extends Component $this->totals = $totals; - $limit = (int) request('limit', setting('default.list_limit', '25')); - $this->transactions = $this->paginate($this->transactions->sortByDesc('paid_at'), $limit); - $this->documents = $this->paginate($this->documents->sortByDesc('issued_at'), $limit); + $this->transactions = $this->paginate($this->transactions->sortByDesc('paid_at')); + $this->documents = $this->paginate($this->documents->sortByDesc('issued_at')); return view('components.contacts.show.content'); } @@ -91,7 +90,7 @@ class Content extends Component * * @return LengthAwarePaginator */ - public function paginate($items, $perPage = 15, $page = null, $options = []) + public function paginate($items, $perPage = null, $page = null, $options = []) { $perPage = $perPage ?: (int) request('limit', setting('default.list_limit', '25')); diff --git a/composer.lock b/composer.lock index a02752f94..30435d7da 100644 --- a/composer.lock +++ b/composer.lock @@ -413,16 +413,16 @@ }, { "name": "akaunting/laravel-money", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/akaunting/laravel-money.git", - "reference": "22336631239eb008e26d322faa208cbc50757a38" + "reference": "a4a3a204250a1185080c9cf0fe6f7f50d0e144cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/akaunting/laravel-money/zipball/22336631239eb008e26d322faa208cbc50757a38", - "reference": "22336631239eb008e26d322faa208cbc50757a38", + "url": "https://api.github.com/repos/akaunting/laravel-money/zipball/a4a3a204250a1185080c9cf0fe6f7f50d0e144cf", + "reference": "a4a3a204250a1185080c9cf0fe6f7f50d0e144cf", "shasum": "" }, "require": { @@ -475,9 +475,9 @@ ], "support": { "issues": "https://github.com/akaunting/laravel-money/issues", - "source": "https://github.com/akaunting/laravel-money/tree/3.0.1" + "source": "https://github.com/akaunting/laravel-money/tree/3.1.0" }, - "time": "2022-05-11T06:34:38+00:00" + "time": "2022-07-19T11:23:57+00:00" }, { "name": "akaunting/laravel-mutable-observer", @@ -907,16 +907,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.231.6", + "version": "3.231.8", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "54c5fe6667c73010d954ce4c4d657d093f0bdcbf" + "reference": "99b3e4585ac82a6e9ab6d1944d90231456fefbea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/54c5fe6667c73010d954ce4c4d657d093f0bdcbf", - "reference": "54c5fe6667c73010d954ce4c4d657d093f0bdcbf", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/99b3e4585ac82a6e9ab6d1944d90231456fefbea", + "reference": "99b3e4585ac82a6e9ab6d1944d90231456fefbea", "shasum": "" }, "require": { @@ -993,9 +993,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.231.6" + "source": "https://github.com/aws/aws-sdk-php/tree/3.231.8" }, - "time": "2022-07-14T18:20:54+00:00" + "time": "2022-07-18T18:20:47+00:00" }, { "name": "balping/json-raw-encoder", @@ -5038,16 +5038,16 @@ }, { "name": "league/commonmark", - "version": "2.3.3", + "version": "2.3.4", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "0da1dca5781dd3cfddbe328224d9a7a62571addc" + "reference": "155ec1c95626b16fda0889cf15904d24890a60d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/0da1dca5781dd3cfddbe328224d9a7a62571addc", - "reference": "0da1dca5781dd3cfddbe328224d9a7a62571addc", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/155ec1c95626b16fda0889cf15904d24890a60d5", + "reference": "155ec1c95626b16fda0889cf15904d24890a60d5", "shasum": "" }, "require": { @@ -5140,7 +5140,7 @@ "type": "tidelift" } ], - "time": "2022-06-07T21:28:26+00:00" + "time": "2022-07-17T16:25:47+00:00" }, { "name": "league/config", @@ -5226,16 +5226,16 @@ }, { "name": "league/flysystem", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "34a68067b7ae3b836ea5e57e1fc432478372a4f5" + "reference": "1a941703dfb649f9b821e7bc425e782f576a805e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/34a68067b7ae3b836ea5e57e1fc432478372a4f5", - "reference": "34a68067b7ae3b836ea5e57e1fc432478372a4f5", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/1a941703dfb649f9b821e7bc425e782f576a805e", + "reference": "1a941703dfb649f9b821e7bc425e782f576a805e", "shasum": "" }, "require": { @@ -5296,7 +5296,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.1.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.1.1" }, "funding": [ { @@ -5312,25 +5312,25 @@ "type": "tidelift" } ], - "time": "2022-06-29T17:29:54+00:00" + "time": "2022-07-18T09:59:40+00:00" }, { "name": "league/flysystem-aws-s3-v3", - "version": "3.0.22", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git", - "reference": "e5fc508faf83df2fbd2a215d2b4bea9584906221" + "reference": "fa46ce9fbad9bfc73d8b160ffeb2c1793fe9c73b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/e5fc508faf83df2fbd2a215d2b4bea9584906221", - "reference": "e5fc508faf83df2fbd2a215d2b4bea9584906221", + "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/fa46ce9fbad9bfc73d8b160ffeb2c1793fe9c73b", + "reference": "fa46ce9fbad9bfc73d8b160ffeb2c1793fe9c73b", "shasum": "" }, "require": { "aws/aws-sdk-php": "^3.132.4", - "league/flysystem": "^2.0.0 || ^3.0.0", + "league/flysystem": "^3.0.0", "league/mime-type-detection": "^1.0.0", "php": "^8.0.2" }, @@ -5366,9 +5366,23 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem-aws-s3-v3/issues", - "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.0.22" + "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.1.1" }, - "time": "2022-06-29T07:09:46+00:00" + "funding": [ + { + "url": "https://offset.earth/frankdejonge", + "type": "custom" + }, + { + "url": "https://github.com/frankdejonge", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/flysystem", + "type": "tidelift" + } + ], + "time": "2022-07-18T09:31:34+00:00" }, { "name": "league/mime-type-detection", @@ -7522,16 +7536,16 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "1.24.0", + "version": "1.24.1", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "ebe8745c92a7cac4514d040758393b5399633b83" + "reference": "69991111e05fca3ff7398e1e7fca9ebed33efec6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/ebe8745c92a7cac4514d040758393b5399633b83", - "reference": "ebe8745c92a7cac4514d040758393b5399633b83", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/69991111e05fca3ff7398e1e7fca9ebed33efec6", + "reference": "69991111e05fca3ff7398e1e7fca9ebed33efec6", "shasum": "" }, "require": { @@ -7620,9 +7634,9 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.24.0" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.24.1" }, - "time": "2022-07-09T13:49:09+00:00" + "time": "2022-07-18T19:50:48+00:00" }, { "name": "phpoption/phpoption", @@ -14115,5 +14129,5 @@ "ext-zip": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/resources/assets/js/views/modules/apps.js b/resources/assets/js/views/modules/apps.js index 12ff89136..bffdda633 100644 --- a/resources/assets/js/views/modules/apps.js +++ b/resources/assets/js/views/modules/apps.js @@ -29,6 +29,10 @@ const app = new Vue({ AkauntingSlider }, + created() { + document.addEventListener('click', this.closeIfClickedOutside); + }, + mounted() { if (typeof app_slug !== 'undefined') { this.onReleases(1); @@ -84,6 +88,12 @@ const app = new Vue({ addToCartLoading: false, loadMoreLoading: false, + live_search: { + data: [], + modal: false, + not_found: false + }, + route_url: url } }, @@ -288,5 +298,34 @@ const app = new Vue({ this.loadMoreLoading = false; }); }, + + closeIfClickedOutside(event) { + let el = this.$refs.liveSearchModal; + let target = event.target; + + if (el !== target && target.contains(el)) { + this.live_search.modal = false; + } + }, + + onLiveSearch(event) { + let target_length = event.target.value.length; + + if (target_length > 2) { + window.axios.get(url + '/apps/search?keyword=' + event.target.value) + .then(response => { + this.live_search.data = response.data.data.data; + this.live_search.modal = true; + this.live_search.not_found = false; + }) + .catch(error => { + this.live_search.not_found = true; + this.live_search.data = []; + console.log(error); + }) + } else if (target_length == 0) { + this.live_search.modal = false; + } + } } }); diff --git a/resources/lang/en-GB/modules.php b/resources/lang/en-GB/modules.php index 12c1115e6..48f9b7501 100644 --- a/resources/lang/en-GB/modules.php +++ b/resources/lang/en-GB/modules.php @@ -50,6 +50,7 @@ return [ 'hosted_on_akaunting' => 'Hosted on akaunting.com', 'only_works_cloud' => 'This app is available only on Cloud.', 'only_premium_plan' => 'This app is available only on Premium Cloud.', + 'not_found' => 'No app found', 'about' => 'About', diff --git a/resources/views/banking/accounts/show.blade.php b/resources/views/banking/accounts/show.blade.php index 060163ee0..5bfa87706 100644 --- a/resources/views/banking/accounts/show.blade.php +++ b/resources/views/banking/accounts/show.blade.php @@ -116,15 +116,15 @@ @stack('summary_incoming_start') - + @stack('summary_incoming_end') @stack('summary_outgoing_start') - + @stack('summary_outgoing_end') @stack('summary_current_start') - + @stack('summary_current_end') @@ -225,7 +225,7 @@ - + @@ -243,11 +243,7 @@ - - - - - @@ -265,7 +261,7 @@ @foreach($transactions as $item) - + @@ -283,11 +279,7 @@ - - {{ $item->account->name }} - - -