added requests
This commit is contained in:
parent
7a1069bb5c
commit
74ebff9940
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Portal;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Portal\InvoiceShow as Request;
|
||||
use App\Models\Sale\Invoice;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Traits\Currencies;
|
||||
@ -41,7 +42,7 @@ class Invoices extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Invoice $invoice)
|
||||
public function show(Invoice $invoice, Request $request)
|
||||
{
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
@ -57,7 +58,7 @@ class Invoices extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function printInvoice(Invoice $invoice)
|
||||
public function printInvoice(Invoice $invoice, Request $request)
|
||||
{
|
||||
$invoice = $this->prepareInvoice($invoice);
|
||||
|
||||
@ -71,7 +72,7 @@ class Invoices extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function pdfInvoice(Invoice $invoice)
|
||||
public function pdfInvoice(Invoice $invoice, Request $request)
|
||||
{
|
||||
$invoice = $this->prepareInvoice($invoice);
|
||||
|
||||
@ -92,22 +93,6 @@ class Invoices extends Controller
|
||||
|
||||
protected function prepareInvoice(Invoice $invoice)
|
||||
{
|
||||
$paid = 0;
|
||||
|
||||
foreach ($invoice->transactions as $item) {
|
||||
$amount = $item->amount;
|
||||
|
||||
if ($invoice->currency_code != $item->currency_code) {
|
||||
$item->default_currency_code = $invoice->currency_code;
|
||||
|
||||
$amount = $item->getAmountConvertedFromDefault();
|
||||
}
|
||||
|
||||
$paid += $amount;
|
||||
}
|
||||
|
||||
$invoice->paid = $paid;
|
||||
|
||||
$invoice->template_path = 'sales.invoices.print_' . setting('invoice.template' ,'default');
|
||||
|
||||
event(new \App\Events\Sale\InvoicePrinting($invoice));
|
||||
@ -121,22 +106,6 @@ class Invoices extends Controller
|
||||
redirect()->route('login');
|
||||
}
|
||||
|
||||
$paid = 0;
|
||||
|
||||
foreach ($invoice->transactions as $item) {
|
||||
$amount = $item->amount;
|
||||
|
||||
if ($invoice->currency_code != $item->currency_code) {
|
||||
$item->default_currency_code = $invoice->currency_code;
|
||||
|
||||
$amount = $item->getAmountConvertedFromDefault();
|
||||
}
|
||||
|
||||
$paid += $amount;
|
||||
}
|
||||
|
||||
$invoice->paid = $paid;
|
||||
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
$payment_actions = [];
|
||||
|
@ -4,11 +4,11 @@ namespace App\Http\Controllers\Portal;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Http\Requests\Portal\PaymentShow as Request;
|
||||
use App\Utilities\Modules;
|
||||
|
||||
class Payments extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@ -30,7 +30,7 @@ class Payments extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Transaction $payment)
|
||||
public function show(Transaction $payment, Request $request)
|
||||
{
|
||||
$payment_methods = Modules::getPaymentMethods('all');
|
||||
|
||||
|
30
app/Http/Requests/Portal/InvoiceShow.php
Normal file
30
app/Http/Requests/Portal/InvoiceShow.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Portal;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class InvoiceShow extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->invoice->contact_id == user()->contact->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
30
app/Http/Requests/Portal/PaymentShow.php
Normal file
30
app/Http/Requests/Portal/PaymentShow.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Portal;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class PaymentShow extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->payment->contact_id == user()->contact->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
@ -36,9 +36,9 @@
|
||||
<thead class="thead-light">
|
||||
<tr class="row table-head-line">
|
||||
<th class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block">{{ Form::bulkActionAllGroup() }}</th>
|
||||
<th class="col-md-2 col-lg-2 col-xl-1 d-none d-md-block">@sortablelink('invoice_number', trans_choice('general.numbers', 1), ['filter' => 'active, visible'], ['class' => 'col-aka', 'rel' => 'nofollow'])</th>
|
||||
<th class="col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-3 text-left">@sortablelink('contact_name', trans_choice('general.customers', 1))</th>
|
||||
<th class="col-xs-4 col-sm-4 col-md-3 col-lg-1 col-xl-1 text-right">@sortablelink('amount', trans('general.amount'))</th>
|
||||
<th class="col-md-2 col-lg-1 col-xl-1 d-none d-md-block">@sortablelink('invoice_number', trans_choice('general.numbers', 1), ['filter' => 'active, visible'], ['class' => 'col-aka', 'rel' => 'nofollow'])</th>
|
||||
<th class="col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left">@sortablelink('contact_name', trans_choice('general.customers', 1))</th>
|
||||
<th class="col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right">@sortablelink('amount', trans('general.amount'))</th>
|
||||
<th class="col-lg-2 col-xl-2 d-none d-lg-block text-left">@sortablelink('invoiced_at', trans('invoices.invoice_date'))</th>
|
||||
<th class="col-lg-2 col-xl-2 d-none d-lg-block text-left">@sortablelink('due_at', trans('invoices.due_date'))</th>
|
||||
<th class="col-lg-1 col-xl-1 d-none d-lg-block text-center">@sortablelink('status', trans_choice('general.statuses', 1))</th>
|
||||
@ -51,9 +51,9 @@
|
||||
@php $paid = $item->paid; @endphp
|
||||
<tr class="row align-items-center border-top-1">
|
||||
<td class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block">{{ Form::bulkActionGroup($item->id, $item->invoice_number) }}</td>
|
||||
<td class="col-md-2 col-lg-2 col-xl-1 d-none d-md-block"><a class="col-aka" href="{{ route('invoices.show' , $item->id) }}">{{ $item->invoice_number }}</a></td>
|
||||
<td class="col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-3 text-left">{{ $item->contact_name }}</td>
|
||||
<td class="col-xs-4 col-sm-4 col-md-3 col-lg-1 col-xl-1 text-right">@money($item->amount, $item->currency_code, true)</td>
|
||||
<td class="col-md-2 col-lg-1 col-xl-1 d-none d-md-block"><a class="col-aka" href="{{ route('invoices.show' , $item->id) }}">{{ $item->invoice_number }}</a></td>
|
||||
<td class="col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left">{{ $item->contact_name }}</td>
|
||||
<td class="col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right">@money($item->amount, $item->currency_code, true)</td>
|
||||
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left">@date($item->invoiced_at)</td>
|
||||
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left">@date($item->due_at)</td>
|
||||
<td class="col-lg-1 col-xl-1 d-none d-lg-block text-center">
|
||||
|
Loading…
x
Reference in New Issue
Block a user