auto tawarruq
This commit is contained in:
@@ -1276,6 +1276,38 @@ class AliranTunaiController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function alirantunaiTebusAutoTawarruq(Request $request){
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$gadai = Http::get(config('api.url') . '/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' .$request->norujukan)->json();
|
||||
$gadai_detail = $gadai[0];
|
||||
|
||||
$tebus = Http::get(config('api.url') . '/api/listpenebusanhistory/'. $auth_user['cawangan'],['norujukan' => $request->norujukan])->json();
|
||||
$tebus_detail = $tebus[0];
|
||||
|
||||
$getTunai2=Http::get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $tebus_detail['teller']])->json();
|
||||
|
||||
$keluar=$getTunai2['keluar'];
|
||||
$baki=$getTunai2['baki'];
|
||||
$masuk=$getTunai2['masuk'];
|
||||
$bakiawal=$getTunai2['bakiawal'];
|
||||
$pendahuluan=$getTunai2['tambah'];
|
||||
$serahan=$getTunai2['kurang'];
|
||||
$totalmasuk = 0;
|
||||
$bakiakhir = $baki;
|
||||
$totalkeluar = 0;
|
||||
|
||||
$bakiakhir = $bakiakhir + $request->totalbayaran;
|
||||
|
||||
$updateTunai=Http::put( config('api.url').'/api/updateTunaiGT/'.$auth_user['cawangan'], [
|
||||
'kodlaluan' => $tebus_detail['teller'],
|
||||
'keluar'=>$keluar,
|
||||
'masuk'=>$masuk,
|
||||
'bakiakhir'=>$bakiakhir
|
||||
]);
|
||||
}
|
||||
|
||||
public function alirantunaiUpahBknTawarruq(Request $request){
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
@@ -425,6 +425,46 @@ class GadaianController extends Controller
|
||||
return view('print.resittebusseparuh',compact('transaction','gadai','customers_info','penebusan','wakil','totaltransaction'));
|
||||
}
|
||||
|
||||
public function resitautotawarruq($id)
|
||||
{
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$gadai = Http::get(config('api.url') . '/api/gadai/norujukan/'. $id)->json();
|
||||
|
||||
$totaltransaction = 0;
|
||||
|
||||
$transaction = Http::get(config('api.url') . '/api/transaction/'. $id)->json();
|
||||
|
||||
foreach($transaction as $trans)
|
||||
{
|
||||
$totaltransaction += $trans['duit_masuk'];
|
||||
}
|
||||
|
||||
if(sizeof($gadai) != 0)
|
||||
$gadai = $gadai[0][0];
|
||||
|
||||
$customers_info = Http::get(config('api.url') . '/api/customers/'. $gadai['nokp'])->json();
|
||||
|
||||
$transaction_keuntungan = Http::get(config('api.url'). '/api/transaksi_keuntungan_latest/'. $id)->json();
|
||||
if(sizeof($customers_info) != 0)
|
||||
$customers_info = $customers_info[0];
|
||||
|
||||
|
||||
$penebusan = Http::get(config('api.url') . '/api/listpenebusanhistory/' . $auth_user['cawangan'],[ "norujukan" => $id])->json();
|
||||
|
||||
if(sizeof($penebusan) != 0)
|
||||
$penebusan = $penebusan[0];
|
||||
|
||||
$wakil = Http::get(config('api.url') . '/api/getwakil/' . $auth_user['cawangan'] . '/code/' . $penebusan['nowakil'])->json();
|
||||
|
||||
// dd($wakil);
|
||||
if(sizeof($wakil) != 0)
|
||||
$wakil = $wakil[0];
|
||||
|
||||
return view('print.resittebusautotawarruq',compact('transaction','gadai','customers_info','penebusan','wakil','totaltransaction','transaction_keuntungan'));
|
||||
}
|
||||
|
||||
public function resittebus($id)
|
||||
{
|
||||
|
||||
|
||||
@@ -697,6 +697,145 @@ class PenebusanController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function tebusautotawarruq(Request $request)
|
||||
{
|
||||
$api_url = config('api.url');
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$curent_year = substr($current->year,2,2);
|
||||
$curent_month = sprintf("%02d", $current->month);
|
||||
$current_day = sprintf("%02d", $current->day);
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
////////////////////////
|
||||
/// UPDATE TEBUS API////
|
||||
///////////////////////
|
||||
$updatetebus = Http::put(config('api.url').'/api/updateautotawarruq/'. $auth_user['cawangan'] .'/' . $request->norujukan,[
|
||||
'nopelanggan' => $request->nopelanggan,
|
||||
'jenistebus' => $request->jenistebus,
|
||||
'jbg' => $request->jbg,
|
||||
'kadarupah' => $request->kadarupah,
|
||||
'nilai_marhun' => $request->nilai_marhun,
|
||||
'pinjaman' => $request->pinjaman_lama,
|
||||
'ansuran' => $request->ansuran,
|
||||
'addpinjaman'=> $request->addpinjaman,
|
||||
'bakipinjaman' => $request->bakipinjaman,
|
||||
'bakiupah' => $request->bakiupah,
|
||||
'nowakil' => $request->nowakil,
|
||||
'historygadaian' => $request->historygadaian,
|
||||
'marhun' => $request->marhun,
|
||||
'jenisbayarantebus' => $request->jenisbayarantebus,
|
||||
'teller' => $request->teller,
|
||||
|
||||
'totalbayaran' => $request->totalbayaran,
|
||||
])->json();
|
||||
|
||||
|
||||
//////////////////////
|
||||
/// MAKING NEW SAG////
|
||||
/////////////////////
|
||||
$gadai_transaction = Http::get(config('api.url') . '/api/gadai/'. $auth_user['cawangan'] . '/' . $current->toDateString())->json();
|
||||
if($gadai_transaction){
|
||||
$new_sirig = $gadai_transaction['sirig'] + 1;
|
||||
|
||||
}else{
|
||||
$new_sirig = 1;
|
||||
}
|
||||
|
||||
$new_transaction = sprintf("%04d",$new_sirig);
|
||||
$norujukanbaru = strtoupper($auth_user['cawangan']) . $curent_year . $curent_month . $current_day . '-' .$new_transaction;
|
||||
|
||||
$gadai = Http::post(config('api.url').'/api/gadai/'.$auth_user['cawangan'],[
|
||||
'norujukan' => $norujukanbaru,
|
||||
'nopelanggan' => $request->nopelanggan,
|
||||
'nokp' => $request->noic,
|
||||
'sirig' => $new_sirig
|
||||
]);
|
||||
|
||||
|
||||
//////////////////////
|
||||
////Update SAG BARU///
|
||||
/////////////////////
|
||||
$keuntungan_sebln = $request->keuntungan_sebulan;
|
||||
$keuntungan_sebln = str_replace(',','',$keuntungan_sebln);
|
||||
|
||||
$total_nilai_marhun = $request->total_nilai_marhun;
|
||||
$margin_pinjaman = $request->pinjaman / $total_nilai_marhun;
|
||||
$kadarupah = $request->kadarkeuntungan * 100;
|
||||
$keuntungan6bulan = $keuntungan_sebln * 6;
|
||||
$keuntungan12bulan = $keuntungan_sebln * 12;
|
||||
$hargajualan = $request->pinjaman + $keuntungan12bulan;
|
||||
|
||||
|
||||
$gadai = Http::put(config('api.url').'/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' . $norujukanbaru,[
|
||||
'kodcaw' => $auth_user['cawangan'],
|
||||
'nilaimarhun' => round($total_nilai_marhun, 2),
|
||||
'berat' => round($request->total_berat, 2),
|
||||
'pinjaman' => round($request->pinjaman, 2),
|
||||
'kadarupah' => round($kadarupah, 2),
|
||||
'marhun' => $request->marhun_detail,
|
||||
'percentpinj' => $margin_pinjaman,
|
||||
'teller'=> $auth_user['name'],
|
||||
'upah6' => $keuntungan6bulan,
|
||||
'upah12' => $keuntungan12bulan,
|
||||
'hargajualan' => $hargajualan,
|
||||
'kuantiti_marhun' => $request->kuantiti_marhun
|
||||
])->json();
|
||||
|
||||
$komuditi = Http::put(config('api.url').'/api/komuditi/transaksi',[
|
||||
'unit_komuditi' => round($request->pinjaman, 2),
|
||||
'norujukan' => $norujukanbaru,
|
||||
'kodcaw' => $auth_user['cawangan'],
|
||||
'teller' => $auth_user['name']
|
||||
]);
|
||||
|
||||
////////////////////////////
|
||||
////Update History Gadaian///
|
||||
////////////////////////////
|
||||
|
||||
$updatehistorygadaian = Http::put(config('api.url').'/api/gadai/updatehistory/'. $auth_user['cawangan'] .'/' . $norujukanbaru,[
|
||||
'historygadaian' => $request->norujukan
|
||||
])->json();
|
||||
|
||||
///////////////////////////
|
||||
/// MARHUN UPDATE TABLE////
|
||||
//////////////////////////
|
||||
|
||||
|
||||
$arraymarhunbaru = [];
|
||||
|
||||
$marhunsediada = Http::get(config('api.url') . '/api/marhun/'. $request->norujukan)->json();
|
||||
|
||||
$marhunyangdiambil = $marhunsediada[0];
|
||||
foreach($marhunyangdiambil as $index=>$marhunloop)
|
||||
{
|
||||
$karatbaru = str_replace('.','-',$marhunloop['karat']);
|
||||
$hargabaru = Http::get(config('api.url') . '/api/harga_emas/'. $karatbaru)->json();
|
||||
|
||||
$nilaimarhun = (floatval($hargabaru['harga']) * floatval($marhunloop['berat']));
|
||||
|
||||
array_push($arraymarhunbaru, ["bil" => $marhunloop['bil'],"marhun" => $marhunloop['marhun'],"nota" => $marhunloop['nota'],"karat" => $marhunloop['karat'], "berat" => $marhunloop['berat'], "harga" => $hargabaru['harga'], "n_marhun" => $nilaimarhun]);
|
||||
}
|
||||
|
||||
foreach($arraymarhunbaru as $array1){
|
||||
$updatemarhun = Http::post(config('api.url').'/api/marhun/'. $auth_user['cawangan'],[
|
||||
'norujukan' => $norujukanbaru,
|
||||
'marhun' => $array1['marhun'],
|
||||
'nota' => $array1['nota'],
|
||||
'karat' => $array1['karat'],
|
||||
'berat_emas' => $array1['berat'],
|
||||
'harga' => $array1['harga'],
|
||||
'nilai_marhun' => $array1['n_marhun']
|
||||
])->json();
|
||||
}
|
||||
|
||||
$this->AliranTunaiController->alirantunaiTebusAutoTawarruq($request);
|
||||
|
||||
|
||||
return response()->json($updatemarhun,200);
|
||||
|
||||
}
|
||||
|
||||
public function tebusseparuh(Request $request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user