This commit is contained in:
Afiq Zakwan
2023-12-20 08:04:51 +08:00
parent f9d812f326
commit b8ff35e804
6 changed files with 71 additions and 13 deletions
+16
View File
@@ -213,4 +213,20 @@ class MarhunController extends Controller
return response()->json($marhun);
}
public function getNilaiMarhunLatest(Request $request){
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
$marhuns = Marhun::on($cawangan['mysql'])->where('norujukan',$request->norujukan)->get();
$totalnilaimarhun = 0;
foreach($marhuns as $index=>$marhun){
$harga = HargaEmas::on('mysql7')->where('karat',$marhun->karat)->first();
$nilai_marhun = $marhun->berat * $harga->harga;
$totalnilaimarhun = $totalnilaimarhun + $nilai_marhun;
}
return response()->json($totalnilaimarhun);
}
}
@@ -53,7 +53,8 @@ class TransactionOnlineController extends Controller
'tarikh' => $current->toDateString(),
'masa' => $current->toTimeString(),
'customer_name' => $request->customer_name,
'tempohbayar'=>$sag['tempoh']
'tempohbayar'=>$sag['tempoh'],
'jenisbayaran' => $request->jenisbayaran ? $request->jenisbayaran : 'A'
]);
return response()->json($transaction,201);
@@ -77,12 +78,14 @@ class TransactionOnlineController extends Controller
->where('kodcaw','=',$transaction['kodcaw'])
->first();
$gadai_data = Gadai::on($cawangan['mysql'])->where([['norujukan',$transaction['norujukan']],['nokp',$transaction['nokp']]])->first();
if($gadai_data['hargajualan'] > 0){
$this->updateGadaiMarhunKaunter($transaction['kodcaw'],$transaction['norujukan'],$transaction['total_payment'],$transaction['paid_at'],$transaction['tempohbayar']);
}else{
$this->createAdvansur($transaction['kodcaw'],$transaction['norujukan'],$transaction['total_payment'],$transaction['paid_at']);
if($transaction->jenisbayaran == 'A'){
if($gadai_data['hargajualan'] > 0){
$this->updateGadaiMarhunKaunter($transaction['kodcaw'],$transaction['norujukan'],$transaction['total_payment'],$transaction['paid_at'],$transaction['tempohbayar']);
}else{
$this->createAdvansur($transaction['kodcaw'],$transaction['norujukan'],$transaction['total_payment'],$transaction['paid_at']);
}
}
GlDetail::on($cawangan['mysql'])->create([
'kodcaw' => $transaction['kodcaw'],
@@ -174,15 +177,14 @@ class TransactionOnlineController extends Controller
$onepercent = new OnePercentServices();
$old_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
$margin_semasa = ($gadai['bakipjm'] / $gadai['nilaimarhun']) * 100;
$keuntungan = $onepercent->kiraanKeuntunganSebenar($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$margin_semasa);
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']);
if($gadai['tagbaru'] == 1){
$upahsemasa = $keuntungan;
$upah_semasa = $keuntungan;
}
$baki_hargajualan = $gadai['bakihargajualan'] - $bayaran;
$baki_bayaran = $bayaran - $upahsemasa;
@@ -318,7 +320,7 @@ class TransactionOnlineController extends Controller
$current = Carbon::now();
$current = new Carbon();
$boolmasa = false;
$boolmasa = false;
$transaction_online = TransactionOnline::on('mysql7')->where([['norujukan',$request->norujukan],['status','PAID'],['update_status',0],['tarikh',$current->toDateString()]])->first();
$transaction_masa = TransactionOnline::on('mysql7')->where([['norujukan',$request->norujukan],['status','NOT PAID'],['tarikh',$current->toDateString()]])
+9 -2
View File
@@ -50,8 +50,15 @@ class MasterServices
return $response;
}
public function kiraUpahTawarruq($kodcaw,$norujukan){
$response = $this->engine->getUpahSebenar($norujukan);
public function kiraUpahTawarruq($kodcaw,$norujukan,$jeniskeuntungan){
if($jeniskeuntungan == 'onepercent'){
$onepercent = new OnePercentEngine($this->cawangan);
$response = $onepercent->getUpahSebenar($norujukan);
}else{
$tawarruq = new TawarruqEngine($this->cawangan);
$response = $tawarruq->getUpahSebenar($norujukan);
}
return $response;
}
+1 -1
View File
@@ -15,7 +15,7 @@ class TransactionOnline extends Model
* @var array
*/
protected $fillable = [
'nokp','reference_no','nosiri','total_payment','tarikh','masa','status','billplz_id','kodcaw','norujukan','paid_at','customer_name','update_status','update_serahan','tempohbayar','tagportal'
'nokp','reference_no','nosiri','total_payment','tarikh','masa','status','billplz_id','kodcaw','norujukan','paid_at','customer_name','update_status','update_serahan','tempohbayar','tagportal','jenisbayaran'
];
/**
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddJenisbayaranColumnInTransactionOnlineTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection('mysql7')->table('transaction_online', function (Blueprint $table) {
$table->string('jenisbayaran')->default('A');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::connection('mysql7')->table('transaction_online', function (Blueprint $table) {
$table->dropColumn(['jenisbayaran']);
});
}
}
+1
View File
@@ -162,6 +162,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('marhun/laporan/{kodcaw}/{tarikh}',['uses'=>'MarhunController@getLaporanMarhunHarian']);
$router->get('marhunterkumpul/laporan/{kodcaw}/{tarikh}',['uses'=>'MarhunController@getLaporanMarhunTerkumpul']);
$router->get('marhun/mutu/sag',['uses'=>'MarhunController@getMutuMarhun']);
$router->get('marhun/nilai/terkini',['uses'=>'MarhunController@getNilaiMarhunLatest']);
$router->get('jemas',['uses'=>'MarhunController@getAllJemas']);