Customer OfflinePayment finished
This commit is contained in:
parent
021b853127
commit
b068b7f7a6
@ -4,8 +4,16 @@ namespace App\Listeners\Incomes\Invoice;
|
|||||||
|
|
||||||
use App\Events\InvoicePaid;
|
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.
|
* Handle the event.
|
||||||
@ -33,10 +41,10 @@ class Paid extends Listener
|
|||||||
if ($request['amount'] > $invoice->amount) {
|
if ($request['amount'] > $invoice->amount) {
|
||||||
$message = trans('messages.error.added', ['type' => trans_choice('general.payment', 1)]);
|
$message = trans('messages.error.added', ['type' => trans_choice('general.payment', 1)]);
|
||||||
|
|
||||||
return response()->json([
|
return [
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'error' => $message,
|
'error' => $message,
|
||||||
]);
|
];
|
||||||
} elseif ($request['amount'] == $invoice->amount) {
|
} elseif ($request['amount'] == $invoice->amount) {
|
||||||
$invoice->invoice_status_code = 'paid';
|
$invoice->invoice_status_code = 'paid';
|
||||||
} else {
|
} else {
|
||||||
@ -59,9 +67,9 @@ class Paid extends Listener
|
|||||||
|
|
||||||
InvoiceHistory::create($request->input());
|
InvoiceHistory::create($request->input());
|
||||||
|
|
||||||
return response()->json([
|
return [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'error' => false,
|
'error' => false,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
'Illuminate\Auth\Events\Logout' => [
|
'Illuminate\Auth\Events\Logout' => [
|
||||||
'App\Listeners\Auth\Logout',
|
'App\Listeners\Auth\Logout',
|
||||||
],
|
],
|
||||||
'App\Events\Events\InvoicePaid' => [
|
'App\Events\InvoicePaid' => [
|
||||||
'App\Listeners\Incomes\Invoice\Paid',
|
'App\Listeners\Incomes\Invoice\Paid',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -49,6 +49,6 @@ class OfflinePayment extends Controller
|
|||||||
{
|
{
|
||||||
$result = event(new InvoicePaid($invoice, $request));
|
$result = event(new InvoicePaid($invoice, $request));
|
||||||
|
|
||||||
return response()->json($result);
|
return response()->json($result[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ Route::group(['middleware' => ['web', 'auth', 'language', 'adminmenu', 'permissi
|
|||||||
Route::post('settings/delete', 'Settings@delete');
|
Route::post('settings/delete', 'Settings@delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::group(['prefix' => 'customers', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () {
|
Route::group(['middleware' => ['web', 'auth', 'language', 'customermenu', 'permission:read-customer-panel'], 'prefix' => 'customers', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () {
|
||||||
Route::get('invoices/{invoice}/offlinepayment', 'OfflinePayment@show');
|
Route::get('invoices/{invoice}/offlinepayment', 'OfflinePayment@show');
|
||||||
Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm');
|
Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm');
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
$('#button-confirm').button('reset');
|
$('#button-confirm').button('reset');
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
if (data['error']) {
|
||||||
|
alert(data['error']);
|
||||||
|
}
|
||||||
|
|
||||||
if (data['success']) {
|
if (data['success']) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user