168 lines
5.6 KiB
PHP
168 lines
5.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\Konfirmasibank\Entities;
|
|
|
|
use Spatie\Activitylog\LogOptions;
|
|
use Spatie\Activitylog\Traits\LogsActivity;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Str;
|
|
use Carbon\Carbon;
|
|
|
|
|
|
class ViewAccount extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $connection = 'db2';
|
|
protected $table = 'STG_DB.VW_ACCOUNTS';
|
|
protected $primaryKey = 'CUSTOMER_NO';
|
|
|
|
//public $incrementing = false;
|
|
|
|
protected $fillable = [
|
|
"' ACCOUNT_NUMBER',
|
|
'CUSTOMER_NO',
|
|
'WORKING_BALANCE',
|
|
'BATCH_DATE',
|
|
'CO_CODE',
|
|
'ACCOUNT_TITLE_1',
|
|
'PRODUCT',
|
|
'ARR_STATUS',
|
|
'PRODUCT_LINE',
|
|
'CURRENCY',
|
|
'MATURITY_DATE',
|
|
'ARRANGEMENT_ID'"
|
|
];
|
|
|
|
public function getSearchAccount($cif ,$arrAccount, $kodecabang, $startDate){
|
|
// dd($cif ,$arrAccount, $kodecabang, $startDate);
|
|
$uppercaseKodeCabang = Str::upper($kodecabang);
|
|
$data = [];
|
|
|
|
|
|
if($arrAccount == null){
|
|
|
|
|
|
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT")
|
|
->select('*')
|
|
->where('CUSTOMER_NO',$cif)
|
|
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
|
|
->where('INACTIV_MARKER', NULL)
|
|
->where('BATCH_DATE',$startDate)
|
|
->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']);
|
|
//->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('*')
|
|
->where('CUSTOMER_NO',$cif)
|
|
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
|
|
->whereIn('ACCOUNT_NUMBER', $arrAccount)
|
|
->where('OPENING_DATE', $startDate);
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
|
|
|
|
public function getAccount($cif ,$arrAccount, $kodecabang, $startDate){
|
|
$uppercaseKodeCabang = Str::upper($kodecabang);
|
|
|
|
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT")
|
|
->select('*')
|
|
->where('CUSTOMER_NO',$cif)
|
|
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
|
|
->where('INACTIV_MARKER', NULL)
|
|
->where('BATCH_DATE', $startDate)
|
|
->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101'])
|
|
->whereIn('ACCOUNT_NUMBER', $arrAccount);
|
|
return $data;
|
|
}
|
|
|
|
public function getAAaccount($cust, $acc){
|
|
$data = [];
|
|
$data = DB::connection("db2")->table("STG_DB.VW_AA_ACCOUNT")->select('MATURITY_DATE','PRODUCT','TERM')
|
|
// ->where('CUSTOMER', $cif)
|
|
->where('CUSTOMER', $cust)
|
|
->where('LINKED_APPL_ID', $acc);
|
|
return $data;
|
|
}
|
|
|
|
|
|
public function getPinjaman($cus_no,$arrAccount, $dateCore){
|
|
|
|
$data = [];
|
|
$data = DB::connection("db2")->table("STG_DB.VW_AA_ARR")
|
|
->select('*')
|
|
->where('CUSTOMER',$cus_no)
|
|
->where('CATEGORY' , 3);
|
|
// ->where('BATCH_DATE', $dateCore);
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
public function getFasilitas($cus_no){
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.LIMIT")->select('*')->where('@ID', 'like', "%" .$cus_no. "%")->get();
|
|
return $data;
|
|
}
|
|
|
|
public function getCustomer($cus_no){
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.CUSTOMER")->select('CUSTOMER_NO','STREET','RESIDENCE','ADDRESS','SHORT_NAME')->where('CUSTOMER_NO', $cus_no);
|
|
return $data;
|
|
}
|
|
|
|
public function getTerm($arr_id){
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.AA_ARR_TERM_AMOUNT")->select(DB::raw('MAX(ID) AS ID'),DB::raw('MAX(TERM) AS TERM'))->where('ID', 'like', "%" .$arr_id."%")->orderBy('ID','DESC')->get();
|
|
return $data;
|
|
}
|
|
|
|
public function getInterest($arr_id){
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.AA_ARR_INTEREST")->select(DB::raw('MAX(ID) AS ID'),DB::raw('MAX(FIXED_RATE) AS FIXED_RATE'))->where('ID', 'like', "%".$arr_id."%")->orderBy('ID','DESC')->get();
|
|
return $data;
|
|
}
|
|
|
|
public function getCategory($category_id){
|
|
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.CATEGORY")->select('ID','SHORT_NAME')->where('ID',$category_id)->get();
|
|
return $data;
|
|
}
|
|
|
|
public function getAA($aa_id){
|
|
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.AA_ARRANGEMENENT")->select('ID')->where('ID', 'like',"%".$aa_id."%")->orderBy('ID','DESC')->get();
|
|
return $data;
|
|
}
|
|
|
|
public function getLimit($cus_id,$periode){
|
|
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.LIMIT AS LM")
|
|
->join('STG_DB.LIMIT_REFERENCE AS LR', 'LM.LIMIT_PRODUCT', '=', 'LR.ID')
|
|
->join('STG_DB.COMPANY AS CP', 'LM.CO_CODE', '=', 'CP.ID')
|
|
->join('STG_DB.CATEGORY AS CT', 'LM.LIMIT_PRODUCT', '=', 'CT.ID')
|
|
->select('LM.LIMIT_CURRENCY','LM.APPROVAL_DATE','LM.EXPIRY_DATE','LM.AVAIL_AMT','LM.BATCH_DATE','LM.EXPIRY_DATE','LR.SHORT_NAME','LR.LIMIT_PERCENTAGE','CP.COMPANY_NAME','CT.SHORT_NAME AS ACCOUNT_TYPE')
|
|
->where('LM.@ID', 'like',"%".$cus_id."%")
|
|
->where('LM.BATCH_DATE', 'like',"%".$periode."%")
|
|
->orderBy('LM.@ID','DESC')->get();
|
|
return $data;
|
|
}
|
|
|
|
public function getLimitProduct($limit_product_id){
|
|
|
|
$data = [];
|
|
$data =DB::connection("db2")->table("STG_DB.LIMIT_REFERENCE")->select('ID','SHORT_NAME','LIMIT_PERCENTAGE')->where('ID',$limit_product_id)->first();
|
|
return $data;
|
|
}
|
|
|
|
} |