DONE: merged code annur with into one codebase
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
APP_NAME=Lumen
|
||||
APP_ENV=production
|
||||
APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
||||
APP_DEBUG=true
|
||||
APP_URL=https://apiannurv2.erahn.com.my
|
||||
APP_TIMEZONE=Asia/Kuala_Lumpur
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_SLACK_WEBHOOK_URL=
|
||||
|
||||
DB_CONNECTION_2=mysql
|
||||
DB_HOST_2=192.168.1.216
|
||||
DB_PORT_2=3306
|
||||
DB_DATABASE_2=annur_tampoi
|
||||
DB_USERNAME_2=spider
|
||||
DB_PASSWORD_2=arrahn@123
|
||||
|
||||
DB_CONNECTION_7=mysql
|
||||
DB_HOST_7=192.168.1.216
|
||||
DB_PORT_7=3306
|
||||
DB_DATABASE_7=master_annur
|
||||
DB_USERNAME_7=spider
|
||||
DB_PASSWORD_7=arrahn@123
|
||||
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_CONNECTION=sync
|
||||
|
||||
TENNANT_MASTER_DB=master_annur
|
||||
@@ -21,7 +21,7 @@ Tebus=penyelesaian penuh/ansuran
|
||||
docker exec -i api_arrahn_staging_mysql mysql -uroot -proot erahn_test < erahn_test.sql
|
||||
```
|
||||
|
||||
## Disable the cawangan in arrahn_master_db
|
||||
## Disable the cawangan in arrahn_master_db using feature flag
|
||||
|
||||
## Feature Flag
|
||||
1. Register the flag in api_arrahn/app/Feature.php
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App;
|
||||
class Feature
|
||||
{
|
||||
const PEMBIAYAAN_ONLINE = 'pembiayaan_online';
|
||||
const REBET_ANNUR = 'rebet_annur';
|
||||
|
||||
/**
|
||||
* Known flag keys. New features: add a constant here, then INSERT rows for pilot kodcaw.
|
||||
@@ -15,6 +16,7 @@ class Feature
|
||||
{
|
||||
return [
|
||||
self::PEMBIAYAAN_ONLINE,
|
||||
self::REBET_ANNUR,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -40,6 +42,7 @@ class Feature
|
||||
{
|
||||
return [
|
||||
self::PEMBIAYAAN_ONLINE => 'Pembiayaan Online',
|
||||
self::REBET_ANNUR => 'Rebet / diskaun Annur',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -78,7 +78,9 @@ class Gadai extends Model
|
||||
'tagkomuditi',
|
||||
'tempohbayar',
|
||||
'lelong_tawarruq',
|
||||
'tag_tebus'
|
||||
'tag_tebus',
|
||||
'kadarrebet',
|
||||
'diskaun'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -537,7 +537,7 @@ class GadaiController extends Controller
|
||||
|
||||
public function getLaporanGadai($kodcaw,$tarikh){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('cara_terima','t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent')
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('cara_terima','t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent','kadarrebet','diskaun')
|
||||
->where('t_gadai','=',$tarikh)
|
||||
->orderBy('teller')
|
||||
->orderBy('sirig')
|
||||
@@ -564,7 +564,9 @@ class GadaiController extends Controller
|
||||
"alamat1"=> $customer_info['alamat1'],
|
||||
"teller"=> $gadaiData['teller'],
|
||||
"onepercent"=> $gadaiData['onepercent'],
|
||||
"ujrah"=> $gadaiData['ujrah']
|
||||
"ujrah"=> $gadaiData['ujrah'],
|
||||
"kadarrebet"=> $gadaiData['kadarrebet'],
|
||||
"diskaun"=> $gadaiData['diskaun']
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -642,6 +644,8 @@ class GadaiController extends Controller
|
||||
"teller"=> $g->teller,
|
||||
"ujrah"=> $g->ujrah,
|
||||
"onepercent"=> $g->onepercent,
|
||||
"kadarrebet"=> $g->kadarrebet,
|
||||
"diskaun"=> $g->diskaun,
|
||||
"tagbaru"=> $g->tagbaru,
|
||||
"kodkerja"=> optional($customer)->kodkerja,
|
||||
"bangsa"=> optional($customer)->bangsa,
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Panjar;
|
||||
use App\HargaEmas;
|
||||
use App\Moratorium;
|
||||
use App\Audit;
|
||||
use App\Feature;
|
||||
use App\LookupWakil;
|
||||
|
||||
use App\StokAudit1;
|
||||
@@ -193,7 +194,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 +233,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 +276,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 +313,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 +1676,53 @@ class TebusController extends Controller
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function RebetPromoCalculation($kodcaw, Request $request)
|
||||
{
|
||||
$kodcaw = $request->kodcaw ?: $kodcaw;
|
||||
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||
return response(0);
|
||||
}
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||
|
||||
$rebet = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as db2', 'tebus.norujukan', '=', 'db2.norujukan')
|
||||
->where('tebus.t_tebus', '<=', $request->tarikh)
|
||||
->where('db2.hargajualan', '>', '0')
|
||||
->whereNotNull('db2.hargajualan')
|
||||
->sum('diskaun_rebate');
|
||||
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function PelarasanRebate($kodcaw, Request $request)
|
||||
{
|
||||
$kodcaw = $request->kodcaw ?: $kodcaw;
|
||||
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||
return response(0);
|
||||
}
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')
|
||||
->where('kodcaw', $kodcaw)
|
||||
->first();
|
||||
|
||||
$tarikhLaporan = Carbon::parse($request->tarikh)->toDateString();
|
||||
$tarikhTamatPelarasan = '2026-09-02';
|
||||
$tarikhAkhir = $tarikhLaporan > $tarikhTamatPelarasan
|
||||
? $tarikhTamatPelarasan
|
||||
: $tarikhLaporan;
|
||||
|
||||
$rebet = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as db2', 'tebus.norujukan', '=', 'db2.norujukan')
|
||||
->whereDate('tebus.t_tebus', '>=', '2025-05-13')
|
||||
->whereDate('tebus.t_tebus', '<=', $tarikhAkhir)
|
||||
->where('db2.hargajualan', '>', 0)
|
||||
->whereDate('db2.t_gadai', '>', '2023-05-21')
|
||||
->sum('tebus.diskaun_rebate');
|
||||
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function RebetCalculationLejer($kodcaw,Request $request)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
@@ -1687,6 +1738,26 @@ class TebusController extends Controller
|
||||
return response($rebet);
|
||||
}
|
||||
|
||||
public function RebetPromoCalculationLejer($kodcaw, Request $request)
|
||||
{
|
||||
$kodcaw = $request->kodcaw ?: $kodcaw;
|
||||
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||
return response(0);
|
||||
}
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $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();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class KadarRebet extends Model
|
||||
{
|
||||
protected $table = 'kadar_rebet';
|
||||
protected $connection = 'mysql7';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'pembiayaan_min',
|
||||
'pembiayaan_max',
|
||||
'kadarrebet',
|
||||
];
|
||||
}
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Support\v2;
|
||||
|
||||
use App\Feature;
|
||||
use App\KadarRebet;
|
||||
use App\KadarUpah;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class Calculation
|
||||
{
|
||||
@@ -55,7 +58,7 @@ class Calculation
|
||||
return $ujrah_sebenar;
|
||||
}
|
||||
|
||||
public function kiraanKeuntunganRebet(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
||||
public function kiraanKeuntunganRebet(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0, $kodcaw = null){
|
||||
|
||||
$this->one_percent = $this->getKadarUpah($nilaimarhun);
|
||||
|
||||
@@ -66,8 +69,59 @@ class Calculation
|
||||
$ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0;
|
||||
|
||||
$keuntungan = $onepercent + $ujrah_sebenar;
|
||||
$annur = $this->kiraanDiskaunAnnur($kodcaw, $pembiayaan, $keuntungan);
|
||||
|
||||
return ['keuntungan' => $keuntungan,'onepercent' => $onepercent, 'ujrah' => $ujrah_sebenar];
|
||||
return [
|
||||
'keuntungan' => $keuntungan,
|
||||
'onepercent' => $onepercent,
|
||||
'ujrah' => $ujrah_sebenar,
|
||||
'diskaun' => $annur['diskaun'],
|
||||
'kadarrebet' => $annur['kadarrebet'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Annur promotional discount. Other cawangan get 0 unless rebet_annur is enabled.
|
||||
*/
|
||||
public function kiraanDiskaunAnnur($kodcaw, float $pembiayaan = 0.0, float $keuntungan = 0.0)
|
||||
{
|
||||
$empty = ['kadarrebet' => 0, 'diskaun' => 0];
|
||||
|
||||
try {
|
||||
if (!$kodcaw || !Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||
return $empty;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $empty;
|
||||
}
|
||||
|
||||
$percent = $this->kiraanRebetAnnur($pembiayaan);
|
||||
if ($percent <= 0 || $keuntungan <= 0) {
|
||||
return ['kadarrebet' => $percent, 'diskaun' => 0];
|
||||
}
|
||||
|
||||
return [
|
||||
'kadarrebet' => $percent,
|
||||
'diskaun' => $this->getRoundedMethod($keuntungan * ($percent / 100)),
|
||||
];
|
||||
}
|
||||
|
||||
private function kiraanRebetAnnur(float $pembiayaan = 0.0)
|
||||
{
|
||||
try {
|
||||
if (!Schema::connection('mysql7')->hasTable('kadar_rebet')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$kadarrebet = KadarRebet::on('mysql7')
|
||||
->where('pembiayaan_min', '<=', $pembiayaan)
|
||||
->where('pembiayaan_max', '>=', $pembiayaan)
|
||||
->sum('kadarrebet');
|
||||
|
||||
return (float) $kadarrebet;
|
||||
} catch (\Exception $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function kiraanKeuntunganSebenar(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Support\v2;
|
||||
use App\Audit;
|
||||
use App\Cawangan;
|
||||
use App\Customer;
|
||||
use App\Feature;
|
||||
use App\KadarUpah;
|
||||
use App\Support\v2\Calculation;
|
||||
use Carbon\Carbon;
|
||||
@@ -137,14 +138,13 @@ if (is_null($kadar_raw)) {
|
||||
$upah12 = $onepercentservices->getRoundedMethod($upah1 * 12);
|
||||
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
|
||||
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
|
||||
$annur = $onepercentservices->kiraanDiskaunAnnur($request->kodcaw, $request->pinjaman, $keuntungan['keuntungan']);
|
||||
|
||||
$hargajualan = $request->pinjaman + $upah12;
|
||||
|
||||
$akrual = $this->kiraupahTawarruqStokAuditUjrahOnePercent(0.5,0,$kadar_raw,$request->pinjaman,$total_nilai_marhun,$margin_pinjam);
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])
|
||||
->where('norujukan','=',$norujukan)
|
||||
->update(array(
|
||||
$gadaiFields = [
|
||||
'nilaimarhun' => $total_nilai_marhun,
|
||||
'berat'=> $total_berat,
|
||||
'pinjaman' => $request->pinjaman,
|
||||
@@ -176,7 +176,23 @@ if (is_null($kadar_raw)) {
|
||||
'tagbaru' => 1,
|
||||
'tunggakanujrah' => $akrual['ujrah'],
|
||||
'tunggakanonepercent' => $akrual['keuntungan'],
|
||||
));
|
||||
];
|
||||
if (Feature::enabled($request->kodcaw, Feature::REBET_ANNUR)) {
|
||||
$requestedKadar = (float) $request->input('kadar_rebate', 0);
|
||||
$requestedDiskaun = (float) $request->input('rebate', 0);
|
||||
|
||||
if ($requestedKadar > 0 || $requestedDiskaun > 0) {
|
||||
$gadaiFields['kadarrebet'] = $requestedKadar;
|
||||
$gadaiFields['diskaun'] = $requestedDiskaun;
|
||||
} elseif (($request->transaction ?? '') === 'Daftar Gadai') {
|
||||
$gadaiFields['kadarrebet'] = $annur['kadarrebet'];
|
||||
$gadaiFields['diskaun'] = $annur['diskaun'];
|
||||
}
|
||||
}
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])
|
||||
->where('norujukan','=',$norujukan)
|
||||
->update($gadaiFields);
|
||||
|
||||
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||
|
||||
@@ -240,14 +256,15 @@ if (is_null($kadar_raw)) {
|
||||
}
|
||||
$bilang_bln = $tempoh - $gadai_data['tempohbayar'];
|
||||
|
||||
$upah = $onepercentservices->kiraanKeuntunganRebet($gadai_data['bakipjm'],$gadai_data['nilaimarhun'],$gadai_data['kadarupah'],$gadai_data['margin_semasa']);
|
||||
$upah = $onepercentservices->kiraanKeuntunganRebet($gadai_data['bakipjm'],$gadai_data['nilaimarhun'],$gadai_data['kadarupah'],$gadai_data['margin_semasa'], $this->kodcaw);
|
||||
|
||||
//$upahrebet_raw = $bilang_bln * $upah['keuntungan'];
|
||||
$onepercent = $onepercentservices->getRoundedMethod($bilang_bln * $upah['onepercent']);
|
||||
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']);
|
||||
$upahrebet_raw = $onepercent + $ujrah;
|
||||
$upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw);
|
||||
|
||||
$upahrebet_raw = $upahrebet_raw - ($upah['diskaun'] ?? 0);
|
||||
|
||||
return $upahrebet_raw;
|
||||
}
|
||||
|
||||
@@ -282,7 +299,7 @@ if (is_null($kadar_raw)) {
|
||||
|
||||
$margin_semasa = ($gadai['bakipjm'] / $gadai['nilaimarhun']) * 100;
|
||||
|
||||
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']);
|
||||
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa'], $kodcaw);
|
||||
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']);
|
||||
|
||||
$onepercentasal = $gadai['pinjaman'] * (1/100);
|
||||
@@ -319,7 +336,7 @@ if (is_null($kadar_raw)) {
|
||||
$keun = $onepercent->getRoundedMethod($onepercentasal * $bilang_bln);
|
||||
$keuntungan_rebate = $onepercent->getRoundedMethod($keuntungan['onepercent'] * $bilang_bln);
|
||||
|
||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||
$transactionUpahFields = [
|
||||
'norujukan' => $norujukan,
|
||||
'bayaran_keuntungan' => $upahsemasa,
|
||||
'bayaran_pembiayaan' => $baki_bayaran,
|
||||
@@ -333,7 +350,12 @@ if (is_null($kadar_raw)) {
|
||||
'tempoh' => $gadai['tempoh'],
|
||||
'beza_tempoh' => $bilang_bln,
|
||||
'margin_semasa' => $margin_semasa,
|
||||
]);
|
||||
];
|
||||
if (Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||
$transactionUpahFields['kadardiskaun'] = $keuntungan['diskaun'] ?? 0;
|
||||
}
|
||||
|
||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create($transactionUpahFields);
|
||||
|
||||
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([
|
||||
'kodcaw' => $old_data['kodcaw'],
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Support\v2;
|
||||
use App\Advansur;
|
||||
use App\Audit;
|
||||
use App\Cawangan;
|
||||
use App\Feature;
|
||||
use App\KadarUpah;
|
||||
use App\Support\v2\Calculation;
|
||||
use Carbon\Carbon;
|
||||
@@ -39,6 +40,32 @@ class Penebusan
|
||||
$this->cawangan_info = $cawangan_info;
|
||||
}
|
||||
|
||||
private function diskaunAnnur($kodcaw, $gadai)
|
||||
{
|
||||
try {
|
||||
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||
return 0.0;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return (float) ($gadai['diskaun'] ?? 0);
|
||||
}
|
||||
|
||||
private function tebusAnnurFields($kodcaw, $diskaun)
|
||||
{
|
||||
try {
|
||||
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||
return [];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return ['diskaun_rebate' => $diskaun];
|
||||
}
|
||||
|
||||
public function tebusTawarruq($kodcaw,$norujukan){
|
||||
$onepercentservices = new Calculation();
|
||||
|
||||
@@ -53,7 +80,8 @@ class Penebusan
|
||||
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
|
||||
|
||||
$rebet = $this->rebetselepastawarruq($kodcaw,$norujukan,$jeniskeuntungan);
|
||||
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet;
|
||||
$diskaun = $this->diskaunAnnur($kodcaw, $gadai_data);
|
||||
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet - $diskaun;
|
||||
|
||||
// $hargatebus = round($harga_tebus,PHP_ROUND_HALF_UP);
|
||||
// $hargatebus = bcdiv(round($harga_tebus,2),1,1);
|
||||
@@ -485,6 +513,8 @@ class Penebusan
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||
|
||||
$diskaun = $this->diskaunAnnur($kodcaw, $gadai);
|
||||
|
||||
//check duplicate
|
||||
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first();
|
||||
|
||||
@@ -502,7 +532,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,10 +543,15 @@ class Penebusan
|
||||
$ujrah = $array_onepercent['ujrah'];
|
||||
$onepercent = $array_onepercent['onepercent'];
|
||||
}
|
||||
|
||||
$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(array_merge([
|
||||
'kodcaw'=> $kodcaw,
|
||||
'norujukan'=> $norujukan,
|
||||
'nopelanggan' => $request->nopelanggan,
|
||||
@@ -543,7 +577,7 @@ class Penebusan
|
||||
'teller' => $request->teller,
|
||||
'ujrah' => $ujrah_rebet,
|
||||
'onepercent' => $onepercent_rebet,
|
||||
]);
|
||||
], $this->tebusAnnurFields($kodcaw, $diskaun)));
|
||||
|
||||
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
||||
'tarikh' => $current->toDateString(),
|
||||
@@ -561,7 +595,7 @@ class Penebusan
|
||||
|
||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||
'norujukan' => $norujukan,
|
||||
'bayaran_keuntungan' => $upah_tebus,
|
||||
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||
'bayaran_pembiayaan' => $gadai['bakipjm'],
|
||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||
'tarikh_bayaran'=> $current,
|
||||
@@ -651,6 +685,8 @@ class Penebusan
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||
|
||||
$diskaun = $this->diskaunAnnur($kodcaw, $gadai);
|
||||
|
||||
//check duplicate
|
||||
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->where('trans_type','=','AT')->first();
|
||||
|
||||
@@ -668,7 +704,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);
|
||||
@@ -681,6 +716,9 @@ class Penebusan
|
||||
$ujrah = $array_onepercent['ujrah'];
|
||||
$onepercent = $array_onepercent['onepercent'];
|
||||
}
|
||||
|
||||
$harga_tebus['harga'] -= $diskaun;
|
||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||
}
|
||||
|
||||
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
|
||||
@@ -690,7 +728,7 @@ class Penebusan
|
||||
|
||||
// $upah_rebet = $this->kiraUpahRebet($kodcaw,$norujukan);
|
||||
|
||||
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
||||
$create_tebus = Tebus::on($cawangan['mysql'])->create(array_merge([
|
||||
'kodcaw'=> $kodcaw,
|
||||
'norujukan'=> $norujukan,
|
||||
'nopelanggan' => $request->nopelanggan,
|
||||
@@ -716,7 +754,7 @@ class Penebusan
|
||||
'teller' => $request->teller,
|
||||
'ujrah' => $ujrah_rebet,
|
||||
'onepercent' => $onepercent_rebet,
|
||||
]);
|
||||
], $this->tebusAnnurFields($kodcaw, $diskaun)));
|
||||
|
||||
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
||||
'tarikh' => $current->toDateString(),
|
||||
@@ -734,9 +772,11 @@ class Penebusan
|
||||
|
||||
$bayaran_pembiayaan = $request->totalbayaran - $request->bakiupah;
|
||||
|
||||
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||
|
||||
$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,
|
||||
@@ -1131,12 +1171,16 @@ class Penebusan
|
||||
$onepercent_rebet = $array_onepercent_rebet['onepercent'] - $upah_rebet['onepercent'];
|
||||
$ujrah_rebet = $array_onepercent_rebet['ujrah'] - $upah_rebet['ujrah'];
|
||||
|
||||
$diskaun = $this->diskaunAnnur($kodcaw, $gadai);
|
||||
$harga_tebus['harga'] -= $diskaun;
|
||||
$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'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateKadarRebetTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Master DB (mysql7) — Annur rebet bands by pembiayaan range.
|
||||
* Empty table + feature flag off = other cawangan unchanged.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::connection('mysql7')->hasTable('kadar_rebet')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::connection('mysql7')->create('kadar_rebet', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->decimal('pembiayaan_min', 12, 2)->default(0);
|
||||
$table->decimal('pembiayaan_max', 12, 2)->default(0);
|
||||
$table->decimal('kadarrebet', 8, 4)->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection('mysql7')->dropIfExists('kadar_rebet');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddAnnurDiskaunColumns extends Migration
|
||||
{
|
||||
public function getActiveDB()
|
||||
{
|
||||
$config_db = array_keys(config('database.connections'));
|
||||
|
||||
return array_filter($config_db, function ($connection) {
|
||||
try {
|
||||
if ($connection === 'mysql7') {
|
||||
return false;
|
||||
}
|
||||
DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
if (Schema::connection($dbase)->hasTable('gadai')) {
|
||||
$addKadar = !Schema::connection($dbase)->hasColumn('gadai', 'kadarrebet');
|
||||
$addDiskaun = !Schema::connection($dbase)->hasColumn('gadai', 'diskaun');
|
||||
if ($addKadar || $addDiskaun) {
|
||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use ($addKadar, $addDiskaun) {
|
||||
if ($addKadar) {
|
||||
$table->decimal('kadarrebet', 8, 4)->nullable()->default(0);
|
||||
}
|
||||
if ($addDiskaun) {
|
||||
$table->decimal('diskaun', 12, 2)->nullable()->default(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection($dbase)->hasTable('tebus')
|
||||
&& !Schema::connection($dbase)->hasColumn('tebus', 'diskaun_rebate')
|
||||
) {
|
||||
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
|
||||
$table->decimal('diskaun_rebate', 12, 2)->nullable()->default(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection('mysql7')->hasTable('transaksi_keuntungan')
|
||||
&& !Schema::connection('mysql7')->hasColumn('transaksi_keuntungan', 'kadardiskaun')
|
||||
) {
|
||||
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||
$table->decimal('kadardiskaun', 12, 2)->nullable()->default(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
if (Schema::connection($dbase)->hasTable('gadai')) {
|
||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use ($dbase) {
|
||||
$drops = [];
|
||||
if (Schema::connection($dbase)->hasColumn('gadai', 'kadarrebet')) {
|
||||
$drops[] = 'kadarrebet';
|
||||
}
|
||||
if (Schema::connection($dbase)->hasColumn('gadai', 'diskaun')) {
|
||||
$drops[] = 'diskaun';
|
||||
}
|
||||
if ($drops) {
|
||||
$table->dropColumn($drops);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection($dbase)->hasTable('tebus')
|
||||
&& Schema::connection($dbase)->hasColumn('tebus', 'diskaun_rebate')
|
||||
) {
|
||||
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
|
||||
$table->dropColumn('diskaun_rebate');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection('mysql7')->hasTable('transaksi_keuntungan')
|
||||
&& Schema::connection('mysql7')->hasColumn('transaksi_keuntungan', 'kadardiskaun')
|
||||
) {
|
||||
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||
$table->dropColumn('kadardiskaun');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -580,6 +580,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']);
|
||||
@@ -610,6 +612,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('ModalOnlineLejer/{kodcaw}', ['uses' => 'VaultController@CalculationModalOnlineLejer']);
|
||||
$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 --//
|
||||
|
||||
Reference in New Issue
Block a user