Customer OfflinePayment finished

This commit is contained in:
Cüneyt Şentürk
2017-11-19 04:14:02 +03:00
parent 021b853127
commit b068b7f7a6
5 changed files with 20 additions and 8 deletions

View File

@ -4,8 +4,16 @@ namespace App\Listeners\Incomes\Invoice;
use App\Events\InvoicePaid;
class Paid extends Listener
use App\Models\Income\Invoice;
use App\Models\Income\InvoicePayment;
use App\Models\Income\InvoiceHistory;
use App\Traits\DateTime;
use Date;
class Paid
{
use DateTime;
/**
* Handle the event.
@ -33,10 +41,10 @@ class Paid extends Listener
if ($request['amount'] > $invoice->amount) {
$message = trans('messages.error.added', ['type' => trans_choice('general.payment', 1)]);
return response()->json([
return [
'success' => false,
'error' => $message,
]);
];
} elseif ($request['amount'] == $invoice->amount) {
$invoice->invoice_status_code = 'paid';
} else {
@ -59,9 +67,9 @@ class Paid extends Listener
InvoiceHistory::create($request->input());
return response()->json([
return [
'success' => true,
'error' => false,
]);
];
}
}

View File

@ -24,7 +24,7 @@ class EventServiceProvider extends ServiceProvider
'Illuminate\Auth\Events\Logout' => [
'App\Listeners\Auth\Logout',
],
'App\Events\Events\InvoicePaid' => [
'App\Events\InvoicePaid' => [
'App\Listeners\Incomes\Invoice\Paid',
],
];