fix tanya upah

This commit is contained in:
Hafifie PKB
2024-02-03 23:29:44 +08:00
parent 363402dcf0
commit bfc9dcf065
2 changed files with 44 additions and 8 deletions
+23 -8
View File
@@ -677,6 +677,8 @@ class Penebusan
} }
public function kiraupahTawarruqByTarikh($kodcaw,$norujukan,$tarikh){ public function kiraupahTawarruqByTarikh($kodcaw,$norujukan,$tarikh){
$onepercentservices = new Calculation();
$cawangan = Cawangan::on('mysql7') $cawangan = Cawangan::on('mysql7')
->where('kodcaw','=',$kodcaw) ->where('kodcaw','=',$kodcaw)
->first(); ->first();
@@ -685,6 +687,10 @@ class Penebusan
->where('norujukan','=',$norujukan) ->where('norujukan','=',$norujukan)
->first(); ->first();
$transaction_keuntungan = TransaksiKeuntungan::on('mysql7')
->where('norujukan','=',$norujukan)
->sum('keuntungan_rebet');
$tempoh_func = $this->kiraanTarikhJBG($gadai_data['t_gadai'],$tarikh); $tempoh_func = $this->kiraanTarikhJBG($gadai_data['t_gadai'],$tarikh);
if($tempoh_func >= 12.0){ if($tempoh_func >= 12.0){
@@ -696,19 +702,28 @@ class Penebusan
$upahsemasa_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['pinjaman']); $upahsemasa_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['pinjaman']);
$upah_semasa_round = number_format($upahsemasa_raw,2); // $upah_semasa_round = number_format($upahsemasa_raw,2);
if(strpos($upah_semasa_round,',')){ // if(strpos($upah_semasa_round,',')){
$upah_semasa_round = str_replace(',','',$upah_semasa_round); // $upah_semasa_round = str_replace(',','',$upah_semasa_round);
} // }
$upah_semasa = substr($upah_semasa_round, 0, -1); // $upah_semasa = substr($upah_semasa_round, 0, -1);
if(strpos($upah_semasa,',')){ // if(strpos($upah_semasa,',')){
$upah_semasa = str_replace(',','',$upah_semasa); // $upah_semasa = str_replace(',','',$upah_semasa);
} // }
$upah_semasa = $onepercentservices->getRoundedMethod($upahsemasa_raw);
$upahrebet_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['bakipjm']);
$upah_rebet = $onepercentservices->getRoundedMethod($upahrebet_raw);
$rebet_raw =$gadai_data['upah12'] - $transaction_keuntungan - $upah_rebet;
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet_raw;
$array_return = [ $array_return = [
'upahsemasa' => $upah_semasa, 'upahsemasa' => $upah_semasa,
'tempoh' => $tempoh, 'tempoh' => $tempoh,
'harga_tebus' => $harga_tebus,
]; ];
return $array_return; return $array_return;
+21
View File
@@ -797,6 +797,10 @@ class Penebusan
->where('norujukan','=',$norujukan) ->where('norujukan','=',$norujukan)
->first(); ->first();
$transaction_keuntungan = TransaksiKeuntungan::on('mysql7')
->where('norujukan','=',$norujukan)
->sum('keuntungan_rebet');
$tempoh_func = $this->kiraanTarikhJBG($gadai_data['t_gadai'],$tarikh); $tempoh_func = $this->kiraanTarikhJBG($gadai_data['t_gadai'],$tarikh);
if($tempoh_func >= 12.0){ if($tempoh_func >= 12.0){
@@ -806,6 +810,7 @@ class Penebusan
} }
$bilang_bln = $tempoh - $gadai_data['tempohbayar']; $bilang_bln = $tempoh - $gadai_data['tempohbayar'];
/* Keuntungan Sebenar */
$upah = $onepercentservices->kiraanKeuntunganSebenar($gadai_data['pinjaman'],$gadai_data['nilaimarhun'],$gadai_data['kadarupah'],$gadai_data['margin_semasa']); $upah = $onepercentservices->kiraanKeuntunganSebenar($gadai_data['pinjaman'],$gadai_data['nilaimarhun'],$gadai_data['kadarupah'],$gadai_data['margin_semasa']);
$keuntungan_semasa = $onepercentservices->getRoundedMethod($bilang_bln * $upah['onepercent']); $keuntungan_semasa = $onepercentservices->getRoundedMethod($bilang_bln * $upah['onepercent']);
@@ -814,12 +819,28 @@ class Penebusan
$upahsemasa_raw = $onepercentservices->getRoundedMethod($upahsemasa_raw); $upahsemasa_raw = $onepercentservices->getRoundedMethod($upahsemasa_raw);
$keuntungan_1bln = $onepercentservices->getRoundedMethod((1 * $upah['onepercent'])+(1 * $upah['ujrah'])); $keuntungan_1bln = $onepercentservices->getRoundedMethod((1 * $upah['onepercent'])+(1 * $upah['ujrah']));
/* Keuntungan Rebet */
$upah_rebet_kira = $onepercentservices->kiraanKeuntunganRebet($gadai_data['bakipjm'],$gadai_data['nilaimarhun'],$gadai_data['kadarupah'],$gadai_data['margin_semasa']);
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah_rebet_kira['ujrah']);
$onepercent = $onepercentservices->getRoundedMethod($bilang_bln * $upah_rebet_kira['onepercent']);
$keuntungan = $ujrah + $onepercent;
$upahrebet_raw = $onepercentservices->getRoundedMethod($keuntungan);
$rebet_raw =$gadai_data['upah12'] - $transaction_keuntungan - $upahrebet_raw;
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet_raw;
$array_return = [ $array_return = [
'keuntungan_1bln' => $keuntungan_1bln, 'keuntungan_1bln' => $keuntungan_1bln,
'pendapatan' => $upahsemasa_raw, 'pendapatan' => $upahsemasa_raw,
'keuntungan' => $keuntungan_semasa, 'keuntungan' => $keuntungan_semasa,
'ujrah' => $ujrah_semasa, 'ujrah' => $ujrah_semasa,
'keuntungan_rebet' => $onepercent,
'ujrah_rebet' => $ujrah,
'tempoh' => $tempoh, 'tempoh' => $tempoh,
'harga_tebus' => $harga_tebus,
]; ];
return $array_return; return $array_return;