added penyelarasan and fix onepercent formula for lejeram
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Coordination extends Model
|
||||
{
|
||||
protected $table = 'coordination';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
|
||||
'id',
|
||||
'details',
|
||||
'glcode',
|
||||
'date',
|
||||
'reg_user_id',
|
||||
'ver_op_user_id',
|
||||
'ver_acc_user_id',
|
||||
'amount',
|
||||
'jenis'
|
||||
];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
// protected $hidden = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -3158,6 +3158,7 @@ class AdminPageController extends Controller
|
||||
|
||||
|
||||
$total = $sum_keuntungan + $sum_bayaran + $summation_ansuran;
|
||||
// $total = $sum_keuntungan + $sum_bayaran;
|
||||
return response()->json($total);
|
||||
}
|
||||
|
||||
|
||||
@@ -1699,4 +1699,18 @@ class LaporanController extends Controller
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getPenyelarasan($kodcaw,Request $request){
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$response = Coordination::on($cawangan['mysql'])->where('tarikh',$request->tarikh)->first()->toArray();
|
||||
|
||||
if($response){
|
||||
return response()->json($response,200);
|
||||
}else{
|
||||
return response('notfound');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Coordination;
|
||||
use App\Cawangan;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PenyelarasanController extends Controller
|
||||
{
|
||||
public function getPenyelarasan($kodcaw,Request $request){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw',$kodcaw)->first();
|
||||
$coordination = Coordination::on($cawangan['mysql'])->where('date',$request->tarikh)->get();
|
||||
|
||||
return response()->json($coordination);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
namespace App\Http\Controllers\Reports;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\Gadai;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Reports\OnePercentService as ReportOne;
|
||||
use App\TransaksiKeuntungan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Support\v1\Calculation as V1Calculation;
|
||||
use App\Support\v2\Calculation as V2Calculation;
|
||||
|
||||
use Lcobucci\JWT\Signer\Rsa;
|
||||
|
||||
class OnePercentController extends Controller
|
||||
@@ -89,4 +96,138 @@ class OnePercentController extends Controller
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
public function getStokAuditBackdate(Request $request){
|
||||
$cawangan = Cawangan::where('kodcaw','KB2')->first();
|
||||
$tarikh = '2024-02-01';
|
||||
|
||||
$akrual = Gadai::on($cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['t_gadai','<=',$tarikh],['sttebus','=','']])
|
||||
->orWhere([['tagpalsu','=',0],['t_update','>',$tarikh],['sttebus','!=',''],['t_gadai','<=',$tarikh]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC')
|
||||
->get();
|
||||
|
||||
$chunkSize = 100;
|
||||
$summationonepercent = 0;
|
||||
$summationujrah = 0;
|
||||
$summationupah = 0;
|
||||
$count = 0;
|
||||
$summationbkpjm = 0;
|
||||
$array_test = [];
|
||||
|
||||
$akrual->chunk($chunkSize)->each(function ($chunk) use(&$summationupah,&$array_test,$tarikh,&$summationonepercent,&$summationujrah,&$count,&$summationbkpjm) {
|
||||
// Process each chunk of items
|
||||
foreach ($chunk as $item) {
|
||||
$sagbaru = ($item->tagbaru) ? true : false;
|
||||
$trans_keun = TransaksiKeuntungan::on('mysql7')->where([['norujukan','=',$item->norujukan],['bayaran_pembiayaan','>=',0]])->whereDate('tarikh_bayaran','<=',$tarikh)->get();
|
||||
|
||||
if($sagbaru == false){
|
||||
$tawarruqservices = new V1Calculation();
|
||||
}else{
|
||||
$calculation = new V2Calculation();
|
||||
}
|
||||
|
||||
if($trans_keun->isNotEmpty()){
|
||||
$bakipinjaman = $item->pinjaman;
|
||||
$last_transaction = Carbon::parse($trans_keun->last()->tarikh_bayaran)->toDateString();
|
||||
if($last_transaction > $tarikh){
|
||||
$last_transaction = $tarikh;
|
||||
}
|
||||
|
||||
$trans_keun->each(function($trans) use(&$bakipinjaman){
|
||||
$bakipinjaman -= $trans['bayaran_pembiayaan'];
|
||||
});
|
||||
|
||||
|
||||
|
||||
$kiraan = ($sagbaru) ? $calculation->kiraanKeuntunganRebet($bakipinjaman,$item->nilaimarhun,$item->kadarupah,(($bakipinjaman/$item->nilaimarhun) * 100)) : $tawarruqservices->kiraanTawarruq($bakipinjaman,$item->kadarupah);
|
||||
$tempoh = $this->kiraanTarikhJBG($item->t_gadai,$tarikh);
|
||||
$tempoh_last_transaction = $this->kiraanTarikhJBG($item->t_gadai,$last_transaction);
|
||||
$tempoh_belum_bayar = $tempoh - $tempoh_last_transaction;
|
||||
|
||||
if($sagbaru){
|
||||
$onepercent = $calculation->getRoundedMethod($kiraan['onepercent'] * $tempoh_belum_bayar);
|
||||
$ujrah = $calculation->getRoundedMethod($kiraan['ujrah'] * $tempoh_belum_bayar);
|
||||
$summationonepercent += $onepercent;
|
||||
$summationujrah += $ujrah;
|
||||
$summationbkpjm += $bakipinjaman;
|
||||
array_push($array_test,['norujukan' => $item->norujukan,'ujrah' => $ujrah,'onepercent' => $onepercent,'pinjaman' => $item->pinjaman, 'bakipjm' => $bakipinjaman,'tempoh' => $tempoh_belum_bayar]);
|
||||
}else{
|
||||
$upahsemasa_raw = $tempoh_belum_bayar * $kiraan;
|
||||
|
||||
$upah_semasa_round = number_format($upahsemasa_raw,2);
|
||||
$upah_semasa = substr($upah_semasa_round, 0, -1);
|
||||
if(strpos($upah_semasa,',')){
|
||||
$upah_semasa = str_replace(',','',$upah_semasa);
|
||||
}
|
||||
|
||||
$summationupah += $upah_semasa;
|
||||
|
||||
array_push($array_test,['norujukan' => $item->norujukan,'upah' => $upah_semasa,'pinjaman' => $item->pinjaman, 'bakipjm' => $item->pinjaman,'tempoh' => $tempoh_belum_bayar]);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$kiraan = ($sagbaru) ? $calculation->kiraanKeuntunganRebet($item->pinjaman,$item->nilaimarhun,$item->kadarupah,(($item->pinjaman/$item->nilaimarhun) * 100)) : $tawarruqservices->kiraanTawarruq($item->pinjaman,$item->kadarupah);
|
||||
$tempoh = $this->kiraanTarikhJBG($item->t_gadai,$tarikh);
|
||||
|
||||
if($sagbaru){
|
||||
$onepercent = $calculation->getRoundedMethod($kiraan['onepercent'] * $tempoh);
|
||||
$ujrah = $calculation->getRoundedMethod($kiraan['ujrah'] * $tempoh);
|
||||
$summationonepercent += $onepercent;
|
||||
$summationujrah += $ujrah;
|
||||
$summationbkpjm += $item->pinjaman;
|
||||
|
||||
array_push($array_test,['norujukan' => $item->norujukan,'ujrah' => $ujrah,'onepercent' => $onepercent,'pinjaman' => $item->pinjaman, 'bakipjm' => $item->pinjaman,'tempoh' => $tempoh]);
|
||||
}else{
|
||||
$upahsemasa_raw = $tempoh * $kiraan;
|
||||
$upah_semasa_round = number_format($upahsemasa_raw,2);
|
||||
$upah_semasa = substr($upah_semasa_round, 0, -1);
|
||||
if(strpos($upah_semasa,',')){
|
||||
$upah_semasa = str_replace(',','',$upah_semasa);
|
||||
}
|
||||
$summationupah += $upah_semasa;
|
||||
array_push($array_test,['norujukan' => $item->norujukan,'upah' => $upah_semasa,'pinjaman' => $item->pinjaman, 'bakipjm' => $item->pinjaman,'tempoh' => $tempoh]);
|
||||
}
|
||||
|
||||
}
|
||||
$count++;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return response()->json($array_test);
|
||||
|
||||
}
|
||||
|
||||
private function kiraanTarikhJBG($tarikhgadai,$tarikh){
|
||||
$tarikh_gadai = Carbon::parse($tarikhgadai. ' 00:00:00');
|
||||
$tarikh = new Carbon($tarikh);
|
||||
$tahun_gadai = $tarikh_gadai->year;
|
||||
$bulan_gadai = $tarikh_gadai->month;
|
||||
$hari_gadai = $tarikh_gadai->day;
|
||||
$tahun_semasa = $tarikh->year;
|
||||
$bulan_semasa = $tarikh->month;
|
||||
$hari_semasa = $tarikh->day;
|
||||
if($hari_semasa >= $hari_gadai){
|
||||
$beza_hari = $hari_semasa - $hari_gadai + 1;
|
||||
}else if($hari_semasa < $hari_gadai){
|
||||
$bulan_semasa = $bulan_semasa - 1;
|
||||
$beza_hari = ($hari_semasa + 30) - $hari_gadai + 1;
|
||||
}
|
||||
$extensivemonth_gadai = 0;
|
||||
if($beza_hari >= 1 && $beza_hari <= 15){
|
||||
$extensivemonth_gadai = 0.5;
|
||||
}else if($beza_hari >= 16){
|
||||
$extensivemonth_gadai = 1;
|
||||
}else{
|
||||
$extensivemonth_gadai = 0;
|
||||
}
|
||||
$beza_tahun = $tahun_semasa - $tahun_gadai;
|
||||
$beza_bulan = ($bulan_semasa + ($beza_tahun * 12)) - $bulan_gadai;
|
||||
$tempoh_gadai = $beza_bulan + $extensivemonth_gadai;
|
||||
|
||||
return $tempoh_gadai;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1488,7 +1488,7 @@ class TebusController extends Controller
|
||||
$bukanansuran = 0;
|
||||
if($bukanansuran_data){
|
||||
foreach($bukanansuran_data as $index=>$bukanansuranData){
|
||||
$gadaiData = Gadai::on($cawangan['mysql'])->where([['norujukan',$bukanansuranData['norujukan']],['hargajualan','<>',null]])->first();
|
||||
$gadaiData = Gadai::on($cawangan['mysql'])->where([['norujukan',$bukanansuranData['norujukan']],['hargajualan','<>',null],['tagbaru',0]])->first();
|
||||
if($gadaiData){
|
||||
$bukanansuran += $bukanansuranData['keuntungan_rebet'];
|
||||
}
|
||||
@@ -1756,6 +1756,7 @@ class TebusController extends Controller
|
||||
}else if($calculate_month < 0){
|
||||
$jumlahakru = AkruNet::on($cawangan['mysql'])
|
||||
->where('bulan','<=',$intmonth_sekarang)
|
||||
->where('tahun',$year)
|
||||
->sum('jumlah');
|
||||
|
||||
return response()->json($jumlahakru);
|
||||
|
||||
@@ -71,37 +71,38 @@ class OnePercentService
|
||||
$keuntungan = TransaksiKeuntungan::on('mysql7')
|
||||
->whereIn('norujukan',$norujukan)
|
||||
->sum('onepercent_rebet');
|
||||
|
||||
}else{
|
||||
$akrual = Gadai::on($this->cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['t_gadai','<=',$start],['sttebus','=',''],['tagbaru',1]])
|
||||
->orWhere([['tagbaru',1],['tagpalsu','=',0],['t_update','>',$start],['sttebus','!=',''],['t_gadai','<=',$start]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC')
|
||||
->get();
|
||||
// $akrual = Gadai::on($this->cawangan['mysql'])
|
||||
// ->where([['tagpalsu','=',0],['t_gadai','<=',$start],['sttebus','=',''],['tagbaru',1]])
|
||||
// ->orWhere([['tagbaru',1],['tagpalsu','=',0],['t_update','>',$start],['sttebus','!=',''],['t_gadai','<=',$start]])
|
||||
// ->orderBy('t_gadai', 'ASC')
|
||||
// ->orderBy('sirig', 'ASC')
|
||||
// ->get();
|
||||
|
||||
|
||||
$keuntungan = $this->calculateTotalProfit($akrual,$start);
|
||||
$keuntungan = $keuntungan['onepercent'];
|
||||
// $keuntungan = $this->calculateTotalProfit($akrual,$start);
|
||||
// $keuntungan = $keuntungan['onepercent'];
|
||||
|
||||
$formData = [
|
||||
'kodcaw' => $this->cawangan['kodcaw'],
|
||||
'tarikh' => $start,
|
||||
];
|
||||
|
||||
$request = new Request($formData);
|
||||
|
||||
$akru = $this->calculateAccruedIncome($request);
|
||||
|
||||
$keuntungan = $akru['accrual_income_onepercent'];
|
||||
}
|
||||
return $keuntungan;
|
||||
|
||||
}else if($type == 'L'){
|
||||
$akrual = Gadai::on($this->cawangan['mysql'])->where([['sttebus',''],['tagbaru',1],['t_update','>=',$start],['t_update','<=',$end]])->sum('tunggakanonepercent');
|
||||
|
||||
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->where('t_update','>=',$start)->where('t_update','<=',$end)->pluck('norujukan');
|
||||
|
||||
|
||||
//Keuntungan Pada Bukan Bulan Yang Sama
|
||||
$keuntungan = TransaksiKeuntungan::on('mysql7')
|
||||
->whereIn('norujukan',$norujukan)
|
||||
->whereDate('tarikh_bayaran','>=',$start)
|
||||
->whereDate('tarikh_bayaran','<=',$end)
|
||||
->sum('onepercent_rebet');
|
||||
/* Keuntungan Semasa */
|
||||
$keuntungan_semasa = $this->CurrentProfit($start,$end,$this->cawangan['kodcaw']);
|
||||
$totalkeuntungan=$keuntungan_semasa['onepercent'];
|
||||
}
|
||||
|
||||
$totalkeuntungan = $keuntungan + $akrual;
|
||||
|
||||
return $totalkeuntungan;
|
||||
}
|
||||
|
||||
@@ -125,31 +126,35 @@ class OnePercentService
|
||||
->whereIn('norujukan',$norujukan)
|
||||
->sum('ujrah_rebet');
|
||||
}else{
|
||||
$akrual = Gadai::on($this->cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['t_gadai','<=',$start],['sttebus','=',''],['tagbaru',1]])
|
||||
->orWhere([['tagbaru',1],['tagpalsu','=',0],['t_update','>',$start],['sttebus','!=',''],['t_gadai','<=',$start]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC')
|
||||
->get();
|
||||
// $akrual = Gadai::on($this->cawangan['mysql'])
|
||||
// ->where([['tagpalsu','=',0],['t_gadai','<=',$start],['sttebus','=',''],['tagbaru',1]])
|
||||
// ->orWhere([['tagbaru',1],['tagpalsu','=',0],['t_update','>',$start],['sttebus','!=',''],['t_gadai','<=',$start]])
|
||||
// ->orderBy('t_gadai', 'ASC')
|
||||
// ->orderBy('sirig', 'ASC')
|
||||
// ->get();
|
||||
|
||||
$keuntungan = $this->calculateTotalProfit($akrual,$start);
|
||||
$keuntungan = $keuntungan['ujrah'];
|
||||
// $keuntungan = $this->calculateTotalProfit($akrual,$start);
|
||||
// $keuntungan = $keuntungan['ujrah'];
|
||||
|
||||
$formData = [
|
||||
'kodcaw' => $this->cawangan['kodcaw'],
|
||||
'tarikh' => $start,
|
||||
];
|
||||
|
||||
$request = new Request($formData);
|
||||
|
||||
$akru = $this->calculateAccruedIncome($request);
|
||||
|
||||
$keuntungan = $akru['accrual_income_ujrah'];
|
||||
}
|
||||
return $keuntungan;
|
||||
|
||||
}else if($type == 'L'){
|
||||
$akrual = Gadai::on($this->cawangan['mysql'])->where([['sttebus',''],['tagbaru',1],['t_update','>=',$start],['t_update','<=',$end]])->sum('tunggakanujrah');
|
||||
|
||||
$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','<=',$end)
|
||||
->sum('ujrah_rebet');;
|
||||
/* Keuntungan Semasa */
|
||||
$keuntungan_semasa = $this->CurrentProfit($start,$end,$this->cawangan['kodcaw']);
|
||||
$totalujrah = $keuntungan_semasa['ujrah'];
|
||||
}
|
||||
|
||||
$totalujrah = $ujrah + $akrual;
|
||||
return $totalujrah;
|
||||
}
|
||||
|
||||
|
||||
@@ -587,6 +587,9 @@ class Penebusan
|
||||
'duit_masuk' => $request->bakiupah,
|
||||
'created_at' => $current,
|
||||
'bakiharga' => $baki_hargajualan,
|
||||
'nowakil' => (int)$request->nowakil,
|
||||
'duitpelanggan' => isset($request->duitpelanggan) ? $request->duitpelanggan : 0,
|
||||
'bakipelanggan' => $request->bakipelanggan
|
||||
]);
|
||||
}else{
|
||||
$baki_hargajualan = $gadai['bakihargajualan'] - $request->bakipinjaman;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCoordinationTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
public function getActiveDB(){
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db,function($connection){
|
||||
try{
|
||||
if($connection == 'mysql7')
|
||||
return false;
|
||||
|
||||
$db = DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch(\Exception $e){
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return $db_connection;
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
|
||||
if (!Schema::connection($dbase)->hasTable('coordination')) {
|
||||
Schema::connection($dbase)->create('coordination', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('details',50);
|
||||
$table->string('glcode',10);
|
||||
$table->string('jenis',20);
|
||||
$table->date('date')->nullable();
|
||||
$table->integer('reg_user_id');
|
||||
$table->integer('ver_op_user_id');
|
||||
$table->integer('ver_acc_user_id');
|
||||
$table->decimal('amount', 9, 2);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
|
||||
Schema::connection($dbase)->dropIfExists('akru_net_pecahan');
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,6 @@ $router->group(['prefix' => 'api/reports'], function () use ($router) {
|
||||
$router->get('getaccrualincome/all',['uses' => 'OnePercentController@getAllCawanganAccruedIncome']);
|
||||
$router->get('getTotalCurrentProfit/{kod_cawangan}', ['uses' => 'OnePercentController@getCurrentProfit']);
|
||||
|
||||
$router->get('stokaudit/get',['uses' => 'OnePercentController@getStokAuditBackdate']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -547,6 +547,10 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('Lejer/PendapatanAkrual/{kodcaw}',['uses'=>'LaporanController@SemakanPendapatanAkrual']);
|
||||
$router->get('Backup/ImbangDuga/{kodcaw}',['uses'=>'LaporanController@SemakanBackupImbangDuga']);
|
||||
|
||||
/* Penyelarasan */
|
||||
$router->get('penyelarasan/{kodcaw}',['uses'=>'PenyelarasanController@getPenyelarasan']);
|
||||
|
||||
|
||||
//END IMBANG DUGA & LEJER AM//
|
||||
|
||||
//ADDED LEJER AM
|
||||
|
||||
Reference in New Issue
Block a user