update query konfirmasi bank

This commit is contained in:
KhatamNugraha
2023-10-02 16:07:59 +07:00
parent 655d3e346c
commit 6272105c91
3 changed files with 53 additions and 85 deletions

View File

@ -38,7 +38,8 @@ class ViewAccount extends Model
'ARRANGEMENT_ID'" 'ARRANGEMENT_ID'"
]; ];
public function getSearchAccount($cif ,$arrAccount, $kodecabang, $startDate, $endDate){ public function getSearchAccount($cif ,$arrAccount, $kodecabang, $startDate){
$today = Carbon::now(); $today = Carbon::now();
$currentYear = $today->format("Y"); $currentYear = $today->format("Y");
$pastYear = $today->subYear(3)->format('Y'); $pastYear = $today->subYear(3)->format('Y');
@ -52,25 +53,20 @@ class ViewAccount extends Model
if($arrAccount == null){ if($arrAccount == null){
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") $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('CUSTOMER_NO',$cif)
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
->whereBetween('OPENING_DATE', [$startDate, $endDate]) ->where('INACTIV_MARKER', NULL)
// ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660']) ->where('BATCH_DATE', 'LIKE', "%" .$startDate."%")
->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE'); ->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{ }else{
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") $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('*') ->select('*')
->where('CUSTOMER_NO',$cif) ->where('CUSTOMER_NO',$cif)
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
->whereIn('ACCOUNT_NUMBER', $arrAccount) ->whereIn('ACCOUNT_NUMBER', $arrAccount)
->whereBetween('OPENING_DATE', [$startDate, $endDate]); ->where('OPENING_DATE', $startDate);
} }
return $data; return $data;
@ -78,58 +74,37 @@ class ViewAccount extends Model
public function getAccount($cif ,$arrAccount, $kodecabang, $startDate, $endDate){ public function getAccount($cif ,$arrAccount, $kodecabang, $startDate){
// dd($cif ,$arrAccount, $kodecabang, $startDate);
$today = Carbon::now();
$currentYear = $today->format("Y");
$pastYear = $today->subYear(3)->format('Y');
$uppercaseKodeCabang = Str::upper($kodecabang); $uppercaseKodeCabang = Str::upper($kodecabang);
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") $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('CUSTOMER_NO',$cif)
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
->whereBetween('OPENING_DATE', [$startDate, $endDate]) ->where('INACTIV_MARKER', NULL)
->whereIn('ACCOUNT_NUMBER', $arrAccount) ->where('BATCH_DATE', 'LIKE', "%" .$startDate."%")
->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101'])
->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');
// $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');
return $data; return $data;
} }
public function getAAaccount($cus_no,$acc_no){ public function getAAaccount($cust){
$data = []; $data = [];
$data = DB::connection("db2")->table("STG_DB.VW_AA_ARR_NEW")->select('ARRANGEMENT_ID','PRODUCT_LINE','PRODUCT','CUSTOMER','LINKED_APPL_ID','MATURITY_DATE') $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', $cus_no) // ->where('CUSTOMER', $cif)
->where('LINKED_APPL_ID', $acc_no) ->where('CUSTOMER', $cust)
->get(); ->where('CATEGORY', 3);
return $data; 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){ public function getPinjaman($cus_no,$arrAccount){
$data = []; $data = [];
$data = DB::connection("db2")->table("STG_DB.VW_AA_ARR_NEW") $data = DB::connection("db2")->table("STG_DB.VW_AA_ARR")
->select('*') ->select('*')
->where('CUSTOMER',$cus_no) ->where('CUSTOMER',$cus_no)
//->where(DB::raw("LEFT(CATEGORY, 1)") , 3) ->where('CATEGORY' , 3)
->whereIn('ACCOUNT_NUMBER', $arrAccount); ->whereIn('ACCOUNT_NUMBER', $arrAccount);
return $data; return $data;
@ -195,4 +170,4 @@ class ViewAccount extends Model
return $data; return $data;
} }
} }

View File

@ -48,10 +48,10 @@
// dd( $today->format()); // dd( $today->format());
// Menambahkan 1 tahun ke tanggal saat ini // Menambahkan 1 tahun ke tanggal saat ini
$currentYear = $today->format("Y-m-d"); $currentYear = $today->format("Y");
// Menambahkan 5 tahun ke tanggal saat ini // 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(); $signer = Signer::where('status',1)->get();
@ -72,19 +72,27 @@
public function getData(Request $request) public function getData(Request $request)
{ {
$data = []; $data = [];
$Account = new ViewAccount; $Account = new ViewAccount;
$arrAccount = []; $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 = ''; $maturityDate = '';
$aaID= ''; $aaID= '';
$product = ''; $product = '';
foreach ($Accounts as $key => $account) { foreach ($Accounts as $key => $account) {
$Arrangement = $Account->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER);
$data[$key]['CUSTOMER_NO'] = $account->CUSTOMER_NO; $data[$key]['CUSTOMER_NO'] = $account->CUSTOMER_NO;
$data[$key]['INACTIV_MARKER'] = $account->INACTIV_MARKER;
$data[$key]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER; $data[$key]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER;
$data[$key]['COMPANY_NAME'] = $account->COMPANY_NAME; $data[$key]['COMPANY_NAME'] = $account->COMPANY_NAME;
$data[$key]['SHORT_TITLE'] = $account->SHORT_TITLE; $data[$key]['SHORT_TITLE'] = $account->SHORT_TITLE;
@ -92,25 +100,19 @@
$data[$key]['SHORT_NAME'] = $account->SHORT_NAME; $data[$key]['SHORT_NAME'] = $account->SHORT_NAME;
$data[$key]['CURRENCY'] = $account->CURRENCY; $data[$key]['CURRENCY'] = $account->CURRENCY;
$data[$key]['OPENING_DATE'] = Carbon::parse($account->OPENING_DATE)->format('d-m-Y'); $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]['MATURITY_DATE'] = $Arrangement[$key]->MATURITY_DATE ?? 'NIHIL';
$data[$key]['PRODUCT'] = (count($Arrangement) > 0) ? $Arrangement[0]->PRODUCT : '-'; $data[$key]['PRODUCT'] = $Arrangement[$key]->PRODUCT ?? 'NIHIL';
} }
return json_encode($data );
return json_encode($data);
} }
public function postExp(Request $request){
dd($request);
}
/* /*
----- export pdf ----- ----- export pdf -----
*/ */
public function export(Request $request) { public function export(Request $request) {
if (is_null($this->user) || !$this->user->can('konfirmasibank.report')) { if (is_null($this->user) || !$this->user->can('konfirmasibank.report')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !'); abort(403, 'Sorry !! You are Unauthorized to view any master data !');
} }
@ -122,14 +124,16 @@
$DataPinjaman = []; $DataPinjaman = [];
$DataLimit = []; $DataLimit = [];
$DataAA = []; $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(); $GetCustomer = $ViewAccount->getCustomer($request['cus_no'])->first();
$Arrangement = $ViewAccount->getAAaccount($request['cus_no'])->get();
// dd( $Arrangement);
$MaturityDate = ''; $MaturityDate = '';
$product = ''; $product = '';
$AAID= ''; $AAID= '';
foreach ($listAccount as $key1 => $account) { 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]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER;
$DataAccounts[$key1]['CUSTOMER_NO'] = $account->CUSTOMER_NO; $DataAccounts[$key1]['CUSTOMER_NO'] = $account->CUSTOMER_NO;
@ -139,21 +143,10 @@
$DataAccounts[$key1]['PRODUCT'] = $product ?? '-'; $DataAccounts[$key1]['PRODUCT'] = $product ?? '-';
$DataAccounts[$key1]['COMPANY_NAME'] = $account->COMPANY_NAME; $DataAccounts[$key1]['COMPANY_NAME'] = $account->COMPANY_NAME;
$DataAccounts[$key1]['WORKING_BALANCE'] = $account->WORKING_BALANCE; $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]['MATURITY_DATE'] = (count($Arrangement) > 0) ? date('d-m-Y',strtotime($Arrangement[$key1]->MATURITY_DATE)) : 'NIHIL' ;
$DataAccounts[$key1]['ARRANGEMENT_ID'] = (count($Arrangement) > 0) ? $Arrangement[0]->ID : '-' ; $DataAccounts[$key1]['ARRANGEMENT_ID'] = (count($Arrangement) > 0) ? $Arrangement[$key1]->ARRANGEMENT_ID : 'NIHIL' ;
$ListBunga =$ViewAccount->getInterest((count($Arrangement) > 0) ? $Arrangement[0]->ID : ''); $DataAccounts[$key1]['FIXED_RATE'] = $Arrangement[$key1]->FIXED_RATE ?? 'NIHIL';
$ListTenor =$ViewAccount->getTerm((count($Arrangement) > 0) ? $Arrangement[0]->ID : ''); $DataAccounts[$key1]['TERM'] = $Arrangement[$key1]->TERM ?? 'NIHIL';
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;
}
}
} }
$ListPinjaman =$ViewAccount->getPinjaman($request['cus_no'],$arrAccount )->get(); $ListPinjaman =$ViewAccount->getPinjaman($request['cus_no'],$arrAccount )->get();
@ -530,4 +523,4 @@
} }
} }

