added nilaimarhun for marign teller and pc
This commit is contained in:
@@ -5,7 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\MaxMutuEmas;
|
||||
use App\MaxPinjaman;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
class MaxPinjamanController extends Controller
|
||||
{
|
||||
public function getAllMaxPinjaman(Request $request)
|
||||
@@ -18,15 +18,19 @@ class MaxPinjamanController extends Controller
|
||||
$pinjaman = [
|
||||
[
|
||||
"user_type" => "teller",
|
||||
"max" => $calculateMargin['teller']
|
||||
"max" => $calculateMargin['teller'],
|
||||
"teller_pinjaman" => $calculateMargin['teller_pinjaman']
|
||||
|
||||
],
|
||||
[
|
||||
"user_type" => "khazanah",
|
||||
"max" => $calculateMargin['pc']
|
||||
"max" => $calculateMargin['pc'],
|
||||
"pc_pinjaman" => $calculateMargin['pc_pinjaman']
|
||||
],
|
||||
[
|
||||
"user_type" => "operasi",
|
||||
"max" => $calculateMargin['operasi']
|
||||
"max" => $calculateMargin['operasi'],
|
||||
"operasi_pinjaman" => $calculateMargin['operasi_pinjaman']
|
||||
]
|
||||
];
|
||||
} else {
|
||||
@@ -37,15 +41,18 @@ class MaxPinjamanController extends Controller
|
||||
|
||||
public function calculateMaxPinjamanMutu($data, $mutu,$totalMarhun)
|
||||
{
|
||||
$totalMaxPC = 0;
|
||||
$totalMaxTeller = 0;
|
||||
$totalMaxOperasi = 0;
|
||||
$totalMaxMarhunPC = 0;
|
||||
$totalMaxMarhunTeller = 0;
|
||||
$totalMaxMarhunOperasi = 0;
|
||||
|
||||
if($mutu == null || $totalMarhun == 0){
|
||||
return [
|
||||
"pc" => 0,
|
||||
"pc_pinjaman" => 0,
|
||||
"teller" => 0,
|
||||
"operasi" => 0
|
||||
"teller_pinjaman" => 0,
|
||||
"operasi" => 0,
|
||||
"operasi_pinjaman" => 0
|
||||
];
|
||||
}
|
||||
$mutuKarat = array_map(function($item) {
|
||||
@@ -59,20 +66,22 @@ class MaxPinjamanController extends Controller
|
||||
$margin = $data->where('karat', $karat)->first();
|
||||
if($margin){
|
||||
$nilai = $mutuNilai[$index];
|
||||
$totalMaxPC += ($margin->pc/100) * $nilai;
|
||||
$totalMaxTeller += ($margin->teller/100) * $nilai;
|
||||
$totalMaxOperasi += ($margin->operasi/100) * $nilai;
|
||||
$totalMaxMarhunPC += round(($margin->pc/100) * $nilai, 2);
|
||||
$totalMaxMarhunTeller += round(($margin->teller/100) * $nilai, 2);
|
||||
$totalMaxMarhunOperasi += round(($margin->operasi/100) * $nilai, 2);
|
||||
}
|
||||
}
|
||||
$totalMaxPC = $totalMarhun > 0 ? ($totalMaxPC / $totalMarhun) * 100 : 0;
|
||||
$totalMaxTeller = $totalMarhun > 0 ? ($totalMaxTeller / $totalMarhun) * 100 : 0;
|
||||
$totalMaxOperasi = $totalMarhun > 0 ? ($totalMaxOperasi / $totalMarhun) * 100 : 0;
|
||||
|
||||
|
||||
$totalMaxPC = $totalMarhun > 0 ? ($totalMaxMarhunPC / $totalMarhun) * 100 : 0;
|
||||
$totalMaxTeller = $totalMarhun > 0 ? ($totalMaxMarhunTeller / $totalMarhun) * 100 : 0;
|
||||
$totalMaxOperasi = $totalMarhun > 0 ? ($totalMaxMarhunOperasi / $totalMarhun) * 100 : 0;
|
||||
return [
|
||||
"pc" => round($totalMaxPC,2),
|
||||
"pc_pinjaman" => round(($totalMaxPC / 100) * $totalMarhun, 2),
|
||||
"teller" => round($totalMaxTeller,2),
|
||||
"operasi" => round($totalMaxOperasi,2)
|
||||
"teller_pinjaman" => round(($totalMaxTeller / 100) * $totalMarhun, 2),
|
||||
"operasi" => round($totalMaxOperasi,2),
|
||||
"operasi_pinjaman" => round(($totalMaxOperasi / 100) * $totalMarhun, 2)
|
||||
];
|
||||
}
|
||||
|
||||
@@ -94,9 +103,9 @@ class MaxPinjamanController extends Controller
|
||||
$maxmutuemas = MaxMutuEmas::on('mysql7')->where('karat', $karat)->first();
|
||||
|
||||
if($maxmutuemas && $nilaimarhun > 0){
|
||||
$maxmutuemas->maxteller = ($maxmutuemas->teller/100) * $nilaimarhun;
|
||||
$maxmutuemas->maxpc = ($maxmutuemas->pc/100) * $nilaimarhun;
|
||||
$maxmutuemas->maxoperasi = ($maxmutuemas->operasi/100) * $nilaimarhun;
|
||||
$maxmutuemas->maxteller = round(($maxmutuemas->teller/100) * $nilaimarhun, 2);
|
||||
$maxmutuemas->maxpc = round(($maxmutuemas->pc/100) * $nilaimarhun, 2);
|
||||
$maxmutuemas->maxoperasi = round(($maxmutuemas->operasi/100) * $nilaimarhun, 2);
|
||||
} else if($maxmutuemas) {
|
||||
$maxmutuemas->maxteller = 0;
|
||||
$maxmutuemas->maxpc = 0;
|
||||
|
||||
Reference in New Issue
Block a user