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

This commit is contained in:
Azfar Arsyad
2023-12-07 12:54:59 +08:00
17 changed files with 191 additions and 66 deletions
+2
View File
@@ -9,6 +9,8 @@ class Cawangan extends Model
protected $table = 'arrahn_master_db';
protected $connection = 'mysql7';
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
+2 -2
View File
@@ -3143,7 +3143,7 @@ class AdminPageController extends Controller
})
->whereIn('trans.norujukan',$get_norujukan)
->where('transaction.trans_type','T')
->where('onepercent','=',0)
->where('margin_semasa','=',0)
->sum('keuntungan_rebet');
$sum_keun_ansuran = Transaction::on('mysql7')
@@ -3154,7 +3154,7 @@ class AdminPageController extends Controller
})
->whereIn('trans.norujukan',$get_norujukan)
->where('transaction.trans_type','A')
->where('onepercent','=',0)
->where('margin_semasa','=',0)
->sum('bayaran_keuntungan');
$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 * $upah['keuntungan'];
$upah_rebet_round = number_format($upahrebet_raw,2);
$upah_rebet = substr($upah_rebet_round, 0, -1);
if(strpos($upah_rebet,',')){
$upah_rebet = str_replace(',','',$upah_rebet);
}
// $upah_rebet_round = number_format($upahrebet_raw,2);
// $upah_rebet = substr($upah_rebet_round, 0, -1);
// if(strpos($upah_rebet,',')){
// $upah_rebet = str_replace(',','',$upah_rebet);
// }
// $upah_rebet = floatval(preg_replace('/[^\d.]/', '', $upah_rebet));
return $upah_rebet;
return $upahrebet_raw;
}
public function updateGadaiMarhunOnline($kodcaw,$norujukan,Request $request){
@@ -525,6 +525,8 @@ class GadaiController extends Controller
}
$bilang_bln = $tempoh - $gadai['tempohbayar'];
$rounded = $upahsemasa - (($keuntungan['ujrah'] * $bilang_bln) + ($onepercentasal * $bilang_bln));
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan,
'bayaran_keuntungan' => $upahsemasa,
@@ -539,6 +541,7 @@ class GadaiController extends Controller
'tempoh' => $gadai['tempoh'],
'beza_tempoh' => $bilang_bln,
'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){
+4 -3
View File
@@ -578,9 +578,10 @@ class LelongController extends Controller
if($cawangan['tagarrahnbid'] == 1){
// $lelong = Http::withOptions(['verify' => true])->get('https://niklah.arrahn.com.my/api/portalApi',[
$lelong = Http::withOptions(['verify' => true])->get('http://adminbid.arrahn/api/portalApi',[
'norujukan' => $request->norujukan
])->json();
// $lelong = Http::withOptions(['verify' => true])->get('http://adminbid.arrahn/api/portalApi',[
// 'norujukan' => $request->norujukan
// ])->json();
$lelong = null;
$lelong = ($lelong != null) ? $lelong['lelong'] : [];
if( $lelong == null )
{
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Reports;
use App\Http\Controllers\Controller;
use App\Services\Reports\OnePercentService as ReportOne;
use App\TransaksiKeuntungan;
use Illuminate\Http\Request;
class OnePercentController extends Controller
@@ -25,6 +26,14 @@ class OnePercentController extends Controller
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)
{
$reports = new ReportOne($kod_cawangan);
@@ -40,4 +49,22 @@ class OnePercentController extends Controller
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);
}
}
+27 -23
View File
@@ -65,7 +65,6 @@ class TebusController extends Controller
if(strpos($hargatebus,',')){
$hargatebus = str_replace(',','',$hargatebus);
}
return response()->json($hargatebus);
}
@@ -89,7 +88,11 @@ class TebusController extends Controller
$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){
@@ -157,16 +160,16 @@ class TebusController extends Controller
}
// $upah_rebet = round($upahrebet_raw ,PHP_ROUND_HALF_UP);
$upah_rebet_round = number_format($upahrebet_raw,2);
if(strpos($upah_rebet_round,',')){
$upah_rebet_round = str_replace(',','',$upah_rebet_round);
}
$upah_rebet = substr($upah_rebet_round, 0, -1);
if(strpos($upah_rebet,',')){
$upah_rebet = str_replace(',','',$upah_rebet);
}
// $upah_rebet_round = number_format($upahrebet_raw,2);
// if(strpos($upah_rebet_round,',')){
// $upah_rebet_round = str_replace(',','',$upah_rebet_round);
// }
// $upah_rebet = substr($upah_rebet_round, 0, -1);
// if(strpos($upah_rebet,',')){
// $upah_rebet = str_replace(',','',$upah_rebet);
// }
return $upah_rebet;
return $upahrebet_raw;
}
public function kiraUpahRebetSebenar($kodcaw,$norujukan){
@@ -449,15 +452,15 @@ class TebusController extends Controller
$rebet_raw =$gadai_data['upah12'] - $transaction_keuntungan - $upah_rebet;
// dd($gadai_data['upah12'],$transaction_keuntungan,$upah_rebet,$jeniskeuntungan,$rebet_raw);
$rebet_round = bcdiv(round($rebet_raw,2),1,1);
$rebet_round = number_format($rebet_round,2);
// $rebet_round = bcdiv(round($rebet_raw,2),1,1);
// $rebet_round = number_format($rebet_round,2);
if(strpos($rebet_round,',')){
$rebet_round = str_replace(',','',$rebet_round);
}
$rebet = substr($rebet_round, 0, -1);
return $rebet;
// if(strpos($rebet_round,',')){
// $rebet_round = str_replace(',','',$rebet_round);
// }
// $rebet = substr($rebet_round, 0, -1);
return $rebet_raw;
}
public function tebusUpdate($kodcaw,$norujukan,Request $request){
@@ -479,7 +482,7 @@ class TebusController extends Controller
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
$ujrah=0;$onepercent=0;
$ujrah=0;$onepercent=0;$rounded=0;
if($gadai['hargajualan'] == null){
$harga_tebus = $this->hargaTebusNotTawarruq($kodcaw,$norujukan);
$upah_tebus = $this->kiraUpahNotTawarruq($kodcaw,$norujukan);
@@ -489,7 +492,7 @@ class TebusController extends Controller
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
$upah_tebus = $this->kiraupahTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
$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'){
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
@@ -515,7 +518,7 @@ class TebusController extends Controller
'pinjaman' => $gadai['pinjaman'],
'ansuran' => 0.00,
'addpinjaman' => $request->addpinjaman,
'bakipjm' => $harga_tebus,
'bakipjm' => $harga_tebus['harga'],
'bakiupah' => $upah_tebus,
'terima' => "*",
'kodgl' => "0",
@@ -557,6 +560,7 @@ class TebusController extends Controller
'margin_semasa' => ($request->jeniskeuntungan == 'onepercent') ? $margin_semasa : 0,
'tempoh' => $gadai['tempoh'],
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']),
'rounded' => $harga_tebus['rounded'],
]);
if($request->jenistebus == 'P'){
@@ -579,7 +583,7 @@ class TebusController extends Controller
'nokp' => $gadai['nokp'],
'teller' => $request->teller,
'kodcaw' => $kodcaw,
'duit_masuk' => $harga_tebus,
'duit_masuk' => $harga_tebus['harga'],
'created_at' => $current,
'bakiharga' => $baki_hargajualan,
'nowakil' => (int)$request->nowakil,
+8 -5
View File
@@ -60,12 +60,15 @@ class SMSPelangganSAGLAMAbysag extends Job
if($tarikhmatang > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum '.$tarikhmatangnew.'.';
}elseif($tarikhmatang < $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatangnew.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
}else
if($tarikhmatang1 < $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatangnew.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';
}
}elseif($this->lelong_tawarruq == '0'){
if($tarikhmatang1 > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum '.$tarikhmatang1new.'.';
}elseif($tarikhmatang1 > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatang1new.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
}elseif($tarikhmatang1 <= $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatang1new.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';
}
}
if(env('APP_ENV') != 'production'){
$mobile_no = env('ADMIN_PHONE_NUMBER');
+8 -5
View File
@@ -60,12 +60,15 @@ class WhatsappPelangganSAGLAMAbysag extends Job
if($tarikhmatang > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum *'.$tarikhmatangnew.'*.';
}elseif($tarikhmatang < $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatangnew.'*, Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
}else
if($tarikhmatang1 < $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatangnew.'*, Sila perbaharui SAG anda di cawangan Ar-Rahn.';
}
}elseif($this->lelong_tawarruq == '0'){
if($tarikhmatang1 > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum *'.$tarikhmatang1new.'*.';
}elseif($tarikhmatang1 > $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatang1new.'*, Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
}elseif($tarikhmatang1 <= $today){
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatang1new.'*, Sila perbaharui SAG anda di cawangan Ar-Rahn.';
}
}
if(env('APP_ENV') != 'production'){
$mobile_no = env('ADMIN_PHONE_NUMBER');
+47 -11
View File
@@ -4,6 +4,7 @@ namespace App\Services\Reports;
use App\Cawangan;
use App\CawanganDetail;
use App\Gadai;
use App\TransaksiKeuntungan;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
@@ -13,18 +14,49 @@ class OnePercentService
{
// `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'){
$keuntungan = TransaksiKeuntungan::on('mysql7')->sum('onepercent_rebet');
}else if($type == 'L'){
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->pluck('norujukan');
$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','<=',$end)
->sum('onepercent_rebet');;
@@ -37,12 +69,16 @@ class OnePercentService
if($type == 'B'){
$ujrah = TransaksiKeuntungan::on('mysql7')->sum('ujrah_rebet');
// $ujrah = TransaksiKeuntungan::on('mysql7')->selectRaw('SUM(ujrah - ujrah_rebet) as total')
// ->first();
// $ujrah = $ujrah['total'];
}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)
->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','<=',$end)
->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
*/
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();
foreach($db_connection as $dbase){
Schema::connection($dbase)->table('gadai', function (Blueprint $table) {
$table->dropColumn(['kadarujrah', 'ujrah', 'onepercent','margin_semasa','tagbaru']);
});
if (Schema::connection('mysql7')->hasColumn('ujrah', 'onepercent')){
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('beza_tempoh', 5, 2);
$table->decimal('margin_semasa', 5, 2);
$table->decimal('rounded', 5, 2);
});
}
@@ -31,8 +32,10 @@ class AddOnepercentToTransactionKeuntunganTable extends Migration
*/
public function down()
{
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
$table->dropColumn(['ujrah', 'ujrah_rebet', 'onepercent', 'onepercent_rebet', 'tempoh', 'beza_tempoh', 'margin_semasa']);
});
if (Schema::connection('mysql7')->hasColumn('ujrah', 'onepercent')){
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();
foreach($db_connection as $dbase){
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
$table->dropColumn(['ujrah', 'onepercent']);
});
if (Schema::connection($dbase)->hasColumn('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) {
if($connection['database'] === 'online_arrahn' || $connection['database'] === 'master_krk'){
if($connection['database'] === 'online_arrahn2' || $connection['database'] === 'master_krk'){
return true;
}
+20
View File
@@ -0,0 +1,20 @@
<?php
use App\Cawangan;
use Illuminate\Database\Seeder;
class GroupIdSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
Cawangan::on('mysql7')->where('tagarrahnbid', '=', 1)->update([
'group_id' => 1,
]);
}
}
+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('ujrah/balance/{kod_cawangan}', ['uses' => 'OnePercentController@getUjrahImbangDuga']);
$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']);
});
});