mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-29 11:15:58 +00:00
Invoice & Clients sorting
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use DB;
|
||||
use App\Models\User;
|
||||
use ByteUnits\Metric;
|
||||
use App\Services\StripeService;
|
||||
|
||||
@@ -20,8 +20,12 @@ class ClientController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$clients = Client::sortable()
|
||||
->whereUserId(Auth::id())
|
||||
->get();
|
||||
|
||||
return response(
|
||||
new OasisViewClientCollection(Auth::user()->clients),
|
||||
new OasisViewClientCollection($clients),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Oasis;
|
||||
|
||||
use App\Http\Requests\Oasis\ShareInvoiceRequest;
|
||||
use App\Http\Resources\Oasis\OasisInvoiceResource;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Storage;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Oasis\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Oasis\Invoice;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Http\Requests\Oasis\ShareInvoiceRequest;
|
||||
use App\Http\Requests\Oasis\StoreInvoiceRequest;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Resources\Oasis\OasisInvoiceResource;
|
||||
use App\Http\Resources\Oasis\OasisViewInvoiceResource;
|
||||
use App\Http\Resources\Oasis\OasisViewInvoiceCollection;
|
||||
use App\Notifications\Oasis\InvoiceDeliveryNotification;
|
||||
@@ -28,8 +27,13 @@ class InvoiceController extends Controller
|
||||
*/
|
||||
public function get_all_regular_invoices()
|
||||
{
|
||||
$invoices = Invoice::sortable()
|
||||
->whereUserId(Auth::id())
|
||||
->whereInvoiceType('regular-invoice')
|
||||
->get();
|
||||
|
||||
return response(
|
||||
new OasisViewInvoiceCollection(Auth::user()->regularInvoices),
|
||||
new OasisViewInvoiceCollection($invoices),
|
||||
200
|
||||
);
|
||||
}
|
||||
@@ -39,8 +43,13 @@ class InvoiceController extends Controller
|
||||
*/
|
||||
public function get_all_advance_invoices()
|
||||
{
|
||||
$invoices = Invoice::sortable()
|
||||
->whereUserId(Auth::id())
|
||||
->whereInvoiceType('advance-invoice')
|
||||
->get();
|
||||
|
||||
return response(
|
||||
new OasisViewInvoiceCollection(Auth::user()->advanceInvoices),
|
||||
new OasisViewInvoiceCollection($invoices),
|
||||
200
|
||||
);
|
||||
}
|
||||
@@ -63,7 +72,7 @@ class InvoiceController extends Controller
|
||||
*/
|
||||
public function download_invoice(Invoice $invoice)
|
||||
{
|
||||
if (!Storage::exists(invoice_path($invoice))) {
|
||||
if (! Storage::exists(invoice_path($invoice))) {
|
||||
abort(404, 'Not Found');
|
||||
}
|
||||
|
||||
@@ -75,9 +84,9 @@ class InvoiceController extends Controller
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$query = remove_accents(request()->input('query'));
|
||||
|
||||
$results = Invoice::search($query)
|
||||
$results = Invoice::search(
|
||||
remove_accents(request()->input('query'))
|
||||
)
|
||||
->where('user_id', request()->user()->id)
|
||||
->where('invoice_type', request()->input('type'))
|
||||
->get();
|
||||
@@ -100,33 +109,33 @@ class InvoiceController extends Controller
|
||||
$user = $request->user();
|
||||
|
||||
$invoice = Invoice::create([
|
||||
'user_id' => $user->id,
|
||||
'client_id' => $client->id ?? null,
|
||||
'invoice_type' => $request->invoice_type,
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'user_id' => $user->id,
|
||||
'client_id' => $client->id ?? null,
|
||||
'invoice_type' => $request->invoice_type,
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'variable_number' => $request->variable_number,
|
||||
'delivery_at' => $request->delivery_at,
|
||||
'discount_type' => $request->discount_type ?? null,
|
||||
'discount_rate' => $request->discount_rate ?? null,
|
||||
'items' => json_decode($request->items),
|
||||
'user' => $user->invoiceProfile,
|
||||
'client' => [
|
||||
'email' => $client->email ?? $request->client_email,
|
||||
'name' => $client->name ?? $request->client_name,
|
||||
'address' => $client->address ?? $request->client_address,
|
||||
'city' => $client->city ?? $request->client_city,
|
||||
'delivery_at' => $request->delivery_at,
|
||||
'discount_type' => $request->discount_type ?? null,
|
||||
'discount_rate' => $request->discount_rate ?? null,
|
||||
'items' => json_decode($request->items),
|
||||
'user' => $user->invoiceProfile,
|
||||
'client' => [
|
||||
'email' => $client->email ?? $request->client_email,
|
||||
'name' => $client->name ?? $request->client_name,
|
||||
'address' => $client->address ?? $request->client_address,
|
||||
'city' => $client->city ?? $request->client_city,
|
||||
'postal_code' => $client->postal_code ?? $request->client_postal_code,
|
||||
'country' => $client->country ?? $request->client_country,
|
||||
'ico' => $client->ico ?? $request->client_ico,
|
||||
'dic' => $client->dic ?? $request->client_dic ?? null,
|
||||
'ic_dph' => $client->ic_dph ?? $request->client_ic_dph ?? null,
|
||||
'country' => $client->country ?? $request->client_country,
|
||||
'ico' => $client->ico ?? $request->client_ico,
|
||||
'dic' => $client->dic ?? $request->client_dic ?? null,
|
||||
'ic_dph' => $client->ic_dph ?? $request->client_ic_dph ?? null,
|
||||
],
|
||||
]);
|
||||
|
||||
// Generate PDF
|
||||
\PDF::loadView('oasis.invoices.invoice', [
|
||||
'invoice' => Invoice::find($invoice->id),
|
||||
'user' => $user,
|
||||
'user' => $user,
|
||||
])
|
||||
->setPaper('a4')
|
||||
->setOrientation('portrait')
|
||||
@@ -158,12 +167,12 @@ class InvoiceController extends Controller
|
||||
$user = $request->user();
|
||||
|
||||
$invoice->update([
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'variable_number' => $request->variable_number,
|
||||
'delivery_at' => $request->delivery_at,
|
||||
'discount_type' => $request->discount_type ?? null,
|
||||
'discount_rate' => $request->discount_rate ?? null,
|
||||
'items' => json_decode($request->items),
|
||||
'delivery_at' => $request->delivery_at,
|
||||
'discount_type' => $request->discount_type ?? null,
|
||||
'discount_rate' => $request->discount_rate ?? null,
|
||||
'items' => json_decode($request->items),
|
||||
]);
|
||||
|
||||
Storage::delete(invoice_path($invoice));
|
||||
@@ -171,7 +180,7 @@ class InvoiceController extends Controller
|
||||
// Generate PDF
|
||||
\PDF::loadView('oasis.invoices.invoice', [
|
||||
'invoice' => Invoice::find($invoice->id),
|
||||
'user' => $user,
|
||||
'user' => $user,
|
||||
])
|
||||
->setPaper('a4')
|
||||
->setOrientation('portrait')
|
||||
@@ -205,7 +214,7 @@ class InvoiceController extends Controller
|
||||
);
|
||||
|
||||
return response(
|
||||
'Done.',
|
||||
'Done',
|
||||
204
|
||||
);
|
||||
}
|
||||
@@ -231,19 +240,19 @@ class InvoiceController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
return [
|
||||
'clients' => $user->clients->map(function ($client) {
|
||||
'isVatPayer' => $user->invoiceProfile->ic_dph ?? false,
|
||||
'latestInvoiceNumber' => $user->regularInvoices->first()
|
||||
? (int) $user->regularInvoices->first()->invoice_number
|
||||
: null,
|
||||
'recommendedInvoiceNumber' => $user->regularInvoices->first()
|
||||
? (int) $user->regularInvoices->first()->invoice_number + 1
|
||||
: Carbon::now()->format('Y') . '0001',
|
||||
'clients' => $user->clients->map(function ($client) {
|
||||
return [
|
||||
'label' => $client->name,
|
||||
'value' => $client->id,
|
||||
];
|
||||
}),
|
||||
'isVatPayer' => $user->invoiceProfile->ic_dph ?? false,
|
||||
'latestInvoiceNumber' => $user->regularInvoices->first()
|
||||
? (int)$user->regularInvoices->first()->invoice_number
|
||||
: null,
|
||||
'recommendedInvoiceNumber' => $user->regularInvoices->first()
|
||||
? (int)$user->regularInvoices->first()->invoice_number + 1
|
||||
: Carbon::now()->format('Y') . '0001',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -253,21 +262,21 @@ class InvoiceController extends Controller
|
||||
*/
|
||||
private function getOrStoreClient(StoreInvoiceRequest $request)
|
||||
{
|
||||
if (!Str::isUuid($request->client) && $request->store_client) {
|
||||
if (! Str::isUuid($request->client) && $request->store_client) {
|
||||
return $request->user()
|
||||
->clients()
|
||||
->create([
|
||||
'avatar' => store_avatar($request, 'client_avatar') ?? null,
|
||||
'name' => $request->client_name,
|
||||
'email' => $request->client_email ?? null,
|
||||
'avatar' => store_avatar($request, 'client_avatar') ?? null,
|
||||
'name' => $request->client_name,
|
||||
'email' => $request->client_email ?? null,
|
||||
'phone_number' => $request->client_phone_number ?? null,
|
||||
'address' => $request->client_address,
|
||||
'city' => $request->client_city,
|
||||
'postal_code' => $request->client_postal_code,
|
||||
'country' => $request->client_country,
|
||||
'ico' => $request->client_ico ?? null,
|
||||
'dic' => $request->client_dic ?? null,
|
||||
'ic_dph' => $request->client_ic_dph ?? null,
|
||||
'address' => $request->client_address,
|
||||
'city' => $request->client_city,
|
||||
'postal_code' => $request->client_postal_code,
|
||||
'country' => $request->client_country,
|
||||
'ico' => $request->client_ico ?? null,
|
||||
'dic' => $request->client_dic ?? null,
|
||||
'ic_dph' => $request->client_ic_dph ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ class InvoiceProfileController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user->invoiceProfile) {
|
||||
|
||||
return response(
|
||||
new InvoiceProfileResource($user->invoiceProfile),
|
||||
200
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Oasis;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Oasis;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
@@ -16,22 +15,22 @@ class OasisInvoiceResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
'type' => 'invoice',
|
||||
'id' => $this->id,
|
||||
'type' => 'invoice',
|
||||
'attributes' => [
|
||||
'name' => $this->client['name'] . ' ' . format_to_currency($this->total_net, $this->currency),
|
||||
'invoice_number' => $this->invoice_number,
|
||||
'name' => $this->client['name'] . ' ' . format_to_currency($this->total_net, $this->currency),
|
||||
'invoice_number' => $this->invoice_number,
|
||||
'variable_number' => $this->variable_number,
|
||||
'invoice_type' => $this->invoice_type,
|
||||
'delivery_at' => $this->delivery_at,
|
||||
'items' => $this->items,
|
||||
'discount_type' => $this->discount_type,
|
||||
'discount_rate' => $this->discount_rate,
|
||||
'client' => $this->client,
|
||||
'total' => format_to_currency($this->total_net, $this->currency),
|
||||
'file_url' => "/oasis/invoice/$this->id",
|
||||
'mimetype' => 'pdf',
|
||||
'created_at' => format_date($this->created_at, '%d. %B. %Y'),
|
||||
'invoice_type' => $this->invoice_type,
|
||||
'delivery_at' => $this->delivery_at,
|
||||
'items' => $this->items,
|
||||
'discount_type' => $this->discount_type,
|
||||
'discount_rate' => $this->discount_rate,
|
||||
'client' => $this->client,
|
||||
'total' => format_to_currency($this->total_net, $this->currency),
|
||||
'file_url' => "/oasis/invoice/$this->id",
|
||||
'mimetype' => 'pdf',
|
||||
'created_at' => format_date($this->created_at, '%d. %B. %Y'),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -76,7 +76,6 @@ function invoice_tax_base($invoice)
|
||||
'rate' => $item['tax_rate'],
|
||||
'total' => $item['price'] * $item['amount'],
|
||||
]);
|
||||
|
||||
} else {
|
||||
$bag->map(function ($bagItem) use ($item) {
|
||||
if ($bagItem['rate'] === $item['tax_rate']) {
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace App\Models\Oasis;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -14,7 +15,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
*/
|
||||
class Client extends Model
|
||||
{
|
||||
use HasFactory, Searchable;
|
||||
use HasFactory, Searchable, Sortable;
|
||||
|
||||
public $guarded = ['id'];
|
||||
|
||||
@@ -22,6 +23,11 @@ class Client extends Model
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
public $sortable = [
|
||||
'created_at',
|
||||
'name',
|
||||
];
|
||||
|
||||
/**
|
||||
* Format avatar to full url
|
||||
*
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models\Oasis;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
use HasFactory, Searchable;
|
||||
use HasFactory, Searchable, Sortable;
|
||||
|
||||
protected $casts = [
|
||||
'items' => 'array',
|
||||
@@ -24,6 +24,12 @@ class Invoice extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
public $sortable = [
|
||||
'invoice_number',
|
||||
'created_at',
|
||||
'total_net',
|
||||
];
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
@@ -192,10 +192,10 @@ return [
|
||||
'in.empty.bill_profile_description' => 'Before your first invoice, please set up your billing profile.',
|
||||
'in.empty.clients_invoices' => "Client doesn't have any invoices yet.",
|
||||
|
||||
'in.empty.invoice_page_title' => "Create Your First Invoice",
|
||||
'in.empty.invoice_page_title' => 'Create Your First Invoice',
|
||||
'in.empty.invoice_page_description' => "It's very easy, just click on the button below.",
|
||||
|
||||
'in.empty.client_page_title' => "Create Your First Client",
|
||||
'in.empty.client_page_title' => 'Create Your First Client',
|
||||
|
||||
'in.form.some_issues' => 'We found some issues in your form. Please check it out and submit again',
|
||||
'in.form.create_client' => 'Create Client',
|
||||
@@ -282,4 +282,6 @@ return [
|
||||
'in.share.type_email' => 'Type email address...',
|
||||
'in.share.submit_share' => 'Send Invoice',
|
||||
'in.share.invoice_sended' => 'Your invoice has been sent successfully',
|
||||
'in.sort_by_net' => 'Sort By Total Net',
|
||||
'in.sort_by_invoice_number' => 'Sort By Invoice Number',
|
||||
];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"/chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~chunks/app-index~chu~e360f8a1.js": "/chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~chunks/app-index~chu~e360f8a1.js?id=9a997811677c9fcc0c6e",
|
||||
"/chunks/admin-account~chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/datab~062c965c.js": "/chunks/admin-account~chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/datab~062c965c.js?id=515118382f7ad5724a54",
|
||||
"/chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~chunks/~56ae6336.js": "/chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~chunks/~56ae6336.js?id=3500df10c19053acd77b",
|
||||
"/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/oasis/invoices/list~chunks/platform~chunks/sh~d177b2e8.js": "/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/oasis/invoices/list~chunks/platform~chunks/sh~d177b2e8.js?id=7ebb93e8d3cedf069c0b",
|
||||
"/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/oasis/invoices/list~chunks/platform~chunks/sh~d177b2e8.js": "/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/oasis/invoices/list~chunks/platform~chunks/sh~d177b2e8.js?id=e04cb058c0e83d3171dc",
|
||||
"/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/settings~chunks/shared/file-browser.js": "/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/settings~chunks/shared/file-browser.js?id=e15b67406596821c2be9",
|
||||
"/chunks/admin~chunks/oasis/invoices~chunks/platform.js": "/chunks/admin~chunks/oasis/invoices~chunks/platform.js?id=5bbc9cca3bfcc01fdc87",
|
||||
"/chunks/admin~chunks/oasis/invoices~chunks/platform~chunks/shared.js": "/chunks/admin~chunks/oasis/invoices~chunks/platform~chunks/shared.js?id=1ca47708816a4be47a0a",
|
||||
@@ -57,7 +57,7 @@
|
||||
"/chunks/oasis/invoices/create-client.js": "/chunks/oasis/invoices/create-client.js?id=a27824905ee00e5b9d5e",
|
||||
"/chunks/oasis/invoices/create-invoice.js": "/chunks/oasis/invoices/create-invoice.js?id=da39947baccf666a1efc",
|
||||
"/chunks/oasis/invoices/edit-invoice.js": "/chunks/oasis/invoices/edit-invoice.js?id=b8776f1c1d5b8b0626da",
|
||||
"/chunks/oasis/invoices/list.js": "/chunks/oasis/invoices/list.js?id=d2b607b91b69247bf05c",
|
||||
"/chunks/oasis/invoices/list.js": "/chunks/oasis/invoices/list.js?id=b64e4b332c1b2fe4155d",
|
||||
"/chunks/oasis/invoices/profile.js": "/chunks/oasis/invoices/profile.js?id=cb529bbeb676d24b011e",
|
||||
"/chunks/oasis/invoices~chunks/platform~chunks/shared.js": "/chunks/oasis/invoices~chunks/platform~chunks/shared.js?id=41015b7ab9210a0e2df6",
|
||||
"/chunks/oasis/platba.js": "/chunks/oasis/platba.js?id=791bf891bb4a384c0890",
|
||||
@@ -154,5 +154,26 @@
|
||||
"/chunks/oasis/invoices.a2e81296c5286a6ab9cf.hot-update.js": "/chunks/oasis/invoices.a2e81296c5286a6ab9cf.hot-update.js",
|
||||
"/chunks/oasis/invoices.3dd500d45303576331bf.hot-update.js": "/chunks/oasis/invoices.3dd500d45303576331bf.hot-update.js",
|
||||
"/chunks/oasis/invoices.23848caf5faa2c2cd4a3.hot-update.js": "/chunks/oasis/invoices.23848caf5faa2c2cd4a3.hot-update.js",
|
||||
"/chunks/oasis/invoices.0bf75b19f8e77e4eac43.hot-update.js": "/chunks/oasis/invoices.0bf75b19f8e77e4eac43.hot-update.js"
|
||||
"/chunks/oasis/invoices.0bf75b19f8e77e4eac43.hot-update.js": "/chunks/oasis/invoices.0bf75b19f8e77e4eac43.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.b3a43153ac90cb3cca4a.hot-update.js": "/chunks/oasis/invoices/list.b3a43153ac90cb3cca4a.hot-update.js",
|
||||
"/js/main.cecf5b73f06061c06bd5.hot-update.js": "/js/main.cecf5b73f06061c06bd5.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.cecf5b73f06061c06bd5.hot-update.js": "/chunks/oasis/invoices/list.cecf5b73f06061c06bd5.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.424d115407676741fcdc.hot-update.js": "/chunks/oasis/invoices/list.424d115407676741fcdc.hot-update.js",
|
||||
"/js/main.66bc5e1fb750efafbd0e.hot-update.js": "/js/main.66bc5e1fb750efafbd0e.hot-update.js",
|
||||
"/js/main.de282024eb55ef14581a.hot-update.js": "/js/main.de282024eb55ef14581a.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.7bba12a9911d54749f73.hot-update.js": "/chunks/oasis/invoices/list.7bba12a9911d54749f73.hot-update.js",
|
||||
"/js/main.161eb537875d969d5b6e.hot-update.js": "/js/main.161eb537875d969d5b6e.hot-update.js",
|
||||
"/js/main.d880a78c9e4a48feb609.hot-update.js": "/js/main.d880a78c9e4a48feb609.hot-update.js",
|
||||
"/js/main.a5e4b2ace70bee20a1a0.hot-update.js": "/js/main.a5e4b2ace70bee20a1a0.hot-update.js",
|
||||
"/js/main.9b066fbed86ecec52dee.hot-update.js": "/js/main.9b066fbed86ecec52dee.hot-update.js",
|
||||
"/js/main.cc585a2b18a03b71620e.hot-update.js": "/js/main.cc585a2b18a03b71620e.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.36b8e5b030586fb0d35d.hot-update.js": "/chunks/oasis/invoices/list.36b8e5b030586fb0d35d.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.07126decb4f904d571aa.hot-update.js": "/chunks/oasis/invoices/list.07126decb4f904d571aa.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.2d37b25effcf088e4f9c.hot-update.js": "/chunks/oasis/invoices/list.2d37b25effcf088e4f9c.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.ccf983e1788b1e40ec9c.hot-update.js": "/chunks/oasis/invoices/list.ccf983e1788b1e40ec9c.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.d279ac45643d3f93208c.hot-update.js": "/chunks/oasis/invoices/list.d279ac45643d3f93208c.hot-update.js",
|
||||
"/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/oasis/invoices/list~chunks/platform~chunks/sh~d177b2e8.645b3154cb8b4cb5bef6.hot-update.js": "/chunks/admin~chunks/files~chunks/oasis/invoices~chunks/oasis/invoices/list~chunks/platform~chunks/sh~d177b2e8.645b3154cb8b4cb5bef6.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.c35b17432d1251d93bbb.hot-update.js": "/chunks/oasis/invoices/list.c35b17432d1251d93bbb.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.b0ff13923b3e0c3e1f3f.hot-update.js": "/chunks/oasis/invoices/list.b0ff13923b3e0c3e1f3f.hot-update.js",
|
||||
"/chunks/oasis/invoices/list.34473b8481c7f1601ee0.hot-update.js": "/chunks/oasis/invoices/list.34473b8481c7f1601ee0.hot-update.js"
|
||||
}
|
||||
|
||||
@@ -44,8 +44,13 @@
|
||||
<ToolbarGroup>
|
||||
<PopoverWrapper>
|
||||
<ToolbarButton @click.stop.native="showSortingMenu" source="preview-sorting" :action="$t('actions.sorting_view')" />
|
||||
<PopoverItem name="desktop-sorting">
|
||||
<OptionGroup>
|
||||
<PopoverItem name="desktop-sorting" side="left">
|
||||
<OptionGroup v-if="$isThisLocation(['regular-invoice', 'advance-invoice'])">
|
||||
<Option @click.native.stop="sort('created_at')" :title="$t('preview_sorting.sort_date')" icon="calendar" />
|
||||
<Option @click.native.stop="sort('total_net')" :title="$t('in.sort_by_net')" icon="dollar" />
|
||||
<Option @click.native.stop="sort('invoice_number')" :title="$t('in.sort_by_invoice_number')" icon="file-text" />
|
||||
</OptionGroup>
|
||||
<OptionGroup v-if="$isThisLocation('clients')">
|
||||
<Option @click.native.stop="sort('created_at')" :title="$t('preview_sorting.sort_date')" icon="calendar" />
|
||||
<Option @click.native.stop="sort('name')" :title="$t('preview_sorting.sort_alphabet')" icon="alphabet" />
|
||||
</OptionGroup>
|
||||
@@ -113,6 +118,10 @@
|
||||
data() {
|
||||
return {
|
||||
query: '',
|
||||
filter: {
|
||||
sort: 'DESC',
|
||||
field: undefined
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -121,6 +130,24 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sort(field) {
|
||||
this.filter.field = field
|
||||
|
||||
// Set sorting direction
|
||||
if (this.filter.sort === 'DESC')
|
||||
this.filter.sort = 'ASC'
|
||||
else if (this.filter.sort === 'ASC')
|
||||
this.filter.sort = 'DESC'
|
||||
|
||||
// Save to localStorage sorting options
|
||||
localStorage.setItem('sorting-invoices', JSON.stringify({ sort: this.filter.sort, field: this.filter.field }))
|
||||
|
||||
// Update sorting state in vuex
|
||||
this.$store.commit('UPDATE_INVOICE_SORTING')
|
||||
|
||||
// Get data using the application location
|
||||
this.$getInvoiceDataByLocation()
|
||||
},
|
||||
createInvoice(type) {
|
||||
this.$router.push({name: 'CreateInvoice', query: {type: type}})
|
||||
},
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<box-icon v-if="icon === 'box'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<clock-icon v-if="icon === 'clock'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<send-icon v-if="icon === 'send'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<dollar-sign-icon v-if="icon === 'dollar'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
</div>
|
||||
<div class="text-label group-hover-text-theme" :class="{'text-theme': isActive}">
|
||||
{{ title }}
|
||||
@@ -49,6 +50,7 @@
|
||||
<script>
|
||||
import AlphabetIcon from '@/components/FilesView/Icons/AlphabetIcon'
|
||||
import {
|
||||
DollarSignIcon,
|
||||
UserPlusIcon,
|
||||
FilePlusIcon,
|
||||
SendIcon,
|
||||
@@ -95,6 +97,7 @@ import {
|
||||
'icon'
|
||||
],
|
||||
components: {
|
||||
DollarSignIcon,
|
||||
UserPlusIcon,
|
||||
FilePlusIcon,
|
||||
SendIcon,
|
||||
|
||||
Vendored
+16
@@ -1,10 +1,26 @@
|
||||
import i18n from '@/i18n/index'
|
||||
import {debounce} from 'lodash'
|
||||
import {events} from './bus'
|
||||
import store from "./store";
|
||||
|
||||
const OasisHelpers = {
|
||||
install(Vue) {
|
||||
|
||||
Vue.prototype.$getInvoiceDataByLocation = function () {
|
||||
|
||||
let currentLocation = store.getters.currentFolder && store.getters.currentFolder.location
|
||||
? store.getters.currentFolder.location
|
||||
: undefined
|
||||
|
||||
let actions = {
|
||||
'regular-invoice': 'getRegularInvoices',
|
||||
'advance-invoice': 'getAdvanceInvoices',
|
||||
'clients': 'getClients',
|
||||
}
|
||||
|
||||
this.$store.dispatch(actions[currentLocation])
|
||||
}
|
||||
|
||||
Vue.prototype.$shareInvoice = function (entry) {
|
||||
events.$emit('popup:open', {
|
||||
name: 'share-invoice',
|
||||
|
||||
@@ -2,7 +2,12 @@ import {events} from '@/bus'
|
||||
import axios from "axios"
|
||||
import Vue from "vue"
|
||||
|
||||
const defaultState = {}
|
||||
const defaultState = {
|
||||
invoiceSorting: {
|
||||
sort: localStorage.getItem('sorting') ? JSON.parse(localStorage.getItem('sorting')).sort : 'DESC',
|
||||
field: localStorage.getItem('sorting') ? JSON.parse(localStorage.getItem('sorting')).field : 'created_at',
|
||||
},
|
||||
}
|
||||
|
||||
const actions = {
|
||||
getRegularInvoices: ({commit, getters}) => {
|
||||
@@ -15,7 +20,7 @@ const actions = {
|
||||
})
|
||||
|
||||
axios
|
||||
.get('/api/oasis/invoices/regular')
|
||||
.get('/api/oasis/invoices/regular' + getters.invoiceSorting.URI)
|
||||
.then(response => {
|
||||
commit('LOADING_STATE', {loading: false, data: response.data})
|
||||
})
|
||||
@@ -36,7 +41,7 @@ const actions = {
|
||||
})
|
||||
|
||||
axios
|
||||
.get('/api/oasis/invoices/advance')
|
||||
.get('/api/oasis/invoices/advance' + getters.invoiceSorting.URI)
|
||||
.then(response => {
|
||||
commit('LOADING_STATE', {loading: false, data: response.data})
|
||||
})
|
||||
@@ -57,7 +62,7 @@ const actions = {
|
||||
})
|
||||
|
||||
axios
|
||||
.get('/api/oasis/clients')
|
||||
.get('/api/oasis/clients' + getters.invoiceSorting.URI)
|
||||
.then(response => {
|
||||
commit('LOADING_STATE', {loading: false, data: response.data})
|
||||
})
|
||||
@@ -97,17 +102,20 @@ const actions = {
|
||||
})
|
||||
.catch(() => Vue.prototype.$isSomethingWrong())
|
||||
},
|
||||
deleteClient: ({commit, getters}, payload) => {
|
||||
//
|
||||
},
|
||||
sendInvoice: ({commit, getters}, payload) => {
|
||||
//
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
UPDATE_INVOICE_SORTING(state) {
|
||||
state.invoiceSorting.field = JSON.parse(localStorage.getItem('sorting-invoices')).field
|
||||
state.invoiceSorting.sort = JSON.parse(localStorage.getItem('sorting-invoices')).sort
|
||||
},
|
||||
}
|
||||
|
||||
const mutations = {}
|
||||
|
||||
const getters = {}
|
||||
const getters = {
|
||||
invoiceSorting: (state) => {
|
||||
return {sorting: state.invoiceSorting, URI: '?sort=' + state.invoiceSorting.field + '&direction=' + state.invoiceSorting.sort}
|
||||
},
|
||||
}
|
||||
|
||||
export default {
|
||||
state: defaultState,
|
||||
|
||||
Reference in New Issue
Block a user