Merge branch 'ujrah_master' of https://bitbucket.org/arrahn-pkb/api_arrahn into finadev

This commit is contained in:
Afrina Alimi
2023-12-06 23:54:41 +08:00
13 changed files with 153 additions and 56 deletions
+2 -2
View File
@@ -3143,7 +3143,7 @@ class AdminPageController extends Controller
}) })
->whereIn('trans.norujukan',$get_norujukan) ->whereIn('trans.norujukan',$get_norujukan)
->where('transaction.trans_type','T') ->where('transaction.trans_type','T')
->where('onepercent','=',0) ->where('margin_semasa','=',0)
->sum('keuntungan_rebet'); ->sum('keuntungan_rebet');
$sum_keun_ansuran = Transaction::on('mysql7') $sum_keun_ansuran = Transaction::on('mysql7')
@@ -3154,7 +3154,7 @@ class AdminPageController extends Controller
}) })
->whereIn('trans.norujukan',$get_norujukan) ->whereIn('trans.norujukan',$get_norujukan)
->where('transaction.trans_type','A') ->where('transaction.trans_type','A')
->where('onepercent','=',0) ->where('margin_semasa','=',0)
->sum('bayaran_keuntungan'); ->sum('bayaran_keuntungan');
$total = $sum_keun_tebus + $sum_keun_ansuran; $total = $sum_keun_tebus + $sum_keun_ansuran;
+9 -6
View File
@@ -399,14 +399,14 @@ class GadaiController extends Controller
// $upahrebet_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['bakipjm']); // $upahrebet_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['bakipjm']);
$upahrebet_raw = $bilang_bln * $upah['keuntungan']; $upahrebet_raw = $bilang_bln * $upah['keuntungan'];
$upah_rebet_round = number_format($upahrebet_raw,2); // $upah_rebet_round = number_format($upahrebet_raw,2);
$upah_rebet = substr($upah_rebet_round, 0, -1); // $upah_rebet = substr($upah_rebet_round, 0, -1);
if(strpos($upah_rebet,',')){ // if(strpos($upah_rebet,',')){
$upah_rebet = str_replace(',','',$upah_rebet); // $upah_rebet = str_replace(',','',$upah_rebet);
} // }
// $upah_rebet = floatval(preg_replace('/[^\d.]/', '', $upah_rebet)); // $upah_rebet = floatval(preg_replace('/[^\d.]/', '', $upah_rebet));
return $upah_rebet; return $upahrebet_raw;
} }
public function updateGadaiMarhunOnline($kodcaw,$norujukan,Request $request){ public function updateGadaiMarhunOnline($kodcaw,$norujukan,Request $request){
@@ -525,6 +525,8 @@ class GadaiController extends Controller
} }
$bilang_bln = $tempoh - $gadai['tempohbayar']; $bilang_bln = $tempoh - $gadai['tempohbayar'];
$rounded = $upahsemasa - (($keuntungan['ujrah'] * $bilang_bln) + ($onepercentasal * $bilang_bln));
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([ $transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan, 'norujukan' => $norujukan,
'bayaran_keuntungan' => $upahsemasa, 'bayaran_keuntungan' => $upahsemasa,
@@ -539,6 +541,7 @@ class GadaiController extends Controller
'tempoh' => $gadai['tempoh'], 'tempoh' => $gadai['tempoh'],
'beza_tempoh' => $bilang_bln, 'beza_tempoh' => $bilang_bln,
'margin_semasa' => $margin_semasa, 'margin_semasa' => $margin_semasa,
'rounded' => $rounded,
]); ]);
DB::connection($cawangan['mysql'])->transaction(function () use($cawangan,$baki_pinjaman,$current,$norujukan,$gadai,$baki_hargajualan,$lelong_tawarruq,$margin_semasa){ DB::connection($cawangan['mysql'])->transaction(function () use($cawangan,$baki_pinjaman,$current,$norujukan,$gadai,$baki_hargajualan,$lelong_tawarruq,$margin_semasa){
+4 -3
View File
@@ -578,9 +578,10 @@ class LelongController extends Controller
if($cawangan['tagarrahnbid'] == 1){ if($cawangan['tagarrahnbid'] == 1){
// $lelong = Http::withOptions(['verify' => true])->get('https://niklah.arrahn.com.my/api/portalApi',[ // $lelong = Http::withOptions(['verify' => true])->get('https://niklah.arrahn.com.my/api/portalApi',[
$lelong = Http::withOptions(['verify' => true])->get('http://adminbid.arrahn/api/portalApi',[ // $lelong = Http::withOptions(['verify' => true])->get('http://adminbid.arrahn/api/portalApi',[
'norujukan' => $request->norujukan // 'norujukan' => $request->norujukan
])->json(); // ])->json();
$lelong = null;
$lelong = ($lelong != null) ? $lelong['lelong'] : []; $lelong = ($lelong != null) ? $lelong['lelong'] : [];
if( $lelong == null ) if( $lelong == null )
{ {
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Reports;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Services\Reports\OnePercentService as ReportOne; use App\Services\Reports\OnePercentService as ReportOne;
use App\TransaksiKeuntungan;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class OnePercentController extends Controller class OnePercentController extends Controller
@@ -25,6 +26,14 @@ class OnePercentController extends Controller
return response()->json($response); return response()->json($response);
} }
public function getRoundedImbangDuga(string $kod_cawangan)
{
$reports = new ReportOne($kod_cawangan);
$response = $reports->getTotalRounded('B');
return response()->json($response);
}
public function getKeuntunganLejerAm(string $kod_cawangan,Request $request) public function getKeuntunganLejerAm(string $kod_cawangan,Request $request)
{ {
$reports = new ReportOne($kod_cawangan); $reports = new ReportOne($kod_cawangan);
@@ -40,4 +49,22 @@ class OnePercentController extends Controller
return response()->json($response); return response()->json($response);
} }
public function getRoundedLejerAm(string $kod_cawangan)
{
$reports = new ReportOne($kod_cawangan);
$response = $reports->getTotalRounded('B');
return response()->json($response);
}
public function getTotalRebate(Request $request){
$totalrebate = TransaksiKeuntungan::on('mysql7')
->where('norujukan',$request->norujukan)
->selectRaw('SUM(ujrah - ujrah_rebet) as ujrah')
->selectRaw('SUM(onepercent - onepercent_rebet) as onepercent')
->first();
return response()->json($totalrebate);
}
} }
+26 -22
View File
@@ -65,7 +65,6 @@ class TebusController extends Controller
if(strpos($hargatebus,',')){ if(strpos($hargatebus,',')){
$hargatebus = str_replace(',','',$hargatebus); $hargatebus = str_replace(',','',$hargatebus);
} }
return response()->json($hargatebus); return response()->json($hargatebus);
} }
@@ -89,7 +88,11 @@ class TebusController extends Controller
$hargatebus = str_replace(',','',$hargatebus); $hargatebus = str_replace(',','',$hargatebus);
} }
return $hargatebus; $rounded = $hargatebus - $harga_tebus;
Log::info([$harga_tebus,$rebet]);
$arrayharga = ['harga' => $hargatebus, 'rounded' => $rounded];
return $arrayharga;
} }
public function kiraupahTawarruq($kodcaw,$norujukan,$jeniskeuntungan){ public function kiraupahTawarruq($kodcaw,$norujukan,$jeniskeuntungan){
@@ -157,16 +160,16 @@ class TebusController extends Controller
} }
// $upah_rebet = round($upahrebet_raw ,PHP_ROUND_HALF_UP); // $upah_rebet = round($upahrebet_raw ,PHP_ROUND_HALF_UP);
$upah_rebet_round = number_format($upahrebet_raw,2); // $upah_rebet_round = number_format($upahrebet_raw,2);
if(strpos($upah_rebet_round,',')){ // if(strpos($upah_rebet_round,',')){
$upah_rebet_round = str_replace(',','',$upah_rebet_round); // $upah_rebet_round = str_replace(',','',$upah_rebet_round);
} // }
$upah_rebet = substr($upah_rebet_round, 0, -1); // $upah_rebet = substr($upah_rebet_round, 0, -1);
if(strpos($upah_rebet,',')){ // if(strpos($upah_rebet,',')){
$upah_rebet = str_replace(',','',$upah_rebet); // $upah_rebet = str_replace(',','',$upah_rebet);
} // }
return $upah_rebet; return $upahrebet_raw;
} }
public function kiraUpahRebetSebenar($kodcaw,$norujukan){ public function kiraUpahRebetSebenar($kodcaw,$norujukan){
@@ -449,15 +452,15 @@ class TebusController extends Controller
$rebet_raw =$gadai_data['upah12'] - $transaction_keuntungan - $upah_rebet; $rebet_raw =$gadai_data['upah12'] - $transaction_keuntungan - $upah_rebet;
// dd($gadai_data['upah12'],$transaction_keuntungan,$upah_rebet,$jeniskeuntungan,$rebet_raw); // dd($gadai_data['upah12'],$transaction_keuntungan,$upah_rebet,$jeniskeuntungan,$rebet_raw);
$rebet_round = bcdiv(round($rebet_raw,2),1,1); // $rebet_round = bcdiv(round($rebet_raw,2),1,1);
$rebet_round = number_format($rebet_round,2); // $rebet_round = number_format($rebet_round,2);
if(strpos($rebet_round,',')){ // if(strpos($rebet_round,',')){
$rebet_round = str_replace(',','',$rebet_round); // $rebet_round = str_replace(',','',$rebet_round);
} // }
$rebet = substr($rebet_round, 0, -1); // $rebet = substr($rebet_round, 0, -1);
return $rebet; return $rebet_raw;
} }
public function tebusUpdate($kodcaw,$norujukan,Request $request){ public function tebusUpdate($kodcaw,$norujukan,Request $request){
@@ -479,7 +482,7 @@ class TebusController extends Controller
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first(); $gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
$ujrah=0;$onepercent=0; $ujrah=0;$onepercent=0;$rounded=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);
@@ -489,7 +492,7 @@ class TebusController extends Controller
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan); $harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
$upah_tebus = $this->kiraupahTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan); $upah_tebus = $this->kiraupahTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan); $upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
$upah_rebet_sebenar = $harga_tebus - $gadai['bakipjm']; $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);
@@ -515,7 +518,7 @@ class TebusController extends Controller
'pinjaman' => $gadai['pinjaman'], 'pinjaman' => $gadai['pinjaman'],
'ansuran' => 0.00, 'ansuran' => 0.00,
'addpinjaman' => $request->addpinjaman, 'addpinjaman' => $request->addpinjaman,
'bakipjm' => $harga_tebus, 'bakipjm' => $harga_tebus['harga'],
'bakiupah' => $upah_tebus, 'bakiupah' => $upah_tebus,
'terima' => "*", 'terima' => "*",
'kodgl' => "0", 'kodgl' => "0",
@@ -557,6 +560,7 @@ class TebusController extends Controller
'margin_semasa' => ($request->jeniskeuntungan == 'onepercent') ? $margin_semasa : 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']),
'rounded' => $harga_tebus['rounded'],
]); ]);
if($request->jenistebus == 'P'){ if($request->jenistebus == 'P'){
@@ -579,7 +583,7 @@ class TebusController extends Controller
'nokp' => $gadai['nokp'], 'nokp' => $gadai['nokp'],
'teller' => $request->teller, 'teller' => $request->teller,
'kodcaw' => $kodcaw, 'kodcaw' => $kodcaw,
'duit_masuk' => $harga_tebus, 'duit_masuk' => $harga_tebus['harga'],
'created_at' => $current, 'created_at' => $current,
'bakiharga' => $baki_hargajualan, 'bakiharga' => $baki_hargajualan,
'nowakil' => (int)$request->nowakil, 'nowakil' => (int)$request->nowakil,
+46 -10
View File
@@ -4,6 +4,7 @@ namespace App\Services\Reports;
use App\Cawangan; use App\Cawangan;
use App\CawanganDetail; use App\CawanganDetail;
use App\Gadai;
use App\TransaksiKeuntungan; use App\TransaksiKeuntungan;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -13,18 +14,49 @@ class OnePercentService
{ {
// `B` stands for balance sheet and `L` stands for Ledger // `B` stands for balance sheet and `L` stands for Ledger
private $kod_cawangan;
private $cawangan;
public function __construct($kod_cawangan){
$this->kod_cawangan = $kod_cawangan;
$this->cawangan = Cawangan::where('kodcaw',$kod_cawangan)->first();
}
public function __construct($kod_cawangan)
{ public function getTotalRounded($type='B',$start = '2023-12-14',$end = '2023-12-14'){
if($type == 'B'){
$rounded = TransaksiKeuntungan::on('mysql7')
->leftJoin('transaction as trans', function($join)
{
$join->on('trans.norujukan', '=', 'transaksi_keuntungan.norujukan');
$join->on('trans.created_at', '=', 'transaksi_keuntungan.tarikh_bayaran');
})
->where('trans.trans_type','T')
->sum('transaksi_keuntungan.rounded');
}else if($type == 'L'){
$rounded = TransaksiKeuntungan::on('mysql7')
->whereDate('tarikh_bayaran','>=',$start)
->whereDate('tarikh_bayaran','<=',$end)
->sum('rounded');;
}
return $rounded;
} }
public function getTotalKeuntungan($type = 'B',$start = '2023-12-14',$end = '2023-12-14') : Float{ public function getTotalKeuntungan($type = 'B',$start = '2023-12-14',$end = '2023-12-14') : Float{
if($type == 'B'){ if($type == 'B'){
$keuntungan = TransaksiKeuntungan::on('mysql7')->sum('onepercent_rebet'); $norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->pluck('norujukan');
}else if($type == 'L'){
$keuntungan = TransaksiKeuntungan::on('mysql7') $keuntungan = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->sum('onepercent_rebet');
}else if($type == 'L'){
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->where('t_update','>=',$start)->where('t_update','<=',$end)->pluck('norujukan');
$keuntungan = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->whereDate('tarikh_bayaran','>=',$start) ->whereDate('tarikh_bayaran','>=',$start)
->whereDate('tarikh_bayaran','<=',$end) ->whereDate('tarikh_bayaran','<=',$end)
->sum('onepercent_rebet');; ->sum('onepercent_rebet');;
@@ -37,12 +69,16 @@ class OnePercentService
if($type == 'B'){ if($type == 'B'){
$ujrah = TransaksiKeuntungan::on('mysql7')->sum('ujrah_rebet'); $norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->pluck('norujukan');
// $ujrah = TransaksiKeuntungan::on('mysql7')->selectRaw('SUM(ujrah - ujrah_rebet) as total')
// ->first();
// $ujrah = $ujrah['total'];
}else if($type == 'L'){
$ujrah = TransaksiKeuntungan::on('mysql7') $ujrah = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->sum('ujrah_rebet');
}else if($type == 'L'){
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->pluck('norujukan');
$ujrah = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->whereDate('tarikh_bayaran','>=',$start) ->whereDate('tarikh_bayaran','>=',$start)
->whereDate('tarikh_bayaran','<=',$end) ->whereDate('tarikh_bayaran','<=',$end)
->sum('ujrah_rebet');; ->sum('ujrah_rebet');;
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Services;
use App\KadarUpah;
class TawarruqServices
{
protected $maks_margin = 80;
protected $one_percent = 1;
private function getCalculation(){
}
}
+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' 'norujukan','bayaran_keuntungan','tarikh_bayaran','kodcaw','bayaran_pembiayaan','keuntungan_rebet','ujrah','ujrah_rebet','onepercent','onepercent_rebet','tempoh','beza_tempoh','margin_semasa','rounded'
]; ];
/** /**
@@ -62,9 +62,11 @@ class AddOnepercentToGadaiTable extends Migration
$db_connection = $this->getActiveDB(); $db_connection = $this->getActiveDB();
foreach($db_connection as $dbase){ foreach($db_connection as $dbase){
Schema::connection($dbase)->table('gadai', function (Blueprint $table) { if (Schema::connection('mysql7')->hasColumn('ujrah', 'onepercent')){
$table->dropColumn(['kadarujrah', 'ujrah', 'onepercent','margin_semasa','tagbaru']); Schema::connection($dbase)->table('gadai', function (Blueprint $table) {
}); $table->dropColumn(['kadarujrah', 'ujrah', 'onepercent','margin_semasa','tagbaru']);
});
}
} }
} }
} }
@@ -21,6 +21,7 @@ class AddOnepercentToTransactionKeuntunganTable extends Migration
$table->decimal('tempoh', 5, 2); $table->decimal('tempoh', 5, 2);
$table->decimal('beza_tempoh', 5, 2); $table->decimal('beza_tempoh', 5, 2);
$table->decimal('margin_semasa', 5, 2); $table->decimal('margin_semasa', 5, 2);
$table->decimal('rounded', 5, 2);
}); });
} }
@@ -31,8 +32,10 @@ class AddOnepercentToTransactionKeuntunganTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) { if (Schema::connection('mysql7')->hasColumn('ujrah', 'onepercent')){
$table->dropColumn(['ujrah', 'ujrah_rebet', 'onepercent', 'onepercent_rebet', 'tempoh', 'beza_tempoh', 'margin_semasa']); Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
}); $table->dropColumn(['ujrah', 'ujrah_rebet', 'onepercent', 'onepercent_rebet', 'tempoh', 'beza_tempoh', 'margin_semasa','rounded']);
});
}
} }
} }
@@ -57,9 +57,11 @@ class AddOnepercentToTebusTable extends Migration
$db_connection = $this->getActiveDB(); $db_connection = $this->getActiveDB();
foreach($db_connection as $dbase){ foreach($db_connection as $dbase){
Schema::connection($dbase)->table('tebus', function (Blueprint $table) { if (Schema::connection($dbase)->hasColumn('ujrah', 'onepercent')){
$table->dropColumn(['ujrah', 'onepercent']); Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
}); $table->dropColumn(['ujrah', 'onepercent']);
});
}
} }
} }
} }
@@ -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'){ if($connection['database'] === 'online_arrahn2' || $connection['database'] === 'master_krk'){
return true; return true;
} }
+3
View File
@@ -12,6 +12,9 @@ $router->group(['prefix'=>'api/reports'], function () use ($router){
$router->get('onepercent/ledger/{kod_cawangan}', ['uses' => 'OnePercentController@getKeuntunganLejerAm']); $router->get('onepercent/ledger/{kod_cawangan}', ['uses' => 'OnePercentController@getKeuntunganLejerAm']);
$router->get('ujrah/balance/{kod_cawangan}', ['uses' => 'OnePercentController@getUjrahImbangDuga']); $router->get('ujrah/balance/{kod_cawangan}', ['uses' => 'OnePercentController@getUjrahImbangDuga']);
$router->get('ujrah/ledger/{kod_cawangan}', ['uses' => 'OnePercentController@getUjrahLejerAm']); $router->get('ujrah/ledger/{kod_cawangan}', ['uses' => 'OnePercentController@getUjrahLejerAm']);
$router->get('rounded/balance/{kod_cawangan}', ['uses' => 'OnePercentController@getRoundedImbangDuga']);
$router->get('rounded/ledger/{kod_cawangan}', ['uses' => 'OnePercentController@getRoundedLejerAm']);
$router->get('totalrebate', ['uses' => 'OnePercentController@getTotalRebate']);
}); });
}); });