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
+144 -153
View File
@@ -392,38 +392,37 @@ class SetupDevEnvironment extends Command
'mimetype' => 'pdf',
],
[
'name' => 'Project Notes',
'name' => 'Project Notes',
'basename' => 'Project Notes.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Personal Savings',
'name' => 'Personal Savings',
'basename' => 'School Report.pages',
'mimetype' => 'pages',
],
[
'name' => 'License',
'name' => 'License',
'basename' => 'Stories of the Night Skies.pages',
'mimetype' => 'pages',
],
])
->each(function ($file) use ($user, $documents) {
$basename = Str::random(12) . '-' . $file['basename'];
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
// Create file record
File::create([
'folder_id' => $documents->id,
'user_id' => $user->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'author' => 'user',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'folder_id' => $documents->id,
'user_id' => $user->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'author' => 'user',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -431,33 +430,32 @@ class SetupDevEnvironment extends Command
// Get documents to shared folder
collect([
[
'name' => 'Home plan',
'name' => 'Home plan',
'basename' => 'Licence.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Software Licence',
'name' => 'Software Licence',
'basename' => 'Project Notes.pdf',
'mimetype' => 'pdf',
]
],
])
->each(function ($file) use ($user, $shared_folder) {
$basename = Str::random(12) . '-' . $file['basename'];
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
// Create file record
File::create([
'folder_id' => $shared_folder->id,
'user_id' => $user->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'author' => 'user',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'folder_id' => $shared_folder->id,
'user_id' => $user->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'author' => 'user',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -465,58 +463,57 @@ class SetupDevEnvironment extends Command
// Get documents to peter's files folder
collect([
[
'name' => 'Project Backup',
'name' => 'Project Backup',
'basename' => 'Licence.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Yearly report',
'name' => 'Yearly report',
'basename' => 'Project Notes.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Work Update',
'name' => 'Work Update',
'basename' => 'School Report.pages',
'mimetype' => 'pages',
],
[
'name' => 'Person Writing on Notebook',
'name' => 'Person Writing on Notebook',
'basename' => 'Stories of the Night Skies.pages',
'mimetype' => 'pages',
],
[
'name' => 'Blank Business Composition Computer',
'name' => 'Blank Business Composition Computer',
'basename' => 'Licence.pdf',
'mimetype' => 'pdf',
],
[
'name' => '2020 April - Export',
'name' => '2020 April - Export',
'basename' => 'Project Notes.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Ballpen Blur Close Up Computer',
'name' => 'Ballpen Blur Close Up Computer',
'basename' => 'School Report.pages',
'mimetype' => 'pages',
],
])
->each(function ($file) use ($user, $peters_files) {
$basename = Str::random(12) . '-' . $file['basename'];
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
// Create file record
File::create([
'folder_id' => $peters_files->id,
'user_id' => $user->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'author' => 'visitor',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'folder_id' => $peters_files->id,
'user_id' => $user->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'author' => 'visitor',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -529,22 +526,21 @@ class SetupDevEnvironment extends Command
'Sphere Bound 3D Titles.mp4',
])
->each(function ($file) use ($user, $videohive) {
$basename = Str::random(12) . '-' . $file;
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, 'private');
// Create file record
File::create([
'folder_id' => $videohive->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'video',
'author' => 'user',
'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000),
'folder_id' => $videohive->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'video',
'author' => 'user',
'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -554,22 +550,21 @@ class SetupDevEnvironment extends Command
'Apple Watch App Video Promotion.mp4',
])
->each(function ($file) use ($user, $video) {
$basename = Str::random(12) . '-' . $file;
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, 'private');
// Create file record
File::create([
'folder_id' => $video->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'video',
'author' => 'user',
'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000),
'folder_id' => $video->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'video',
'author' => 'user',
'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -579,22 +574,21 @@ class SetupDevEnvironment extends Command
'D-Block & S-te-Fan - Bla Bla.mp3',
])
->each(function ($file) use ($user, $audio) {
$basename = Str::random(12) . '-' . $file;
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/audio/$file"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/audio/$file"), $basename, 'private');
// Create file record
File::create([
'folder_id' => $audio->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'audio',
'author' => 'user',
'mimetype' => 'mp3',
'filesize' => rand(1000000, 4000000),
'folder_id' => $audio->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'audio',
'author' => 'user',
'mimetype' => 'mp3',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -615,24 +609,23 @@ class SetupDevEnvironment extends Command
'You Are My Sunshine.jpg',
])
->each(function ($file) use ($user, $apartments) {
$basename = Str::random(12) . '-' . $file;
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/$file"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/thumbnail-$file"), "thumbnail-$basename", "private");
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/$file"), $basename, 'private');
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/thumbnail-$file"), "thumbnail-$basename", 'private');
// Create file record
File::create([
'folder_id' => null,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'image',
'author' => 'user',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'thumbnail' => "thumbnail-$basename",
'folder_id' => null,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'image',
'author' => 'user',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'thumbnail' => "thumbnail-$basename",
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -648,24 +641,23 @@ class SetupDevEnvironment extends Command
'Kitchen Island.jpg',
])
->each(function ($file) use ($user, $apartments) {
$basename = Str::random(12) . '-' . $file;
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/$file"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/thumbnail-$file"), "thumbnail-$basename", "private");
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/$file"), $basename, 'private');
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/thumbnail-$file"), "thumbnail-$basename", 'private');
// Create file record
File::create([
'folder_id' => $apartments->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'image',
'author' => 'user',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'thumbnail' => "thumbnail-$basename",
'folder_id' => $apartments->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'image',
'author' => 'user',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'thumbnail' => "thumbnail-$basename",
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -685,24 +677,23 @@ class SetupDevEnvironment extends Command
'Yellow Animal Eyes Fur.jpg',
])
->each(function ($file) use ($user, $nature) {
$basename = Str::random(12) . '-' . $file;
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/$file"), $basename, "private");
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/thumbnail-$file"), "thumbnail-$basename", "private");
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/$file"), $basename, 'private');
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/thumbnail-$file"), "thumbnail-$basename", 'private');
// Create file record
File::create([
'folder_id' => $nature->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'image',
'author' => 'user',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'thumbnail' => "thumbnail-$basename",
'folder_id' => $nature->id,
'user_id' => $user->id,
'name' => $file,
'basename' => $basename,
'type' => 'image',
'author' => 'user',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'thumbnail' => "thumbnail-$basename",
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -720,13 +711,13 @@ class SetupDevEnvironment extends Command
$images->each(function ($id) use ($user) {
Share::create([
'user_id' => $user->id,
'item_id' => $id,
'type' => 'file',
'user_id' => $user->id,
'item_id' => $id,
'type' => 'file',
'is_protected' => false,
'permission' => 'editor',
'password' => null,
'expire_in' => null,
'permission' => 'editor',
'password' => null,
'expire_in' => null,
]);
});
@@ -737,13 +728,13 @@ class SetupDevEnvironment extends Command
$files->each(function ($id) use ($user) {
Share::create([
'user_id' => $user->id,
'item_id' => $id,
'type' => 'file',
'user_id' => $user->id,
'item_id' => $id,
'type' => 'file',
'is_protected' => false,
'permission' => 'editor',
'password' => null,
'expire_in' => null,
'permission' => 'editor',
'password' => null,
'expire_in' => null,
]);
});
}
@@ -756,116 +747,116 @@ class SetupDevEnvironment extends Command
// Get options
collect([
[
'name' => 'setup_wizard_database',
'name' => 'setup_wizard_database',
'value' => 1,
],
[
'name' => 'app_title',
'name' => 'app_title',
'value' => 'VueFileManager',
],
[
'name' => 'app_description',
'name' => 'app_description',
'value' => 'Your self-hosted storage cloud software powered by Laravel and Vue',
],
[
'name' => 'app_logo',
'name' => 'app_logo',
'value' => 'system/logo.svg',
],
[
'name' => 'app_logo_horizontal',
'name' => 'app_logo_horizontal',
'value' => 'system/logo-horizontal.svg',
],
[
'name' => 'app_favicon',
'name' => 'app_favicon',
'value' => 'system/favicon.png',
],
[
'name' => 'app_og_image',
'name' => 'app_og_image',
'value' => 'system/og-image.jpg',
],
[
'name' => 'app_touch_icon',
'name' => 'app_touch_icon',
'value' => 'system/touch-icon.png',
],
[
'name' => 'google_analytics',
'name' => 'google_analytics',
'value' => '',
],
[
'name' => 'contact_email',
'name' => 'contact_email',
'value' => '',
],
[
'name' => 'registration',
'name' => 'registration',
'value' => 1,
],
[
'name' => 'payments_active',
'name' => 'payments_active',
'value' => 1,
],
[
'name' => 'storage_limitation',
'name' => 'storage_limitation',
'value' => 1,
],
[
'name' => 'storage_default',
'name' => 'storage_default',
'value' => 5,
],
[
'name' => 'setup_wizard_success',
'name' => 'setup_wizard_success',
'value' => 1,
],
[
'name' => 'license',
'name' => 'license',
'value' => $this->license,
],
[
'name' => 'purchase_code',
'name' => 'purchase_code',
'value' => '26b889eb-3602-4bf2-beb3-3sc378fcf484',
],
[
'name' => 'billing_address',
'name' => 'billing_address',
'value' => 'Palo Alto 20',
],
[
'name' => 'billing_city',
'name' => 'billing_city',
'value' => 'Palo Alto',
],
[
'name' => 'billing_country',
'name' => 'billing_country',
'value' => 'US',
],
[
'name' => 'billing_name',
'name' => 'billing_name',
'value' => 'VueFileManager Inc.',
],
[
'name' => 'billing_phone_number',
'name' => 'billing_phone_number',
'value' => '312343141243214',
],
[
'name' => 'billing_postal_code',
'name' => 'billing_postal_code',
'value' => '43213',
],
[
'name' => 'billing_state',
'name' => 'billing_state',
'value' => 'California',
],
[
'name' => 'billing_vat_number',
'name' => 'billing_vat_number',
'value' => '41241241234',
]
],
])->each(function ($col) {
Setting::forceCreate([
'name' => $col['name'],
'value' => $col['value']
'name' => $col['name'],
'value' => $col['value'],
]);
});
// Get system images
collect(['logo.svg', 'logo-horizontal.svg', 'favicon.png', 'og-image.jpg', 'touch-icon.png'])
->each(function ($file) {
Storage::putFileAs("system", storage_path("demo/app/$file"), $file, "private");
Storage::putFileAs('system', storage_path("demo/app/$file"), $file, 'private');
});
}
@@ -876,12 +867,12 @@ class SetupDevEnvironment extends Command
{
// Migrate database
$this->call('migrate:fresh', [
'--force' => true
'--force' => true,
]);
// Generate app key
$this->call('key:generate', [
'--force' => true
'--force' => true,
]);
}
@@ -894,4 +885,4 @@ class SetupDevEnvironment extends Command
$this->call('config:clear');
$this->call('view:clear');
}
}
}
+32 -34
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',
]);
}
}