Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import { FormsModule } from '@angular/forms';
- import { FormGroup, FormControl, FormBuilder, Validators,ReactiveFormsModule } from '@angular/forms';
- import { Http, Headers, RequestOptions } from '@angular/http';
- import { Router } from "@angular/router";
- import { AppDecryptMe } from "../../app.DecryptMe";
- import { GetusercredService } from '../../getusercred.service';
- import { CheckusercredService } from '../../checkusercred.service';
- import { CallServiceFunction } from '../../callServiceFunction';
- import { printECLCalculationPdf } from '../../Reporting/ECLcalculationprintpdf';
- import { DatePipe } from '@angular/common';
- import { printCreditLossxls } from '../../Reporting/creditloss-xls';
- import { markDirty } from '@angular/core/src/render3';
- import { printECLCalculationXLS } from '../../Reporting/ECLCalculation-xls';
- import { creditLossReportXLS } from '../../Reporting/creditLossPrintXls';
- import { conditionallyCreateMapObjectLiteral } from '@angular/compiler/src/render3/view/util';
- declare function showSwal(e):any;
- declare var $ :any;
- @Component({
- selector: 'app-eclcalculation',
- templateUrl: './eclcalculation.component.html',
- styleUrls: ['./eclcalculation.component.css'],
- providers: [DatePipe,printECLCalculationPdf,printCreditLossxls,printECLCalculationXLS,creditLossReportXLS]
- })
- export class EclcalculationComponent implements OnInit {
- counter:string;
- public submitted: boolean;
- //error message
- errMess: any;
- filteringForm = new FormGroup({
- currencyFiltering: new FormControl('',[]),
- ratingFiltering: new FormControl('',[]),
- typeFiltering: new FormControl('',[]),
- codeTypeFiltering: new FormControl('',[]),
- assetTypeFiltering:new FormControl('',[]),
- lembagaFiltering:new FormControl('',[]),
- });
- editCalcForm= new FormGroup({
- assetTypeF: new FormControl('null',[
- // Validators.required
- ]),
- assetNameF:new FormControl('',[
- // Validators.required
- ]),
- ratingF:new FormControl('null',[
- Validators.required
- ]),
- // ratingLGD:new FormControl('null',[
- // Validators.required
- // ]),
- calculateType:new FormControl('',[
- Validators.required
- ]),
- tenorF:new FormControl('',[
- // Validators.pattern("[0-9]*['.']?[0-9]*"),
- // Validators.pattern("/^\d.d?\d+$/"),
- // Validators.pattern("^\d*\.?\d+$"),
- Validators.required
- ]),
- buyDate:new FormControl('',[
- Validators.required
- ]),
- maturityDate:new FormControl('',[
- Validators.required
- ]),
- eirRateF:new FormControl('',[
- Validators.pattern("(\\d+)(\\.)?(\\d+)?"),
- Validators.required
- ]),
- nominalF:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- type:new FormControl('null',[
- Validators.required
- ]),
- codeType:new FormControl('null',[
- Validators.required
- ]),
- name:new FormControl('',[
- Validators.required
- ]),
- loanType:new FormControl('',[
- Validators.required
- ]),
- currency:new FormControl('null',[
- Validators.required,
- Validators.pattern("[a-zA-Z]{3}"),
- ]),
- lembaga:new FormControl('',[
- Validators.required
- ]),
- kurs:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- nominalEqivalen:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- rekening:new FormControl('',[
- // Validators.required
- ]),
- period:new FormControl('',[
- Validators.required
- ]),
- PD:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- LGD:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- ccf:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- discountFactor:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- coaDebet:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- coaKredit:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- })
- //^[0-100]
- updateForm= new FormGroup({
- assetTypeUpdate: new FormControl('null',[
- // Validators.required
- ]),
- assetNameUpdate:new FormControl('',[
- // Validators.required
- ]),
- ratingUpdate:new FormControl('',[
- Validators.required
- ]),
- caltype:new FormControl('',[
- Validators.required
- ]),
- // ratingLGDUpdate:new FormControl('',[
- // Validators.required
- // ]),
- buyDateUpdate:new FormControl('',[
- Validators.required
- ]),
- maturityDateUpdate:new FormControl('',[
- Validators.required
- ]),
- eirRateUpdate:new FormControl('',[
- Validators.pattern("(\\d+)(\\.)?(\\d+)?"),
- Validators.required
- ]),
- mtmUpdate: new FormControl('',[
- Validators.required,
- Validators.pattern("[0-9]*['.']?[0-9]*")
- ]),
- nominalUpdate:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- typeUpdate:new FormControl('',[
- Validators.required
- ]),
- codeTypeUpdate:new FormControl('',[
- Validators.required
- ]),
- nameUpdate:new FormControl('',[
- Validators.required
- ]),
- loanTypeUpdate:new FormControl('',[
- Validators.required
- ]),
- currencyUpdate:new FormControl('',[
- Validators.required,
- Validators.pattern("[a-zA-Z]{3}"),
- ]),
- lembagaUpdate:new FormControl('',[
- Validators.required
- ]),
- kursUpdate:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- nominalEqivalenUpdate:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- coaDebetUpdate:new FormControl('',[]),
- coaKreditUpdate:new FormControl('',[]),
- rekeningUpdate:new FormControl('',[
- // Validators.required
- ]),
- periodUpdate:new FormControl('',[
- Validators.required
- ]),
- PDUpdate:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- LGDUpdate:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- ccfUpdate:new FormControl('',[
- Validators.pattern("[0-9]*"),
- Validators.required
- ]),
- creditLossUpdate:new FormControl('',[
- ]),
- discountFactorUpdate:new FormControl('',[
- ]),
- })
- loginForm = new FormGroup({
- username: new FormControl('',[
- Validators.required,
- ]),
- password: new FormControl('', [
- Validators.required,
- //Validators.pattern("^(?=.[a-z])(?=.[A-Z])(?=.*[0-9])[a-zA-Z0-9]+$")
- ])
- });
- //counter update&edit
- updateCounter: number = 0;
- code: number ;
- //for view data
- loadingBar="true";
- dataNotFound="false";
- serviceReturn:any;
- statusService:any;
- serviceReturn2:any;
- statusService2:any;
- serviceReturn3:any;
- statusService3:any;
- serviceReturn4:any;
- statusService4:any;
- serviceReturn5:any;
- statusService5:any;
- serviceReturn6:any;
- statusService6:any;
- serviceReturn7:any;
- statusService7:any;
- buyDateReform="";
- maturityDateReform="";
- listRatingName=[];
- listCalculation=[];
- id=[];
- type=[];
- codeType=[];
- name=[];
- loanType=[];
- currency=[];
- lembaga=[];
- eirRate=[];
- nominal=[];
- kurs=[];
- nominalEqivalen=[];
- rekening=[];
- period=[];
- assetType=[];
- assetName=[];
- rating=[];
- ratingLGD=[];
- buyDate=[];
- buyDate2=[];
- maturityDate=[];
- maturityDate2=[];
- creditLoss=[];
- discountFactor=[];
- calculateType=[];
- PD=[];
- LGD=[];
- ccf=[];
- dataExcel=[];
- //usercredential
- roleId:any;
- userId:any;
- jsonDeleteAssetCreditLoss:any;
- jsonInquiryAssetCreditLoss:any;
- jsonupdateAssetCreditLoss:any;
- jsonGenerateAssetCreditLoss:any;
- //upload
- formDataUpload:FormData = new FormData();
- uploadFileForm= new FormGroup({
- uploadFile: new FormControl('',[
- Validators.required
- ])
- });
- arrayOfJsonTemplate=[];
- jsonTemplate={};
- //filtering
- currencyFilter=[];
- ratingFilter=[];
- typeECLFilter=[];
- codeTypeFilter=[];
- assetTypeFilter=[];
- lembagaFilter=[];
- //lembaga
- listLembaga=[
- "Pefindo",
- "SnP"
- ]
- constructor(private _fb: FormBuilder,public http:Http,private printECL: printECLCalculationPdf, public router:Router, private datePipe: DatePipe, public getUserCred:GetusercredService, public checkUserCred:CheckusercredService, public decryptMe: AppDecryptMe,private callService: CallServiceFunction,private printXls:printCreditLossxls,private printECLXLS:creditLossReportXLS) { }
- listCurrencyDist=[];
- onChangeLembaga(lembagaIn)
- {
- if(lembagaIn=="Pefindo")
- {
- this.listCurrencyDist.push("IDR")
- }
- else
- {
- this.listCurrencyDist=[
- 'JPY',
- 'HKD',
- 'SIN',
- 'MYR',
- 'AUD',
- 'NZD',
- 'GBP',
- 'NLG',
- 'SGD',
- 'USD',
- 'ITL',
- 'EUR',
- 'USS'
- ]
- }
- }
- onChangeLembagaUpdate(lembagaInUpdate)
- {
- console.log("lembaga in " + lembagaInUpdate)
- console.log("currency up " + this.currencyUp)
- this.updateForm.get("lembagaUpdate").patchValue(lembagaInUpdate)
- this.updateForm.get("currencyUpdate").patchValue(this.currencyUp)
- if(lembagaInUpdate=="Pefindo")
- {
- this.listCurrencyDist.push("IDR")
- }
- else
- {
- this.listCurrencyDist=[
- 'JPY',
- 'HKD',
- 'SIN',
- 'MYR',
- 'AUD',
- 'NZD',
- 'GBP',
- 'NLG',
- 'SGD',
- 'USD',
- 'ITL',
- 'EUR',
- 'USS'
- ]
- }
- }
- inquiryListRating()
- {
- this.arrayOfJsonTemplate=[];
- let body2 = {
- "roleId": this.roleId,
- "taskCode":this.jsonInquiryAssetCreditLoss.taskCode,
- "userId":this.userId,
- "url":"inquiryListAssetRatingService"
- };
- console.log(JSON.stringify(body2));
- this.callService.getRestResult(body2).subscribe((res) =>{
- this.serviceReturn4=res.json();
- this.statusService4=this.serviceReturn4["0"].serviceContent.status;
- this.listRatingName=[];
- console.log("hasil status : "+this.statusService4);
- if(this.statusService4=="S")
- {
- if(this.serviceReturn4["0"].serviceContent.assetRatingName.length>0)
- {
- for (let i=0; i<this.serviceReturn4["0"].serviceContent.assetRatingName.length; i++)
- {
- this.jsonTemplate={};
- this.listRatingName.push(this.serviceReturn4["0"].serviceContent.assetRatingName[i].rating);
- this.jsonTemplate['ratingupload'] = this.serviceReturn4["0"].serviceContent.assetRatingName[i].rating;
- this.arrayOfJsonTemplate.push(this.jsonTemplate);
- }
- console.log("ini jalan : "+JSON.stringify(this.listRatingName));
- }
- else
- {
- this.listRatingName=[];
- }
- this.inquiryListRatingLGD();
- }
- else if(this.statusService4 =="L"){
- this.router.navigateByUrl("/");
- }
- },
- (err)=> {this.router.navigateByUrl('/error500')})
- }
- deletecalc="";
- deletename="";
- open(calcId : string,calcName:string)
- {
- this.deletecalc=calcId;
- this.deletename=calcName;
- }
- jsonObjectForPrint={};
- arrayOfECLlist=[];
- inquirycalculation(currency: String, rating: String, type: String, codeType: String, assetType: String, lembaga: String)
- {
- this.loadingBar="true";
- this.listCalculation=[];
- this.arrayOfECLlist=[];
- let body2 = {
- "userId":this.userId,
- "roleId": this.roleId,
- "taskCode":this.jsonInquiryAssetCreditLoss.taskCode,
- "url":"inquiryAssetCreditLossService",
- "currency":currency,
- "rating":rating,
- "codeType":codeType,
- "type":type,
- "assetType":assetType,
- "lembaga":lembaga
- };
- console.log(JSON.stringify(body2));
- this.inquiryListRating();
- this.callService.getRestResult(body2).subscribe((res) =>{
- this.serviceReturn7=res.json();
- this.statusService7=this.serviceReturn7["0"].serviceContent.status;
- this.assetName=[];
- this.id=[];
- this.assetType=[];
- this.eirRate=[];
- this.ratingLGD=[];
- this.maturityDate=[];
- this.creditLoss=[];
- this.buyDate=[];
- this.rating=[];
- this.nominal=[];
- this.discountFactor=[];
- this.type=[];
- this.codeType=[];
- this.name=[];
- this.loanType=[];
- this.currency=[];
- this.lembaga=[];
- this.kurs=[];
- this.nominalEqivalen=[];
- this.rekening=[];
- this.period=[];
- this.calculateType=[];
- this.PD=[];
- this.LGD=[];
- this.ccf=[];
- this.dataExcel=[];
- this.currencyFilter=[];
- this.ratingFilter=[];
- this.typeECLFilter=[];
- this.codeTypeFilter=[];
- this.assetTypeFilter=[];
- this.lembagaFilter=[];
- console.log("hasil status : "+this.statusService7);
- if(this.statusService7=="S")
- {
- this.loadingBar="false"
- // this.getCodeType();
- console.log("masukin");
- this.loadingBar="false";
- this.dataNotFound="false";
- for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterAssetType.length; i++)
- {
- this.assetTypeFilter.push(this.serviceReturn7["0"].serviceContent.filterAssetType[i].assetType)
- }
- for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterType.length; i++)
- {
- this.typeECLFilter.push(this.serviceReturn7["0"].serviceContent.filterType[i].type)
- }
- for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterCodeType.length; i++)
- {
- this.codeTypeFilter.push(this.serviceReturn7["0"].serviceContent.filterCodeType[i].codeType)
- }
- for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterLembaga.length; i++)
- {
- this.lembagaFilter.push(this.serviceReturn7["0"].serviceContent.filterLembaga[i].lembaga)
- }
- for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterCurrency.length; i++)
- {
- this.currencyFilter.push(this.serviceReturn7["0"].serviceContent.filterCurrency[i].currency)
- }
- for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterRating.length; i++)
- {
- this.ratingFilter.push(this.serviceReturn7["0"].serviceContent.filterRating[i].rating)
- }
- if(this.serviceReturn7["0"].serviceContent.assetCreditLoss.length>0)
- {
- for (let i=0; i<this.serviceReturn7["0"].serviceContent.assetCreditLoss.length; i++)
- {
- this.listCalculation.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i]);
- this.assetName.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetName);
- this.id.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].id);
- //this.tenor.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].tenor);
- this.assetType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetType);
- this.eirRate.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].eirRate);
- this.ratingLGD.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].ratingLGD);
- //this.calculatetype.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].calculateType);
- this.maturityDate.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].maturityDate);
- this.maturityDate2.push(this.maturityDate[i].substring(6,8)+" - "+this.maturityDate[i].substring(4,6)+" - "+this.maturityDate[i].substring(0,4));
- this.creditLoss.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].creditLoss);
- this.buyDate.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].buyDate);
- this.buyDate2.push(this.buyDate[i].substring(6,8)+" - "+this.buyDate[i].substring(4,6)+" - "+this.buyDate[i].substring(0,4));
- this.rating.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].rating);
- this.nominal.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nominal);
- //this.nilaiWajar.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nilaiWajar);
- this.discountFactor.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].discountFactor);
- this.type.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].type)
- this.codeType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].codeType)
- this.name.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].name)
- this.loanType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].loanType)
- this.currency.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].currency)
- this.lembaga.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].lembaga)
- this.kurs.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].kurs)
- this.nominalEqivalen.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nominalEqivalen)
- this.rekening.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].rekening)
- this.period.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].period)
- this.calculateType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].calculateType)
- this.PD.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].PD)
- this.LGD.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].LGD)
- this.ccf.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].ccf)
- this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].buyDate = this.buyDate2[i];
- this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].maturityDate = this.maturityDate2[i];
- this.updateForm.get('nominalUpdate').setValue(this.nominal)
- this.jsonObjectForPrint={};
- this.jsonObjectForPrint['assetName']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetName;
- // this.jsonObjectForPrint['id']=this.serviceReturn["0"].serviceContent.assetCreditLoss[i].id;
- this.jsonObjectForPrint['tenor']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].tenor;
- this.jsonObjectForPrint['assetType']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetType;
- // this.jsonObjectForPrint['ratingLGD']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].ratingLGD;
- this.jsonObjectForPrint['eirRate']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].eirRate;
- this.jsonObjectForPrint['mtm']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].mtm;
- this.jsonObjectForPrint['maturityDate']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].maturityDate;
- this.jsonObjectForPrint['buyDate']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].buyDate;
- this.jsonObjectForPrint['rating']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].rating;
- this.jsonObjectForPrint['nominal']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nominal;
- this.jsonObjectForPrint['nilaiWajar']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nilaiWajar;
- this.jsonObjectForPrint['discountFactor']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].discountFactor;
- this.jsonObjectForPrint['creditLoss']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].creditLoss;
- this.arrayOfECLlist.push(this.jsonObjectForPrint);
- let data:any[]=[];
- data.push(this.assetType[i]);
- data.push(this.assetName[i]);
- data.push(this.rating[i]);
- data.push(this.ratingLGD[i]);
- data.push(this.buyDate2[i]);
- data.push(this.maturityDate2[i]);
- data.push(this.eirRate[i]);
- data.push(this.nominal[i]);
- data.push(this.creditLoss[i]);
- this.dataExcel.push(data);
- }
- console.log("nominaalll " + this.nominal)
- console.log(this.buyDate + " ini buydate")
- }
- else if (this.serviceReturn7["0"].serviceContent.assetCreditLoss.length==0)
- {
- this.loadingBar="false";
- this.dataNotFound="true";
- this.inquiryListRating();
- this.assetName=[];
- this.id=[];
- // this.tenor=[];
- this.assetType=[];
- this.eirRate=[];
- this.ratingLGD=[];
- this.maturityDate=[];
- this.creditLoss=[];
- this.buyDate=[];
- this.rating=[];
- this.nominal=[];
- // this.nilaiWajar=[];
- }
- this.getType();
- }
- else if(this.statusService7 =="L"){
- this.router.navigateByUrl("/");
- }
- },
- (err)=> {this.router.navigateByUrl('/error500')})
- }
- CallingDropdown()
- {
- this.markUntouched();
- var currency = this.filteringForm.get("currencyFiltering").value;
- var rating = this.filteringForm.get("ratingFiltering").value;
- var type = this.filteringForm.get("typeFiltering").value;
- var codeType = this.filteringForm.get("codeTypeFiltering").value;
- var assetType = this.filteringForm.get("assetTypeFiltering").value;
- var lembaga = this.filteringForm.get("lembagaFiltering").value;
- this.inquirycalculation(currency, rating, type, codeType, assetType, lembaga);
- }
- markUntouched()
- {
- this.editCalcForm.controls['type'].markAsUntouched();
- this.editCalcForm.controls['codeType'].markAsUntouched();
- this.editCalcForm.controls['name'].markAsUntouched();
- this.editCalcForm.controls['loanType'].markAsUntouched();
- this.editCalcForm.controls['currency'].markAsUntouched();
- this.editCalcForm.controls['lembaga'].markAsUntouched();
- this.editCalcForm.controls['kurs'].markAsUntouched();
- this.editCalcForm.controls['nominalEqivalen'].markAsUntouched();
- this.editCalcForm.controls['rekening'].markAsUntouched();
- this.editCalcForm.controls['period'].markAsUntouched();
- this.editCalcForm.controls['assetTypeF'].markAsUntouched()
- this.editCalcForm.controls['assetNameF'].markAsUntouched()
- this.editCalcForm.controls['ratingF'].markAsUntouched()
- this.editCalcForm.controls['eirRateF'].markAsUntouched()
- this.editCalcForm.controls['nominalF'].markAsUntouched()
- this.editCalcForm.controls['coaDebet'].markAsUntouched()
- this.editCalcForm.controls['coaKredit'].markAsUntouched()
- this.editCalcForm.controls['nominalF'].setValue('');
- this.editCalcForm.controls['kurs'].setValue('');
- // this.editCalcForm.controls['ratingLGD'].markAsUntouched()
- }
- goConfigCalculation()
- {
- this.listCalculation=[];
- // this.editCalcForm.reset();
- if(this.jsonGenerateAssetCreditLoss['statusAccess']=="Y")
- {
- var type = this.editCalcForm.controls['type'].value;
- var codeType = this.editCalcForm.controls['codeType'].value;
- var name = this.editCalcForm.controls['name'].value;
- var loanType = this.editCalcForm.controls['loanType'].value;
- var currency = this.editCalcForm.controls['currency'].value;
- var lembaga = this.editCalcForm.controls['lembaga'].value;
- var kurs = this.editCalcForm.controls['kurs'].value;
- var nominalEqivalen = this.editCalcForm.controls['nominalEqivalen'].value;
- var rekening = this.editCalcForm.controls['rekening'].value;
- var period = this.editCalcForm.controls['period'].value;
- // var calculateType = this.editCalcForm.controls['calculateType'].value;
- const assetType = this.editCalcForm.controls['assetTypeF'].value
- var assetName = this.editCalcForm.controls['assetNameF'].value
- var rating = this.editCalcForm.controls['ratingF'].value
- // var tenor = this.editCalcForm.controls['tenorF'].value
- // var buyDate = this.editCalcForm.controls['buyDate'].value
- // var maturityDate = this.editCalcForm.controls['maturityDate'].value
- var eirRate = this.editCalcForm.controls['eirRateF'].value
- var nominal = this.editCalcForm.controls['nominalF'].value
- var coaDebet = this.editCalcForm.controls['coaDebet'].value;
- var coaKredit = this.editCalcForm.controls['coaKredit'].value;
- // var ratingLGD = this.editCalcForm.controls['ratingLGD'].value
- // var calculateType = this.editCalcForm.controls['calculateType'].value;
- // var calculateType = "PD1YEAR";
- // console.log("calculate Type : "+calculateType);
- var buyDate=$('#buyDate').first().val().toString()
- var dateYear1 = $('#buyDate').first().val().toString().substring(6,10);
- var maturityDate=$('#maturityDate').first().val().toString()
- var dateYear2 = $('#maturityDate').first().val().toString().substring(6,10);
- var buyDateYear=$('#buyDate').first().val().toString().substring(6,10);
- var buyDateMonth=$('#buyDate').first().val().toString().substring(3,5);
- var buyDateDay=$('#buyDate').first().val().toString().substring(0,2);
- console.log("bd " + buyDate);
- console.log("md " + maturityDate);
- console.log(buyDateYear+buyDateMonth+buyDateDay);
- this.buyDateReform=buyDate.substring(6,10)+buyDate.substring(0,2)+buyDate.substring(3,5)
- this.maturityDateReform=maturityDate.substring(6,10)+maturityDate.substring(0,2)+maturityDate.substring(3,5);
- console.log("buy date reform " + this.buyDateReform);
- console.log("md reform " + this.maturityDateReform);
- let body2 = {
- "type":type,
- "codeType":codeType,
- "name":name,
- "loanType":loanType,
- "currency":currency.toUpperCase(),
- "lembaga":lembaga,
- "kurs":kurs,
- "nominalEqivalen":nominalEqivalen,
- "rekening":rekening,
- "period":period,
- "assetType":assetType,
- "assetName" :assetName,
- "rating":rating,
- // "ratingLGD":ratingLGD,
- // "calculateType":calculateType,
- // "tenor":tenor,
- "buyDate":this.buyDateReform,
- "maturityDate":this.maturityDateReform,
- "eirRate":eirRate,
- "nominal":nominal,
- "coaDebet":coaDebet,
- "coaKredit":coaKredit,
- "roleId": this.roleId,
- "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
- "userId":this.userId,
- "url":"configureAssetCreditLossService",
- "jsonDataBefore":{},
- "jsonDataAfter":{
- "type":type,
- "codeType":codeType,
- "name":name,
- "loanType":loanType,
- "currency":currency.toUpperCase(),
- "lembaga":lembaga,
- "kurs":kurs,
- "nominalEqivalen":nominalEqivalen,
- "rekening":rekening,
- "period":period,
- "assetType":assetType,
- "assetName" :assetName,
- "rating":rating,
- // "ratingLGD":ratingLGD,
- // "calculateType":calculateType,
- // "tenor":tenor,
- "buyDate":this.buyDateReform,
- "maturityDate":this.maturityDateReform,
- "eirRate":eirRate,
- "nominal":nominal,
- "coaDebet":coaDebet,
- "coaKredit":coaKredit,
- }
- };
- console.log("inputan configure : "+JSON.stringify(body2));
- this.callService.getRestResult(body2).subscribe((res) =>{
- this.serviceReturn2=res.json();
- this.statusService2=this.serviceReturn2["0"].serviceContent.status;
- console.log("hasil status configure : "+this.statusService2);
- if(this.statusService2=="S")
- {
- this.editCalcForm.reset();
- showSwal('success-add-ecl');
- this.inquirycalculation("","","","","","");
- }
- else if(this.statusService2=="C"){
- showSwal('need-approval')
- }
- else if(this.statusService2 =="L"){
- this.router.navigateByUrl("/");
- }
- else
- {
- this.errMess=this.serviceReturn2["0"].serviceContent.errorMessage;
- showSwal('failed-add-ecl');
- this.inquirycalculation("","","","","","");
- }
- },
- (err)=> {this.router.navigateByUrl('/error500')})
- }
- else{
- showSwal('access-denied');
- }
- }
- deleteCalculation(calcId : string)
- {
- if(this.jsonDeleteAssetCreditLoss['statusAccess']=="Y")
- {
- let body2 = {
- "id":calcId,
- "roleId": this.roleId,
- "taskCode":this.jsonDeleteAssetCreditLoss.taskCode,
- "userId":this.userId,
- "url":"deleteAssetCreditLossService",
- "jsonDataBefore":{},
- "jsonDataAfter":{
- "id":calcId,
- }
- };
- console.log("this is segment to delete : "+body2);
- this.callService.getRestResult(body2).subscribe((res) =>{
- this.serviceReturn3=res.json();
- this.statusService3=this.serviceReturn3["0"].serviceContent.status;
- if(this.statusService3=="S")
- {
- showSwal('success-delete');
- this.inquirycalculation("","","","","","");
- }
- else if(this.statusService3 =="L"){
- this.router.navigateByUrl("/");
- }
- else if(this.statusService3=="C"){
- showSwal('need-approval');
- }
- else{
- showSwal('failed-delete');
- }
- },
- (err)=> {this.router.navigateByUrl('/error500')})
- }
- else{
- showSwal('access-denied');
- }
- }
- // goCalculateValue()
- // {
- // this.loadingBar="true"
- // this.dataNotFound="false";
- // if(this.jsonGenerateAssetCreditLoss['statusAccess']=="Y")
- // {
- // let body2 = {
- // "roleId": this.roleId,
- // "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
- // "userId":this.userId,
- // "url":"calculateAssetCreditLossWithLGDService",
- // "jsonDataBefore":{},
- // "jsonDataAfter":{
- // "roleId": this.roleId,
- // "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
- // "userId":this.userId,
- // "url":"calculateAssetCreditLossWithLGDService",
- // }
- // };
- // this.callService.getRestResult(body2).subscribe((res) =>{
- // this.serviceReturn5=res.json();
- // this.statusService5=this.serviceReturn5["0"].serviceContent.status;
- // console.log(this.statusService5);
- // if(this.statusService5=="S")
- // {
- // console.log("masuk if luar");
- // this.loadingBar="false";
- // this.dataNotFound="false";
- // showSwal('success-calculate-ecl')
- // this.inquirycalculation();
- // }
- // else if(this.statusService5 =="L"){
- // this.router.navigateByUrl("/");
- // }
- // else if(this.statusService5=="C")
- // {
- // showSwal('need-approval')
- // }
- // else{
- // this.loadingBar="false";
- // this.dataNotFound="false";
- // this.errMess=this.serviceReturn5["0"].serviceContent.errorMessage;
- // showSwal('failed-calculate-ecl');
- // this.inquirycalculation();
- // }
- // },
- // (err)=>{this.router.navigateByUrl('/error500')}
- // )
- // }
- // else{
- // showSwal('access-denied');
- // }
- // }
- bodyApproval:any;
- goCalculateValue()
- {
- if(this.jsonGenerateAssetCreditLoss['statusAccess']=="Y")
- {
- this.loadingBar='true';
- let body2 = {
- "roleId": this.roleId,
- "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
- "userId":this.userId,
- "url":"calculateAssetCreditLossWithLGDService",
- "jsonDataBefore":{},
- "jsonDataAfter":{
- "taskCode":this.jsonGenerateAssetCreditLoss.taskCode
- }
- };
- this.callService.getRestResult(body2).subscribe((res) =>{
- this.serviceReturn5=res.json();
- this.statusService5=this.serviceReturn5["0"].serviceContent.status;
- console.log("status calculate:" + this.statusService5);
- if(this.statusService5=="S")
- {
- this.loadingBar='false';
- console.log("masuk if luar");
- showSwal('success-calculate-ecl')
- this.inquirycalculation("","","","","","");
- }
- else if(this.statusService5 =="L"){
- this.loadingBar='false';
- this.router.navigateByUrl("/");
- }
- else if(this.statusService5=="C")
- {
- console.log("Masuk??");
- this.loadingBar='false';
- $("#exampleModal-5").modal('show');
- this.bodyApproval = {
- "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
- };
- }
- else{
- this.loadingBar='false';
- this.errMess=this.serviceReturn5["0"].serviceContent.errorMessage;
- showSwal('failed-calculate-ecl');
- // this.inquirycalculation();
- this.ngOnInit();
- }
- },
- (err)=>{this.router.navigateByUrl('/error500')}
- )
- }
- else{
- showSwal('access-denied');
- }
- }
- login()
- {
- var usernameNow = this.loginForm.controls['username'].value;
- var passwordNow = this.loginForm.controls['password'].value;
- let body2 = {
- "roleId":-1,
- "roleIdRequest":this.roleId,
- "userIdRequest":this.userId,
- "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
- "username":usernameNow,
- "password":passwordNow,
- "body":this.bodyApproval,
- "url":"loginApprovalService"
- };
- console.log("Body login approval : "+ JSON.stringify(body2));
- this.callService.getRestResultLogin(body2).subscribe((res) =>{
- let serviceReturnLogin=res.json();
- let statusServiceLogin=serviceReturnLogin['0'].serviceContent.resultMap.resultCheck;
- if(statusServiceLogin=="S"){
- this.loginForm.reset();
- this.userId = serviceReturnLogin['0'].serviceContent.resultMap.userid;
- this.roleId = serviceReturnLogin['0'].serviceContent.resultMap.roleId;
- this.goCalculateValue();
- } else{
- showSwal("invalid-approv");
- }
- })
- }
- lembagaUp;
- currencyUp;
- updateData(codeInput : number, index : number){
- /*if(this.jsonInquiryAssetCreditLoss['statusAccess']=="Y")
- {*/
- var typeUp;
- this.code = codeInput;
- this.updateCounter = 1;
- for (var i = 0; i < this.listCalculation.length; ++i) {
- if(this.listCalculation[i].id==codeInput){
- console.log("buyy" + this.listCalculation[i].buyDate);
- console.log("mattt "+this.listCalculation[i].maturityDate);
- // this.updateForm.get("mtmUpdate").setValue(this.dataCalculation[i].mtm);
- console.log("nominal update " + this.listCalculation[i].nominal)
- console.log("credit update " + this.listCalculation[i].creditLoss)
- this.updateForm.get("assetTypeUpdate").setValue(this.listCalculation[i].assetType);
- this.updateForm.get("assetNameUpdate").setValue(this.listCalculation[i].assetName);
- this.updateForm.get("ratingUpdate").setValue(this.listCalculation[i].rating);
- // this.updateForm.get("ratingLGDUpdate").setValue(this.listCalculation[i].ratingLGD);
- // this.updateForm.get("caltype").setValue(this.listCalculation[i].calculateType);
- this.updateForm.get("discountFactorUpdate").setValue(this.listCalculation[i].discountFactor);
- this.updateForm.get("creditLossUpdate").setValue(this.listCalculation[i].creditLoss);
- this.updateForm.get("typeUpdate").patchValue(this.listCalculation[i].type);
- typeUp=this.listCalculation[i].type;
- this.updateForm.get("codeTypeUpdate").patchValue(this.listCalculation[i].codeType);
- console.log("code type update " + this.listCalculation[i].codeType)
- console.log("code type update form " + this.updateForm.get("codeTypeUpdate").value)
- this.updateForm.get("nameUpdate").setValue(this.listCalculation[i].name);
- this.updateForm.get("loanTypeUpdate").setValue(this.listCalculation[i].loanType);
- this.updateForm.get("currencyUpdate").patchValue(this.listCalculation[i].currency);
- this.updateForm.get("lembagaUpdate").setValue(this.listCalculation[i].lembaga);
- this.lembagaUp=this.listCalculation[i].lembaga;
- this.currencyUp=this.listCalculation[i].currency;
- this.updateForm.get("kursUpdate").setValue(this.listCalculation[i].kurs);
- this.updateForm.get("nominalEqivalenUpdate").setValue(this.listCalculation[i].nominalEqivalen);
- this.updateForm.get("rekeningUpdate").setValue(this.listCalculation[i].rekening);
- this.updateForm.get("periodUpdate").setValue(this.listCalculation[i].period);
- // this.updateForm.get("maturityDateUpdate").setValue(this.listCalculation[i].calculateType);
- this.updateForm.get("PDUpdate").setValue(this.listCalculation[i].PD);
- this.updateForm.get("LGDUpdate").setValue(this.listCalculation[i].LGD);
- this.updateForm.get("ccfUpdate").setValue(this.listCalculation[i].ccf);
- // 03 - 09 - 2019
- let buyDate = this.listCalculation[i].buyDate;
- console.log("bbuyy "+ buyDate)
- let strBuyDate = buyDate.substring(10,14)+"-"+buyDate.substring(5,7)+"-"+buyDate.substring(0,2);
- console.log("str buy date " + strBuyDate)
- this.updateForm.get("buyDateUpdate").setValue(strBuyDate);
- let maturityDate = this.listCalculation[i].maturityDate;
- let strMaturityDate = maturityDate.substring(10,14)+"-"+maturityDate.substring(5,7)+"-"+maturityDate.substring(0,2);
- this.updateForm.get("maturityDateUpdate").setValue(strMaturityDate);
- let eirRate = this.listCalculation[i].eirRate * 100;
- this.updateForm.get("eirRateUpdate").setValue(eirRate);
- this.updateForm.get("nominalUpdate").setValue(this.listCalculation[i].nominal);
- console.log("nominal form " + this.updateForm.get("nominalUpdate").value)
- }
- }
- this.getCodeTypeUpdate(typeUp);
- /*}
- else{
- showSwal('access-denied');
- }*/
- }
- updateDetailCreditLost(codeInput : number, arrayIndex:string)
- {
- /*if(this.jsonupdateAssetCreditLoss['statusAccess']=="Y")
- {*/
- var assetType = (this.updateForm.get('assetTypeUpdate').value).toString();
- var assetName = (this.updateForm.get('assetNameUpdate').value).toString();
- var rating = (this.updateForm.get('ratingUpdate').value).toString();
- var buyDate = (this.updateForm.get('buyDateUpdate').value).toString();
- var maturityDate = (this.updateForm.get('maturityDateUpdate').value).toString();
- var eirRate = (this.updateForm.get('eirRateUpdate').value).toString();
- var nominal = (this.updateForm.get('nominalUpdate').value).toString();
- // var ratingLGD = (this.updateForm.get('ratingLGDUpdate').value).toString();
- // var caltypeLGD = (this.updateForm.get('caltype').value).toString();
- var type = (this.updateForm.get('typeUpdate').value).toString();
- var codeType = (this.updateForm.get('codeTypeUpdate').value).toString();
- var name = (this.updateForm.get('nameUpdate').value).toString();
- var loanType = (this.updateForm.get('loanTypeUpdate').value).toString();
- var currency = (this.updateForm.get('currencyUpdate').value).toString();
- var lembaga = (this.updateForm.get('lembagaUpdate').value).toString();
- var kurs = (this.updateForm.get('kursUpdate').value).toString();
- var nominalEqivalen = (this.updateForm.get('nominalEqivalenUpdate').value).toString();
- var rekening = (this.updateForm.get('rekeningUpdate').value).toString();
- var period = (this.updateForm.get('periodUpdate').value).toString();
- var coaDebet = (this.updateForm.get('coaDebetUpdate').value).toString();
- var coaKredit = (this.updateForm.get('coaKreditUpdate').value).toString();
- //console.log("mtm 1 :"+ this.updateForm.get('mtmUpdate').value);
- console.log(buyDate);
- console.log(maturityDate);
- var buyDateReform=buyDate.substring(0,4)+buyDate.substring(5,7)+buyDate.substring(8,10);
- var maturityDateReform=maturityDate.substring(0,4)+maturityDate.substring(5,7)+maturityDate.substring(8,10);
- console.log("hasil buy "+buyDate);
- console.log("hasil mature "+maturityDate);
- // let maturityDate = this.listCalculation[i].maturityDate;
- let strBuyDate = buyDate.substring(10,14)+"-"+buyDate.substring(5,7)+"-"+buyDate.substring(0,2);
- this.updateForm.get("buyDateUpdate").setValue(strBuyDate);
- let strMaturityDate = maturityDate.substring(10,14)+"-"+maturityDate.substring(5,7)+"-"+maturityDate.substring(0,2);
- this.updateForm.get("maturityDateUpdate").setValue(strMaturityDate);
- // let strBuyDate = buyDate.substring(0,2)+buyDate.substring(5,7)+buyDate.substring(10,14);
- // let strMaturityDate = maturityDate.substring(0,2)+maturityDate.substring(5,7)+maturityDate.substring(10,14);
- let year=buyDate.substring(10,14);
- let month=buyDate.substring(5,7);
- let day=buyDate.substring(0,2);
- let yearm=maturityDate.substring(10,14);
- let monthm=maturityDate.substring(5,7);
- let daym=maturityDate.substring(0,2);
- console.log("OII" + year+month+day);
- console.log("buy update " + strBuyDate);
- console.log("str buy update " + strMaturityDate);
- //console.log("mtm 1 :"+ this.updateForm.get('mtmUpdate').value);
- let body2 = {
- "id":codeInput,
- "assetType":assetType,
- "assetName":assetName,
- "rating":rating,
- "buyDate":buyDateReform,
- "maturityDate":maturityDateReform,
- "eirRate":eirRate,
- "nominal":nominal,
- // "ratingLGD":ratingLGD,
- // "calculateType":caltypeLGD,
- "type":type,
- "codeType":codeType,
- "name":name,
- "loanType":loanType,
- "currency":currency.toUpperCase(),
- "lembaga":lembaga,
- "kurs":kurs,
- "nominalEqivalen":nominalEqivalen,
- "rekening":rekening,
- "period":period,
- "coaDebet":coaDebet,
- "coaKredit":coaKredit,
- "roleId": this.roleId,
- "taskCode":this.jsonupdateAssetCreditLoss.taskCode,
- "userId":this.userId,
- "url":"updateAssetCreditLossService",
- "jsonDataBefore":{},
- "jsonDataAfter":{
- "id":codeInput,
- "assetType":assetType,
- "assetName":assetName,
- "rating":rating,
- "buyDate":buyDateReform,
- "maturityDate":maturityDateReform,
- "eirRate":eirRate,
- "nominal":nominal,
- // "ratingLGD":ratingLGD,
- // "calculateType":caltypeLGD,
- "type":type,
- "codeType":codeType,
- "name":name,
- "loanType":loanType,
- "currency":currency.toUpperCase(),
- "lembaga":lembaga,
- "kurs":kurs,
- "nominalEqivalen":nominalEqivalen,
- "rekening":rekening,
- "period":period,
- "coaDebet":coaDebet,
- "coaKredit":coaKredit,
- }
- };
- console.log("balikan body : "+JSON.stringify(body2));
- this.callService.getRestResult(body2).subscribe((res) =>{
- this.serviceReturn6=res.json();
- this.statusService6=this.serviceReturn6["0"].serviceContent.status;
- if(this.statusService6=="S")
- {
- this.updateCounter = 0;
- showSwal('success-update');
- this.inquirycalculation("","","","","","");
- }
- else if(this.statusService6=="C"){
- showSwal('need-approval');
- }
- else if(this.statusService6 =="L"){
- this.router.navigateByUrl("/");
- }
- else
- {
- this.errMess=this.serviceReturn6["0"].serviceContent.errorMessage;
- showSwal('failed-update')
- this.inquirycalculation("","","","","","");
- }
- },
- (err)=> {this.router.navigateByUrl('/error500')})
- /*}
- else{
- this.router.navigateByUrl('/home');
- }*/
- }
- reverbUpdateData(){
- this.updateCounter = 0;
- }
- downloadCsv()
- {
- let arrayJsonTemplate2=[];
- let jsonTemplate2={}
- jsonTemplate2['assetType']='AS4';
- jsonTemplate2['assetName']='Laptop';
- jsonTemplate2['rating']='AA';
- jsonTemplate2['rating LGD']='AA';
- jsonTemplate2['buyDate']='20190416';
- jsonTemplate2['maturityDate']='20190416';
- jsonTemplate2['eirRate']='0.12';
- jsonTemplate2['nominal']='3000000';
- jsonTemplate2['calculate type']='LIFETIME';
- arrayJsonTemplate2.push(jsonTemplate2);
- let jsonTemplate3={}
- jsonTemplate3['assetType']='AS4';
- jsonTemplate3['assetName']='Laptop';
- jsonTemplate3['rating']='AA';
- jsonTemplate3['rating LGD']='Example';
- jsonTemplate3['buyDate']='20190416';
- jsonTemplate3['maturityDate']='20190416';
- jsonTemplate3['eirRate']='0.12';
- jsonTemplate3['nominal']='3000000';
- jsonTemplate3['calculate type']='PD1YEAR';
- arrayJsonTemplate2.push(jsonTemplate3)
- this.printXls.exportAsExcelFile(this.arrayOfJsonTemplate,this.arrayListRatingLGD,arrayJsonTemplate2,'CREDITLOSS');
- }
- onchangeUpload(event){
- this.formDataUpload = new FormData();
- let fileList: FileList = event.target.files;
- if(fileList.length > 0) {
- let file: File = fileList[0];
- this.formDataUpload.append('file', file);
- // this.readytoupload =true;
- }
- }
- uploadFileToActivity() {
- /*if(this.jsonupdateAssetCreditLoss['statusAccess']=="Y")
- {*/
- this.loadingBar="true";
- this.reset();
- this.callService.getRestUpload(this.formDataUpload,"uploadFileCreditLossService").subscribe(res =>{
- this.serviceReturn=res;
- if(this.serviceReturn._body=="S"){
- this.loadingBar="false";
- showSwal('success-upload');
- this.uploadFileForm.reset();
- this.inquirycalculation("","","","","","");
- }else{
- this.loadingBar="false";
- showSwal('failed-upload');
- }
- },(err) => { showSwal('error-upload') });
- /*}
- else
- {
- showSwal('access-denied');
- }*/
- }
- reset() {
- this.uploadFileForm.reset();
- }
- baseURL="";
- ngOnInit() {
- // this.editCalcForm.get('type').disable();
- // this.editCalcForm.get('kurs').setValue('');
- // this.editCalcForm.get('nominal').setValue('');
- let Dta = location.href;
- let splitDta = Dta.split("/");
- this.baseURL = splitDta[0]+splitDta[1];
- $('#datepicker-popup1').datepicker({
- enableOnReadonly: true,
- todayHighlight: true,
- autoclose: true,
- });
- $('#datepicker-popup2').datepicker({
- enableOnReadonly: true,
- todayHighlight: true,
- autoclose: true,
- });
- $('#datepicker-popup5').datepicker({
- enableOnReadonly: true,
- todayHighlight: true,
- autoclose: true,
- });
- $('#datepicker-popup3').datepicker({
- enableOnReadonly: true,
- todayHighlight: true,
- autoclose: true,
- });
- // $('#datepicker-popup4').datepicker({
- // enableOnReadonly: true,
- // todayHighlight: true,
- // autoclose: true,
- // });
- $('#datepicker-popup4').datepicker({
- enableOnReadonly: true,
- format: "dd-mm-yyyy",
- todayHighlight: true,
- autoclose: true,
- });
- $('#datepicker-popup5').datepicker({
- enableOnReadonly: true,
- format: "dd-mm-yyyy",
- todayHighlight: true,
- autoclose: true,
- });
- // this.insertDataModelForm = this.fb.group({
- // periodeInsert:['', Validators.required],
- // // detail:this.fb.array( [this.createItem('')])
- // });
- this.decryptMe.startWatching();
- this.decryptMe.onTimerStart();
- this.jsonDeleteAssetCreditLoss={};
- this.jsonInquiryAssetCreditLoss={};
- this.jsonupdateAssetCreditLoss={};
- this.jsonGenerateAssetCreditLoss={};
- var usercred=this.getUserCred.getUserData();
- this.jsonInquiryAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"InquiryAssetDataECL"));
- this.jsonDeleteAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"DeleteAssetDataECL"));
- this.jsonupdateAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"UpdateAssetDataECL"));
- this.jsonGenerateAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"GenerateAssetDataECL"));
- this.roleId = JSON.parse(usercred).roleId;
- this.userId = JSON.parse(usercred).userId;
- this.counter="0";
- console.log('test : ' + this.jsonInquiryAssetCreditLoss['statusAccess']);
- /*if(this.jsonInquiryAssetCreditLoss['statusAccess']=="Y")
- {*/
- //console.log("test: " + this.jsonInquiryAssetCreditLoss['statusAccess']=="Y");
- this.inquirycalculation("","","","","","");
- /*}
- else
- {
- showSwal('access-denied');
- }*/
- }
- today="";
- datetime="";
- generateReport()
- {
- console.log("masuk generate report");
- let tanggal:any;
- let date = new Date();
- let month = date.getMonth();
- let day = date.getDate();
- let hour = date.getHours();
- let minute = date.getMinutes();
- let secon = date.getSeconds();
- var sekarang = new Date(date.getFullYear(),month,day,hour,minute,secon);
- var waktu = new Date(date.getFullYear(),month,day,hour,minute,secon);
- this.today= this.datePipe.transform(sekarang,'yMM');
- this.datetime=this.datePipe.transform(waktu,'dd MMMM y - HH:mm:ss');
- tanggal = this.datetime;
- console.log("tanggal :"+tanggal);
- let jsonForPrint={}
- jsonForPrint['itemList']=this.arrayOfECLlist;
- jsonForPrint['tanggal']=tanggal;
- // jsonForPrint['breaktype']=this.breakType;
- console.log("list ecl " + this.arrayOfECLlist);
- this.printECL.printreportPDF(JSON.stringify(jsonForPrint));
- }
- listRatingNameLGD = [];
- arrayListRatingLGD=[];
- inquiryListRatingLGD()
- {
- this.arrayListRatingLGD = [];
- let body2 = {
- "roleId": this.roleId,
- //"taskCode":this.jsonInquiryListAssetRating.taskCode
- "userId":this.userId,
- "url":"inquiryListAssetRatingLGDService"
- };
- this.callService.getRestResult(body2).subscribe((res) =>{
- this.serviceReturn4=res.json();
- this.statusService4=this.serviceReturn4["0"].serviceContent.status;
- this.listRatingNameLGD=[];
- console.log("hasil status : "+this.statusService4);
- if(this.statusService4=="S")
- {
- if(this.serviceReturn4["0"].serviceContent.assetRatingName.length>0)
- {
- for (let i=0; i<this.serviceReturn4["0"].serviceContent.assetRatingName.length; i++)
- {
- this.listRatingNameLGD.push(this.serviceReturn4["0"].serviceContent.assetRatingName[i].ratingType);
- let jsontemplate = {};
- jsontemplate['rating LGD']=this.serviceReturn4["0"].serviceContent.assetRatingName[i].ratingType;
- this.arrayListRatingLGD.push(jsontemplate);
- }
- }
- else
- {
- this.listRatingNameLGD=[];
- }
- }
- else if(this.statusService4 =="L"){
- this.router.navigateByUrl("/");
- }
- })
- }
- statusService9:any;
- serviceReturn9:any;
- typeFilter=[];
- getType()
- {
- this.typeFilter=[];
- let body2={
- "roleId": this.roleId,
- "taskCode":"inquiryConfigurationAssetTypeService",
- "userId":this.userId,
- "url":"inquiryConfigurationAssetTypeService"
- }
- this.callService.getRestResult(body2).subscribe((res) =>{
- let serviceReturn=res.json();
- console.log("return : "+JSON.stringify(serviceReturn));
- let statusService=serviceReturn["0"].serviceContent.status;
- console.log("hasil status type 1 : "+ statusService);
- console.log("hasil status type 2 : "+ serviceReturn["0"].serviceContent.status);
- if(statusService=="S")
- {
- for(var i = 0; i<serviceReturn["0"].serviceContent.listAssetType.length; i++)
- {
- this.typeFilter.push(serviceReturn["0"].serviceContent.listAssetType[i]);
- // this.typeFil.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i].assetType)
- }
- // this.getCodeType();
- }
- else
- {
- console.log("f get type")
- }
- });
- }
- codeTypeFil=[];
- typeFil=[];
- selectedType="";
- getCodeType(typein: string)
- {
- console.log("masuk get code")
- this.codeTypeFil=[];
- this.typeFil=[];
- this.selectedType=typein;
- console.log("type!!" + this.selectedType)
- let body2 = {
- "roleId": this.roleId,
- "taskCode":"inquiryConfigurationAssetTypeService",
- "userId":this.userId,
- "url":"inquiryConfigurationAssetTypeService"
- };
- this.callService.getRestResult(body2).subscribe((res) =>{
- let serviceReturn=res.json();
- console.log("return : "+JSON.stringify(serviceReturn));
- let statusService=serviceReturn["0"].serviceContent.status;
- console.log("hasil status code type 1 : "+ statusService);
- console.log("hasil status code type 2 : "+ serviceReturn["0"].serviceContent.status);
- console.log("len " + serviceReturn["0"].serviceContent.assetTypeList.length)
- if(statusService=="S")
- {
- for(var i = 0; i<serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList.length; i++)
- {
- this.typeFil.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i].assetType)
- }
- for(let i=0; i<this.typeFil.length;i++){
- console.log("KOTA");
- console.log("compare "+this.typeFil[i]+" vs "+this.selectedType);
- if(this.typeFil[i] == this.selectedType){
- this.codeTypeFil.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i])
- this.editCalcForm.controls.codeType.patchValue(this.codeTypeFil[i]);
- }
- }
- }
- });
- }
- codeTypeFilUp=[];
- typeFilUp=[];
- selectedTypeUp="";
- getCodeTypeUpdate(typein: string)
- {
- console.log("masuk get code up")
- this.codeTypeFilUp=[];
- this.typeFilUp=[];
- this.selectedTypeUp=typein;
- var codeUp=this.updateForm.get("codeTypeUpdate").value;
- console.log("code!!" + codeUp)
- console.log("type!!" + this.selectedTypeUp)
- let body2 = {
- "roleId": this.roleId,
- "taskCode":"inquiryConfigurationAssetTypeService",
- "userId":this.userId,
- "url":"inquiryConfigurationAssetTypeService"
- };
- this.callService.getRestResult(body2).subscribe((res) =>{
- let serviceReturn=res.json();
- console.log("return : "+JSON.stringify(serviceReturn));
- let statusService=serviceReturn["0"].serviceContent.status;
- console.log("hasil status code type 1 : "+ statusService);
- console.log("hasil status code type 2 : "+ serviceReturn["0"].serviceContent.status);
- console.log("len " + serviceReturn["0"].serviceContent.assetTypeList.length)
- if(statusService=="S")
- {
- for(var i = 0; i<serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList.length; i++)
- {
- this.typeFilUp.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i].assetType)
- }
- for(let i=0; i<this.typeFilUp.length;i++){
- console.log("KOTA");
- console.log("compare "+this.typeFilUp[i]+" vs "+this.selectedTypeUp);
- if(this.typeFilUp[i] == this.selectedTypeUp){
- this.codeTypeFilUp.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i])
- this.updateForm.controls.codeTypeUpdate.patchValue(codeUp);
- }
- }
- // this.updateForm.get("codeTypeUpdate").patchValue(this.listCalculation[i].codeType);
- this.onChangeLembagaUpdate(this.lembagaUp);
- }
- });
- }
- setType;
- // onChangeCodeType(valueCodeType)
- // {
- // console.log("val!! " + this.editCalcForm.get('codeType').value)
- // if(this.editCalcForm.get('codeType').value=="null")
- // {
- // this.editCalcForm.get('type').setValue("");
- // this.editCalcForm.controls['type'].markAsTouched();
- // }
- // else{
- // for(var i = 0; i<this.typeFil.length; i++)
- // {
- // if(this.codeTypeFil[i].assetCode==valueCodeType)
- // {
- // this.setType=this.codeTypeFil[i].assetType;
- // }
- // }
- // this.editCalcForm.get('type').disable();
- // this.editCalcForm.get('type').setValue(this.setType);
- // // console.log("val " + this.editCalcForm.get('codeType').value)
- // }
- // }
- // onChangeCodeTypeUpdate(valueCodeType)
- // {
- // console.log("val2!! " + this.updateForm.get('codeTypeUpdate').value)
- // if(this.updateForm.get('codeTypeUpdate').value=="null")
- // {
- // console.log("val 2 msk null")
- // this.updateForm.controls['typeUpdate'].setValue("");
- // this.updateForm.controls['typeUpdate'].markAsTouched();
- // console.log("value up" + this.updateForm.controls['typeUpdate'].value)
- // }
- // else{
- // console.log("masuk else")
- // for(var i = 0; i<this.typeFil.length; i++)
- // {
- // if(this.codeTypeFil[i].assetCode==valueCodeType)
- // {
- // this.setType=this.codeTypeFil[i].assetType;
- // }
- // }
- // this.updateForm.get('typeUpdate').disable();
- // this.updateForm.get('typeUpdate').setValue(this.setType);
- // }
- // }
- nominalVal="";
- onChangeNominal(valueNominal)
- {
- console.log("nominal " + valueNominal)
- this.nominalVal=valueNominal;
- let nominalKurs;
- nominalKurs = this.kursVal
- let nominalEq;
- if(nominalKurs=="" || this.nominalVal=="")
- {
- this.editCalcForm.get('nominalEqivalen').setValue("Please input nominal and kurs value");
- }
- else
- {
- nominalEq = parseInt(this.nominalVal) * parseInt(nominalKurs);
- console.log("nominal eq " + nominalEq)
- this.editCalcForm.get('nominalEqivalen').setValue(nominalEq);
- }
- }
- nominalValUpdate="";
- onChangeNominalUpdate(valueNominal)
- {
- console.log("nominal " + valueNominal)
- this.nominalValUpdate=valueNominal;
- let nominalKurs;
- nominalKurs = this.kursValUpdate;
- let nominalEq;
- var nominalKursForm = this.updateForm.get('kursUpdate').value
- if(nominalKursForm!="")
- {
- nominalEq = parseInt(this.nominalValUpdate) * parseInt(nominalKursForm);
- this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
- }
- else {
- if(nominalKurs=="" || this.nominalValUpdate=="")
- {
- this.updateForm.get('nominalEqivalenUpdate').setValue("Please input nominal and kurs value");
- }
- else
- {
- nominalEq = parseInt(this.nominalValUpdate) * parseInt(nominalKurs);
- console.log("nominal eq " + nominalEq)
- this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
- }
- }
- }
- kursVal="";
- onChangeKurs(valueKurs)
- {
- console.log("kurs " + valueKurs)
- this.kursVal=valueKurs;
- let nominal;
- let nominalEq;
- nominal = this.nominalVal
- console.log(nominal);
- if(nominal=="" || this.kursVal=="")
- {
- this.editCalcForm.get('nominalEqivalen').setValue("Please input nominal and kurs value");
- }
- else
- {
- nominalEq = parseInt(this.kursVal) * parseInt(nominal);
- console.log("nominal eq 2 " + nominalEq);
- this.editCalcForm.get('nominalEqivalen').setValue(nominalEq);
- }
- console.log(this.kursVal);
- // this.editCalcForm.get('kurs').setValue(this.kursVal);
- }
- kursValUpdate=""
- onChangeKursUpdate(valueKurs)
- {
- console.log("kurs " + valueKurs)
- this.kursValUpdate=valueKurs;
- let nominal;
- let nominalEq;
- var nominalValForm = this.updateForm.get('nominalUpdate').value
- nominal = this.nominalValUpdate
- if(nominalValForm!="")
- {
- nominalEq = parseInt(this.kursValUpdate) * parseInt(nominalValForm);
- this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
- }
- else{
- if(nominal=="" || this.kursValUpdate=="")
- {
- this.updateForm.get('nominalEqivalenUpdate').setValue("Please input nominal and kurs value");
- }
- else
- {
- nominalEq = parseInt(this.kursValUpdate) * parseInt(nominal);
- console.log("nominal eq 2 " + nominalEq);
- this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
- }
- }
- console.log(this.kursValUpdate);
- // this.updateForm.get('kursUpdate').setValue(this.kursValUpdate);
- }
- listAssetType=[];
- // getListAssetType()
- // {
- // console.log("masuk get type")
- // this.listAssetType=[];
- // let body2={
- // "roleId": this.roleId,
- // "taskCode":"inquiryConfigurationAssetTypeService",
- // "userId":this.userId,
- // "url":"inquiryConfigurationAssetTypeService"
- // }
- // }
- // today:any;
- // datetime:any;
- generateReportExcel()
- {
- let data=[];
- let dataTotal=[];
- let dataSummary=[];
- let date = new Date();
- let month = date.getMonth();
- let day = date.getDate();
- let hour = date.getHours();
- let minute = date.getMinutes();
- let secon = date.getSeconds();
- console.log("next : "+(date.getFullYear()));
- var sekarang = new Date(date.getFullYear(),month,day,hour,minute,secon);
- var waktu = new Date(date.getFullYear(),month,day,hour,minute,secon);
- console.log("var : "+waktu);
- var monthArray = ["Januari","Februari","Maret","April","Mei","Juni","Juli",
- "Agustus","September","Oktober","November","Desember"];
- this.today= this.datePipe.transform(sekarang,'yMM');
- this.datetime=this.datePipe.transform(waktu,'yMMdHHmmss');
- console.log("waktunya : "+this.datetime);
- console.log("today : "+this.today);
- let monthString = monthArray[month];
- let yearString = this.datePipe.transform(sekarang,'y');
- let yearMonthString = monthString+" "+yearString;
- let body2 =
- {
- "roleId": this.roleId,
- "userId": this.userId,
- "taskCode": "inquiryAssetCreditLossForPrintService",
- "datetime": this.datetime,
- "url": "inquiryAssetCreditLossForPrintService",
- "randomString": "null",
- "sessionId":"TEST123"
- };
- this.callService.getRestResult(body2).subscribe((res) =>{
- let serviceReturn=res.json();
- let statusService=serviceReturn["0"].serviceContent.status;
- if(statusService=="S")
- {
- let listAsset=[];
- if(serviceReturn["0"].serviceContent.creditLossList.length>0)
- {
- dataTotal=[];
- dataSummary=[];
- for (let i=0; i<serviceReturn["0"].serviceContent.creditLossList.length; i++)
- {
- console.log("DATA STRING : "+JSON.stringify(serviceReturn["0"].serviceContent.creditLossList[i]));
- let jsonTemplateSummary={};
- jsonTemplateSummary['Number']=i+1;
- jsonTemplateSummary['assetType']=serviceReturn["0"].serviceContent.creditLossList[i].typeDist;
- jsonTemplateSummary['transactionType']=serviceReturn["0"].serviceContent.creditLossList[i].transactionType;
- listAsset.push(serviceReturn["0"].serviceContent.creditLossList[i].typeDist);
- data =[];
- let nilaiTercatat = 0;
- let CKPN = 0;
- for(let j=0; j<serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct.length; j++)
- {
- let jsonTemplate={}
- jsonTemplate['jenis']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].type;
- jsonTemplate['kodeParameter']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].codeType;
- jsonTemplate['assetType']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].assetType;
- jsonTemplate['rekening']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].rekening;
- jsonTemplate['assetName']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].assetName;
- jsonTemplate['loanType']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].loanType;
- jsonTemplate['lembaga']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].lembaga;
- jsonTemplate['currency']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].currency;
- jsonTemplate['rating']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].rating;
- jsonTemplate['buyDate']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].buyDate;
- jsonTemplate['maturityDate']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].maturityDate;
- jsonTemplate['eirRate']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].eirRate;
- jsonTemplate['nominal']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].nominal;
- jsonTemplate['kurs']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].kurs;
- jsonTemplate['nominalEqivalen']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].nominalEqivalen;
- jsonTemplate['PD']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].PD;
- jsonTemplate['LGD']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].LGD;
- jsonTemplate['discountFactor']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].discountFactor;
- jsonTemplate['creditLoss']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].creditLoss;
- nilaiTercatat+=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].nominalEqivalen;
- CKPN+=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].creditLoss;
- data.push(jsonTemplate);
- }
- jsonTemplateSummary['summaryCreditLoss']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossSummary;
- dataSummary.push(jsonTemplateSummary);
- dataTotal.push(data);
- }
- }
- // this.printXLS.exportAsExcelFile(dataTotal,rating, 'Stepwise Regression -');
- this.printECLXLS.generateExcel(dataTotal,listAsset,dataSummary,yearMonthString,serviceReturn["0"].serviceContent, 'Laporan OJK -');
- }
- else if(statusService=="L"){
- this.router.navigateByUrl("/");
- }
- else{
- // this.openModalInformation("Failed","Process Failed",0);
- showSwal('failed-add')
- }
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement