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'"
];
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'))
->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;

View File

@ -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();

View File

@ -43,15 +43,15 @@
</div>
<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>
<div class="col-sm-4">
<input type="date" class="form-control form-control-sm" min="{{$data['pastYear']}}" max="{{$data['currentYear']}}" name="startDate" clear id="startDate" placeholder="Tanggal Mulai">
<div class="col-sm-10">
<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 class="col-sm-1">
{{-- <div class="col-sm-1">
<label for="colFormLabelSm" class="col-form-label col-form-label-sm">S/D</label>
</div>
<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">
</div>
</div> --}}
</div>
<div class="text-end">
<button type="submit" class="btn btn-primary btn-sm ms-auto">Cari</button>