View File

@ -43,15 +43,15 @@
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Periode <span style="color:red">*</span></label> <label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Periode <span style="color:red">*</span></label>
<div class="col-sm-4"> <div class="col-sm-10">
<input type="date" class="form-control form-control-sm" min="{{$data['pastYear']}}" max="{{$data['currentYear']}}" name="startDate" clear id="startDate" placeholder="Tanggal Mulai"> <input type="number" class="form-control form-control-sm" min="{{$data['pastYear']}}" max="{{$data['currentYear']}}" name="startDate" clear id="startDate" placeholder="Tanggal Mulai">
</div> </div>
<div class="col-sm-1"> {{-- <div class="col-sm-1">
<label for="colFormLabelSm" class="col-form-label col-form-label-sm">S/D</label> <label for="colFormLabelSm" class="col-form-label col-form-label-sm">S/D</label>
</div> </div>
<div class="col-sm-5"> <div class="col-sm-5">
<input type="date" class="form-control form-control-sm" min="{{$data['pastYear']}}" max="{{$data['currentYear']}}" name="endDate" clear id="endDate" placeholder="Tanggal Selesai"> <input type="date" class="form-control form-control-sm" min="{{$data['pastYear']}}" max="{{$data['currentYear']}}" name="endDate" clear id="endDate" placeholder="Tanggal Selesai">
</div> </div> --}}
</div> </div>
<div class="text-end"> <div class="text-end">
<button type="submit" class="btn btn-primary btn-sm ms-auto">Cari</button> <button type="submit" class="btn btn-primary btn-sm ms-auto">Cari</button>