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