From 6d293f42c8e6a9024632a5a71d20c2fa5fbab82e Mon Sep 17 00:00:00 2001 From: KhatamNugraha Date: Tue, 19 Mar 2024 13:43:41 +0700 Subject: [PATCH] query update --- ...23_08_15_031450_update_table_fasilitas.php | 32 -------------- Entities/Account.php | 42 +++++++++--------- Http/Controllers/KonfirmasiBankController.php | 42 +++++++++++------- Resources/views/pages/index.blade.php | 44 +++++++++++++------ .../views/pages/index_fasilitas.blade.php | 27 ++++-------- 5 files changed, 86 insertions(+), 101 deletions(-) delete mode 100644 Database/Migrations/2023_08_15_031450_update_table_fasilitas.php diff --git a/Database/Migrations/2023_08_15_031450_update_table_fasilitas.php b/Database/Migrations/2023_08_15_031450_update_table_fasilitas.php deleted file mode 100644 index 1c06d53..0000000 --- a/Database/Migrations/2023_08_15_031450_update_table_fasilitas.php +++ /dev/null @@ -1,32 +0,0 @@ -string('nomor_cif'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('fasilitas', function (Blueprint $table) { - - }); - } -}; \ No newline at end of file diff --git a/Entities/Account.php b/Entities/Account.php index d970c03..34d8648 100644 --- a/Entities/Account.php +++ b/Entities/Account.php @@ -47,15 +47,16 @@ class Account extends Model if($arrAccount == null){ $data = DB::connection("db2")->table("STG_DB.ACCOUNT AS AC") - ->selectRaw('AC.CUSTOMER_NO, MAX(INACTIV_MARKER) as INACTIV_MARKER,AC.ACCOUNT_NUMBER,MAX(AC.BATCH_DATE) AS BATCH_DATE,MAX(AC.CURRENCY)AS CURRENCY, AC.SHORT_TITLE,MAX(AC.OPENING_DATE) AS OPENING_DATE, MAX(AC.WORKING_BALANCE) AS WORKING_BALANCE, MAX(AC.CATEGORY) AS CATEGORY,CT.SHORT_NAME,CP.COMPANY_NAME') + ->selectRaw('AC.CUSTOMER_NO , AC.ACCOUNT_NUMBER ,AC.INACTIV_MARKER, AC.CATEGORY ,AC.BATCH_DATE,AC.CURRENCY,AC.SHORT_TITLE,AC.OPENING_DATE,CT.SHORT_NAME,CP.COMPANY_NAME,AC.WORKING_BALANCE') ->join('STG_DB.CATEGORY AS CT', 'AC.CATEGORY', '=', 'CT.ID') ->join('STG_DB.COMPANY AS CP', 'AC.CO_CODE', '=', 'CP.ID') ->where('CUSTOMER_NO',$cif) ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - ->where('INACTIV_MARKER', NULL) + //->where('INACTIV_MARKER', NULL) ->where('AC.BATCH_DATE',$startDate) ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) - ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME') + ->distinct() + // ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME') ->limit(100); }else{ $data = DB::connection("db2")->table("STG_DB.ACCOUNT") @@ -73,16 +74,17 @@ class Account extends Model // $uppercaseKodeCabang = Str::upper($kodecabang); $data = DB::connection("db2")->table("STG_DB.ACCOUNT AS AC") - ->selectRaw('AC.CUSTOMER_NO, MAX(INACTIV_MARKER) as INACTIV_MARKER,AC.ACCOUNT_NUMBER,MAX(AC.BATCH_DATE) AS BATCH_DATE,MAX(AC.CURRENCY)AS CURRENCY, AC.SHORT_TITLE,MAX(AC.OPENING_DATE) AS OPENING_DATE, MAX(AC.WORKING_BALANCE) AS WORKING_BALANCE, MAX(AC.CATEGORY) AS CATEGORY,CT.SHORT_NAME,CP.COMPANY_NAME') + ->selectRaw('AC.CUSTOMER_NO , AC.ACCOUNT_NUMBER ,AC.INACTIV_MARKER, AC.CATEGORY ,AC.BATCH_DATE,AC.CURRENCY,AC.SHORT_TITLE,AC.OPENING_DATE,CT.SHORT_NAME,CP.COMPANY_NAME,AC.WORKING_BALANCE') ->join('STG_DB.CATEGORY AS CT', 'AC.CATEGORY', '=', 'CT.ID') ->join('STG_DB.COMPANY AS CP', 'AC.CO_CODE', '=', 'CP.ID') ->where('CUSTOMER_NO',$cif) // ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - ->where('INACTIV_MARKER', NULL) + //->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') + ->distinct() + //->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) + //->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME') ->limit(100); return $data; } @@ -104,20 +106,16 @@ class Account extends Model } public function getPinjaman($cus_no, $dateCore){ - //dd($cus_no, $accNo, $dateCore); $data = []; - $data = DB::connection("db2")->table("STG_DB.AA_ARRANGEMENT") - ->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) - // ->whereIn(DB::raw("LINKED_APPL_ID"),$arr) - ->where('ARR_STATUS' , 'CURRENT') - // ->orderBy('TERM','DESC'); - ->where('BATCH_DATE', $dateCore) - //->where('LINKED_APPL_ID', $accNo) - // ->groupBy('ARRANGEMENT_ID','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME') - ->limit(100);; + $data = DB::connection("db2")->table("STG_DB.AA_ARRANGEMENT as AA") + ->select('AA.ARRANGEMENT_ID','AA.PRODUCT_LINE','AA.CO_CODE','AA.START_DATE','AA.CURRENCY','AA.PRODUCT','AA.LINKED_APPL_ID','AD.MATURITY_DATE') + ->join('STG_DB.AA_ACCOUNT_DETAILS AS AD', 'AA.ARRANGEMENT_ID', '=', 'AD.ID') + // ->join('STG_DB.AA_ARR_INTEREST AS AI', 'AA.ARRANGEMENT_ID', '=', DB::raw("LEFT(AI.ID, 12)")) + ->where('AA.CUSTOMER',$cus_no) + ->where('AA.BATCH_DATE', $dateCore) + ->where('AA.ARR_STATUS', '<>','CLOSE') + ->limit(100); return $data; @@ -134,21 +132,23 @@ class Account extends Model return $data; } - public function getMaturityDate($arrangementId){ + public function getMaturityDate($arrangementId,$startDate){ $data = []; $data = DB::connection("db2")->table("STG_DB.AA_ACCOUNT_DETAILS") ->select('MATURITY_DATE') ->where('ID' ,$arrangementId) + ->where('BATCH_DATE', $startDate) ->limit(100); // ->orderBy('TERM','DESC'); return $data; } - public function getTermAmount($arrangementId){ + public function getTermAmount($arrangementId, $startDate){ $data = []; $data = DB::connection("db2")->table("STG_DB.AA_ARR_TERM_AMOUNT") ->select('TERM') + ->where('BATCH_DATE', $startDate) ->where(DB::raw("LEFT(ID, 12)"),$arrangementId); // ->orderBy('TERM','DESC'); diff --git a/Http/Controllers/KonfirmasiBankController.php b/Http/Controllers/KonfirmasiBankController.php index fb4fb58..a324920 100644 --- a/Http/Controllers/KonfirmasiBankController.php +++ b/Http/Controllers/KonfirmasiBankController.php @@ -59,13 +59,12 @@ $today = Carbon::now(); // Menambahkan 1 tahun ke tanggal saat ini - $currentYear = $today->format("Y"); + $currentYear = $today->format("d-m-Y"); //get month in roman + // Menambahkan 5 tahun ke tanggal saat ini + $pastYear = $today->subYear(3)->format('d-m-Y'); + $dateRoman = $this->numberToRoman($today->format('n')); - - // Menambahkan 5 tahun ke tanggal saat ini - $pastYear = $today->subYear(3)->format('Y'); - $signer = Signer::where('status',1)->get(); $company = Company::all(); $infoSurat = Letters::orderBy('created_at','desc')->first(); @@ -96,13 +95,21 @@ { - $data = []; - $Account = new Account; - $arrAccount = []; - $startDate = Carbon::parse($request->startDate); - $dateCore = $startDate->subDays(2)->format('m/d/Y'); - $Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang, $dateCore)->get(); - return json_encode($Accounts ); + $data = []; + $Account = new Account; + $arrAccount = []; + $startDate = Carbon::parse($request->startDate); + $dateCore = $startDate->subDays(2)->format('m/d/Y'); + $Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang, $dateCore)->get(); + + foreach ($Accounts as $key => $value) { + $data[$key]['ACCOUNT_NUMBER'] = $value->ACCOUNT_NUMBER; + $data[$key]['COMPANY_NAME'] = $value->COMPANY_NAME; + $data[$key]['SHORT_NAME'] = $value->SHORT_NAME; + $data[$key]['CURRENCY'] = $value->CURRENCY; + $data[$key]['WORKING_BALANCE'] = number_format($value->WORKING_BALANCE, 2, ',', '.') ; + } + return json_encode($data ); } @@ -348,6 +355,7 @@ $arrAccount = explode("," , $request['accNo']); $startDate = Carbon::parse($request['startDate2']); $dateCore = $startDate->subDays(2); + $Account = new Account; $data = []; $DataAccounts = []; @@ -355,7 +363,8 @@ // dd($listAccount); $GetCustomer = $Account->getCustomer($request['cusNo'])->first(); $listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore )->get(); - $Arrangement = $Account->getPinjaman($request['cusNo'], $startDate)->get(); + $Arrangement = $Account->getPinjaman($request['cusNo'], $dateCore)->get(); + foreach ($listAccount as $key1 => $account) { $DataAccounts[$key1]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER; $DataAccounts[$key1]['OPENING_DATE'] = $account->OPENING_DATE; @@ -374,7 +383,7 @@ } foreach ($Arrangement as $key2 => $pinjaman) { - $MaturityDate = $Account->getMaturityDate($pinjaman->ARRANGEMENT_ID, $startDate )->first(); + // $MaturityDate = $Account->getMaturityDate($pinjaman->ARRANGEMENT_ID, $startDate )->first(); $TermAmount = $Account->getTermAmount($pinjaman->ARRANGEMENT_ID,$startDate)->first(); $FixedRate = $Account->getFixedRate($pinjaman->ARRANGEMENT_ID,$startDate)->first(); $balance = $Account->getSingleAccount($pinjaman->LINKED_APPL_ID,$startDate)->first(); @@ -384,14 +393,13 @@ $DataPinjaman[$key2]['START_DATE'] = $pinjaman->START_DATE; $DataPinjaman[$key2]['CURRENCY'] = $pinjaman->CURRENCY; $DataPinjaman[$key2]['PRODUCT'] = $pinjaman->PRODUCT_LINE; - $DataPinjaman[$key2]['WORKING_BALANCE'] = $balance->WORKING_BALANCE != null ? number_format( $balance->WORKING_BALANCE, 2, ',', '.') : 'NIHIL'; + $DataPinjaman[$key2]['WORKING_BALANCE'] = $balance != null ? number_format( $balance->WORKING_BALANCE, 2, ',', '.') : 'NIHIL'; $DataPinjaman[$key2]['TERM'] = $TermAmount ? $TermAmount->TERM : '' ; $DataPinjaman[$key2]['FIXED_RATE'] = $FixedRate ? $FixedRate->FIXED_RATE : ''; - $DataPinjaman[$key2]['MATURITY_DATE'] = $MaturityDate ? $MaturityDate->MATURITY_DATE : '' ; + $DataPinjaman[$key2]['MATURITY_DATE'] = $pinjaman->MATURITY_DATE; $DataPinjaman[$key2]['ACCOUNT_NUMBER'] = $pinjaman->LINKED_APPL_ID; } - // dd( $DataPinjaman); $ListLimits = $Account->getLimit($request['cusNo'],$request['startDate2'])->get(); diff --git a/Resources/views/pages/index.blade.php b/Resources/views/pages/index.blade.php index e9c2595..e4517fe 100644 --- a/Resources/views/pages/index.blade.php +++ b/Resources/views/pages/index.blade.php @@ -3,17 +3,11 @@ $route = explode('.', Route::currentRouteName()); @endphp - - - - {{-- - - --}} - + + @push('styles') + + + @endpush
@@ -67,7 +65,9 @@
- + + +
{{--
@@ -318,11 +318,22 @@ @push('customscript') + +