rebate annur

This commit is contained in:
nurafrinaalimi16
2025-05-11 16:39:11 +08:00
parent 11bbfc1745
commit a2e37f5903
10 changed files with 134 additions and 35 deletions
+3 -1
View File
@@ -73,7 +73,9 @@ class Gadai extends Model
'tagkomuditi',
'tempohbayar',
'lelong_tawarruq',
'tag_tebus'
'tag_tebus',
'kadarrebet',
'diskaun'
];
/**
+4 -2
View File
@@ -570,7 +570,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')
@@ -599,7 +599,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']
]);
}
+37 -4
View File
@@ -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'],
]);
}
@@ -1638,6 +1641,21 @@ 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 RebetCalculationLejer($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
@@ -1653,6 +1671,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();
+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()
{
}
}
+17 -1
View File
@@ -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){
+8 -3
View File
@@ -99,7 +99,9 @@ class GadaiV2
$upah12 = $onepercentservices->getRoundedMethod($upah1 * 12);
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
$kadarrebet = $onepercentservices -> getRoundedMethod($keuntungan['kadarrebet']);
$kadar_rebet = $request->input('kadar_rebate');
$diskaun = $request->input('rebate');
$hargajualan = $request->pinjaman + $upah12;
@@ -139,7 +141,8 @@ class GadaiV2
'tagbaru' => 1,
'tunggakanujrah' => $akrual['ujrah'],
'tunggakanonepercent' => $akrual['keuntungan'],
'kadarrebet' => $kadarrebet,
'kadarrebet' => $kadar_rebet,
'diskaun' => $diskaun
));
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
@@ -211,6 +214,7 @@ 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;
}
@@ -248,7 +252,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);
@@ -297,6 +301,7 @@ class GadaiV2
'tempoh' => $gadai['tempoh'],
'beza_tempoh' => $bilang_bln,
'margin_semasa' => $margin_semasa,
'kadardiskaun' => $keuntungan['diskaun']
]);
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([
+19 -12
View File
@@ -39,33 +39,34 @@ class Penebusan
$this->cawangan_info = $cawangan_info;
}
public function tebusTawarruq($kodcaw,$norujukan){
public function tebusTawarruq($kodcaw, $norujukan)
{
$onepercentservices = new Calculation();
$cawangan = Cawangan::on('mysql7')
->where('kodcaw','=',$kodcaw)
->where('kodcaw', '=', $kodcaw)
->first();
$gadai_data = Gadai::on($cawangan['mysql'])
->where('norujukan','=',$norujukan)
->where('norujukan', '=', $norujukan)
->first();
$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;
// 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);
}
}
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();
@@ -516,6 +520,8 @@ class Penebusan
}
}
// Tolak diskaun dari harga tebus
$harga_tebus['harga'] -= $diskaun;
$create_tebus = Tebus::on($cawangan['mysql'])->create([
'kodcaw'=> $kodcaw,
@@ -543,6 +549,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([
+2 -1
View File
@@ -52,7 +52,8 @@ class Tebus extends Model
'pinjamanterkini',
'tarikhbyrn',
'ujrah',
'onepercent'
'onepercent',
'diskaun_rebate'
];
/**
+1 -1
View File
@@ -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'
];
/**
+2
View File
@@ -528,6 +528,7 @@ $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']);
//-- Harta Semasa --//
$router->get('PinjamanDiberi/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberi']);
@@ -557,6 +558,7 @@ $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('RebetPromoCalculationLejer/{kodcaw}',['uses'=>'TebusController@RebetPromoCalculationLejer']);
$router->get('cajlelongLejer/{kodcaw}',['uses'=>'LelongController@cajlelongcalculationLejer']);
// //-- Harta Semasa --//