From a3dbdaffadb9a45dbe93d76a05332a7f2acf7d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 17 Nov 2017 02:08:31 +0300 Subject: [PATCH] close #79 Fixed: Problems when using customer profile in 1.0.8 --- app/Http/Controllers/Customers/Invoices.php | 40 +-- .../views/customers/invoices/show.blade.php | 304 ++---------------- 2 files changed, 32 insertions(+), 312 deletions(-) diff --git a/app/Http/Controllers/Customers/Invoices.php b/app/Http/Controllers/Customers/Invoices.php index 683cb257b..e561d44f0 100644 --- a/app/Http/Controllers/Customers/Invoices.php +++ b/app/Http/Controllers/Customers/Invoices.php @@ -3,13 +3,11 @@ namespace App\Http\Controllers\Customers; use App\Http\Controllers\Controller; -use App\Http\Requests\Income\InvoicePayment as PaymentRequest; +use App\Http\Requests\Customer\InvoicePayment as PaymentRequest; use App\Models\Banking\Account; use App\Models\Income\Customer; use App\Models\Income\Invoice; use App\Models\Income\InvoiceStatus; -use App\Models\Income\InvoiceHistory; -use App\Models\Income\InvoicePayment; use App\Models\Setting\Category; use App\Models\Setting\Currency; use App\Traits\Currencies; @@ -18,6 +16,8 @@ use App\Traits\Uploads; use Auth; use Jenssegers\Date\Date; +use App\Events\PaymentGatewayConfirm; + use App\Utilities\Modules; class Invoices extends Controller @@ -179,37 +179,11 @@ class Invoices extends Controller */ public function payment(PaymentRequest $request) { - // Get currency object - $currency = Currency::where('code', $request['currency_code'])->first(); + $invoice = Invoice::where(['id' => $request['invoice_id'], 'customer_id' => Auth::user()->customer->id])->first(); - $request['currency_code'] = $currency->code; - $request['currency_rate'] = $currency->rate; + // Fire the event to extend the menu + $result = event(new PaymentGatewayConfirm($request['payment_method'], $invoice)); - // Upload attachment - $attachment_path = $this->getUploadedFilePath($request->file('attachment'), 'revenues'); - if ($attachment_path) { - $request['attachment'] = $attachment_path; - } - - $invoice = Invoice::find($request['invoice_id']); - - $invoice->invoice_status_code = 'partial'; - - $invoice->save(); - - $invoice_payment = InvoicePayment::create($request->input()); - - $request['status_code'] = 'partial'; - $request['notify'] = 0; - - $desc_date = Date::parse($request['paid_at'])->format($this->getCompanyDateFormat()); - $desc_amount = money((float) $request['amount'], $request['currency_code'], true)->format(); - $request['description'] = $desc_date . ' ' . $desc_amount; - - InvoiceHistory::create($request->input()); - - $message = trans('messages.success.added', ['type' => trans_choice('general.revenues', 1)]); - - return response()->json($message); + return response()->json($result); } } diff --git a/resources/views/customers/invoices/show.blade.php b/resources/views/customers/invoices/show.blade.php index 2372549b2..2dede043a 100644 --- a/resources/views/customers/invoices/show.blade.php +++ b/resources/views/customers/invoices/show.blade.php @@ -142,308 +142,54 @@ - -
-
-
-

{{ trans('invoices.histories') }}

- -
- -
- -
-
-
- - - - - - - - - - @foreach($invoice->histories as $history) - - - - - - @endforeach - -
{{ trans('general.date') }}{{ trans_choice('general.statuses', 1) }}{{ trans('general.description') }}
{{ Date::parse($history->created_at)->format($date_format) }}{{ $history->status->name }}{{ $history->description }}
-
-
-
-
- -
-
-
-

{{ trans('invoices.payments') }}

- -
- -
- -
-
-
- - - - - - - - - - - @foreach($invoice->payments as $payment) - - - - - - - @endforeach - -
{{ trans('general.date') }}{{ trans('general.amount') }}{{ trans_choice('general.accounts', 1) }}{{ trans('general.actions') }}
{{ Date::parse($payment->paid_at)->format($date_format) }}@money($payment->amount, $payment->currency_code, true){{ $payment->account->name }} - - - {!! Form::open([ - 'id' => 'invoice-payment-' . $payment->id, - 'method' => 'DELETE', - 'url' => ['incomes/invoices/payment', $payment->id], - 'style' => 'display:inline' - ]) !!} - {!! Form::button(' ' . trans('general.delete'), array( - 'type' => 'button', - 'class' => 'btn btn-danger btn-xs', - 'title' => trans('general.delete'), - 'onclick' => 'confirmDelete("' . '#invoice-payment-' . $payment->id . '", "' . trans_choice('general.payments', 2) . '", "' . trans('general.delete_confirm', ['name' => '' . Date::parse($payment->paid_at)->format($date_format) . ' - ' . money($payment->amount, $payment->currency_code, true) . ' - ' . $payment->account->name . '', 'type' => strtolower(trans_choice('general.revenues', 1))]) . '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")' - )) !!} - {!! Form::close() !!} -
-
-
-
-
@endsection -@push('js') - - -@endpush - -@push('css') - - -@endpush - @push('scripts') @endpush