small fixes, logo update, prefix update

This commit is contained in:
1day2die 2021-12-05 20:08:09 +01:00
parent 57e3cd8430
commit a6de39bc32
6 changed files with 23 additions and 5 deletions

1
.gitignore vendored
View file

@ -19,3 +19,4 @@ yarn-error.log
.env.dev
.env.testing
storage/invoices.zip
storage/app/public/logo.png

View file

@ -198,6 +198,7 @@ class PaymentController extends Controller
$lastInvoiceID = \App\Models\Invoice::where("invoice_name", "like", "%" . now()->format('mY') . "%")->count("id");
$newInvoiceID = $lastInvoiceID + 1;
$InvoiceSettings = InvoiceSettings::all()->first();
$logoPath = storage_path('app/public/logo.png');
$seller = new Party([
'name' => $InvoiceSettings->company_name,
@ -231,16 +232,18 @@ class PaymentController extends Controller
->series(now()->format('mY'))
->delimiter("-")
->sequence($newInvoiceID)
->serialNumberFormat(env("INVOICE_PREFIX", "INV") . '{DELIMITER}{SERIES}{SEQUENCE}')
->logo(storage_path('app/public/logo.png'));
->serialNumberFormat($InvoiceSettings->invoice_prefix . '{DELIMITER}{SERIES}{SEQUENCE}');
if (file_exists($logoPath)) {
$invoice->logo($logoPath);
}
//Save the invoice in "storage\app\invoice\USER_ID\YEAR"
$invoice->filename = $invoice->getSerialNumber() . '.pdf';
$invoice->render();
Storage::disk("local")->put("invoice/" . $user->id . "/" . now()->format('Y') . "/" . $invoice->filename, $invoice->output);
\App\Models\invoice::create([
\App\Models\Invoice::create([
'invoice_user' => $user->id,
'invoice_name' => $invoice->getSerialNumber(),
'payment_id' => $payment->payment_id,

View file

@ -27,7 +27,8 @@ class SettingsController extends Controller
'company_phone' => invoiceSettings::get()->first()->company_phone,
'company_vat' => invoiceSettings::get()->first()->company_vat,
'company_mail' => invoiceSettings::get()->first()->company_mail,
'company_web' => invoiceSettings::get()->first()->company_web
'company_web' => invoiceSettings::get()->first()->company_web,
'invoice_prefix' => invoiceSettings::get()->first()->invoice_prefix
]);
}
@ -61,6 +62,7 @@ class SettingsController extends Controller
invoiceSettings::updateOrCreate(['id' => "1",], ['company_mail' => $request->get('company-mail')]);
invoiceSettings::updateOrCreate(['id' => "1",], ['company_vat' => $request->get('company-vat')]);
invoiceSettings::updateOrCreate(['id' => "1",], ['company_web' => $request->get('company-web')]);
invoiceSettings::updateOrCreate(['id' => "1",], ['invoice_prefix' => $request->get('invoice-prefix')]);
if ($request->hasFile('logo')) {
$request->file('logo')->storeAs('public', 'logo.png');

View file

@ -17,6 +17,7 @@ class InvoiceSettings extends Model
'company_phone',
'company_mail',
'company_vat',
'company_web'
'company_web',
'invoice_prefix'
];
}

View file

@ -165,6 +165,17 @@
</div>
</div>
<!-- website -->
<div class="form-group">
<div class="custom-control mb-3">
<label
for="invoice-prefix">{{__('Enter your custom invoice prefix' )}}</label>
<input x-model="invoice-prefix" id="invoice-prefix" name="invoice-prefix"
type="text" value="{{$invoice_prefix}}"
class="form-control @error('invoice-prefix') is-invalid @enderror">
</div>
</div>
<!-- logo -->
<div class="form-group">
<div class="custom-file mb-3">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB