Compare commits
18 Commits
8970d8e1b8
...
v3.2-annur
| Author | SHA1 | Date | |
|---|---|---|---|
| 2363c2947d | |||
| 280f8cefa4 | |||
| 18936570c5 | |||
| f6b036976f | |||
| eb47c2a9bc | |||
| fb5a007fdc | |||
| 192a70d46e | |||
| 65eb1dfc62 | |||
| 07d442a654 | |||
| a2e37f5903 | |||
| 11bbfc1745 | |||
| e5075859c4 | |||
| 282e8705b2 | |||
| 91cbcf87db | |||
| bbd033f175 | |||
| a5f6d55151 | |||
| 4dd102f67d | |||
| cdcf08b209 |
+3
-1
@@ -73,7 +73,9 @@ class Gadai extends Model
|
||||
'tagkomuditi',
|
||||
'tempohbayar',
|
||||
'lelong_tawarruq',
|
||||
'tag_tebus'
|
||||
'tag_tebus',
|
||||
'kadarrebet',
|
||||
'diskaun'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ use App\Status;
|
||||
use App\LookupStatus;
|
||||
use App\ARFiles;
|
||||
use App\WTDDraft;
|
||||
use App\WTDSimulasi;
|
||||
use App\SerahBaki;
|
||||
use App\WTD;
|
||||
use App\StokAudit1;
|
||||
@@ -62,7 +63,6 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Jobs\AccountCheckJob;
|
||||
use App\Penyelarasan;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
@@ -2364,19 +2364,84 @@ class AdminPageController extends Controller
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
|
||||
$latestbatch = SerahBaki::on($cawangan['mysql'])->where('norujukan','baru')->get()->toArray();
|
||||
//$latestbatch = SerahBaki::on($cawangan['mysql'])->where('norujukan','baru')->get()->toArray();
|
||||
//new added
|
||||
$serahBaki = SerahBaki::on($cawangan['mysql'])
|
||||
->where('norujukan', 'baru')
|
||||
->get();
|
||||
|
||||
$allBatchNo = $serahBaki->pluck('batchno')->unique()->toArray();
|
||||
|
||||
$wtddraftData = WTDDraft::on('mysql7')
|
||||
->selectRaw("
|
||||
batchno_serah,
|
||||
YEAR(t_jual) as tahun,
|
||||
GROUP_CONCAT(
|
||||
DISTINCT MONTH(t_jual)
|
||||
ORDER BY MONTH(t_jual)
|
||||
SEPARATOR ','
|
||||
) as bulan
|
||||
")
|
||||
->where('kodcaw', $request->kodcaw)
|
||||
->whereIn('batchno_serah', $allBatchNo)
|
||||
->groupBy('batchno_serah', DB::raw('YEAR(t_jual)'))
|
||||
->get()
|
||||
->groupBy('batchno_serah')
|
||||
->map(function ($rows) {
|
||||
return $rows->map(function ($row) {
|
||||
return [
|
||||
'tahun' => $row->tahun,
|
||||
'bulan' => $row->bulan
|
||||
];
|
||||
})->values();
|
||||
});
|
||||
|
||||
$finalData = $serahBaki->map(function ($item) use ($wtddraftData) {
|
||||
$batchno = $item->batchno;
|
||||
|
||||
$tahun = null;
|
||||
$bulan = [];
|
||||
|
||||
if (!empty($wtddraftData[$batchno])) {
|
||||
// ambil tahun pertama (kebiasaannya satu tahun sahaja)
|
||||
$tahun = $wtddraftData[$batchno][0]['tahun'];
|
||||
|
||||
// convert string "2,3,4,5" → array
|
||||
$bulan = explode(',', $wtddraftData[$batchno][0]['bulan']);
|
||||
}
|
||||
|
||||
return [
|
||||
'batchno' => $batchno,
|
||||
'norujukan' => $item->norujukan,
|
||||
'tarikh' => $item->tarikh,
|
||||
't_jual' => $item->t_jual,
|
||||
'baki' => $item->baki,
|
||||
't_htr_ag' => $item->t_htr_ag,
|
||||
'aktif' => $item->aktif,
|
||||
'tahun' => $tahun,
|
||||
'bulan' => implode(',',$bulan),
|
||||
// field lain kekal
|
||||
];
|
||||
});
|
||||
|
||||
$finalDataArray = $finalData->toArray();
|
||||
//end new added
|
||||
|
||||
$batch_old = WTDDraft::on('mysql7')->select('kodcaw')->where('batchno_serah',0)->where('kodcaw',$request->kodcaw)
|
||||
->groupBy('kodcaw')->get();
|
||||
|
||||
$batch_old_noruj = WTDDraft::on('mysql7')->where('batchno_serah',0)->where('kodcaw',$request->kodcaw)->pluck('norujukan');
|
||||
$lelong_data = Lelong::on($cawangan['mysql'])->whereIn('norujukan',$batch_old_noruj)->get();
|
||||
|
||||
|
||||
foreach($batch_old as $index=>$bo)
|
||||
{
|
||||
array_push($latestbatch,['recno' => 0,'norujukan' => 'lama','batchno' => 0,'baki' => $lelong_data->sum('baki'),'aktif' => 1]);
|
||||
//array_push($latestbatch,['recno' => 0,'norujukan' => 'lama','batchno' => 0,'baki' => $lelong_data->sum('baki'),'aktif' => 1]);
|
||||
array_push($finalDataArray,['recno' => 0,'norujukan' => 'lama','batchno' => 0,'baki' => $lelong_data->sum('baki'),'aktif' => 1]);
|
||||
|
||||
}
|
||||
|
||||
$data = $this->paginate($latestbatch,8);
|
||||
//$data = $this->paginate($latestbatch,8);
|
||||
$data = $this->paginate($finalDataArray,8);
|
||||
|
||||
return response()->json($data,200);
|
||||
|
||||
@@ -2698,8 +2763,9 @@ class AdminPageController extends Controller
|
||||
't_update' => $current->toDateString()));
|
||||
}
|
||||
|
||||
$serahbakiupdate = SerahBaki::on($cawangan['mysql'])->where('batchno',$batchno)->update(array('aktif' => 1,'t_jual' => $current->toDateString(),'nopelanggan' => $request->nocek));;
|
||||
|
||||
//$serahbakiupdate = SerahBaki::on($cawangan['mysql'])->where('batchno',$batchno)->update(array('aktif' => 1,'t_jual' => $current->toDateString(),'nopelanggan' => $request->nocek));;
|
||||
$serahbakiupdate = SerahBaki::on($cawangan['mysql'])->where('batchno',$batchno)->update(array('aktif' => 1,'t_jual' => $current->toDateString(),'nopelanggan' => $request->nocek,'t_htr_ag' => $request->tarikhAG));
|
||||
|
||||
return response()->json('success',200);
|
||||
|
||||
}catch (\Throwable $e){
|
||||
@@ -3160,8 +3226,6 @@ class AdminPageController extends Controller
|
||||
|
||||
return response()->json($customers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function AkruKeuntunganSebenar(Request $request){
|
||||
|
||||
@@ -3760,16 +3824,16 @@ class AdminPageController extends Controller
|
||||
|
||||
$get_imbangduga = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $lastDayOfYear)->first();
|
||||
$get_imbangduga = optional($get_imbangduga)->toArray() ?? [];
|
||||
if(empty($get_imbangduga)){
|
||||
$requestData = new Request([
|
||||
'tarikh' => $request->tarikh,
|
||||
'kodcaw' => $kodcaw,
|
||||
]);
|
||||
$exception_case = $this->AkruKeuntunganSebenar($requestData);
|
||||
}
|
||||
// if(empty($get_imbangduga)){
|
||||
// $requestData = new Request([
|
||||
// 'tarikh' => $request->tarikh,
|
||||
// 'kodcaw' => $kodcaw,
|
||||
// ]);
|
||||
// $exception_case = $this->AkruKeuntunganSebenar($requestData);
|
||||
// }
|
||||
|
||||
$backdate_keun_sebenar += isset($get_imbangduga['keun_sebenar']) ? $get_imbangduga['keun_sebenar'] : 0;
|
||||
$backdate_keun_sebenar += $exception_case;
|
||||
$backdate_keun_sebenar += (float) ($exception_case ?? 0);
|
||||
$recentDate->subYear()->startOfYear();
|
||||
}
|
||||
|
||||
@@ -3785,14 +3849,7 @@ class AdminPageController extends Controller
|
||||
$total = ($utgrugilama + $lelong + $upahsimpantebus + $upahsimpanlelong + $upahsimpanansur + $gstcajlelong + $keuntungansebenar + $upahsimpankeuntungansebelumtawarruq + $available_akru + $total_keuntungan_sebenar + $akru_ujrah + $akru_1percent) + $parameter;
|
||||
|
||||
if($kodcaw == '011229')
|
||||
$total -= 45390.37;
|
||||
|
||||
if($kodcaw == 'KB2')
|
||||
$total -= 64.8;
|
||||
|
||||
$total += Penyelarasan::on('mysql7')
|
||||
->where('kodcaw', $kodcaw)
|
||||
->sum(DB::raw('rugilelong + bakilelong + `lain-lain`'));
|
||||
$total -= 45390.37;
|
||||
|
||||
return response()->json($total,200);
|
||||
}
|
||||
@@ -3965,4 +4022,222 @@ class AdminPageController extends Controller
|
||||
'result' => $status === 'completed' ? $result : null,
|
||||
]);
|
||||
}
|
||||
|
||||
//function wtd baru
|
||||
public function janaSimulasiWTD(Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $request->kodcaw)->first();
|
||||
|
||||
//listing sag belum tuntut cwgn
|
||||
$sag_cwgn = collect(
|
||||
Lelong::on($cawangan['mysql'])
|
||||
->selectRaw('norujukan')
|
||||
->whereYear('t_jual', $request->tahun)
|
||||
->whereNull('trkhtuntut')
|
||||
->where('baki', '>', 0)
|
||||
->pluck('norujukan') // lebih bersih
|
||||
);
|
||||
|
||||
//listing sag blocked
|
||||
$sag_online = collect(
|
||||
WTDDraft::on('mysql7')
|
||||
->selectRaw('norujukan')
|
||||
->where('kodcaw', '=', $request->kodcaw)
|
||||
->pluck('norujukan')
|
||||
);
|
||||
//dd($sag_online);
|
||||
//filter sag yg tk wujud dlm wtd_draft
|
||||
$filtersag = $sag_cwgn->diff($sag_online);
|
||||
|
||||
//query baru
|
||||
$tarikh_belum_tuntut = Lelong::on($cawangan['mysql'])
|
||||
->selectRaw('
|
||||
MONTH(t_jual) as bulan,
|
||||
SUM(pinjaman) as pembiayaan,
|
||||
ABS(SUM(baki)) as baki,
|
||||
COUNT(DISTINCT norujukan) as jumlah_norujukan,
|
||||
kodcaw
|
||||
')
|
||||
->whereIn('norujukan', $filtersag)
|
||||
->groupBy('bulan', 'kodcaw')
|
||||
->orderBy('bulan')
|
||||
->get();
|
||||
|
||||
$tarikh_belum_tuntut = $tarikh_belum_tuntut->map(function ($item) {
|
||||
$item->bulan = \Carbon\Carbon::create()->month($item->bulan)->format('F');
|
||||
return $item;
|
||||
});
|
||||
|
||||
return response()->json($tarikh_belum_tuntut);
|
||||
}
|
||||
|
||||
public function RekodSimulasiWTD(Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $request->kodcaw)->first();
|
||||
|
||||
$rekod_simulasi = Lelong::on($cawangan['mysql'])
|
||||
->join('gadai','lelong.norujukan','=','gadai.norujukan')
|
||||
->selectRaw('ABS(lelong.baki) as baki, lelong.t_lelong, lelong.pinjaman, lelong.norujukan, gadai.nokp')
|
||||
->whereMonth('lelong.t_jual', $request->month)
|
||||
->whereYear('lelong.t_jual', $request->year)
|
||||
->whereNull('lelong.trkhtuntut')
|
||||
->where('lelong.baki', '>', 0)
|
||||
->get();
|
||||
|
||||
return response()->json($rekod_simulasi);
|
||||
}
|
||||
|
||||
public function prosesSimulasiWTD(Request $request)
|
||||
{
|
||||
$proses = $request->input;
|
||||
|
||||
// dd($proses, $cawangan);
|
||||
|
||||
$baki = 0;
|
||||
$jumlahPembiayaan = 0;
|
||||
$simulasi = WTDSimulasi::max('simulasi')+1;
|
||||
|
||||
foreach ($proses as $item) {
|
||||
WTDSimulasi::create([
|
||||
'bulan' => $item['bulan'],
|
||||
'tahun' => $item['tahun'],
|
||||
'kodcaw' => $item['kodcaw'],
|
||||
'jumlah_sag' => $item['jumlah_sag'],
|
||||
'pembiayaan'=> $item['pembiayaan'],
|
||||
'baki'=> $item['baki'],
|
||||
'simulasi' => $simulasi,
|
||||
]);
|
||||
$baki += $item['baki'];
|
||||
$jumlahPembiayaan = $item['pembiayaan'];
|
||||
}
|
||||
|
||||
return response()->json(['status' => 'success','simulasi' => $simulasi,'baki' => $baki,'pinjaman' => $jumlahPembiayaan]);
|
||||
}
|
||||
|
||||
public function pengesahanSimulasiWTD(Request $request)
|
||||
{
|
||||
// Decode the JSON records from the request
|
||||
$records = json_decode($request->records, true);
|
||||
|
||||
// Retrieve and clean 'kodcaw' from the request
|
||||
$kodcaw = $request->kodcaw;
|
||||
$kodcaw_clean = str_replace('"', '', $kodcaw);
|
||||
|
||||
// Get the database connection for the branch (cawangan)
|
||||
$cawangan = Cawangan::where('kodcaw', $kodcaw_clean)->first();
|
||||
|
||||
// Check if 'Cawangan' exists
|
||||
if (!$cawangan) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Invalid branch code (kodcaw).'], 404);
|
||||
}
|
||||
|
||||
$cawangan_connection = $cawangan->mysql;
|
||||
|
||||
// Get the latest batch number and increment it
|
||||
$latestBatch = SerahBaki::on($cawangan_connection)->max('batchno') + 1;
|
||||
|
||||
// Initialize total variables
|
||||
$totalPembiayaan = 0;
|
||||
$totalBaki = 0;
|
||||
|
||||
|
||||
try {
|
||||
// Iterate through the records and save them to the WTDDraft table
|
||||
foreach ($records as $record) {
|
||||
// Check if 'bulan' and 'tahun' exist in the record
|
||||
if (!isset($record['bulan']) || !isset($record['tahun'])) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Missing bulan or tahun in records.'], 400);
|
||||
}
|
||||
$month = DateTime::createFromFormat('F', $record["bulan"])->format('n');
|
||||
|
||||
|
||||
// Query norujukan records from the database
|
||||
$query_norujukan = Lelong::on($cawangan_connection)
|
||||
->join('gadai', 'lelong.norujukan', '=', 'gadai.norujukan')
|
||||
->selectRaw('ABS(lelong.baki) as baki, lelong.t_lelong, lelong.pinjaman, lelong.norujukan, gadai.nokp, lelong.t_jual')
|
||||
->whereMonth('lelong.t_jual', $month)
|
||||
->whereYear('lelong.t_jual', $record["tahun"])
|
||||
->whereNull('lelong.trkhtuntut')
|
||||
->where('lelong.baki', '>', 0)
|
||||
->get();
|
||||
|
||||
// Save each record to the WTDDraft table
|
||||
foreach ($query_norujukan as $query) {
|
||||
$wtddraft = new WTDDraft();
|
||||
$wtddraft->nokp = $query['nokp'];
|
||||
$wtddraft->kodcaw = $kodcaw_clean;
|
||||
$wtddraft->norujukan = $query['norujukan'];
|
||||
$wtddraft->t_jual = $query['t_jual'];
|
||||
$wtddraft->t_gadai = $query['t_gadai'] ?? null; // Optional: ensure 't_gadai' exists
|
||||
$wtddraft->t_lelong = $query['t_lelong'];
|
||||
$wtddraft->batchno_serah = $latestBatch;
|
||||
$wtddraft->save();
|
||||
}
|
||||
|
||||
// Accumulate totals
|
||||
$totalPembiayaan += $record['pembiayaan'] ?? 0;
|
||||
$totalBaki += $record['baki'] ?? 0;
|
||||
}
|
||||
|
||||
// Create a new record in the SerahBaki table
|
||||
SerahBaki::on($cawangan_connection)->create([
|
||||
'norujukan' => 'baru',
|
||||
'batchno' => $latestBatch,
|
||||
'hargajual' => 0.00,
|
||||
'pinjaman' => $totalPembiayaan,
|
||||
'upah' => 0.00,
|
||||
'cajlel' => 0.00,
|
||||
'gst_cl' => 0.00,
|
||||
'gst_hj' => 0.00,
|
||||
'baki' => $totalBaki,
|
||||
'tarikh' => Carbon::now()->toDateString(),
|
||||
't_jual' => Carbon::now()->toDateString(),
|
||||
'nopelanggan' => '',
|
||||
'aktif' => 0,
|
||||
]);
|
||||
|
||||
// Return a success response with the new batch number
|
||||
return response()->json(['status' => 'success', 'batchno' => $latestBatch], 200);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
// Log the error and return a failure response
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getLine());
|
||||
return response()->json(['status' => 'error', 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function simulasiToDraft(Request $request)
|
||||
{
|
||||
$bulan = $request->bulan;
|
||||
|
||||
if (!$bulan || count($bulan) === 0) {
|
||||
return response()->json(['error' => 'Sila pilih sekurang-kurangnya satu bulan.'], 400);
|
||||
}
|
||||
|
||||
$simulasi = WTDSimulasi::whereIn('bulan', $bulan)->get();
|
||||
|
||||
if ($simulasi->isEmpty()) {
|
||||
return response()->json(['error' => 'Tiada data untuk bulan yang dipilih.'], 404);
|
||||
}
|
||||
|
||||
// foreach ($simulasi as $data) {
|
||||
// WTDDraft::create([
|
||||
// 'nokp' => $data->nokp ?? null,
|
||||
// 'kodcaw' => $data->kodcaw ?? null,
|
||||
// 'norujukan' => $data->norujukan ?? null,
|
||||
// 't_jual' => $data->t_jual ?? null,
|
||||
// 't_gadai' => $data->t_gadai ?? null,
|
||||
// 't_lelong' => $data->t_lelong ?? null,
|
||||
// 'batchno_serah' => $data->simulasi, // Simpan sebagai rujukan
|
||||
// ]);
|
||||
// }
|
||||
|
||||
//dd($bulan, $simulasi);
|
||||
|
||||
return response()->json(['message' => 'Data berjaya dipindahkan ke WTD Draft!']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ class GadaiController extends Controller
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent','tagbaru')
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent','tagbaru','diskaun')
|
||||
->where('t_gadai','>=',$request->mula)
|
||||
->where('t_gadai','<=',$request->akhir)
|
||||
->orderBy('t_gadai')
|
||||
@@ -618,7 +618,9 @@ class GadaiController extends Controller
|
||||
"teller"=> $gadaiData['teller'],
|
||||
"ujrah"=> $gadaiData['ujrah'],
|
||||
"onepercent"=> $gadaiData['onepercent'],
|
||||
"tagbaru"=> $gadaiData['tagbaru']
|
||||
"tagbaru"=> $gadaiData['tagbaru'],
|
||||
"kadar_rebet" => $gadaiData['kadarrebet'],
|
||||
"diskaun" => $gadaiData['diskaun']
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -847,7 +847,7 @@ $date = new Carbon($request->tarikh);
|
||||
$bilangan_tebus = $tebus->count();
|
||||
// $bilangan_ansuran = $ansuran->count();
|
||||
//$bilangan_customer_baru = Customer::on($cawangan['mysql'])->where([['tarikhdaftar','>=',$request->mula],['tarikhdaftar','<=',$request->akhir]])->count();
|
||||
$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','>=',$request->mula],['tarikhdaftar','<=',$request->akhir]])->count();
|
||||
$bilangan_customer_baru = Customer::on('mysql7')->whereBetween('tarikhdaftar', [$request->mula, $request->akhir])->where('kodcaw', $request->kodcaw)->count();
|
||||
|
||||
//f
|
||||
$data_lelong = Lelong::on($cawangan['mysql'])->where([['t_jual','>=',$request->mula],['t_jual','<=',$request->akhir]])->get();
|
||||
|
||||
@@ -605,9 +605,9 @@ class LelongController extends Controller
|
||||
|
||||
if($cawangan['tagarrahnbid'] == 1){
|
||||
if(env('APP_ENV') != 'production'){
|
||||
$link = 'http://niklah.arrahn.com.my/api/portalApi';
|
||||
$link = 'https://adminbid-annur.erahn.com.my/api/portalApi';
|
||||
}else{
|
||||
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi';
|
||||
$link = 'https://adminbid-annur.erahn.com.my/api/portalApi';
|
||||
}
|
||||
|
||||
$lelong = Http::withOptions(['verify' => true])->get($link,[
|
||||
|
||||
@@ -203,7 +203,7 @@ class MarhunController extends Controller
|
||||
$marhun = Marhun::on($cawangan['mysql'])
|
||||
->select('marhun.norujukan','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai','marhun.tag_permata', 'marhun.berat_batu_permata')
|
||||
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
|
||||
->rightJoin('online_arrahn.customer as customer', 'customer.kpbaru','=','gadai.nokp')
|
||||
->rightJoin('master_annur.customer as customer', 'customer.kpbaru','=','gadai.nokp')
|
||||
->where('marhun.t_gadai','=',$tarikh)
|
||||
->orderBy('marhun.t_gadai')
|
||||
->get();
|
||||
@@ -221,7 +221,7 @@ class MarhunController extends Controller
|
||||
$marhun = Marhun::on($cawangan['mysql'])
|
||||
->select('marhun.norujukan','gadai.sttebus','gadai.pinjaman','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai')
|
||||
->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan')
|
||||
->rightJoin('online_arrahn.customer as customer', 'customer.kpbaru','=','gadai.nokp')
|
||||
->rightJoin('master_annur.customer as customer', 'customer.kpbaru','=','gadai.nokp')
|
||||
->where('marhun.t_gadai','<=',$tarikh)
|
||||
->whereYear('marhun.t_gadai','=',$current->year)
|
||||
->where('gadai.sttebus','=','')
|
||||
|
||||
@@ -48,7 +48,7 @@ class GadaianController extends Controller
|
||||
$summary_gadaian_data = array_map(function ($db_connection) use ($request) {
|
||||
$query = Gadai::on($db_connection);
|
||||
|
||||
$query->select(DB::raw('count(norujukan) as total_gadaian, sum(berat) as sum_berat, sum(nilaimarhun) as sum_nilai_marhun, sum(pinjaman) as sum_pinjaman'));
|
||||
$query->select(DB::raw('count(norujukan) as total_gadaian, sum(berat) as sum_berat, sum(nilaimarhun) as sum_nilai_marhun, sum(pinjaman) as sum_pinjaman, sum(upah12) as sum_upah_12'));
|
||||
|
||||
$query->when($request->filled('startDate') and $request->filled('endDate'), function ($q) use ($request) {
|
||||
return $q->where('t_gadai', '>=', $request->startDate)
|
||||
|
||||
@@ -193,7 +193,7 @@ class TebusController extends Controller
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$tebus_data = Tebus::on($cawangan['mysql'])
|
||||
->select('tebus.t_tebus', 'gad.t_gadai','gad.hargajualan','gad.bakihargajualan','gad.bakipjm as gadaibakipjm','tebus.nilaimarhun','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','gad.nokp','tebus.jbg','tebus.ujrah','tebus.onepercent','gad.tagbaru')
|
||||
->select('tebus.t_tebus', 'gad.t_gadai','gad.hargajualan','gad.bakihargajualan','gad.bakipjm as gadaibakipjm','tebus.nilaimarhun','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','gad.nokp','tebus.jbg','tebus.ujrah','tebus.onepercent','gad.tagbaru','tebus.diskaun_rebate')
|
||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||
// ->join('online_arrahn.customer as cust', function($join)
|
||||
// {
|
||||
@@ -232,7 +232,8 @@ class TebusController extends Controller
|
||||
"nokp"=>$tebusData['nokp'],
|
||||
"jbg"=>$tebusData['jbg'],
|
||||
"ujrah"=>$trans['ujrah_rebet'],
|
||||
"onepercent"=>$trans['onepercent_rebet']
|
||||
"onepercent"=>$trans['onepercent_rebet'],
|
||||
"diskaun_rebate"=>$tebusData['diskaun_rebate'],
|
||||
|
||||
]);
|
||||
}
|
||||
@@ -274,7 +275,8 @@ class TebusController extends Controller
|
||||
'tebus.jbg',
|
||||
'tebus.ujrah',
|
||||
'tebus.onepercent',
|
||||
'gad.tagbaru'
|
||||
'gad.tagbaru',
|
||||
'tebus.diskaun_rebate'
|
||||
)
|
||||
->join('gadai as gad', 'gad.norujukan', '=', 'tebus.norujukan')
|
||||
->where('tebus.t_tebus', '>=', $request->mula)
|
||||
@@ -310,7 +312,8 @@ class TebusController extends Controller
|
||||
"jbg"=>$tebusData['jbg'],
|
||||
"ujrah"=>$trans['ujrah_rebet'],
|
||||
"onepercent"=>$trans['onepercent_rebet'],
|
||||
"tagbaru"=>$tebusData['tagbaru']
|
||||
"tagbaru"=>$tebusData['tagbaru'],
|
||||
"diskaun_rebate"=>$tebusData['diskaun_rebate'],
|
||||
|
||||
]);
|
||||
}
|
||||
@@ -1672,6 +1675,37 @@ class TebusController extends Controller
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function RebetPromoCalculation($kodcaw,Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
|
||||
$rebet = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as db2','tebus.norujukan','=','db2.norujukan')
|
||||
// ->where('tebus.t_tebus','>','2021-04-13')
|
||||
->where('tebus.t_tebus','<=',$request->tarikh)
|
||||
->where('db2.hargajualan','>','0') // tambahan 2021-05-07
|
||||
->whereNotNull('db2.hargajualan')
|
||||
->sum('diskaun_rebate');
|
||||
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function PelarasanRebate($kodcaw,Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
|
||||
// Jumlah diskaun_rebate dari 13/5/2025 hingga tarikh semasa
|
||||
$rebet = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as db2', 'tebus.norujukan', '=', 'db2.norujukan')
|
||||
->whereBetween('tebus.t_tebus', ['2025-05-13', $request->tarikh])
|
||||
->where('db2.hargajualan', '>', 0)
|
||||
->where('db2.t_gadai', '>', '2023-05-21')
|
||||
->whereNotNull('db2.hargajualan')
|
||||
->sum('diskaun_rebate');
|
||||
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function RebetCalculationLejer($kodcaw,Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
@@ -1687,6 +1721,21 @@ class TebusController extends Controller
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function RebetPromoCalculationLejer($kodcaw,Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
|
||||
$rebet = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as db2','tebus.norujukan','=','db2.norujukan')
|
||||
->where('tebus.t_tebus','>=',$request->mula)
|
||||
->where('tebus.t_tebus','<=',$request->hingga)
|
||||
->where('db2.hargajualan','>','0')
|
||||
->whereNotNull('db2.hargajualan')
|
||||
->sum('diskaun_rebate');
|
||||
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function getUpahLamaToday($kodcaw,$norujukan)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\GlDetail;
|
||||
use App\imbangdugalama;
|
||||
use App\GlCode;
|
||||
use App\Panjar;
|
||||
use App\Tebus;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
@@ -375,7 +376,7 @@ class VaultController extends Controller
|
||||
return response()->json($gldetail,200);
|
||||
}
|
||||
|
||||
public function TunaiDiTangan($kodcaw,Request $request)
|
||||
public function TunaiDiTangan($kodcaw,Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
@@ -411,6 +412,7 @@ class VaultController extends Controller
|
||||
return response()->json($totalbakiakhirtunai);
|
||||
}
|
||||
|
||||
|
||||
public function TunaiDiTanganLejer($kodcaw,Request $request)
|
||||
{
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class KadarRebet extends Model
|
||||
{
|
||||
protected $table = 'kadar_rebet';
|
||||
public $timestamps = false;
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
// protected $hidden = [];
|
||||
|
||||
function transaction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -398,7 +398,7 @@ class OnePercentService
|
||||
$t_gadai = Carbon::parse($gadai->t_gadai);
|
||||
$t_bayaran = Carbon::parse($trans->tarikh_bayaran);
|
||||
|
||||
if ($t_gadai->month === $t_bayaran->month && $t_gadai->year === $t_bayaran->year) {
|
||||
if (($t_gadai->month == $t_bayaran->month) && ($t_gadai->year == $t_bayaran->year)) {
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace App\Support\v2;
|
||||
|
||||
use App\KadarUpah;
|
||||
use App\KadarRebet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Calculation
|
||||
{
|
||||
@@ -41,6 +43,16 @@ class Calculation
|
||||
return $onepercent;
|
||||
}
|
||||
|
||||
private function kiraanRebetAnnur (float $pembiayaan = 0.0){
|
||||
|
||||
$kadarrebet = KadarRebet::on('mysql7')
|
||||
->where('pembiayaan_min', '<=', $pembiayaan)
|
||||
->where('pembiayaan_max', '>=', $pembiayaan)
|
||||
->sum('kadarrebet');
|
||||
|
||||
return $kadarrebet;
|
||||
}
|
||||
|
||||
public function kiraanUjrahSebenar(float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
||||
|
||||
if($kadarujrah >= 1){
|
||||
@@ -61,13 +73,17 @@ class Calculation
|
||||
|
||||
$onepercent = $this->kiraanOnePercent($pembiayaan);
|
||||
$ujrah_sebenar = $this->kiraanUjrahSebenar($nilaimarhun,$kadarujrah,$margin);
|
||||
$discount = $this->kiraanRebetAnnur($pembiayaan);
|
||||
Log::debug('discount:' . $discount);
|
||||
|
||||
$onepercent = (!empty($onepercent)) ? $this->getRoundedMethod($onepercent) : 0;
|
||||
$ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0;
|
||||
|
||||
$keuntungan = $onepercent + $ujrah_sebenar;
|
||||
|
||||
return ['keuntungan' => $keuntungan,'onepercent' => $onepercent, 'ujrah' => $ujrah_sebenar];
|
||||
$kadar_diskaun = $this->getRoundedMethod($keuntungan * ($discount/100));
|
||||
Log::debug('kadar_discount:' .$kadar_diskaun);
|
||||
return ['keuntungan' => $keuntungan,'onepercent' => $onepercent, 'ujrah' => $ujrah_sebenar,'diskaun' => $kadar_diskaun];
|
||||
}
|
||||
|
||||
public function kiraanKeuntunganSebenar(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
||||
|
||||
+45
-36
@@ -58,31 +58,34 @@ class GadaiV2
|
||||
}
|
||||
}
|
||||
|
||||
private function getKadarUpahAnggota($nokp,$total_nilai_marhun = 0,$groupid = 2) : Float{
|
||||
//Log::info('DEBUG NOKP:' . $nokp);
|
||||
if($nokp){
|
||||
$customer = Customer::on('mysql7')
|
||||
->select('tag_anggota')
|
||||
->where(function($q) use ($nokp) {
|
||||
$q->where('kpbaru', $nokp)
|
||||
->orWhere('kplama', $nokp);
|
||||
})
|
||||
->first();
|
||||
$customer = $customer ? $customer->toArray() : [];
|
||||
if(isset($customer) && $customer['tag_anggota'] == 1){
|
||||
return 0.16;
|
||||
}else{
|
||||
return KadarUpah::where('min', '<=', $total_nilai_marhun)
|
||||
->where('max', '>=', $total_nilai_marhun)
|
||||
->where('group_id', $groupid)
|
||||
->value('kadarujrah');
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
|
||||
private function getKadarUpahAnggota($nokp, $total_nilai_marhun = 0, $groupid = 2): ?float
|
||||
{
|
||||
if (!$nokp) {
|
||||
return null; // tiada nokp = tak boleh tentukan kadar
|
||||
}
|
||||
|
||||
$customer = Customer::on('mysql7')
|
||||
->select('tag_anggota')
|
||||
->where(function ($q) use ($nokp) {
|
||||
$q->where('kpbaru', $nokp)
|
||||
->orWhere('kplama', $nokp);
|
||||
})
|
||||
->first();
|
||||
|
||||
$customer = $customer ? $customer->toArray() : [];
|
||||
|
||||
if (isset($customer['tag_anggota']) && $customer['tag_anggota'] == 1) {
|
||||
return 0.00; // ahli — kadar 0.00 memang sah
|
||||
}
|
||||
|
||||
$kadar = KadarUpah::where('min', '<=', $total_nilai_marhun)
|
||||
->where('max', '>=', $total_nilai_marhun)
|
||||
->where('group_id', $groupid)
|
||||
->value('kadarujrah');
|
||||
|
||||
return is_null($kadar) ? null : (float) $kadar; // tak jumpa row = null (block)
|
||||
}
|
||||
|
||||
public function createMarhun($norujukan,HttpRequest $request){
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
@@ -108,19 +111,18 @@ class GadaiV2
|
||||
$total_nilai_marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->sum('n_marhun');
|
||||
$total_berat = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->sum('berat');
|
||||
|
||||
$kadar_raw = $this->getKadarUpahAnggota($request->nokp, $total_nilai_marhun, $cawangan['group_id']);
|
||||
$kadar_raw = $this->getKadarUpahAnggota($request->nokp, $total_nilai_marhun, $cawangan['group_id']);
|
||||
|
||||
if (empty($kadar_raw) || $kadar_raw == 0) {
|
||||
|
||||
Log::error('[BLOCKED] Kadar upah kosong / 0', [
|
||||
'nokp' => $request->nokp,
|
||||
'total_nilai_marhun' => $total_nilai_marhun,
|
||||
'group_id' => $cawangan['group_id'],
|
||||
]);
|
||||
|
||||
throw new \Exception("Kadar upah kosong / 0, transaksi dibatalkan!");
|
||||
}
|
||||
if (is_null($kadar_raw)) {
|
||||
Log::error('[BLOCKED] Kadar upah tidak dijumpai', [
|
||||
'nokp' => $request->nokp,
|
||||
'total_nilai_marhun' => $total_nilai_marhun,
|
||||
'group_id' => $cawangan['group_id'],
|
||||
]);
|
||||
throw new \Exception("Kadar upah tidak dijumpai, transaksi dibatalkan!");
|
||||
}
|
||||
|
||||
// $kadar_raw = 0.00 (ahli) akan lepas ke sini dan diteruskan
|
||||
|
||||
// query kadar upah lama
|
||||
// $kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->first();
|
||||
@@ -135,6 +137,9 @@ class GadaiV2
|
||||
$upah12 = $onepercentservices->getRoundedMethod($upah1 * 12);
|
||||
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
|
||||
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
|
||||
|
||||
$kadar_rebet = $request->input('kadar_rebate');
|
||||
$diskaun = $request->input('rebate');
|
||||
|
||||
$hargajualan = $request->pinjaman + $upah12;
|
||||
|
||||
@@ -174,6 +179,8 @@ class GadaiV2
|
||||
'tagbaru' => 1,
|
||||
'tunggakanujrah' => $akrual['ujrah'],
|
||||
'tunggakanonepercent' => $akrual['keuntungan'],
|
||||
'kadarrebet' => $kadar_rebet,
|
||||
'diskaun' => $diskaun
|
||||
));
|
||||
|
||||
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||
@@ -245,7 +252,8 @@ class GadaiV2
|
||||
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']);
|
||||
$upahrebet_raw = $onepercent + $ujrah;
|
||||
$upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw);
|
||||
|
||||
$upahrebet_raw = $upahrebet_raw - $upah['diskaun'];
|
||||
|
||||
return $upahrebet_raw;
|
||||
}
|
||||
|
||||
@@ -282,7 +290,7 @@ class GadaiV2
|
||||
|
||||
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']);
|
||||
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']);
|
||||
|
||||
Log::debug($keuntungan);
|
||||
$onepercentasal = $gadai['pinjaman'] * (1/100);
|
||||
$ujrahasal = $onepercent->getRoundedMethod($ujrahasal);
|
||||
$onepercentasal = $onepercent->getRoundedMethod($onepercentasal);
|
||||
@@ -331,6 +339,7 @@ class GadaiV2
|
||||
'tempoh' => $gadai['tempoh'],
|
||||
'beza_tempoh' => $bilang_bln,
|
||||
'margin_semasa' => $margin_semasa,
|
||||
'kadardiskaun' => $keuntungan['diskaun']
|
||||
]);
|
||||
|
||||
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([
|
||||
|
||||
@@ -39,33 +39,34 @@ class Penebusan
|
||||
$this->cawangan_info = $cawangan_info;
|
||||
}
|
||||
|
||||
public function tebusTawarruq($kodcaw,$norujukan){
|
||||
$onepercentservices = new Calculation();
|
||||
public function tebusTawarruq($kodcaw, $norujukan)
|
||||
{
|
||||
$onepercentservices = new Calculation();
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')
|
||||
->where('kodcaw','=',$kodcaw)
|
||||
->first();
|
||||
$cawangan = Cawangan::on('mysql7')
|
||||
->where('kodcaw', '=', $kodcaw)
|
||||
->first();
|
||||
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])
|
||||
->where('norujukan','=',$norujukan)
|
||||
->first();
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])
|
||||
->where('norujukan', '=', $norujukan)
|
||||
->first();
|
||||
|
||||
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
|
||||
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
|
||||
|
||||
$rebet = $this->rebetselepastawarruq($kodcaw,$norujukan,$jeniskeuntungan);
|
||||
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet;
|
||||
$rebet = $this->rebetselepastawarruq($kodcaw, $norujukan, $jeniskeuntungan);
|
||||
|
||||
// $hargatebus = round($harga_tebus,PHP_ROUND_HALF_UP);
|
||||
// $hargatebus = bcdiv(round($harga_tebus,2),1,1);
|
||||
// $hargatebus = number_format($hargatebus,2);
|
||||
// if(strpos($hargatebus,',')){
|
||||
// $hargatebus = str_replace(',','',$hargatebus);
|
||||
// }
|
||||
// Ambil terus dari column 'diskaun'
|
||||
$diskaun = $gadai_data['diskaun'] ?? 0;
|
||||
|
||||
$hargatebus = $onepercentservices->getRoundedMethod($harga_tebus);
|
||||
// Kira harga tebus selepas tolak rebet & diskaun
|
||||
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet - $diskaun;
|
||||
|
||||
// Apply pembundaran
|
||||
$hargatebus = $onepercentservices->getRoundedMethod($harga_tebus);
|
||||
|
||||
return response()->json($hargatebus);
|
||||
}
|
||||
|
||||
return response()->json($hargatebus);
|
||||
}
|
||||
|
||||
public function hargaTebusTawarruq($kodcaw,$norujukan){
|
||||
$onepercentservices = new Calculation();
|
||||
@@ -485,6 +486,9 @@ class Penebusan
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||
|
||||
// Ambil nilai diskaun
|
||||
$diskaun = $gadai['diskaun'] ?? 0;
|
||||
|
||||
//check duplicate
|
||||
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first();
|
||||
|
||||
@@ -492,7 +496,7 @@ class Penebusan
|
||||
return response()->json('duplicate');
|
||||
}
|
||||
|
||||
$ujrah=0;$onepercent=0;$rounded=0;
|
||||
$ujrah=0;$onepercent=0;$rounded=0;$upah_rebet_sebenar=0;
|
||||
if($gadai['hargajualan'] == null){
|
||||
$harga_tebus = $this->hargaTebusNotTawarruq($kodcaw,$norujukan);
|
||||
$upah_tebus = $this->kiraUpahNotTawarruq($kodcaw,$norujukan);
|
||||
@@ -502,7 +506,6 @@ class Penebusan
|
||||
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
|
||||
$upah_tebus = $this->kiraupahTawarruq($norujukan);
|
||||
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||
|
||||
if($request->jeniskeuntungan == 'onepercent'){
|
||||
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
|
||||
@@ -514,8 +517,14 @@ class Penebusan
|
||||
$ujrah = $array_onepercent['ujrah'];
|
||||
$onepercent = $array_onepercent['onepercent'];
|
||||
}
|
||||
|
||||
// FIX: tolak diskaun DAHULU sebelum kira upah_rebet_sebenar
|
||||
$harga_tebus['harga'] -= $diskaun;
|
||||
|
||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||
}
|
||||
|
||||
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||
|
||||
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
||||
'kodcaw'=> $kodcaw,
|
||||
@@ -543,6 +552,7 @@ class Penebusan
|
||||
'teller' => $request->teller,
|
||||
'ujrah' => $ujrah_rebet,
|
||||
'onepercent' => $onepercent_rebet,
|
||||
'diskaun_rebate' => $diskaun, // Tambah kolum simpan diskaun
|
||||
]);
|
||||
|
||||
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
||||
@@ -559,21 +569,31 @@ class Penebusan
|
||||
'namateller' => $request->teller
|
||||
]);
|
||||
|
||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||
'norujukan' => $norujukan,
|
||||
'bayaran_keuntungan' => $upah_tebus,
|
||||
'bayaran_pembiayaan' => $gadai['bakipjm'],
|
||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||
'tarikh_bayaran'=> $current,
|
||||
'kodcaw'=> $kodcaw,
|
||||
'ujrah' => ($request->jeniskeuntungan == 'onepercent') ? $array_onepercent['ujrah'] : 0,
|
||||
'ujrah_rebet' => ($request->jeniskeuntungan == 'onepercent') ? $ujrah_rebet : 0,
|
||||
'onepercent' => ($request->jeniskeuntungan == 'onepercent') ? $array_onepercent['onepercent'] : 0,
|
||||
'onepercent_rebet' => ($request->jeniskeuntungan == 'onepercent') ? $onepercent_rebet : 0,
|
||||
'margin_semasa' => ($request->jeniskeuntungan == 'onepercent') ? $margin_semasa : 0,
|
||||
'tempoh' => $gadai['tempoh'],
|
||||
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']),
|
||||
]);
|
||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||
'norujukan' => $norujukan,
|
||||
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||
'bayaran_pembiayaan' => $gadai['bakipjm'],
|
||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||
'tarikh_bayaran' => $current,
|
||||
'kodcaw' => $kodcaw,
|
||||
'ujrah' => ($request->jeniskeuntungan == 'onepercent')
|
||||
? $array_onepercent['ujrah']
|
||||
: 0,
|
||||
'ujrah_rebet' => ($request->jeniskeuntungan == 'onepercent')
|
||||
? $ujrah_rebet
|
||||
: 0,
|
||||
'onepercent' => ($request->jeniskeuntungan == 'onepercent')
|
||||
? $array_onepercent['onepercent']
|
||||
: 0,
|
||||
'onepercent_rebet' => ($request->jeniskeuntungan == 'onepercent')
|
||||
? $onepercent_rebet
|
||||
: 0,
|
||||
'margin_semasa' => ($request->jeniskeuntungan == 'onepercent')
|
||||
? $margin_semasa
|
||||
: 0,
|
||||
'tempoh' => $gadai['tempoh'],
|
||||
'beza_tempoh' => $gadai['tempoh'] - $gadai['tempohbayar'],
|
||||
]);
|
||||
|
||||
if($request->jenistebus == 'P'){
|
||||
$baki_hargajualan = $gadai['bakihargajualan'] - $request->bakiupah;
|
||||
@@ -683,6 +703,8 @@ class Penebusan
|
||||
}
|
||||
}
|
||||
|
||||
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||
|
||||
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
|
||||
'sttebus' => "T",
|
||||
't_update' => $current->toDateString(),
|
||||
@@ -736,7 +758,7 @@ class Penebusan
|
||||
|
||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||
'norujukan' => $norujukan,
|
||||
'bayaran_keuntungan' => $upah_tebus,
|
||||
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||
'tarikh_bayaran'=> $current,
|
||||
@@ -1133,10 +1155,12 @@ class Penebusan
|
||||
|
||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||
|
||||
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||
|
||||
try{
|
||||
TransaksiKeuntungan::on('mysql7')->create([
|
||||
'norujukan' => $norujukan,
|
||||
'bayaran_keuntungan' => $upah_tebus,
|
||||
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||
'tarikh_bayaran'=> $current,
|
||||
|
||||
+2
-1
@@ -52,7 +52,8 @@ class Tebus extends Model
|
||||
'pinjamanterkini',
|
||||
'tarikhbyrn',
|
||||
'ujrah',
|
||||
'onepercent'
|
||||
'onepercent',
|
||||
'diskaun_rebate'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ class TransaksiKeuntungan extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'norujukan','bayaran_keuntungan','tarikh_bayaran','kodcaw','bayaran_pembiayaan','keuntungan_rebet','ujrah','ujrah_rebet','onepercent','onepercent_rebet','tempoh','beza_tempoh','margin_semasa','rounded'
|
||||
'norujukan','bayaran_keuntungan','tarikh_bayaran','kodcaw','bayaran_pembiayaan','keuntungan_rebet','ujrah','ujrah_rebet','onepercent','onepercent_rebet','tempoh','beza_tempoh','margin_semasa','rounded','kadardiskaun'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,7 @@ class AddColumnsToKomuditiTransaksi extends Migration
|
||||
{
|
||||
$online_arrahn_connection_array = array_filter(config('database.connections'), function($connection) {
|
||||
|
||||
if($connection['database'] === 'online_arrahn' || $connection['database'] === 'master_krk' || $connection['database'] === config('tennant_master.database')){
|
||||
if($connection['database'] === 'online_arrahn' || $connection['database'] === 'master_annur' || $connection['database'] === config('tennant_master.database')){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateKadarRebetTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::connection('mysql7')->table('kadar_rebet', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->decimal('min');
|
||||
$table->decimal('max');
|
||||
$table->decimal('kadar_rebet');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('kadar_rebet');
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class KadarRebet extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -550,6 +550,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('CalculationPendahuluanSerahan/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahan']);
|
||||
$router->get('KeuntunganArRahn/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntungan']);
|
||||
$router->get('RebetCalculation/{kodcaw}',['uses'=>'TebusController@RebetCalculation']);
|
||||
$router->get('RebetPromoCalculation/{kodcaw}',['uses'=>'TebusController@RebetPromoCalculation']);
|
||||
$router->get('PelarasanRebate/{kodcaw}',['uses'=>'TebusController@PelarasanRebate']);
|
||||
|
||||
//-- Harta Semasa --//
|
||||
$router->get('PinjamanDiberi/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberi']);
|
||||
@@ -579,7 +581,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('PendahuluanSerahanLejer/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahanLejer']);
|
||||
$router->get('KeuntunganArRahnLejer/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntunganLejer']);
|
||||
$router->get('RebetCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetCalculationLejer']);
|
||||
$router->get('cajlelongLejer/{kodcaw}',['uses'=>'LelongController@cajlelongcalculationLejer']);
|
||||
$router->get('RebetPromoCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetPromoCalculationLejer']);
|
||||
$router->get('cajlelongLejer/{kodcaw}',['uses'=>'LelongController@cajlelongcalculationLejer']);
|
||||
|
||||
// //-- Harta Semasa --//
|
||||
$router->get('PinjamanDiberiLejer/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberiLejer']);
|
||||
|
||||
Reference in New Issue
Block a user