18 Commits

Author SHA1 Message Date
nurafrinaalimi16 2363c2947d fix diskaun promosi on tebus 2026-09-02 16:41:49 +08:00
nurafrinaalimi16 280f8cefa4 Merge remote-tracking branch 'origin/prod-kopkb' into test/merge-prod-kopkb 2026-09-01 11:15:13 +08:00
dev_kopkb 18936570c5 Merged in feature/kadar-anggota (pull request #444)
change kadar anggota to 1%
2026-08-26 15:00:40 +00:00
nurafrinaalimi16 f6b036976f change kadar anggota to 1% 2026-08-26 22:57:52 +08:00
root eb47c2a9bc latest stable version 2026-08-26 15:40:26 +08:00
nurafrinaalimi16 fb5a007fdc pelarasan rebate on imbang duga 2025-08-17 16:05:57 +08:00
nurafrinaalimi16 192a70d46e fix vault controller for rebate annur 2025-06-15 16:42:36 +08:00
nurafrinaalimi16 65eb1dfc62 add rebet to vault controller 2025-05-19 16:31:27 +08:00
nurafrinaalimi16 07d442a654 migrate for kadar rebet annur 2025-05-11 16:39:50 +08:00
nurafrinaalimi16 a2e37f5903 rebate annur 2025-05-11 16:39:11 +08:00
Ain Izazi 11bbfc1745 feat audit sag hilang and tuntut baki 2025-02-03 12:37:33 +08:00
Ain Izazi e5075859c4 feature audit kaunter 2025-02-03 12:37:33 +08:00
nurafrinaalimi16 282e8705b2 Merge branch 'production' of https://bitbucket.org/arrahn-pkb/api_arrahn into annur-rebate 2025-01-26 12:56:45 +08:00
nurafrinaalimi16 91cbcf87db fix marhun controller and connection database 2024-12-03 20:39:01 +08:00
nurafrinaalimi16 bbd033f175 Merge branch 'production' of https://bitbucket.org/arrahn-pkb/api_arrahn into annur-rebate 2024-12-03 12:54:50 +08:00
Afiq Hamzah a5f6d55151 Add .env.prod.example for docker environment 2024-11-26 13:12:56 +08:00
hayatie 4dd102f67d db 2024-11-21 12:18:48 +08:00
dev_kopkb cdcf08b209 add kadar rebate at GadaiV2 2024-11-19 11:41:31 +08:00
20 changed files with 596 additions and 120 deletions
+3 -1
View File
@@ -73,7 +73,9 @@ class Gadai extends Model
'tagkomuditi', 'tagkomuditi',
'tempohbayar', 'tempohbayar',
'lelong_tawarruq', 'lelong_tawarruq',
'tag_tebus' 'tag_tebus',
'kadarrebet',
'diskaun'
]; ];
/** /**
+297 -22
View File
@@ -30,6 +30,7 @@ use App\Status;
use App\LookupStatus; use App\LookupStatus;
use App\ARFiles; use App\ARFiles;
use App\WTDDraft; use App\WTDDraft;
use App\WTDSimulasi;
use App\SerahBaki; use App\SerahBaki;
use App\WTD; use App\WTD;
use App\StokAudit1; use App\StokAudit1;
@@ -62,7 +63,6 @@ use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Jobs\AccountCheckJob; use App\Jobs\AccountCheckJob;
use App\Penyelarasan;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
@@ -2364,7 +2364,69 @@ class AdminPageController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); $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) $batch_old = WTDDraft::on('mysql7')->select('kodcaw')->where('batchno_serah',0)->where('kodcaw',$request->kodcaw)
->groupBy('kodcaw')->get(); ->groupBy('kodcaw')->get();
@@ -2373,10 +2435,13 @@ class AdminPageController extends Controller
foreach($batch_old as $index=>$bo) 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); return response()->json($data,200);
@@ -2698,7 +2763,8 @@ class AdminPageController extends Controller
't_update' => $current->toDateString())); '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); return response()->json('success',200);
@@ -3161,8 +3227,6 @@ class AdminPageController extends Controller
return response()->json($customers); return response()->json($customers);
} }
public function AkruKeuntunganSebenar(Request $request){ public function AkruKeuntunganSebenar(Request $request){
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
@@ -3760,16 +3824,16 @@ class AdminPageController extends Controller
$get_imbangduga = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $lastDayOfYear)->first(); $get_imbangduga = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $lastDayOfYear)->first();
$get_imbangduga = optional($get_imbangduga)->toArray() ?? []; $get_imbangduga = optional($get_imbangduga)->toArray() ?? [];
if(empty($get_imbangduga)){ // if(empty($get_imbangduga)){
$requestData = new Request([ // $requestData = new Request([
'tarikh' => $request->tarikh, // 'tarikh' => $request->tarikh,
'kodcaw' => $kodcaw, // 'kodcaw' => $kodcaw,
]); // ]);
$exception_case = $this->AkruKeuntunganSebenar($requestData); // $exception_case = $this->AkruKeuntunganSebenar($requestData);
} // }
$backdate_keun_sebenar += isset($get_imbangduga['keun_sebenar']) ? $get_imbangduga['keun_sebenar'] : 0; $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(); $recentDate->subYear()->startOfYear();
} }
@@ -3787,13 +3851,6 @@ class AdminPageController extends Controller
if($kodcaw == '011229') if($kodcaw == '011229')
$total -= 45390.37; $total -= 45390.37;
if($kodcaw == 'KB2')
$total -= 64.8;
$total += Penyelarasan::on('mysql7')
->where('kodcaw', $kodcaw)
->sum(DB::raw('rugilelong + bakilelong + `lain-lain`'));
return response()->json($total,200); return response()->json($total,200);
} }
@@ -3965,4 +4022,222 @@ class AdminPageController extends Controller
'result' => $status === 'completed' ? $result : null, '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!']);
}
} }
+4 -2
View File
@@ -589,7 +589,7 @@ class GadaiController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $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->mula)
->where('t_gadai','<=',$request->akhir) ->where('t_gadai','<=',$request->akhir)
->orderBy('t_gadai') ->orderBy('t_gadai')
@@ -618,7 +618,9 @@ class GadaiController extends Controller
"teller"=> $gadaiData['teller'], "teller"=> $gadaiData['teller'],
"ujrah"=> $gadaiData['ujrah'], "ujrah"=> $gadaiData['ujrah'],
"onepercent"=> $gadaiData['onepercent'], "onepercent"=> $gadaiData['onepercent'],
"tagbaru"=> $gadaiData['tagbaru'] "tagbaru"=> $gadaiData['tagbaru'],
"kadar_rebet" => $gadaiData['kadarrebet'],
"diskaun" => $gadaiData['diskaun']
]); ]);
} }
+1 -1
View File
@@ -847,7 +847,7 @@ $date = new Carbon($request->tarikh);
$bilangan_tebus = $tebus->count(); $bilangan_tebus = $tebus->count();
// $bilangan_ansuran = $ansuran->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($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 //f
$data_lelong = Lelong::on($cawangan['mysql'])->where([['t_jual','>=',$request->mula],['t_jual','<=',$request->akhir]])->get(); $data_lelong = Lelong::on($cawangan['mysql'])->where([['t_jual','>=',$request->mula],['t_jual','<=',$request->akhir]])->get();
+2 -2
View File
@@ -605,9 +605,9 @@ class LelongController extends Controller
if($cawangan['tagarrahnbid'] == 1){ if($cawangan['tagarrahnbid'] == 1){
if(env('APP_ENV') != 'production'){ if(env('APP_ENV') != 'production'){
$link = 'http://niklah.arrahn.com.my/api/portalApi'; $link = 'https://adminbid-annur.erahn.com.my/api/portalApi';
}else{ }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,[ $lelong = Http::withOptions(['verify' => true])->get($link,[
+2 -2
View File
@@ -203,7 +203,7 @@ class MarhunController extends Controller
$marhun = Marhun::on($cawangan['mysql']) $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') ->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('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) ->where('marhun.t_gadai','=',$tarikh)
->orderBy('marhun.t_gadai') ->orderBy('marhun.t_gadai')
->get(); ->get();
@@ -221,7 +221,7 @@ class MarhunController extends Controller
$marhun = Marhun::on($cawangan['mysql']) $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') ->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('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) ->where('marhun.t_gadai','<=',$tarikh)
->whereYear('marhun.t_gadai','=',$current->year) ->whereYear('marhun.t_gadai','=',$current->year)
->where('gadai.sttebus','=','') ->where('gadai.sttebus','=','')
@@ -48,7 +48,7 @@ class GadaianController extends Controller
$summary_gadaian_data = array_map(function ($db_connection) use ($request) { $summary_gadaian_data = array_map(function ($db_connection) use ($request) {
$query = Gadai::on($db_connection); $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) { $query->when($request->filled('startDate') and $request->filled('endDate'), function ($q) use ($request) {
return $q->where('t_gadai', '>=', $request->startDate) return $q->where('t_gadai', '>=', $request->startDate)
+53 -4
View File
@@ -193,7 +193,7 @@ class TebusController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$tebus_data = Tebus::on($cawangan['mysql']) $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('gadai as gad','gad.norujukan','=','tebus.norujukan')
// ->join('online_arrahn.customer as cust', function($join) // ->join('online_arrahn.customer as cust', function($join)
// { // {
@@ -232,7 +232,8 @@ class TebusController extends Controller
"nokp"=>$tebusData['nokp'], "nokp"=>$tebusData['nokp'],
"jbg"=>$tebusData['jbg'], "jbg"=>$tebusData['jbg'],
"ujrah"=>$trans['ujrah_rebet'], "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.jbg',
'tebus.ujrah', 'tebus.ujrah',
'tebus.onepercent', 'tebus.onepercent',
'gad.tagbaru' 'gad.tagbaru',
'tebus.diskaun_rebate'
) )
->join('gadai as gad', 'gad.norujukan', '=', 'tebus.norujukan') ->join('gadai as gad', 'gad.norujukan', '=', 'tebus.norujukan')
->where('tebus.t_tebus', '>=', $request->mula) ->where('tebus.t_tebus', '>=', $request->mula)
@@ -310,7 +312,8 @@ class TebusController extends Controller
"jbg"=>$tebusData['jbg'], "jbg"=>$tebusData['jbg'],
"ujrah"=>$trans['ujrah_rebet'], "ujrah"=>$trans['ujrah_rebet'],
"onepercent"=>$trans['onepercent_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); 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) public function RebetCalculationLejer($kodcaw,Request $request)
{ {
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
@@ -1687,6 +1721,21 @@ class TebusController extends Controller
return response($rebet); 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) public function getUpahLamaToday($kodcaw,$norujukan)
{ {
$current = Carbon::now(); $current = Carbon::now();
+2
View File
@@ -12,6 +12,7 @@ use App\GlDetail;
use App\imbangdugalama; use App\imbangdugalama;
use App\GlCode; use App\GlCode;
use App\Panjar; use App\Panjar;
use App\Tebus;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Carbon\Carbon; use Carbon\Carbon;
@@ -411,6 +412,7 @@ class VaultController extends Controller
return response()->json($totalbakiakhirtunai); return response()->json($totalbakiakhirtunai);
} }
public function TunaiDiTanganLejer($kodcaw,Request $request) public function TunaiDiTanganLejer($kodcaw,Request $request)
{ {
+31
View File
@@ -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()
{
}
}
+1 -1
View File
@@ -398,7 +398,7 @@ class OnePercentService
$t_gadai = Carbon::parse($gadai->t_gadai); $t_gadai = Carbon::parse($gadai->t_gadai);
$t_bayaran = Carbon::parse($trans->tarikh_bayaran); $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; return false;
}else{ }else{
return true; return true;
+17 -1
View File
@@ -3,7 +3,9 @@
namespace App\Support\v2; namespace App\Support\v2;
use App\KadarUpah; use App\KadarUpah;
use App\KadarRebet;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class Calculation class Calculation
{ {
@@ -41,6 +43,16 @@ class Calculation
return $onepercent; 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){ public function kiraanUjrahSebenar(float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
if($kadarujrah >= 1){ if($kadarujrah >= 1){
@@ -61,13 +73,17 @@ class Calculation
$onepercent = $this->kiraanOnePercent($pembiayaan); $onepercent = $this->kiraanOnePercent($pembiayaan);
$ujrah_sebenar = $this->kiraanUjrahSebenar($nilaimarhun,$kadarujrah,$margin); $ujrah_sebenar = $this->kiraanUjrahSebenar($nilaimarhun,$kadarujrah,$margin);
$discount = $this->kiraanRebetAnnur($pembiayaan);
Log::debug('discount:' . $discount);
$onepercent = (!empty($onepercent)) ? $this->getRoundedMethod($onepercent) : 0; $onepercent = (!empty($onepercent)) ? $this->getRoundedMethod($onepercent) : 0;
$ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0; $ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0;
$keuntungan = $onepercent + $ujrah_sebenar; $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){ public function kiraanKeuntunganSebenar(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
+26 -17
View File
@@ -58,9 +58,12 @@ class GadaiV2
} }
} }
private function getKadarUpahAnggota($nokp,$total_nilai_marhun = 0,$groupid = 2) : Float{ private function getKadarUpahAnggota($nokp, $total_nilai_marhun = 0, $groupid = 2): ?float
//Log::info('DEBUG NOKP:' . $nokp); {
if($nokp){ if (!$nokp) {
return null; // tiada nokp = tak boleh tentukan kadar
}
$customer = Customer::on('mysql7') $customer = Customer::on('mysql7')
->select('tag_anggota') ->select('tag_anggota')
->where(function ($q) use ($nokp) { ->where(function ($q) use ($nokp) {
@@ -68,19 +71,19 @@ class GadaiV2
->orWhere('kplama', $nokp); ->orWhere('kplama', $nokp);
}) })
->first(); ->first();
$customer = $customer ? $customer->toArray() : []; $customer = $customer ? $customer->toArray() : [];
if(isset($customer) && $customer['tag_anggota'] == 1){
return 0.16; if (isset($customer['tag_anggota']) && $customer['tag_anggota'] == 1) {
}else{ return 0.00; // ahli — kadar 0.00 memang sah
return KadarUpah::where('min', '<=', $total_nilai_marhun) }
$kadar = KadarUpah::where('min', '<=', $total_nilai_marhun)
->where('max', '>=', $total_nilai_marhun) ->where('max', '>=', $total_nilai_marhun)
->where('group_id', $groupid) ->where('group_id', $groupid)
->value('kadarujrah'); ->value('kadarujrah');
}
}
return 0.0;
return is_null($kadar) ? null : (float) $kadar; // tak jumpa row = null (block)
} }
public function createMarhun($norujukan,HttpRequest $request){ public function createMarhun($norujukan,HttpRequest $request){
@@ -110,17 +113,16 @@ class GadaiV2
$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) { if (is_null($kadar_raw)) {
Log::error('[BLOCKED] Kadar upah tidak dijumpai', [
Log::error('[BLOCKED] Kadar upah kosong / 0', [
'nokp' => $request->nokp, 'nokp' => $request->nokp,
'total_nilai_marhun' => $total_nilai_marhun, 'total_nilai_marhun' => $total_nilai_marhun,
'group_id' => $cawangan['group_id'], 'group_id' => $cawangan['group_id'],
]); ]);
throw new \Exception("Kadar upah tidak dijumpai, transaksi dibatalkan!");
throw new \Exception("Kadar upah kosong / 0, transaksi dibatalkan!");
} }
// $kadar_raw = 0.00 (ahli) akan lepas ke sini dan diteruskan
// query kadar upah lama // query kadar upah lama
// $kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->first(); // $kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->first();
@@ -136,6 +138,9 @@ class GadaiV2
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']); $ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']); $onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
$kadar_rebet = $request->input('kadar_rebate');
$diskaun = $request->input('rebate');
$hargajualan = $request->pinjaman + $upah12; $hargajualan = $request->pinjaman + $upah12;
$akrual = $this->kiraupahTawarruqStokAuditUjrahOnePercent(0.5,0,$kadar_raw,$request->pinjaman,$total_nilai_marhun,$margin_pinjam); $akrual = $this->kiraupahTawarruqStokAuditUjrahOnePercent(0.5,0,$kadar_raw,$request->pinjaman,$total_nilai_marhun,$margin_pinjam);
@@ -174,6 +179,8 @@ class GadaiV2
'tagbaru' => 1, 'tagbaru' => 1,
'tunggakanujrah' => $akrual['ujrah'], 'tunggakanujrah' => $akrual['ujrah'],
'tunggakanonepercent' => $akrual['keuntungan'], 'tunggakanonepercent' => $akrual['keuntungan'],
'kadarrebet' => $kadar_rebet,
'diskaun' => $diskaun
)); ));
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first(); $new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
@@ -245,6 +252,7 @@ class GadaiV2
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']); $ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']);
$upahrebet_raw = $onepercent + $ujrah; $upahrebet_raw = $onepercent + $ujrah;
$upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw); $upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw);
$upahrebet_raw = $upahrebet_raw - $upah['diskaun'];
return $upahrebet_raw; return $upahrebet_raw;
} }
@@ -282,7 +290,7 @@ class GadaiV2
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']); $keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']);
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']); $ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']);
Log::debug($keuntungan);
$onepercentasal = $gadai['pinjaman'] * (1/100); $onepercentasal = $gadai['pinjaman'] * (1/100);
$ujrahasal = $onepercent->getRoundedMethod($ujrahasal); $ujrahasal = $onepercent->getRoundedMethod($ujrahasal);
$onepercentasal = $onepercent->getRoundedMethod($onepercentasal); $onepercentasal = $onepercent->getRoundedMethod($onepercentasal);
@@ -331,6 +339,7 @@ class GadaiV2
'tempoh' => $gadai['tempoh'], 'tempoh' => $gadai['tempoh'],
'beza_tempoh' => $bilang_bln, 'beza_tempoh' => $bilang_bln,
'margin_semasa' => $margin_semasa, 'margin_semasa' => $margin_semasa,
'kadardiskaun' => $keuntungan['diskaun']
]); ]);
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([ $transaksi_gadai = TransaksiGadai::on('mysql7')->create([
+43 -19
View File
@@ -39,7 +39,8 @@ class Penebusan
$this->cawangan_info = $cawangan_info; $this->cawangan_info = $cawangan_info;
} }
public function tebusTawarruq($kodcaw,$norujukan){ public function tebusTawarruq($kodcaw, $norujukan)
{
$onepercentservices = new Calculation(); $onepercentservices = new Calculation();
$cawangan = Cawangan::on('mysql7') $cawangan = Cawangan::on('mysql7')
@@ -53,20 +54,20 @@ class Penebusan
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal'; $jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
$rebet = $this->rebetselepastawarruq($kodcaw, $norujukan, $jeniskeuntungan); $rebet = $this->rebetselepastawarruq($kodcaw, $norujukan, $jeniskeuntungan);
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet;
// $hargatebus = round($harga_tebus,PHP_ROUND_HALF_UP); // Ambil terus dari column 'diskaun'
// $hargatebus = bcdiv(round($harga_tebus,2),1,1); $diskaun = $gadai_data['diskaun'] ?? 0;
// $hargatebus = number_format($hargatebus,2);
// if(strpos($hargatebus,',')){
// $hargatebus = str_replace(',','',$hargatebus);
// }
// Kira harga tebus selepas tolak rebet & diskaun
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet - $diskaun;
// Apply pembundaran
$hargatebus = $onepercentservices->getRoundedMethod($harga_tebus); $hargatebus = $onepercentservices->getRoundedMethod($harga_tebus);
return response()->json($hargatebus); return response()->json($hargatebus);
} }
public function hargaTebusTawarruq($kodcaw,$norujukan){ public function hargaTebusTawarruq($kodcaw,$norujukan){
$onepercentservices = new Calculation(); $onepercentservices = new Calculation();
@@ -485,6 +486,9 @@ class Penebusan
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first(); $gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
// Ambil nilai diskaun
$diskaun = $gadai['diskaun'] ?? 0;
//check duplicate //check duplicate
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first(); $data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first();
@@ -492,7 +496,7 @@ class Penebusan
return response()->json('duplicate'); return response()->json('duplicate');
} }
$ujrah=0;$onepercent=0;$rounded=0; $ujrah=0;$onepercent=0;$rounded=0;$upah_rebet_sebenar=0;
if($gadai['hargajualan'] == null){ if($gadai['hargajualan'] == null){
$harga_tebus = $this->hargaTebusNotTawarruq($kodcaw,$norujukan); $harga_tebus = $this->hargaTebusNotTawarruq($kodcaw,$norujukan);
$upah_tebus = $this->kiraUpahNotTawarruq($kodcaw,$norujukan); $upah_tebus = $this->kiraUpahNotTawarruq($kodcaw,$norujukan);
@@ -502,7 +506,6 @@ class Penebusan
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan); $harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
$upah_tebus = $this->kiraupahTawarruq($norujukan); $upah_tebus = $this->kiraupahTawarruq($norujukan);
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan); $upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
if($request->jeniskeuntungan == 'onepercent'){ if($request->jeniskeuntungan == 'onepercent'){
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan); $array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
@@ -514,8 +517,14 @@ class Penebusan
$ujrah = $array_onepercent['ujrah']; $ujrah = $array_onepercent['ujrah'];
$onepercent = $array_onepercent['onepercent']; $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([ $create_tebus = Tebus::on($cawangan['mysql'])->create([
'kodcaw'=> $kodcaw, 'kodcaw'=> $kodcaw,
@@ -543,6 +552,7 @@ class Penebusan
'teller' => $request->teller, 'teller' => $request->teller,
'ujrah' => $ujrah_rebet, 'ujrah' => $ujrah_rebet,
'onepercent' => $onepercent_rebet, 'onepercent' => $onepercent_rebet,
'diskaun_rebate' => $diskaun, // Tambah kolum simpan diskaun
]); ]);
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([ $create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
@@ -561,18 +571,28 @@ class Penebusan
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([ $transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan, 'norujukan' => $norujukan,
'bayaran_keuntungan' => $upah_tebus, 'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
'bayaran_pembiayaan' => $gadai['bakipjm'], 'bayaran_pembiayaan' => $gadai['bakipjm'],
'keuntungan_rebet' => $upah_rebet_sebenar, 'keuntungan_rebet' => $upah_rebet_sebenar,
'tarikh_bayaran' => $current, 'tarikh_bayaran' => $current,
'kodcaw' => $kodcaw, 'kodcaw' => $kodcaw,
'ujrah' => ($request->jeniskeuntungan == 'onepercent') ? $array_onepercent['ujrah'] : 0, 'ujrah' => ($request->jeniskeuntungan == 'onepercent')
'ujrah_rebet' => ($request->jeniskeuntungan == 'onepercent') ? $ujrah_rebet : 0, ? $array_onepercent['ujrah']
'onepercent' => ($request->jeniskeuntungan == 'onepercent') ? $array_onepercent['onepercent'] : 0, : 0,
'onepercent_rebet' => ($request->jeniskeuntungan == 'onepercent') ? $onepercent_rebet : 0, 'ujrah_rebet' => ($request->jeniskeuntungan == 'onepercent')
'margin_semasa' => ($request->jeniskeuntungan == 'onepercent') ? $margin_semasa : 0, ? $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'], 'tempoh' => $gadai['tempoh'],
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']), 'beza_tempoh' => $gadai['tempoh'] - $gadai['tempohbayar'],
]); ]);
if($request->jenistebus == 'P'){ if($request->jenistebus == 'P'){
@@ -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( $update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
'sttebus' => "T", 'sttebus' => "T",
't_update' => $current->toDateString(), 't_update' => $current->toDateString(),
@@ -736,7 +758,7 @@ class Penebusan
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([ $transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan, 'norujukan' => $norujukan,
'bayaran_keuntungan' => $upah_tebus, 'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
'bayaran_pembiayaan' => $bayaran_pembiayaan, 'bayaran_pembiayaan' => $bayaran_pembiayaan,
'keuntungan_rebet' => $upah_rebet_sebenar, 'keuntungan_rebet' => $upah_rebet_sebenar,
'tarikh_bayaran'=> $current, 'tarikh_bayaran'=> $current,
@@ -1133,10 +1155,12 @@ class Penebusan
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm']; $upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
try{ try{
TransaksiKeuntungan::on('mysql7')->create([ TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan, 'norujukan' => $norujukan,
'bayaran_keuntungan' => $upah_tebus, 'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
'bayaran_pembiayaan' => $bayaran_pembiayaan, 'bayaran_pembiayaan' => $bayaran_pembiayaan,
'keuntungan_rebet' => $upah_rebet_sebenar, 'keuntungan_rebet' => $upah_rebet_sebenar,
'tarikh_bayaran'=> $current, 'tarikh_bayaran'=> $current,
+2 -1
View File
@@ -52,7 +52,8 @@ class Tebus extends Model
'pinjamanterkini', 'pinjamanterkini',
'tarikhbyrn', 'tarikhbyrn',
'ujrah', 'ujrah',
'onepercent' 'onepercent',
'diskaun_rebate'
]; ];
/** /**
+1 -1
View File
@@ -14,7 +14,7 @@ class TransaksiKeuntungan extends Model
* @var array * @var array
*/ */
protected $fillable = [ 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) { $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; 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()
{
//
}
}
+3
View File
@@ -550,6 +550,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('CalculationPendahuluanSerahan/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahan']); $router->get('CalculationPendahuluanSerahan/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahan']);
$router->get('KeuntunganArRahn/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntungan']); $router->get('KeuntunganArRahn/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntungan']);
$router->get('RebetCalculation/{kodcaw}',['uses'=>'TebusController@RebetCalculation']); $router->get('RebetCalculation/{kodcaw}',['uses'=>'TebusController@RebetCalculation']);
$router->get('RebetPromoCalculation/{kodcaw}',['uses'=>'TebusController@RebetPromoCalculation']);
$router->get('PelarasanRebate/{kodcaw}',['uses'=>'TebusController@PelarasanRebate']);
//-- Harta Semasa --// //-- Harta Semasa --//
$router->get('PinjamanDiberi/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberi']); $router->get('PinjamanDiberi/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberi']);
@@ -579,6 +581,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('PendahuluanSerahanLejer/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahanLejer']); $router->get('PendahuluanSerahanLejer/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahanLejer']);
$router->get('KeuntunganArRahnLejer/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntunganLejer']); $router->get('KeuntunganArRahnLejer/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntunganLejer']);
$router->get('RebetCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetCalculationLejer']); $router->get('RebetCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetCalculationLejer']);
$router->get('RebetPromoCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetPromoCalculationLejer']);
$router->get('cajlelongLejer/{kodcaw}',['uses'=>'LelongController@cajlelongcalculationLejer']); $router->get('cajlelongLejer/{kodcaw}',['uses'=>'LelongController@cajlelongcalculationLejer']);
// //-- Harta Semasa --// // //-- Harta Semasa --//