mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 02:50:39 +00:00
- Invoice listing in frontend
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Share;
|
||||
use App\Services\HelperService;
|
||||
use App\Services\Oasis\OasisDevService;
|
||||
use App\Services\SetupService;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
@@ -77,6 +78,9 @@ class SetupDevEnvironment extends Command
|
||||
'--stop-when-empty' => true,
|
||||
]);
|
||||
|
||||
// Oasis demo content generator
|
||||
resolve(OasisDevService::class)->create_demo_content();
|
||||
|
||||
$this->info('Everything is done, congratulations! 🥳🥳🥳');
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,16 @@
|
||||
namespace App\Http\Controllers\Oasis;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ClientController extends Controller
|
||||
{
|
||||
//
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return response(Auth::user()->clients, 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,25 @@
|
||||
namespace App\Http\Controllers\Oasis;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\Oasis\OasisInvoiceCollection;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
//
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_all_regular_invoices()
|
||||
{
|
||||
return response(new OasisInvoiceCollection(Auth::user()->regularInvoices), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_all_advance_invoices()
|
||||
{
|
||||
return response(new OasisInvoiceCollection(Auth::user()->advanceInvoices), 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Oasis;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class OasisInvoiceCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = OasisInvoiceResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Oasis;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OasisInvoiceResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->client['name'] . ' ' . format_to_currency($this->total_net, $this->currency),
|
||||
'invoiceNumber' => $this->invoice_number,
|
||||
'total' => format_to_currency($this->total_net, $this->currency),
|
||||
'file_url' => '',
|
||||
'clientName' => $this->client['name'],
|
||||
'mimetype' => 'pdf',
|
||||
'created_at' => format_date($this->created_at, '%d. %B. %Y'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -70,4 +70,15 @@ function invoice_total_tax($invoice, $format = false)
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $currency
|
||||
* @param string $locale
|
||||
* @return string
|
||||
*/
|
||||
function format_to_currency($value, $currency, $locale = 'cs')
|
||||
{
|
||||
return Cashier::formatAmount(($value * 100), $currency, $locale);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models\Oasis;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -37,8 +38,15 @@ class Invoice extends Model
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($order) {
|
||||
$order->id = Str::uuid();
|
||||
static::creating(function ($invoice) {
|
||||
$invoice->id = Str::uuid();
|
||||
|
||||
$invoice->delivery_at = $invoice->created_at;
|
||||
$invoice->due_at = Carbon::parse($invoice->created_at)->addWeeks(2);
|
||||
|
||||
$invoice->total_discount = invoice_total_discount($invoice);
|
||||
$invoice->total_net = invoice_total_net($invoice);
|
||||
$invoice->total_tax = invoice_total_tax($invoice);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services\Oasis;
|
||||
|
||||
|
||||
use App\Models\Oasis\Client;
|
||||
use App\Models\Oasis\Invoice;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Sequence;
|
||||
|
||||
class OasisDevService
|
||||
{
|
||||
public function create_demo_content()
|
||||
{
|
||||
$user = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$clients = Client::factory(Client::class)
|
||||
->count(6)
|
||||
->create(['user_id' => $user->id]);
|
||||
|
||||
Invoice::factory(Invoice::class)
|
||||
->state(new Sequence(
|
||||
['client_id' => $clients[0]->id],
|
||||
['client_id' => $clients[1]->id],
|
||||
['client_id' => $clients[2]->id],
|
||||
['client_id' => $clients[3]->id],
|
||||
['client_id' => $clients[4]->id],
|
||||
['client_id' => $clients[5]->id],
|
||||
))->count(14)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'invoice_type' => 'regular_invoice'
|
||||
]);
|
||||
|
||||
Invoice::factory(Invoice::class)
|
||||
->count(14)
|
||||
->state(new Sequence(
|
||||
['client_id' => $clients[0]->id],
|
||||
['client_id' => $clients[1]->id],
|
||||
['client_id' => $clients[2]->id],
|
||||
['client_id' => $clients[3]->id],
|
||||
['client_id' => $clients[4]->id],
|
||||
['client_id' => $clients[5]->id],
|
||||
))->create([
|
||||
'user_id' => $user->id,
|
||||
'invoice_type' => 'advance_invoice'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,13 @@ trait Oasis
|
||||
return $this->hasMany(Client::class);
|
||||
}
|
||||
|
||||
public function createdInvoices()
|
||||
public function regularInvoices()
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
return $this->hasMany(Invoice::class)->whereInvoiceType('regular_invoice');
|
||||
}
|
||||
|
||||
public function advanceInvoices()
|
||||
{
|
||||
return $this->hasMany(Invoice::class)->whereInvoiceType('advance_invoice');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user