From 6272105c91c1066c1109f4e60fb442057a8bda82 Mon Sep 17 00:00:00 2001 From: KhatamNugraha Date: Mon, 2 Oct 2023 16:07:59 +0700 Subject: [PATCH] update query konfirmasi bank --- Entities/ViewAccount.php | 73 ++++++------------- Http/Controllers/KonfirmasiBankController.php | 57 +++++++-------- Resources/views/pages/index.blade.php | 8 +- 3 files changed, 53 insertions(+), 85 deletions(-) diff --git a/Entities/ViewAccount.php b/Entities/ViewAccount.php index 9773192..6358954 100644 --- a/Entities/ViewAccount.php +++ b/Entities/ViewAccount.php @@ -38,7 +38,8 @@ class ViewAccount extends Model 'ARRANGEMENT_ID'" ]; - public function getSearchAccount($cif ,$arrAccount, $kodecabang, $startDate, $endDate){ + public function getSearchAccount($cif ,$arrAccount, $kodecabang, $startDate){ + $today = Carbon::now(); $currentYear = $today->format("Y"); $pastYear = $today->subYear(3)->format('Y'); @@ -52,25 +53,20 @@ class ViewAccount extends Model if($arrAccount == null){ $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") - ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) + ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','INACTIV_MARKER','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) ->where('CUSTOMER_NO',$cif) ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - ->whereBetween('OPENING_DATE', [$startDate, $endDate]) - // ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660']) - ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE'); + ->where('INACTIV_MARKER', NULL) + ->where('BATCH_DATE', 'LIKE', "%" .$startDate."%") + ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660']) + ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE','INACTIV_MARKER'); }else{ $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") - // ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE')) - // ->where('CUSTOMER_NO',$cif) - // ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - // ->whereIn('ACCOUNT_NUMBER', $arrAccount) - // ->whereBetween('OPENING_DATE', [$startDate, $endDate]) - // ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE'); ->select('*') ->where('CUSTOMER_NO',$cif) ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->whereIn('ACCOUNT_NUMBER', $arrAccount) - ->whereBetween('OPENING_DATE', [$startDate, $endDate]); + ->where('OPENING_DATE', $startDate); } return $data; @@ -78,58 +74,37 @@ class ViewAccount extends Model - public function getAccount($cif ,$arrAccount, $kodecabang, $startDate, $endDate){ - - $today = Carbon::now(); - $currentYear = $today->format("Y"); - $pastYear = $today->subYear(3)->format('Y'); + public function getAccount($cif ,$arrAccount, $kodecabang, $startDate){ + // dd($cif ,$arrAccount, $kodecabang, $startDate); $uppercaseKodeCabang = Str::upper($kodecabang); - $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") - ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) + $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") + ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','INACTIV_MARKER','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) ->where('CUSTOMER_NO',$cif) ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - ->whereBetween('OPENING_DATE', [$startDate, $endDate]) - ->whereIn('ACCOUNT_NUMBER', $arrAccount) + ->where('INACTIV_MARKER', NULL) + ->where('BATCH_DATE', 'LIKE', "%" .$startDate."%") ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) - ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE'); - - // $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") - // ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) - // ->where('CUSTOMER_NO',$cif) - // // ->whereIn('ACCOUNT_NUMBER', $arrAccount) - // ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - // ->whereBetween('OPENING_DATE', [$startDate, $endDate]) - // ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660']) - // ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE'); + ->whereIn('ACCOUNT_NUMBER', $arrAccount) + ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE','INACTIV_MARKER'); return $data; } - public function getAAaccount($cus_no,$acc_no){ + public function getAAaccount($cust){ $data = []; - $data = DB::connection("db2")->table("STG_DB.VW_AA_ARR_NEW")->select('ARRANGEMENT_ID','PRODUCT_LINE','PRODUCT','CUSTOMER','LINKED_APPL_ID','MATURITY_DATE') - ->where('CUSTOMER', $cus_no) - ->where('LINKED_APPL_ID', $acc_no) - ->get(); + $data = DB::connection("db2")->table("STG_DB.VW_AA_ARR")->select('ARRANGEMENT_ID','CATEGORY','CATEGORY_NAME','PRODUCT_LINE','PRODUCT','CUSTOMER','LINKED_APPL_ID','MATURITY_DATE') + // ->where('CUSTOMER', $cif) + ->where('CUSTOMER', $cust) + ->where('CATEGORY', 3); return $data; } - // public function getPinjaman($cus_no){ - // $data = []; - // $data = DB::connection("db2")->table("STG_DB.VW_AA_ARR") - // ->select('ARRANGEMENT_ID','LINKED_APPL_ID','CUSTOMER','PRODUCT','PRODUCT_LINE','CURRENCY',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),'BATCH_DATE', DB::raw('MAX(OPENING_DATE) AS OPENING_DATE'),'MATURITY_DATE',DB::raw('MAX(CATEGORY) AS CATEGORY'),'MATURITY_DATE','SHORT_NAME','STREET','ADDRESS','COMPANY_NAME') - // ->where('CUSTOMER',$cus_no) - // ->groupBy('ARRANGEMENT_ID','LINKED_APPL_ID','CUSTOMER','PRODUCT','PRODUCT_LINE','CURRENCY','BATCH_DATE','MATURITY_DATE','SHORT_NAME','STREET','ADDRESS','COMPANY_NAME')->get(); - // return $data; - - // } - public function getPinjaman($cus_no,$arrAccount){ $data = []; - $data = DB::connection("db2")->table("STG_DB.VW_AA_ARR_NEW") + $data = DB::connection("db2")->table("STG_DB.VW_AA_ARR") ->select('*') ->where('CUSTOMER',$cus_no) - //->where(DB::raw("LEFT(CATEGORY, 1)") , 3) + ->where('CATEGORY' , 3) ->whereIn('ACCOUNT_NUMBER', $arrAccount); return $data; @@ -195,4 +170,4 @@ class ViewAccount extends Model return $data; } -} +} \ No newline at end of file diff --git a/Http/Controllers/KonfirmasiBankController.php b/Http/Controllers/KonfirmasiBankController.php index 65eef69..102d2cc 100644 --- a/Http/Controllers/KonfirmasiBankController.php +++ b/Http/Controllers/KonfirmasiBankController.php @@ -48,10 +48,10 @@ // dd( $today->format()); // Menambahkan 1 tahun ke tanggal saat ini - $currentYear = $today->format("Y-m-d"); + $currentYear = $today->format("Y"); // Menambahkan 5 tahun ke tanggal saat ini - $pastYear = $today->subYear(3)->format('Y-m-d'); + $pastYear = $today->subYear(3)->format('Y'); $signer = Signer::where('status',1)->get(); @@ -72,19 +72,27 @@ public function getData(Request $request) { + $data = []; $Account = new ViewAccount; $arrAccount = []; + $startDate = Carbon::parse($request->startDate); + // $endtDate = Carbon::parse($request->endDate); + // $startDateCore = $startDate->subDays(2)->format("Y-m-d"); + // $endDateCore = $endDate->subDays(2)->format("Y-m-d"); - $Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang,$request->startDate,$request->endDate)->get(); + + $Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang, $request->startDate)->get(); + $Arrangement = $Account->getAAaccount($request->cif)->get(); $maturityDate = ''; $aaID= ''; $product = ''; foreach ($Accounts as $key => $account) { - $Arrangement = $Account->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER); + $data[$key]['CUSTOMER_NO'] = $account->CUSTOMER_NO; + $data[$key]['INACTIV_MARKER'] = $account->INACTIV_MARKER; $data[$key]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER; $data[$key]['COMPANY_NAME'] = $account->COMPANY_NAME; $data[$key]['SHORT_TITLE'] = $account->SHORT_TITLE; @@ -92,25 +100,19 @@ $data[$key]['SHORT_NAME'] = $account->SHORT_NAME; $data[$key]['CURRENCY'] = $account->CURRENCY; $data[$key]['OPENING_DATE'] = Carbon::parse($account->OPENING_DATE)->format('d-m-Y'); - $data[$key]['MATURITY_DATE'] = (count($Arrangement) > 0) ? date('d-m-Y',strtotime($Arrangement[0]->MATURITY_DATE)) : '-'; - $data[$key]['PRODUCT'] = (count($Arrangement) > 0) ? $Arrangement[0]->PRODUCT : '-'; + $data[$key]['MATURITY_DATE'] = $Arrangement[$key]->MATURITY_DATE ?? 'NIHIL'; + $data[$key]['PRODUCT'] = $Arrangement[$key]->PRODUCT ?? 'NIHIL'; } - - - return json_encode($data); + return json_encode($data ); } - public function postExp(Request $request){ - dd($request); - } - - /* ----- export pdf ----- */ public function export(Request $request) { + if (is_null($this->user) || !$this->user->can('konfirmasibank.report')) { abort(403, 'Sorry !! You are Unauthorized to view any master data !'); } @@ -122,14 +124,16 @@ $DataPinjaman = []; $DataLimit = []; $DataAA = []; - $listAccount = $ViewAccount->getAccount($request['cus_no'],$arrAccount,$request['kode_cabang'],$request->startDate,$request->endDate)->get(); + $listAccount = $ViewAccount->getAccount($request['cus_no'],$arrAccount,$request['kode_cabang'],$request->startDate)->get(); $GetCustomer = $ViewAccount->getCustomer($request['cus_no'])->first(); + $Arrangement = $ViewAccount->getAAaccount($request['cus_no'])->get(); + // dd( $Arrangement); $MaturityDate = ''; $product = ''; $AAID= ''; foreach ($listAccount as $key1 => $account) { - $Arrangement = $ViewAccount->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER); + //$Arrangement = $ViewAccount->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER); $DataAccounts[$key1]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER; $DataAccounts[$key1]['CUSTOMER_NO'] = $account->CUSTOMER_NO; @@ -139,21 +143,10 @@ $DataAccounts[$key1]['PRODUCT'] = $product ?? '-'; $DataAccounts[$key1]['COMPANY_NAME'] = $account->COMPANY_NAME; $DataAccounts[$key1]['WORKING_BALANCE'] = $account->WORKING_BALANCE; - $DataAccounts[$key1]['MATURITY_DATE'] = (count($Arrangement) > 0) ? date('d-m-Y',strtotime($Arrangement[0]->MATURITY_DATE)) : '-' ; - $DataAccounts[$key1]['ARRANGEMENT_ID'] = (count($Arrangement) > 0) ? $Arrangement[0]->ID : '-' ; - $ListBunga =$ViewAccount->getInterest((count($Arrangement) > 0) ? $Arrangement[0]->ID : ''); - $ListTenor =$ViewAccount->getTerm((count($Arrangement) > 0) ? $Arrangement[0]->ID : ''); - foreach ($ListBunga as $bunga) { - if (strpos($bunga->ID ,(count($Arrangement) > 0) ? $Arrangement[0]->ID : '') !== false) { - $DataAccounts[$key1]['FIXED_RATE'] = $bunga->FIXED_RATE; - - } - } - foreach ($ListTenor as $tenor) { - if (strpos($tenor->ID ,(count($Arrangement) > 0) ? $Arrangement[0]->ID : '') !== false) { - $DataAccounts[$key1]['TERM'] = $tenor->TERM; - } - } + $DataAccounts[$key1]['MATURITY_DATE'] = (count($Arrangement) > 0) ? date('d-m-Y',strtotime($Arrangement[$key1]->MATURITY_DATE)) : 'NIHIL' ; + $DataAccounts[$key1]['ARRANGEMENT_ID'] = (count($Arrangement) > 0) ? $Arrangement[$key1]->ARRANGEMENT_ID : 'NIHIL' ; + $DataAccounts[$key1]['FIXED_RATE'] = $Arrangement[$key1]->FIXED_RATE ?? 'NIHIL'; + $DataAccounts[$key1]['TERM'] = $Arrangement[$key1]->TERM ?? 'NIHIL'; } $ListPinjaman =$ViewAccount->getPinjaman($request['cus_no'],$arrAccount )->get(); @@ -530,4 +523,4 @@ } - } + } \ No newline at end of file diff --git a/Resources/views/pages/index.blade.php b/Resources/views/pages/index.blade.php index 91c389d..176df5c 100644 --- a/Resources/views/pages/index.blade.php +++ b/Resources/views/pages/index.blade.php @@ -43,15 +43,15 @@
-
- +
+
-
+ {{--
-
+
--}}