From 253492605d7c26224e16198a7ae70e12d91f4a91 Mon Sep 17 00:00:00 2001 From: KhatamNugraha Date: Tue, 5 Mar 2024 13:23:08 +0700 Subject: [PATCH] update query result data --- Entities/Account.php | 20 ++++++++++--- Http/Controllers/KonfirmasiBankController.php | 28 ++++++++++--------- Resources/views/exportPdf.blade.php | 4 +-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Entities/Account.php b/Entities/Account.php index 289df25..d0011a2 100644 --- a/Entities/Account.php +++ b/Entities/Account.php @@ -69,7 +69,7 @@ class Account extends Model return $data; } - public function getAccount($cif, $startDate){ + public function getAccount($cif, $arrAccount, $startDate){ // $uppercaseKodeCabang = Str::upper($kodecabang); $data = DB::connection("db2")->table("STG_DB.ACCOUNT AS AC") @@ -80,6 +80,7 @@ class Account extends Model // ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->where('INACTIV_MARKER', NULL) ->where('AC.BATCH_DATE',$startDate) + ->whereIn('AC.ACCOUNT_NUMBER', $arrAccount) ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME') ->limit(100); @@ -107,7 +108,7 @@ class Account extends Model $data = []; $data = DB::connection("db2")->table("STG_DB.AA_ARRANGEMENT") - ->select('ARRANGEMENT_ID','PRODUCT_LINE','CO_CODE','START_DATE','CURRENCY','PRODUCT_LINE','LINKED_APPL_ID') + ->select('ARRANGEMENT_ID','PRODUCT_LINE','CO_CODE','START_DATE','CURRENCY','PRODUCT','LINKED_APPL_ID') // ->join('STG_DB.ACCOUNT AS AC', 'AA.LINKED_APPL_ID', '=', 'AC.ACCOUNT_NUMBER') ->where('CUSTOMER',$cus_no) ->where('ARR_STATUS' , 'CURRENT') @@ -125,8 +126,8 @@ class Account extends Model $data = DB::connection("db2")->table("STG_DB.AA_ARR_INTEREST") ->select('FIXED_RATE') ->where('BATCH_DATE', $startDate) - ->where(DB::raw("LEFT(ID, 12)"),$arrangementId); - // ->orderBy('TERM','DESC'); + ->where(DB::raw("LEFT(ID, 12)"),$arrangementId) + ->orderBy('ID','DESC'); return $data; } @@ -152,6 +153,17 @@ class Account extends Model return $data; } + public function getSingleAccount($acNo, $date){ + $data = []; + $data = DB::connection("db2")->table("STG_DB.ACCOUNT") + ->select('ACCOUNT_NUMBER','WORKING_BALANCE') + ->where('ACCOUNT_NUMBER',$acNo) + ->where('BATCH_DATE',$date) + ->orderBy('ACCOUNT_NUMBER','DESC'); + + return $data; + } + public function getCategory($category){ $data = []; $data = DB::connection("db2")->table("STG_DB.CATEGORY") diff --git a/Http/Controllers/KonfirmasiBankController.php b/Http/Controllers/KonfirmasiBankController.php index c71ae78..c8357db 100644 --- a/Http/Controllers/KonfirmasiBankController.php +++ b/Http/Controllers/KonfirmasiBankController.php @@ -357,11 +357,11 @@ // dd($listAccount); $GetCustomer = $Account->getCustomer($request['cusNo'])->first(); - $listAccount = $Account->getAccount($request['cusNo'], $dateCore )->get(); + $listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore )->get(); + // $Arrangement = $Account->getPinjaman($request['cusNo'],$startDate)->get(); foreach ($listAccount as $key1 => $account) { $Arrangement = $Account->getPinjaman($request['cusNo'],$startDate)->get(); - //dd($Arrangement); $months = ''; $PRODUCTFIXED_RATE = '' ; $MATURITY_DATE =''; @@ -372,7 +372,7 @@ $MaturityDate = $Account->getMaturityDate($pinjaman->ARRANGEMENT_ID, $startDate )->first(); $TermAmount = $Account->getTermAmount($pinjaman->ARRANGEMENT_ID,$startDate)->first(); $FixedRate = $Account->getFixedRate($pinjaman->ARRANGEMENT_ID,$startDate)->first(); - // String asli + $balance = $Account->getSingleAccount($pinjaman->LINKED_APPL_ID,$startDate)->first(); $StringTerm = $TermAmount->TERM; // Panjang string $panjang_string = strlen($StringTerm); @@ -382,29 +382,30 @@ $string_baru = substr($StringTerm, 0, $panjang_string - $panjang_hapus); $Term1 = substr($TermAmount->TERM, -1); if($TermAmount){ - if( $Term1 = 'Y'){ + if( $Term1 == 'Y'){ $monthsInYear = 12; - $months = intval( $string_baru) * $monthsInYear; + $months = intval( $string_baru) * $monthsInYear . 'D'; $PRODUCTFIXED_RATE = $FixedRate ? $FixedRate->FIXED_RATE : ''; - $PRODUCT = $pinjaman->PRODUCT_LINE ; + $PRODUCT = $pinjaman->PRODUCT ; $MATURITY_DATE = $MaturityDate ? $MaturityDate->MATURITY_DATE : ''; $ARRANGEMENT_ID = $pinjaman->ARRANGEMENT_ID ; // $term = $days; - }elseif($Term1 = 'M') { + }elseif($Term1 == 'M') { $averageDaysInMonth = 30.44; - $months = intval($string_baru) / $averageDaysInMonth; + $months = intval($string_baru) / $averageDaysInMonth . 'D'; // return $days; }else{ $months = $TermAmount->TERM; } } + $DataPinjaman[$key2]['ARRANGEMENT_ID'] = $pinjaman->ARRANGEMENT_ID; $DataPinjaman[$key2]['START_DATE'] = $pinjaman->START_DATE; $DataPinjaman[$key2]['CURRENCY'] = $pinjaman->CURRENCY; - $DataPinjaman[$key2]['PRODUCT_LINE'] = $pinjaman->PRODUCT_LINE; - $DataPinjaman[$key2]['WORKING_BALANCE'] = number_format($account->WORKING_BALANCE, 2, ',', '.') ?? ''; - $DataPinjaman[$key2]['TERM'] = $months . ' D'; + $DataPinjaman[$key2]['PRODUCT'] = $pinjaman->PRODUCT; + $DataPinjaman[$key2]['WORKING_BALANCE'] = number_format( $balance->WORKING_BALANCE, 2, ',', '.') ?? ''; + $DataPinjaman[$key2]['TERM'] = $months ; $DataPinjaman[$key2]['FIXED_RATE'] = $FixedRate ? $FixedRate->FIXED_RATE : ''; $DataPinjaman[$key2]['MATURITY_DATE'] = $MaturityDate ? $MaturityDate->MATURITY_DATE : '' ; $DataPinjaman[$key2]['ACCOUNT_NUMBER'] = $pinjaman->LINKED_APPL_ID; @@ -412,7 +413,6 @@ } - $DataAccounts[$key1]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER; $DataAccounts[$key1]['OPENING_DATE'] = $account->OPENING_DATE; $DataAccounts[$key1]['BATCH_DATE'] = $account->BATCH_DATE; @@ -450,6 +450,8 @@ $data['infoSuratOld'] = $infoSuratOld; $data['infoSuratNew'] = $infoSuratNew; + // dd($data); + $pdf = PDF::loadview('konfirmasibank::exportPdf',['data'=>$data]); return $pdf->stream(); @@ -650,4 +652,4 @@ } - } \ No newline at end of file + } diff --git a/Resources/views/exportPdf.blade.php b/Resources/views/exportPdf.blade.php index 3167f5e..18e2f3d 100644 --- a/Resources/views/exportPdf.blade.php +++ b/Resources/views/exportPdf.blade.php @@ -135,7 +135,7 @@ {{ $val['SHORT_NAME'] }} {{ $val['OPENING_DATE'] }} {{ $val['CURRENCY'] }} - {{ $val['WORKING_BALANCE'] }} + {{ $val['WORKING_BALANCE'] }} {{ $val['TERM'] }} {{ $val['FIXED_RATE'] }} {{ $val['MATURITY_DATE'] }} @@ -178,7 +178,7 @@ @foreach ($data['DataPinjaman'] as $key1 => $pinjaman) {{ $i++ }} - {{ $pinjaman['PRODUCT_LINE'] }} + {{ $pinjaman['PRODUCT'] }} {{$pinjaman['START_DATE']}} {{ $pinjaman['CURRENCY'] }} {{$pinjaman['WORKING_BALANCE']}}