Create invoice form part 1.

This commit is contained in:
Peter Papp
2021-04-30 17:53:19 +02:00
parent 5167ae520e
commit 3c3e82758d
51 changed files with 1890 additions and 763 deletions

View File

@@ -1,15 +1,14 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use App\Models\Setting;
use Illuminate\Support\Str;
use App\Models\Oasis\Client;
use App\Models\Oasis\Invoice;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Factories\Sequence;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Sequence;
class SetupOasisEnvironment extends Command
{
@@ -65,28 +64,28 @@ class SetupOasisEnvironment extends Command
$hash = Str::random(12);
// Get invoice logo and stamp
Storage::putFileAs("system", storage_path("demo/app/logo-horizontal.svg"), "{$hash}-logo-horizontal.svg", "private");
Storage::putFileAs("system", storage_path("demo/oasis/stamp.png"), "{$hash}-stamp.png", "private");
Storage::putFileAs('system', storage_path('demo/app/logo-horizontal.svg'), "{$hash}-logo-horizontal.svg", 'private');
Storage::putFileAs('system', storage_path('demo/oasis/stamp.png'), "{$hash}-stamp.png", 'private');
$profile = $user->invoiceProfile()->create([
'company' => 'VueFileManager Inc.',
'company' => 'VueFileManager Inc.',
'registration_notes' => 'Registrácia na OR SR Bratislava I. oddiel: Sro vl. č. 91906',
'logo' => "system/{$hash}-logo-horizontal.svg",
'ico' => '46530045',
'dic' => '2023489457',
'ic_dph' => 'SK2023489457',
'address' => 'Does 11',
'state' => 'Slovakia',
'city' => 'Bratislava',
'postal_code' => '04001',
'country' => 'SK',
'bank' => 'Fio Banka',
'iban' => 'SK20000054236423624',
'swift' => 'FIOZXXX',
'phone' => '+421950123456',
'email' => 'howdy@hi5ve.digital',
'author' => 'John Doe',
'stamp' => "system/{$hash}-stamp.png",
'logo' => "system/{$hash}-logo-horizontal.svg",
'ico' => '46530045',
'dic' => '2023489457',
'ic_dph' => 'SK2023489457',
'address' => 'Does 11',
'state' => 'Slovakia',
'city' => 'Bratislava',
'postal_code' => '04001',
'country' => 'SK',
'bank' => 'Fio Banka',
'iban' => 'SK20000054236423624',
'swift' => 'FIOZXXX',
'phone' => '+421950123456',
'email' => 'howdy@hi5ve.digital',
'author' => 'John Doe',
'stamp' => "system/{$hash}-stamp.png",
]);
$clients = Client::factory(Client::class)
@@ -103,10 +102,10 @@ class SetupOasisEnvironment extends Command
['client_id' => $clients[5]->id],
))->count(2)
->create([
'user_id' => $user->id,
'invoice_type' => 'regular-invoice',
'user_id' => $user->id,
'invoice_type' => 'regular-invoice',
'discount_type' => null,
'user' => $profile->toArray(),
'user' => $profile->toArray(),
]);
$advance_invoices = Invoice::factory(Invoice::class)
@@ -119,22 +118,21 @@ class SetupOasisEnvironment extends Command
['client_id' => $clients[4]->id],
['client_id' => $clients[5]->id],
))->create([
'user_id' => $user->id,
'invoice_type' => 'advance-invoice',
'user_id' => $user->id,
'invoice_type' => 'advance-invoice',
'discount_type' => null,
'user' => $profile->toArray(),
'user' => $profile->toArray(),
]);
// Generate PDF
collect([$regular_invoices, $advance_invoices])
->collapse()
->each(function ($invoice) use ($user) {
$this->info("Generating invoice id: $invoice->id");
\PDF::loadView('oasis.invoices.invoice', [
'invoice' => Invoice::find($invoice->id),
'user' => $user,
'user' => $user,
])
->setPaper('a4')
->setOrientation('portrait')
@@ -147,9 +145,9 @@ class SetupOasisEnvironment extends Command
public function set_oasis_data()
{
Setting::updateOrCreate([
'name' => 'app_color'
'name' => 'app_color',
], [
'value' => '#ae5fec'
'value' => '#ae5fec',
]);
}
}