|
|
|
@ -3,10 +3,7 @@
|
|
|
|
|
namespace App\Http\Controllers\Customer;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Models\Account;
|
|
|
|
|
use App\Models\Customer;
|
|
|
|
|
use App\Models\DepositHistory;
|
|
|
|
|
use App\Models\DepositLocation;
|
|
|
|
|
use App\Models\PaylaterHistory;
|
|
|
|
|
use App\Models\Setting;
|
|
|
|
|
use App\Services\GeneralService;
|
|
|
|
@ -32,10 +29,10 @@ class PaylaterController extends Controller
|
|
|
|
|
if ($paylater->type == PaylaterHistory::TYPE_REPAYMENT) {
|
|
|
|
|
$deposit = DepositHistory::where('related_id', $paylater->id)->first();
|
|
|
|
|
|
|
|
|
|
if (!in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) {
|
|
|
|
|
if (! in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) {
|
|
|
|
|
return redirect()->route('transactions.deposit.show', [
|
|
|
|
|
'deposit' => $deposit,
|
|
|
|
|
'back' => 'customer.paylater.index'
|
|
|
|
|
'back' => 'customer.paylater.index',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -65,7 +62,7 @@ class PaylaterController extends Controller
|
|
|
|
|
|
|
|
|
|
$customer = $request->user('customer');
|
|
|
|
|
|
|
|
|
|
// validate amount
|
|
|
|
|
// validate amount
|
|
|
|
|
if ($customer->paylater->usage < $request->amount) {
|
|
|
|
|
return redirect()->back()
|
|
|
|
|
->with('message', ['type' => 'error', 'message' => 'Nominal Tagihan tidak boleh lebih dari tagihan']);
|
|
|
|
@ -75,7 +72,7 @@ class PaylaterController extends Controller
|
|
|
|
|
$repayment = DepositHistory::query()
|
|
|
|
|
->where([
|
|
|
|
|
['customer_id', '=', $customer->id],
|
|
|
|
|
['type', '=', DepositHistory::TYPE_REPAYMENT]
|
|
|
|
|
['type', '=', DepositHistory::TYPE_REPAYMENT],
|
|
|
|
|
])->where(function ($query) {
|
|
|
|
|
$query->where('is_valid', '!=', DepositHistory::STATUS_VALID)
|
|
|
|
|
->where('is_valid', '!=', DepositHistory::STATUS_REJECT)
|
|
|
|
@ -130,7 +127,7 @@ class PaylaterController extends Controller
|
|
|
|
|
return redirect()->route('transactions.deposit.show', [
|
|
|
|
|
'deposit' => $deposit->id,
|
|
|
|
|
'direct' => 'true',
|
|
|
|
|
'back' => 'customer.paylater.index'
|
|
|
|
|
'back' => 'customer.paylater.index',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|