feat: ✨ Added Enable/Disable Invoices
This commit is contained in:
parent
1a45c16feb
commit
c8071b64d9
|
@ -28,7 +28,8 @@ class Invoices
|
||||||
"SETTINGS::INVOICE:COMPANY_MAIL" => "company-mail",
|
"SETTINGS::INVOICE:COMPANY_MAIL" => "company-mail",
|
||||||
"SETTINGS::INVOICE:COMPANY_VAT" => "company-vat",
|
"SETTINGS::INVOICE:COMPANY_VAT" => "company-vat",
|
||||||
"SETTINGS::INVOICE:COMPANY_WEBSITE" => "company-web",
|
"SETTINGS::INVOICE:COMPANY_WEBSITE" => "company-web",
|
||||||
"SETTINGS::INVOICE:PREFIX" => "invoice-prefix"
|
"SETTINGS::INVOICE:PREFIX" => "invoice-prefix",
|
||||||
|
"SETTINGS::INVOICE:ENABLED" => "enable-invoices",
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($values as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
|
|
|
@ -197,7 +197,11 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
event(new UserUpdateCreditsEvent($user));
|
event(new UserUpdateCreditsEvent($user));
|
||||||
|
|
||||||
|
//only create invoice if SETTINGS::INVOICE:ENABLE is true
|
||||||
|
if (config('SETTINGS::INVOICE:ENABLE') == 'true') {
|
||||||
$this->createInvoice($user, $payment, 'paid');
|
$this->createInvoice($user, $payment, 'paid');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
||||||
|
@ -336,7 +340,10 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
event(new UserUpdateCreditsEvent($user));
|
event(new UserUpdateCreditsEvent($user));
|
||||||
|
|
||||||
|
//only create invoice if SETTINGS::INVOICE:ENABLE is true
|
||||||
|
if (config('SETTINGS::INVOICE:ENABLE') == 'true') {
|
||||||
$this->createInvoice($user, $payment, 'paid');
|
$this->createInvoice($user, $payment, 'paid');
|
||||||
|
}
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
||||||
|
@ -359,7 +366,10 @@ class PaymentController extends Controller
|
||||||
'credit_product_id' => $creditProduct->id,
|
'credit_product_id' => $creditProduct->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->createInvoice($user, $payment, 'processing');
|
//only create invoice if SETTINGS::INVOICE:ENABLE is true
|
||||||
|
if (config('SETTINGS::INVOICE:ENABLE') == 'true') {
|
||||||
|
$this->createInvoice($user, $payment, 'paid');
|
||||||
|
}
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
return redirect()->route('home')->with('success', __('Your payment is being processed!'));
|
return redirect()->route('home')->with('success', __('Your payment is being processed!'));
|
||||||
|
@ -416,8 +426,11 @@ class PaymentController extends Controller
|
||||||
$user->notify(new ConfirmPaymentNotification($payment));
|
$user->notify(new ConfirmPaymentNotification($payment));
|
||||||
event(new UserUpdateCreditsEvent($user));
|
event(new UserUpdateCreditsEvent($user));
|
||||||
|
|
||||||
|
//only create invoice if SETTINGS::INVOICE:ENABLE is true
|
||||||
|
if (config('SETTINGS::INVOICE:ENABLE') == 'true') {
|
||||||
$this->createInvoice($user, $payment, 'paid');
|
$this->createInvoice($user, $payment, 'paid');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (HttpException $ex) {
|
} catch (HttpException $ex) {
|
||||||
abort(422);
|
abort(422);
|
||||||
}
|
}
|
||||||
|
@ -521,7 +534,7 @@ class PaymentController extends Controller
|
||||||
->pricePerUnit($creditProduct->price);
|
->pricePerUnit($creditProduct->price);
|
||||||
|
|
||||||
$notes = [
|
$notes = [
|
||||||
__("Payment method") .": ". $payment->payment_method,
|
__("Payment method") . ": " . $payment->payment_method,
|
||||||
];
|
];
|
||||||
$notes = implode("<br>", $notes);
|
$notes = implode("<br>", $notes);
|
||||||
|
|
||||||
|
@ -591,7 +604,7 @@ class PaymentController extends Controller
|
||||||
return $payment->created_at ? $payment->created_at->diffForHumans() : '';
|
return $payment->created_at ? $payment->created_at->diffForHumans() : '';
|
||||||
})
|
})
|
||||||
->addColumn('actions', function (Payment $payment) {
|
->addColumn('actions', function (Payment $payment) {
|
||||||
return ' <a data-content="'.__("Download").'" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.invoices.downloadSingleInvoice',"id=".$payment->payment_id) . '" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-file-download"></i></a>
|
return ' <a data-content="' . __("Download") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.invoices.downloadSingleInvoice', "id=" . $payment->payment_id) . '" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-file-download"></i></a>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
->rawColumns(['actions'])
|
->rawColumns(['actions'])
|
||||||
|
|
|
@ -144,7 +144,13 @@ class SettingsSeeder extends Seeder
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'The %-value of tax that will be added to the product price on checkout'
|
'description' => 'The %-value of tax that will be added to the product price on checkout'
|
||||||
]);
|
]);
|
||||||
|
//Invoices enabled
|
||||||
|
Settings::firstOrCreate([
|
||||||
|
'key' => 'SETTINGS::INVOICE:ENABLED',
|
||||||
|
], [
|
||||||
|
'value' => 'false',
|
||||||
|
'type' => 'boolean',
|
||||||
|
]);
|
||||||
//Invoice company name
|
//Invoice company name
|
||||||
Settings::firstOrCreate([
|
Settings::firstOrCreate([
|
||||||
'key' => 'SETTINGS::INVOICE:COMPANY_NAME',
|
'key' => 'SETTINGS::INVOICE:COMPANY_NAME',
|
||||||
|
|
|
@ -76,6 +76,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 p-3">
|
<div class="col-md-3 p-3">
|
||||||
|
<div class="custom-control mb-3 p-0">
|
||||||
|
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
|
||||||
|
<div>
|
||||||
|
<input value="true" id="enable-invoices" name="enable-invoices"
|
||||||
|
{{ config('SETTINGS::INVOICE:ENABLED') == 'true' ? 'checked' : '' }} type="checkbox">
|
||||||
|
<label for="enable-invoices">{{ __('Enable Invoices') }} </label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- logo -->
|
<!-- logo -->
|
||||||
<div class="form-group mb-3">
|
<div class="form-group mb-3">
|
||||||
<div class="custom-control p-0">
|
<div class="custom-control p-0">
|
||||||
|
|
Loading…
Reference in a new issue