Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.87 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { FormsModule } from '@angular/forms';
  3. import { FormGroup, FormControl, FormBuilder, Validators,ReactiveFormsModule } from '@angular/forms';
  4. import { Http, Headers, RequestOptions } from '@angular/http';
  5. import { Router } from "@angular/router";
  6. import { AppDecryptMe } from "../../app.DecryptMe";
  7. import { GetusercredService } from '../../getusercred.service';
  8. import { CheckusercredService } from '../../checkusercred.service';
  9. import { CallServiceFunction } from '../../callServiceFunction';
  10. import { printECLCalculationPdf } from '../../Reporting/ECLcalculationprintpdf';
  11. import { DatePipe } from '@angular/common';
  12. import { printCreditLossxls } from '../../Reporting/creditloss-xls';
  13. import { markDirty } from '@angular/core/src/render3';
  14. import { printECLCalculationXLS } from '../../Reporting/ECLCalculation-xls';
  15. import { creditLossReportXLS } from '../../Reporting/creditLossPrintXls';
  16. import { conditionallyCreateMapObjectLiteral } from '@angular/compiler/src/render3/view/util';
  17.  
  18.  
  19. declare function showSwal(e):any;
  20.  
  21. declare var $ :any;
  22.  
  23. @Component({
  24. selector: 'app-eclcalculation',
  25. templateUrl: './eclcalculation.component.html',
  26. styleUrls: ['./eclcalculation.component.css'],
  27. providers: [DatePipe,printECLCalculationPdf,printCreditLossxls,printECLCalculationXLS,creditLossReportXLS]
  28. })
  29. export class EclcalculationComponent implements OnInit {
  30. counter:string;
  31. public submitted: boolean;
  32.  
  33. //error message
  34. errMess: any;
  35.  
  36. filteringForm = new FormGroup({
  37. currencyFiltering: new FormControl('',[]),
  38. ratingFiltering: new FormControl('',[]),
  39. typeFiltering: new FormControl('',[]),
  40. codeTypeFiltering: new FormControl('',[]),
  41. assetTypeFiltering:new FormControl('',[]),
  42. lembagaFiltering:new FormControl('',[]),
  43. });
  44.  
  45. editCalcForm= new FormGroup({
  46. assetTypeF: new FormControl('null',[
  47. // Validators.required
  48. ]),
  49. assetNameF:new FormControl('',[
  50. // Validators.required
  51. ]),
  52. ratingF:new FormControl('null',[
  53. Validators.required
  54. ]),
  55. // ratingLGD:new FormControl('null',[
  56. // Validators.required
  57. // ]),
  58. calculateType:new FormControl('',[
  59. Validators.required
  60. ]),
  61. tenorF:new FormControl('',[
  62. // Validators.pattern("[0-9]*['.']?[0-9]*"),
  63. // Validators.pattern("/^\d.d?\d+$/"),
  64. // Validators.pattern("^\d*\.?\d+$"),
  65. Validators.required
  66. ]),
  67. buyDate:new FormControl('',[
  68. Validators.required
  69. ]),
  70.  
  71. maturityDate:new FormControl('',[
  72. Validators.required
  73. ]),
  74. eirRateF:new FormControl('',[
  75. Validators.pattern("(\\d+)(\\.)?(\\d+)?"),
  76. Validators.required
  77. ]),
  78. nominalF:new FormControl('',[
  79. Validators.pattern("[0-9]*"),
  80. Validators.required
  81. ]),
  82. type:new FormControl('null',[
  83. Validators.required
  84. ]),
  85. codeType:new FormControl('null',[
  86. Validators.required
  87. ]),
  88. name:new FormControl('',[
  89. Validators.required
  90. ]),
  91. loanType:new FormControl('',[
  92. Validators.required
  93. ]),
  94. currency:new FormControl('null',[
  95. Validators.required,
  96. Validators.pattern("[a-zA-Z]{3}"),
  97. ]),
  98. lembaga:new FormControl('',[
  99. Validators.required
  100. ]),
  101. kurs:new FormControl('',[
  102. Validators.pattern("[0-9]*"),
  103. Validators.required
  104. ]),
  105. nominalEqivalen:new FormControl('',[
  106. Validators.pattern("[0-9]*"),
  107. Validators.required
  108. ]),
  109. rekening:new FormControl('',[
  110. // Validators.required
  111. ]),
  112. period:new FormControl('',[
  113. Validators.required
  114. ]),
  115. PD:new FormControl('',[
  116. Validators.pattern("[0-9]*"),
  117. Validators.required
  118. ]),
  119. LGD:new FormControl('',[
  120. Validators.pattern("[0-9]*"),
  121. Validators.required
  122. ]),
  123. ccf:new FormControl('',[
  124. Validators.pattern("[0-9]*"),
  125. Validators.required
  126. ]),
  127. discountFactor:new FormControl('',[
  128. Validators.pattern("[0-9]*"),
  129. Validators.required
  130. ]),
  131. coaDebet:new FormControl('',[
  132. Validators.pattern("[0-9]*"),
  133. Validators.required
  134. ]),
  135. coaKredit:new FormControl('',[
  136. Validators.pattern("[0-9]*"),
  137. Validators.required
  138. ]),
  139. })
  140. //^[0-100]
  141. updateForm= new FormGroup({
  142. assetTypeUpdate: new FormControl('null',[
  143. // Validators.required
  144. ]),
  145. assetNameUpdate:new FormControl('',[
  146. // Validators.required
  147. ]),
  148. ratingUpdate:new FormControl('',[
  149. Validators.required
  150. ]),
  151. caltype:new FormControl('',[
  152. Validators.required
  153. ]),
  154. // ratingLGDUpdate:new FormControl('',[
  155. // Validators.required
  156. // ]),
  157. buyDateUpdate:new FormControl('',[
  158. Validators.required
  159. ]),
  160. maturityDateUpdate:new FormControl('',[
  161. Validators.required
  162. ]),
  163. eirRateUpdate:new FormControl('',[
  164. Validators.pattern("(\\d+)(\\.)?(\\d+)?"),
  165. Validators.required
  166. ]),
  167. mtmUpdate: new FormControl('',[
  168. Validators.required,
  169. Validators.pattern("[0-9]*['.']?[0-9]*")
  170. ]),
  171. nominalUpdate:new FormControl('',[
  172. Validators.pattern("[0-9]*"),
  173. Validators.required
  174. ]),
  175. typeUpdate:new FormControl('',[
  176. Validators.required
  177. ]),
  178. codeTypeUpdate:new FormControl('',[
  179. Validators.required
  180. ]),
  181. nameUpdate:new FormControl('',[
  182. Validators.required
  183. ]),
  184. loanTypeUpdate:new FormControl('',[
  185. Validators.required
  186. ]),
  187. currencyUpdate:new FormControl('',[
  188. Validators.required,
  189. Validators.pattern("[a-zA-Z]{3}"),
  190. ]),
  191. lembagaUpdate:new FormControl('',[
  192. Validators.required
  193. ]),
  194. kursUpdate:new FormControl('',[
  195. Validators.pattern("[0-9]*"),
  196. Validators.required
  197. ]),
  198. nominalEqivalenUpdate:new FormControl('',[
  199. Validators.pattern("[0-9]*"),
  200. Validators.required
  201. ]),
  202.  
  203. coaDebetUpdate:new FormControl('',[]),
  204. coaKreditUpdate:new FormControl('',[]),
  205. rekeningUpdate:new FormControl('',[
  206. // Validators.required
  207. ]),
  208. periodUpdate:new FormControl('',[
  209. Validators.required
  210. ]),
  211. PDUpdate:new FormControl('',[
  212. Validators.pattern("[0-9]*"),
  213. Validators.required
  214. ]),
  215. LGDUpdate:new FormControl('',[
  216. Validators.pattern("[0-9]*"),
  217. Validators.required
  218. ]),
  219. ccfUpdate:new FormControl('',[
  220. Validators.pattern("[0-9]*"),
  221. Validators.required
  222. ]),
  223. creditLossUpdate:new FormControl('',[
  224. ]),
  225. discountFactorUpdate:new FormControl('',[
  226. ]),
  227. })
  228.  
  229. loginForm = new FormGroup({
  230. username: new FormControl('',[
  231. Validators.required,
  232. ]),
  233. password: new FormControl('', [
  234. Validators.required,
  235. //Validators.pattern("^(?=.[a-z])(?=.[A-Z])(?=.*[0-9])[a-zA-Z0-9]+$")
  236. ])
  237. });
  238.  
  239. //counter update&edit
  240. updateCounter: number = 0;
  241. code: number ;
  242.  
  243. //for view data
  244. loadingBar="true";
  245. dataNotFound="false";
  246.  
  247. serviceReturn:any;
  248. statusService:any;
  249.  
  250. serviceReturn2:any;
  251. statusService2:any;
  252.  
  253. serviceReturn3:any;
  254. statusService3:any;
  255.  
  256. serviceReturn4:any;
  257. statusService4:any;
  258.  
  259. serviceReturn5:any;
  260. statusService5:any;
  261.  
  262. serviceReturn6:any;
  263. statusService6:any;
  264.  
  265. serviceReturn7:any;
  266. statusService7:any;
  267.  
  268. buyDateReform="";
  269. maturityDateReform="";
  270.  
  271. listRatingName=[];
  272.  
  273. listCalculation=[];
  274.  
  275. id=[];
  276. type=[];
  277. codeType=[];
  278. name=[];
  279. loanType=[];
  280. currency=[];
  281. lembaga=[];
  282. eirRate=[];
  283. nominal=[];
  284. kurs=[];
  285. nominalEqivalen=[];
  286. rekening=[];
  287. period=[];
  288. assetType=[];
  289. assetName=[];
  290. rating=[];
  291. ratingLGD=[];
  292. buyDate=[];
  293. buyDate2=[];
  294. maturityDate=[];
  295. maturityDate2=[];
  296. creditLoss=[];
  297. discountFactor=[];
  298. calculateType=[];
  299. PD=[];
  300. LGD=[];
  301. ccf=[];
  302.  
  303. dataExcel=[];
  304.  
  305. //usercredential
  306. roleId:any;
  307. userId:any;
  308.  
  309. jsonDeleteAssetCreditLoss:any;
  310. jsonInquiryAssetCreditLoss:any;
  311. jsonupdateAssetCreditLoss:any;
  312. jsonGenerateAssetCreditLoss:any;
  313.  
  314. //upload
  315. formDataUpload:FormData = new FormData();
  316. uploadFileForm= new FormGroup({
  317. uploadFile: new FormControl('',[
  318. Validators.required
  319. ])
  320. });
  321. arrayOfJsonTemplate=[];
  322. jsonTemplate={};
  323.  
  324. //filtering
  325. currencyFilter=[];
  326. ratingFilter=[];
  327. typeECLFilter=[];
  328. codeTypeFilter=[];
  329. assetTypeFilter=[];
  330. lembagaFilter=[];
  331.  
  332. //lembaga
  333. listLembaga=[
  334. "Pefindo",
  335. "SnP"
  336. ]
  337.  
  338.  
  339.  
  340. 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) { }
  341.  
  342.  
  343. listCurrencyDist=[];
  344. onChangeLembaga(lembagaIn)
  345. {
  346. if(lembagaIn=="Pefindo")
  347. {
  348. this.listCurrencyDist.push("IDR")
  349. }
  350. else
  351. {
  352. this.listCurrencyDist=[
  353. 'JPY',
  354. 'HKD',
  355. 'SIN',
  356. 'MYR',
  357. 'AUD',
  358. 'NZD',
  359. 'GBP',
  360. 'NLG',
  361. 'SGD',
  362. 'USD',
  363. 'ITL',
  364. 'EUR',
  365. 'USS'
  366. ]
  367. }
  368. }
  369.  
  370. onChangeLembagaUpdate(lembagaInUpdate)
  371. {
  372. console.log("lembaga in " + lembagaInUpdate)
  373. console.log("currency up " + this.currencyUp)
  374. this.updateForm.get("lembagaUpdate").patchValue(lembagaInUpdate)
  375. this.updateForm.get("currencyUpdate").patchValue(this.currencyUp)
  376. if(lembagaInUpdate=="Pefindo")
  377. {
  378. this.listCurrencyDist.push("IDR")
  379. }
  380. else
  381. {
  382. this.listCurrencyDist=[
  383. 'JPY',
  384. 'HKD',
  385. 'SIN',
  386. 'MYR',
  387. 'AUD',
  388. 'NZD',
  389. 'GBP',
  390. 'NLG',
  391. 'SGD',
  392. 'USD',
  393. 'ITL',
  394. 'EUR',
  395. 'USS'
  396. ]
  397. }
  398. }
  399.  
  400. inquiryListRating()
  401. {
  402. this.arrayOfJsonTemplate=[];
  403. let body2 = {
  404. "roleId": this.roleId,
  405. "taskCode":this.jsonInquiryAssetCreditLoss.taskCode,
  406. "userId":this.userId,
  407. "url":"inquiryListAssetRatingService"
  408. };
  409. console.log(JSON.stringify(body2));
  410.  
  411. this.callService.getRestResult(body2).subscribe((res) =>{
  412. this.serviceReturn4=res.json();
  413.  
  414. this.statusService4=this.serviceReturn4["0"].serviceContent.status;
  415. this.listRatingName=[];
  416.  
  417. console.log("hasil status : "+this.statusService4);
  418.  
  419. if(this.statusService4=="S")
  420. {
  421. if(this.serviceReturn4["0"].serviceContent.assetRatingName.length>0)
  422. {
  423. for (let i=0; i<this.serviceReturn4["0"].serviceContent.assetRatingName.length; i++)
  424. {
  425. this.jsonTemplate={};
  426. this.listRatingName.push(this.serviceReturn4["0"].serviceContent.assetRatingName[i].rating);
  427. this.jsonTemplate['ratingupload'] = this.serviceReturn4["0"].serviceContent.assetRatingName[i].rating;
  428. this.arrayOfJsonTemplate.push(this.jsonTemplate);
  429. }
  430. console.log("ini jalan : "+JSON.stringify(this.listRatingName));
  431. }
  432. else
  433. {
  434. this.listRatingName=[];
  435. }
  436. this.inquiryListRatingLGD();
  437. }
  438. else if(this.statusService4 =="L"){
  439. this.router.navigateByUrl("/");
  440. }
  441. },
  442. (err)=> {this.router.navigateByUrl('/error500')})
  443. }
  444.  
  445. deletecalc="";
  446. deletename="";
  447. open(calcId : string,calcName:string)
  448. {
  449. this.deletecalc=calcId;
  450. this.deletename=calcName;
  451. }
  452.  
  453. jsonObjectForPrint={};
  454. arrayOfECLlist=[];
  455.  
  456. inquirycalculation(currency: String, rating: String, type: String, codeType: String, assetType: String, lembaga: String)
  457. {
  458. this.loadingBar="true";
  459.  
  460. this.listCalculation=[];
  461. this.arrayOfECLlist=[];
  462.  
  463. let body2 = {
  464. "userId":this.userId,
  465. "roleId": this.roleId,
  466. "taskCode":this.jsonInquiryAssetCreditLoss.taskCode,
  467. "url":"inquiryAssetCreditLossService",
  468. "currency":currency,
  469. "rating":rating,
  470. "codeType":codeType,
  471. "type":type,
  472. "assetType":assetType,
  473. "lembaga":lembaga
  474. };
  475. console.log(JSON.stringify(body2));
  476. this.inquiryListRating();
  477. this.callService.getRestResult(body2).subscribe((res) =>{
  478. this.serviceReturn7=res.json();
  479.  
  480. this.statusService7=this.serviceReturn7["0"].serviceContent.status;
  481.  
  482. this.assetName=[];
  483. this.id=[];
  484. this.assetType=[];
  485. this.eirRate=[];
  486. this.ratingLGD=[];
  487. this.maturityDate=[];
  488. this.creditLoss=[];
  489. this.buyDate=[];
  490. this.rating=[];
  491. this.nominal=[];
  492. this.discountFactor=[];
  493.  
  494. this.type=[];
  495. this.codeType=[];
  496. this.name=[];
  497. this.loanType=[];
  498. this.currency=[];
  499. this.lembaga=[];
  500. this.kurs=[];
  501. this.nominalEqivalen=[];
  502. this.rekening=[];
  503. this.period=[];
  504. this.calculateType=[];
  505. this.PD=[];
  506. this.LGD=[];
  507. this.ccf=[];
  508.  
  509. this.dataExcel=[];
  510.  
  511. this.currencyFilter=[];
  512. this.ratingFilter=[];
  513. this.typeECLFilter=[];
  514. this.codeTypeFilter=[];
  515. this.assetTypeFilter=[];
  516. this.lembagaFilter=[];
  517.  
  518. console.log("hasil status : "+this.statusService7);
  519. if(this.statusService7=="S")
  520. {
  521. this.loadingBar="false"
  522. // this.getCodeType();
  523. console.log("masukin");
  524.  
  525. this.loadingBar="false";
  526. this.dataNotFound="false";
  527. for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterAssetType.length; i++)
  528. {
  529. this.assetTypeFilter.push(this.serviceReturn7["0"].serviceContent.filterAssetType[i].assetType)
  530. }
  531.  
  532. for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterType.length; i++)
  533. {
  534. this.typeECLFilter.push(this.serviceReturn7["0"].serviceContent.filterType[i].type)
  535. }
  536.  
  537. for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterCodeType.length; i++)
  538. {
  539. this.codeTypeFilter.push(this.serviceReturn7["0"].serviceContent.filterCodeType[i].codeType)
  540. }
  541.  
  542. for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterLembaga.length; i++)
  543. {
  544. this.lembagaFilter.push(this.serviceReturn7["0"].serviceContent.filterLembaga[i].lembaga)
  545. }
  546.  
  547. for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterCurrency.length; i++)
  548. {
  549. this.currencyFilter.push(this.serviceReturn7["0"].serviceContent.filterCurrency[i].currency)
  550. }
  551.  
  552. for(let i = 0; i<this.serviceReturn7["0"].serviceContent.filterRating.length; i++)
  553. {
  554. this.ratingFilter.push(this.serviceReturn7["0"].serviceContent.filterRating[i].rating)
  555. }
  556.  
  557. if(this.serviceReturn7["0"].serviceContent.assetCreditLoss.length>0)
  558. {
  559. for (let i=0; i<this.serviceReturn7["0"].serviceContent.assetCreditLoss.length; i++)
  560. {
  561.  
  562. this.listCalculation.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i]);
  563.  
  564. this.assetName.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetName);
  565. this.id.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].id);
  566. //this.tenor.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].tenor);
  567. this.assetType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetType);
  568. this.eirRate.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].eirRate);
  569. this.ratingLGD.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].ratingLGD);
  570. //this.calculatetype.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].calculateType);
  571. this.maturityDate.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].maturityDate);
  572. this.maturityDate2.push(this.maturityDate[i].substring(6,8)+" - "+this.maturityDate[i].substring(4,6)+" - "+this.maturityDate[i].substring(0,4));
  573. this.creditLoss.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].creditLoss);
  574. this.buyDate.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].buyDate);
  575. this.buyDate2.push(this.buyDate[i].substring(6,8)+" - "+this.buyDate[i].substring(4,6)+" - "+this.buyDate[i].substring(0,4));
  576. this.rating.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].rating);
  577. this.nominal.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nominal);
  578. //this.nilaiWajar.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nilaiWajar);
  579. this.discountFactor.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].discountFactor);
  580.  
  581. this.type.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].type)
  582. this.codeType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].codeType)
  583. this.name.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].name)
  584. this.loanType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].loanType)
  585. this.currency.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].currency)
  586. this.lembaga.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].lembaga)
  587. this.kurs.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].kurs)
  588. this.nominalEqivalen.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nominalEqivalen)
  589. this.rekening.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].rekening)
  590. this.period.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].period)
  591. this.calculateType.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].calculateType)
  592. this.PD.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].PD)
  593. this.LGD.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].LGD)
  594. this.ccf.push(this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].ccf)
  595.  
  596. this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].buyDate = this.buyDate2[i];
  597. this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].maturityDate = this.maturityDate2[i];
  598.  
  599.  
  600. this.updateForm.get('nominalUpdate').setValue(this.nominal)
  601. this.jsonObjectForPrint={};
  602. this.jsonObjectForPrint['assetName']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetName;
  603. // this.jsonObjectForPrint['id']=this.serviceReturn["0"].serviceContent.assetCreditLoss[i].id;
  604. this.jsonObjectForPrint['tenor']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].tenor;
  605. this.jsonObjectForPrint['assetType']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].assetType;
  606. // this.jsonObjectForPrint['ratingLGD']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].ratingLGD;
  607. this.jsonObjectForPrint['eirRate']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].eirRate;
  608. this.jsonObjectForPrint['mtm']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].mtm;
  609. this.jsonObjectForPrint['maturityDate']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].maturityDate;
  610. this.jsonObjectForPrint['buyDate']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].buyDate;
  611. this.jsonObjectForPrint['rating']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].rating;
  612. this.jsonObjectForPrint['nominal']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nominal;
  613. this.jsonObjectForPrint['nilaiWajar']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].nilaiWajar;
  614. this.jsonObjectForPrint['discountFactor']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].discountFactor;
  615. this.jsonObjectForPrint['creditLoss']=this.serviceReturn7["0"].serviceContent.assetCreditLoss[i].creditLoss;
  616.  
  617. this.arrayOfECLlist.push(this.jsonObjectForPrint);
  618.  
  619. let data:any[]=[];
  620.  
  621. data.push(this.assetType[i]);
  622. data.push(this.assetName[i]);
  623. data.push(this.rating[i]);
  624. data.push(this.ratingLGD[i]);
  625. data.push(this.buyDate2[i]);
  626. data.push(this.maturityDate2[i]);
  627. data.push(this.eirRate[i]);
  628. data.push(this.nominal[i]);
  629. data.push(this.creditLoss[i]);
  630.  
  631. this.dataExcel.push(data);
  632.  
  633. }
  634.  
  635. console.log("nominaalll " + this.nominal)
  636. console.log(this.buyDate + " ini buydate")
  637. }
  638. else if (this.serviceReturn7["0"].serviceContent.assetCreditLoss.length==0)
  639. {
  640. this.loadingBar="false";
  641. this.dataNotFound="true";
  642. this.inquiryListRating();
  643. this.assetName=[];
  644. this.id=[];
  645. // this.tenor=[];
  646. this.assetType=[];
  647. this.eirRate=[];
  648. this.ratingLGD=[];
  649. this.maturityDate=[];
  650. this.creditLoss=[];
  651. this.buyDate=[];
  652. this.rating=[];
  653. this.nominal=[];
  654. // this.nilaiWajar=[];
  655. }
  656.  
  657. this.getType();
  658. }
  659. else if(this.statusService7 =="L"){
  660. this.router.navigateByUrl("/");
  661. }
  662. },
  663. (err)=> {this.router.navigateByUrl('/error500')})
  664. }
  665.  
  666. CallingDropdown()
  667. {
  668. this.markUntouched();
  669. var currency = this.filteringForm.get("currencyFiltering").value;
  670. var rating = this.filteringForm.get("ratingFiltering").value;
  671. var type = this.filteringForm.get("typeFiltering").value;
  672. var codeType = this.filteringForm.get("codeTypeFiltering").value;
  673. var assetType = this.filteringForm.get("assetTypeFiltering").value;
  674. var lembaga = this.filteringForm.get("lembagaFiltering").value;
  675.  
  676. this.inquirycalculation(currency, rating, type, codeType, assetType, lembaga);
  677. }
  678.  
  679.  
  680. markUntouched()
  681. {
  682. this.editCalcForm.controls['type'].markAsUntouched();
  683. this.editCalcForm.controls['codeType'].markAsUntouched();
  684. this.editCalcForm.controls['name'].markAsUntouched();
  685. this.editCalcForm.controls['loanType'].markAsUntouched();
  686. this.editCalcForm.controls['currency'].markAsUntouched();
  687. this.editCalcForm.controls['lembaga'].markAsUntouched();
  688. this.editCalcForm.controls['kurs'].markAsUntouched();
  689. this.editCalcForm.controls['nominalEqivalen'].markAsUntouched();
  690. this.editCalcForm.controls['rekening'].markAsUntouched();
  691. this.editCalcForm.controls['period'].markAsUntouched();
  692.  
  693. this.editCalcForm.controls['assetTypeF'].markAsUntouched()
  694. this.editCalcForm.controls['assetNameF'].markAsUntouched()
  695. this.editCalcForm.controls['ratingF'].markAsUntouched()
  696. this.editCalcForm.controls['eirRateF'].markAsUntouched()
  697. this.editCalcForm.controls['nominalF'].markAsUntouched()
  698. this.editCalcForm.controls['coaDebet'].markAsUntouched()
  699. this.editCalcForm.controls['coaKredit'].markAsUntouched()
  700.  
  701.  
  702. this.editCalcForm.controls['nominalF'].setValue('');
  703. this.editCalcForm.controls['kurs'].setValue('');
  704.  
  705.  
  706. // this.editCalcForm.controls['ratingLGD'].markAsUntouched()
  707.  
  708. }
  709.  
  710.  
  711. goConfigCalculation()
  712. {
  713. this.listCalculation=[];
  714. // this.editCalcForm.reset();
  715.  
  716.  
  717. if(this.jsonGenerateAssetCreditLoss['statusAccess']=="Y")
  718. {
  719.  
  720. var type = this.editCalcForm.controls['type'].value;
  721. var codeType = this.editCalcForm.controls['codeType'].value;
  722. var name = this.editCalcForm.controls['name'].value;
  723. var loanType = this.editCalcForm.controls['loanType'].value;
  724. var currency = this.editCalcForm.controls['currency'].value;
  725. var lembaga = this.editCalcForm.controls['lembaga'].value;
  726. var kurs = this.editCalcForm.controls['kurs'].value;
  727. var nominalEqivalen = this.editCalcForm.controls['nominalEqivalen'].value;
  728. var rekening = this.editCalcForm.controls['rekening'].value;
  729. var period = this.editCalcForm.controls['period'].value;
  730. // var calculateType = this.editCalcForm.controls['calculateType'].value;
  731.  
  732. const assetType = this.editCalcForm.controls['assetTypeF'].value
  733. var assetName = this.editCalcForm.controls['assetNameF'].value
  734. var rating = this.editCalcForm.controls['ratingF'].value
  735. // var tenor = this.editCalcForm.controls['tenorF'].value
  736. // var buyDate = this.editCalcForm.controls['buyDate'].value
  737. // var maturityDate = this.editCalcForm.controls['maturityDate'].value
  738. var eirRate = this.editCalcForm.controls['eirRateF'].value
  739. var nominal = this.editCalcForm.controls['nominalF'].value
  740. var coaDebet = this.editCalcForm.controls['coaDebet'].value;
  741. var coaKredit = this.editCalcForm.controls['coaKredit'].value;
  742. // var ratingLGD = this.editCalcForm.controls['ratingLGD'].value
  743. // var calculateType = this.editCalcForm.controls['calculateType'].value;
  744. // var calculateType = "PD1YEAR";
  745. // console.log("calculate Type : "+calculateType);
  746.  
  747. var buyDate=$('#buyDate').first().val().toString()
  748. var dateYear1 = $('#buyDate').first().val().toString().substring(6,10);
  749. var maturityDate=$('#maturityDate').first().val().toString()
  750. var dateYear2 = $('#maturityDate').first().val().toString().substring(6,10);
  751.  
  752. var buyDateYear=$('#buyDate').first().val().toString().substring(6,10);
  753. var buyDateMonth=$('#buyDate').first().val().toString().substring(3,5);
  754. var buyDateDay=$('#buyDate').first().val().toString().substring(0,2);
  755.  
  756. console.log("bd " + buyDate);
  757.  
  758. console.log("md " + maturityDate);
  759.  
  760. console.log(buyDateYear+buyDateMonth+buyDateDay);
  761.  
  762. this.buyDateReform=buyDate.substring(6,10)+buyDate.substring(0,2)+buyDate.substring(3,5)
  763. this.maturityDateReform=maturityDate.substring(6,10)+maturityDate.substring(0,2)+maturityDate.substring(3,5);
  764.  
  765. console.log("buy date reform " + this.buyDateReform);
  766. console.log("md reform " + this.maturityDateReform);
  767.  
  768.  
  769.  
  770. let body2 = {
  771.  
  772. "type":type,
  773. "codeType":codeType,
  774. "name":name,
  775. "loanType":loanType,
  776. "currency":currency.toUpperCase(),
  777. "lembaga":lembaga,
  778. "kurs":kurs,
  779. "nominalEqivalen":nominalEqivalen,
  780. "rekening":rekening,
  781. "period":period,
  782. "assetType":assetType,
  783. "assetName" :assetName,
  784. "rating":rating,
  785. // "ratingLGD":ratingLGD,
  786. // "calculateType":calculateType,
  787. // "tenor":tenor,
  788. "buyDate":this.buyDateReform,
  789. "maturityDate":this.maturityDateReform,
  790. "eirRate":eirRate,
  791. "nominal":nominal,
  792. "coaDebet":coaDebet,
  793. "coaKredit":coaKredit,
  794. "roleId": this.roleId,
  795. "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
  796. "userId":this.userId,
  797. "url":"configureAssetCreditLossService",
  798. "jsonDataBefore":{},
  799. "jsonDataAfter":{
  800. "type":type,
  801. "codeType":codeType,
  802. "name":name,
  803. "loanType":loanType,
  804. "currency":currency.toUpperCase(),
  805. "lembaga":lembaga,
  806. "kurs":kurs,
  807. "nominalEqivalen":nominalEqivalen,
  808. "rekening":rekening,
  809. "period":period,
  810. "assetType":assetType,
  811. "assetName" :assetName,
  812. "rating":rating,
  813. // "ratingLGD":ratingLGD,
  814. // "calculateType":calculateType,
  815. // "tenor":tenor,
  816. "buyDate":this.buyDateReform,
  817. "maturityDate":this.maturityDateReform,
  818. "eirRate":eirRate,
  819. "nominal":nominal,
  820. "coaDebet":coaDebet,
  821. "coaKredit":coaKredit,
  822. }
  823. };
  824.  
  825. console.log("inputan configure : "+JSON.stringify(body2));
  826.  
  827. this.callService.getRestResult(body2).subscribe((res) =>{
  828. this.serviceReturn2=res.json();
  829.  
  830. this.statusService2=this.serviceReturn2["0"].serviceContent.status;
  831.  
  832. console.log("hasil status configure : "+this.statusService2);
  833.  
  834. if(this.statusService2=="S")
  835. {
  836. this.editCalcForm.reset();
  837. showSwal('success-add-ecl');
  838. this.inquirycalculation("","","","","","");
  839. }
  840. else if(this.statusService2=="C"){
  841. showSwal('need-approval')
  842. }
  843. else if(this.statusService2 =="L"){
  844. this.router.navigateByUrl("/");
  845. }
  846.  
  847. else
  848. {
  849. this.errMess=this.serviceReturn2["0"].serviceContent.errorMessage;
  850. showSwal('failed-add-ecl');
  851. this.inquirycalculation("","","","","","");
  852. }
  853. },
  854. (err)=> {this.router.navigateByUrl('/error500')})
  855. }
  856. else{
  857. showSwal('access-denied');
  858. }
  859.  
  860. }
  861.  
  862. deleteCalculation(calcId : string)
  863. {
  864. if(this.jsonDeleteAssetCreditLoss['statusAccess']=="Y")
  865. {
  866. let body2 = {
  867. "id":calcId,
  868. "roleId": this.roleId,
  869. "taskCode":this.jsonDeleteAssetCreditLoss.taskCode,
  870. "userId":this.userId,
  871. "url":"deleteAssetCreditLossService",
  872. "jsonDataBefore":{},
  873. "jsonDataAfter":{
  874. "id":calcId,
  875. }
  876. };
  877.  
  878. console.log("this is segment to delete : "+body2);
  879.  
  880. this.callService.getRestResult(body2).subscribe((res) =>{
  881. this.serviceReturn3=res.json();
  882.  
  883. this.statusService3=this.serviceReturn3["0"].serviceContent.status;
  884.  
  885. if(this.statusService3=="S")
  886. {
  887. showSwal('success-delete');
  888. this.inquirycalculation("","","","","","");
  889.  
  890. }
  891. else if(this.statusService3 =="L"){
  892. this.router.navigateByUrl("/");
  893. }
  894. else if(this.statusService3=="C"){
  895. showSwal('need-approval');
  896. }
  897. else{
  898. showSwal('failed-delete');
  899. }
  900. },
  901. (err)=> {this.router.navigateByUrl('/error500')})
  902. }
  903. else{
  904. showSwal('access-denied');
  905. }
  906.  
  907. }
  908.  
  909. // goCalculateValue()
  910. // {
  911. // this.loadingBar="true"
  912. // this.dataNotFound="false";
  913. // if(this.jsonGenerateAssetCreditLoss['statusAccess']=="Y")
  914. // {
  915.  
  916. // let body2 = {
  917. // "roleId": this.roleId,
  918. // "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
  919. // "userId":this.userId,
  920. // "url":"calculateAssetCreditLossWithLGDService",
  921. // "jsonDataBefore":{},
  922. // "jsonDataAfter":{
  923. // "roleId": this.roleId,
  924. // "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
  925. // "userId":this.userId,
  926. // "url":"calculateAssetCreditLossWithLGDService",
  927. // }
  928. // };
  929.  
  930. // this.callService.getRestResult(body2).subscribe((res) =>{
  931. // this.serviceReturn5=res.json();
  932.  
  933. // this.statusService5=this.serviceReturn5["0"].serviceContent.status;
  934. // console.log(this.statusService5);
  935.  
  936. // if(this.statusService5=="S")
  937. // {
  938. // console.log("masuk if luar");
  939. // this.loadingBar="false";
  940. // this.dataNotFound="false";
  941. // showSwal('success-calculate-ecl')
  942. // this.inquirycalculation();
  943. // }
  944. // else if(this.statusService5 =="L"){
  945. // this.router.navigateByUrl("/");
  946. // }
  947. // else if(this.statusService5=="C")
  948. // {
  949. // showSwal('need-approval')
  950. // }
  951. // else{
  952. // this.loadingBar="false";
  953. // this.dataNotFound="false";
  954. // this.errMess=this.serviceReturn5["0"].serviceContent.errorMessage;
  955. // showSwal('failed-calculate-ecl');
  956. // this.inquirycalculation();
  957. // }
  958.  
  959. // },
  960. // (err)=>{this.router.navigateByUrl('/error500')}
  961. // )
  962. // }
  963. // else{
  964. // showSwal('access-denied');
  965. // }
  966. // }
  967.  
  968. bodyApproval:any;
  969. goCalculateValue()
  970. {
  971. if(this.jsonGenerateAssetCreditLoss['statusAccess']=="Y")
  972. {
  973. this.loadingBar='true';
  974.  
  975. let body2 = {
  976. "roleId": this.roleId,
  977. "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
  978. "userId":this.userId,
  979. "url":"calculateAssetCreditLossWithLGDService",
  980. "jsonDataBefore":{},
  981. "jsonDataAfter":{
  982. "taskCode":this.jsonGenerateAssetCreditLoss.taskCode
  983. }
  984. };
  985.  
  986. this.callService.getRestResult(body2).subscribe((res) =>{
  987. this.serviceReturn5=res.json();
  988.  
  989. this.statusService5=this.serviceReturn5["0"].serviceContent.status;
  990. console.log("status calculate:" + this.statusService5);
  991.  
  992. if(this.statusService5=="S")
  993. {
  994. this.loadingBar='false';
  995. console.log("masuk if luar");
  996. showSwal('success-calculate-ecl')
  997. this.inquirycalculation("","","","","","");
  998. }
  999. else if(this.statusService5 =="L"){
  1000. this.loadingBar='false';
  1001. this.router.navigateByUrl("/");
  1002. }
  1003. else if(this.statusService5=="C")
  1004. {
  1005. console.log("Masuk??");
  1006. this.loadingBar='false';
  1007. $("#exampleModal-5").modal('show');
  1008. this.bodyApproval = {
  1009. "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
  1010. };
  1011. }
  1012. else{
  1013. this.loadingBar='false';
  1014. this.errMess=this.serviceReturn5["0"].serviceContent.errorMessage;
  1015. showSwal('failed-calculate-ecl');
  1016. // this.inquirycalculation();
  1017. this.ngOnInit();
  1018. }
  1019.  
  1020. },
  1021. (err)=>{this.router.navigateByUrl('/error500')}
  1022. )
  1023. }
  1024. else{
  1025. showSwal('access-denied');
  1026. }
  1027. }
  1028.  
  1029.  
  1030.  
  1031. login()
  1032. {
  1033.  
  1034. var usernameNow = this.loginForm.controls['username'].value;
  1035. var passwordNow = this.loginForm.controls['password'].value;
  1036.  
  1037. let body2 = {
  1038. "roleId":-1,
  1039. "roleIdRequest":this.roleId,
  1040. "userIdRequest":this.userId,
  1041. "taskCode":this.jsonGenerateAssetCreditLoss.taskCode,
  1042. "username":usernameNow,
  1043. "password":passwordNow,
  1044. "body":this.bodyApproval,
  1045. "url":"loginApprovalService"
  1046. };
  1047.  
  1048. console.log("Body login approval : "+ JSON.stringify(body2));
  1049.  
  1050.  
  1051.  
  1052. this.callService.getRestResultLogin(body2).subscribe((res) =>{
  1053. let serviceReturnLogin=res.json();
  1054.  
  1055. let statusServiceLogin=serviceReturnLogin['0'].serviceContent.resultMap.resultCheck;
  1056.  
  1057. if(statusServiceLogin=="S"){
  1058. this.loginForm.reset();
  1059. this.userId = serviceReturnLogin['0'].serviceContent.resultMap.userid;
  1060. this.roleId = serviceReturnLogin['0'].serviceContent.resultMap.roleId;
  1061. this.goCalculateValue();
  1062.  
  1063. } else{
  1064. showSwal("invalid-approv");
  1065. }
  1066. })
  1067. }
  1068.  
  1069. lembagaUp;
  1070. currencyUp;
  1071. updateData(codeInput : number, index : number){
  1072. /*if(this.jsonInquiryAssetCreditLoss['statusAccess']=="Y")
  1073. {*/
  1074.  
  1075. var typeUp;
  1076.  
  1077.  
  1078. this.code = codeInput;
  1079. this.updateCounter = 1;
  1080. for (var i = 0; i < this.listCalculation.length; ++i) {
  1081. if(this.listCalculation[i].id==codeInput){
  1082. console.log("buyy" + this.listCalculation[i].buyDate);
  1083. console.log("mattt "+this.listCalculation[i].maturityDate);
  1084. // this.updateForm.get("mtmUpdate").setValue(this.dataCalculation[i].mtm);
  1085.  
  1086. console.log("nominal update " + this.listCalculation[i].nominal)
  1087. console.log("credit update " + this.listCalculation[i].creditLoss)
  1088. this.updateForm.get("assetTypeUpdate").setValue(this.listCalculation[i].assetType);
  1089. this.updateForm.get("assetNameUpdate").setValue(this.listCalculation[i].assetName);
  1090. this.updateForm.get("ratingUpdate").setValue(this.listCalculation[i].rating);
  1091.  
  1092. // this.updateForm.get("ratingLGDUpdate").setValue(this.listCalculation[i].ratingLGD);
  1093. // this.updateForm.get("caltype").setValue(this.listCalculation[i].calculateType);
  1094. this.updateForm.get("discountFactorUpdate").setValue(this.listCalculation[i].discountFactor);
  1095. this.updateForm.get("creditLossUpdate").setValue(this.listCalculation[i].creditLoss);
  1096.  
  1097.  
  1098. this.updateForm.get("typeUpdate").patchValue(this.listCalculation[i].type);
  1099. typeUp=this.listCalculation[i].type;
  1100. this.updateForm.get("codeTypeUpdate").patchValue(this.listCalculation[i].codeType);
  1101.  
  1102. console.log("code type update " + this.listCalculation[i].codeType)
  1103. console.log("code type update form " + this.updateForm.get("codeTypeUpdate").value)
  1104. this.updateForm.get("nameUpdate").setValue(this.listCalculation[i].name);
  1105. this.updateForm.get("loanTypeUpdate").setValue(this.listCalculation[i].loanType);
  1106. this.updateForm.get("currencyUpdate").patchValue(this.listCalculation[i].currency);
  1107. this.updateForm.get("lembagaUpdate").setValue(this.listCalculation[i].lembaga);
  1108. this.lembagaUp=this.listCalculation[i].lembaga;
  1109. this.currencyUp=this.listCalculation[i].currency;
  1110. this.updateForm.get("kursUpdate").setValue(this.listCalculation[i].kurs);
  1111.  
  1112.  
  1113.  
  1114. this.updateForm.get("nominalEqivalenUpdate").setValue(this.listCalculation[i].nominalEqivalen);
  1115. this.updateForm.get("rekeningUpdate").setValue(this.listCalculation[i].rekening);
  1116. this.updateForm.get("periodUpdate").setValue(this.listCalculation[i].period);
  1117. // this.updateForm.get("maturityDateUpdate").setValue(this.listCalculation[i].calculateType);
  1118. this.updateForm.get("PDUpdate").setValue(this.listCalculation[i].PD);
  1119. this.updateForm.get("LGDUpdate").setValue(this.listCalculation[i].LGD);
  1120. this.updateForm.get("ccfUpdate").setValue(this.listCalculation[i].ccf);
  1121.  
  1122.  
  1123.  
  1124. // 03 - 09 - 2019
  1125. let buyDate = this.listCalculation[i].buyDate;
  1126. console.log("bbuyy "+ buyDate)
  1127. let strBuyDate = buyDate.substring(10,14)+"-"+buyDate.substring(5,7)+"-"+buyDate.substring(0,2);
  1128. console.log("str buy date " + strBuyDate)
  1129. this.updateForm.get("buyDateUpdate").setValue(strBuyDate);
  1130.  
  1131. let maturityDate = this.listCalculation[i].maturityDate;
  1132. let strMaturityDate = maturityDate.substring(10,14)+"-"+maturityDate.substring(5,7)+"-"+maturityDate.substring(0,2);
  1133. this.updateForm.get("maturityDateUpdate").setValue(strMaturityDate);
  1134.  
  1135. let eirRate = this.listCalculation[i].eirRate * 100;
  1136.  
  1137. this.updateForm.get("eirRateUpdate").setValue(eirRate);
  1138. this.updateForm.get("nominalUpdate").setValue(this.listCalculation[i].nominal);
  1139.  
  1140. console.log("nominal form " + this.updateForm.get("nominalUpdate").value)
  1141.  
  1142. }
  1143. }
  1144.  
  1145. this.getCodeTypeUpdate(typeUp);
  1146.  
  1147. /*}
  1148. else{
  1149. showSwal('access-denied');
  1150. }*/
  1151. }
  1152.  
  1153.  
  1154. updateDetailCreditLost(codeInput : number, arrayIndex:string)
  1155. {
  1156. /*if(this.jsonupdateAssetCreditLoss['statusAccess']=="Y")
  1157. {*/
  1158. var assetType = (this.updateForm.get('assetTypeUpdate').value).toString();
  1159. var assetName = (this.updateForm.get('assetNameUpdate').value).toString();
  1160. var rating = (this.updateForm.get('ratingUpdate').value).toString();
  1161. var buyDate = (this.updateForm.get('buyDateUpdate').value).toString();
  1162. var maturityDate = (this.updateForm.get('maturityDateUpdate').value).toString();
  1163. var eirRate = (this.updateForm.get('eirRateUpdate').value).toString();
  1164. var nominal = (this.updateForm.get('nominalUpdate').value).toString();
  1165. // var ratingLGD = (this.updateForm.get('ratingLGDUpdate').value).toString();
  1166. // var caltypeLGD = (this.updateForm.get('caltype').value).toString();
  1167.  
  1168. var type = (this.updateForm.get('typeUpdate').value).toString();
  1169. var codeType = (this.updateForm.get('codeTypeUpdate').value).toString();
  1170. var name = (this.updateForm.get('nameUpdate').value).toString();
  1171. var loanType = (this.updateForm.get('loanTypeUpdate').value).toString();
  1172. var currency = (this.updateForm.get('currencyUpdate').value).toString();
  1173. var lembaga = (this.updateForm.get('lembagaUpdate').value).toString();
  1174. var kurs = (this.updateForm.get('kursUpdate').value).toString();
  1175. var nominalEqivalen = (this.updateForm.get('nominalEqivalenUpdate').value).toString();
  1176. var rekening = (this.updateForm.get('rekeningUpdate').value).toString();
  1177. var period = (this.updateForm.get('periodUpdate').value).toString();
  1178. var coaDebet = (this.updateForm.get('coaDebetUpdate').value).toString();
  1179. var coaKredit = (this.updateForm.get('coaKreditUpdate').value).toString();
  1180. //console.log("mtm 1 :"+ this.updateForm.get('mtmUpdate').value);
  1181. console.log(buyDate);
  1182. console.log(maturityDate);
  1183. var buyDateReform=buyDate.substring(0,4)+buyDate.substring(5,7)+buyDate.substring(8,10);
  1184. var maturityDateReform=maturityDate.substring(0,4)+maturityDate.substring(5,7)+maturityDate.substring(8,10);
  1185.  
  1186. console.log("hasil buy "+buyDate);
  1187. console.log("hasil mature "+maturityDate);
  1188.  
  1189. // let maturityDate = this.listCalculation[i].maturityDate;
  1190.  
  1191.  
  1192. let strBuyDate = buyDate.substring(10,14)+"-"+buyDate.substring(5,7)+"-"+buyDate.substring(0,2);
  1193. this.updateForm.get("buyDateUpdate").setValue(strBuyDate);
  1194. let strMaturityDate = maturityDate.substring(10,14)+"-"+maturityDate.substring(5,7)+"-"+maturityDate.substring(0,2);
  1195. this.updateForm.get("maturityDateUpdate").setValue(strMaturityDate);
  1196.  
  1197.  
  1198. // let strBuyDate = buyDate.substring(0,2)+buyDate.substring(5,7)+buyDate.substring(10,14);
  1199. // let strMaturityDate = maturityDate.substring(0,2)+maturityDate.substring(5,7)+maturityDate.substring(10,14);
  1200.  
  1201. let year=buyDate.substring(10,14);
  1202. let month=buyDate.substring(5,7);
  1203. let day=buyDate.substring(0,2);
  1204.  
  1205. let yearm=maturityDate.substring(10,14);
  1206. let monthm=maturityDate.substring(5,7);
  1207. let daym=maturityDate.substring(0,2);
  1208.  
  1209.  
  1210. console.log("OII" + year+month+day);
  1211.  
  1212. console.log("buy update " + strBuyDate);
  1213. console.log("str buy update " + strMaturityDate);
  1214.  
  1215. //console.log("mtm 1 :"+ this.updateForm.get('mtmUpdate').value);
  1216.  
  1217. let body2 = {
  1218. "id":codeInput,
  1219. "assetType":assetType,
  1220. "assetName":assetName,
  1221. "rating":rating,
  1222. "buyDate":buyDateReform,
  1223. "maturityDate":maturityDateReform,
  1224. "eirRate":eirRate,
  1225. "nominal":nominal,
  1226. // "ratingLGD":ratingLGD,
  1227. // "calculateType":caltypeLGD,
  1228. "type":type,
  1229. "codeType":codeType,
  1230. "name":name,
  1231. "loanType":loanType,
  1232. "currency":currency.toUpperCase(),
  1233. "lembaga":lembaga,
  1234. "kurs":kurs,
  1235. "nominalEqivalen":nominalEqivalen,
  1236. "rekening":rekening,
  1237. "period":period,
  1238. "coaDebet":coaDebet,
  1239. "coaKredit":coaKredit,
  1240. "roleId": this.roleId,
  1241. "taskCode":this.jsonupdateAssetCreditLoss.taskCode,
  1242. "userId":this.userId,
  1243. "url":"updateAssetCreditLossService",
  1244. "jsonDataBefore":{},
  1245. "jsonDataAfter":{
  1246. "id":codeInput,
  1247. "assetType":assetType,
  1248. "assetName":assetName,
  1249. "rating":rating,
  1250. "buyDate":buyDateReform,
  1251. "maturityDate":maturityDateReform,
  1252. "eirRate":eirRate,
  1253. "nominal":nominal,
  1254. // "ratingLGD":ratingLGD,
  1255. // "calculateType":caltypeLGD,
  1256. "type":type,
  1257. "codeType":codeType,
  1258. "name":name,
  1259. "loanType":loanType,
  1260. "currency":currency.toUpperCase(),
  1261. "lembaga":lembaga,
  1262. "kurs":kurs,
  1263. "nominalEqivalen":nominalEqivalen,
  1264. "rekening":rekening,
  1265. "period":period,
  1266. "coaDebet":coaDebet,
  1267. "coaKredit":coaKredit,
  1268.  
  1269. }
  1270. };
  1271.  
  1272.  
  1273.  
  1274.  
  1275. console.log("balikan body : "+JSON.stringify(body2));
  1276.  
  1277. this.callService.getRestResult(body2).subscribe((res) =>{
  1278. this.serviceReturn6=res.json();
  1279.  
  1280. this.statusService6=this.serviceReturn6["0"].serviceContent.status;
  1281.  
  1282. if(this.statusService6=="S")
  1283. {
  1284. this.updateCounter = 0;
  1285. showSwal('success-update');
  1286. this.inquirycalculation("","","","","","");
  1287. }
  1288. else if(this.statusService6=="C"){
  1289. showSwal('need-approval');
  1290. }
  1291. else if(this.statusService6 =="L"){
  1292. this.router.navigateByUrl("/");
  1293. }
  1294. else
  1295. {
  1296. this.errMess=this.serviceReturn6["0"].serviceContent.errorMessage;
  1297. showSwal('failed-update')
  1298. this.inquirycalculation("","","","","","");
  1299. }
  1300. },
  1301. (err)=> {this.router.navigateByUrl('/error500')})
  1302. /*}
  1303. else{
  1304. this.router.navigateByUrl('/home');
  1305. }*/
  1306. }
  1307.  
  1308. reverbUpdateData(){
  1309. this.updateCounter = 0;
  1310. }
  1311.  
  1312. downloadCsv()
  1313. {
  1314. let arrayJsonTemplate2=[];
  1315. let jsonTemplate2={}
  1316. jsonTemplate2['assetType']='AS4';
  1317. jsonTemplate2['assetName']='Laptop';
  1318. jsonTemplate2['rating']='AA';
  1319. jsonTemplate2['rating LGD']='AA';
  1320. jsonTemplate2['buyDate']='20190416';
  1321. jsonTemplate2['maturityDate']='20190416';
  1322. jsonTemplate2['eirRate']='0.12';
  1323. jsonTemplate2['nominal']='3000000';
  1324. jsonTemplate2['calculate type']='LIFETIME';
  1325.  
  1326.  
  1327.  
  1328. arrayJsonTemplate2.push(jsonTemplate2);
  1329.  
  1330. let jsonTemplate3={}
  1331. jsonTemplate3['assetType']='AS4';
  1332. jsonTemplate3['assetName']='Laptop';
  1333. jsonTemplate3['rating']='AA';
  1334. jsonTemplate3['rating LGD']='Example';
  1335. jsonTemplate3['buyDate']='20190416';
  1336. jsonTemplate3['maturityDate']='20190416';
  1337. jsonTemplate3['eirRate']='0.12';
  1338. jsonTemplate3['nominal']='3000000';
  1339. jsonTemplate3['calculate type']='PD1YEAR';
  1340.  
  1341. arrayJsonTemplate2.push(jsonTemplate3)
  1342.  
  1343.  
  1344. this.printXls.exportAsExcelFile(this.arrayOfJsonTemplate,this.arrayListRatingLGD,arrayJsonTemplate2,'CREDITLOSS');
  1345. }
  1346. onchangeUpload(event){
  1347. this.formDataUpload = new FormData();
  1348. let fileList: FileList = event.target.files;
  1349. if(fileList.length > 0) {
  1350. let file: File = fileList[0];
  1351. this.formDataUpload.append('file', file);
  1352. // this.readytoupload =true;
  1353. }
  1354. }
  1355. uploadFileToActivity() {
  1356.  
  1357. /*if(this.jsonupdateAssetCreditLoss['statusAccess']=="Y")
  1358. {*/
  1359. this.loadingBar="true";
  1360. this.reset();
  1361. this.callService.getRestUpload(this.formDataUpload,"uploadFileCreditLossService").subscribe(res =>{
  1362. this.serviceReturn=res;
  1363.  
  1364. if(this.serviceReturn._body=="S"){
  1365. this.loadingBar="false";
  1366. showSwal('success-upload');
  1367. this.uploadFileForm.reset();
  1368. this.inquirycalculation("","","","","","");
  1369. }else{
  1370. this.loadingBar="false";
  1371. showSwal('failed-upload');
  1372. }
  1373.  
  1374. },(err) => { showSwal('error-upload') });
  1375. /*}
  1376. else
  1377. {
  1378. showSwal('access-denied');
  1379. }*/
  1380. }
  1381.  
  1382. reset() {
  1383. this.uploadFileForm.reset();
  1384. }
  1385.  
  1386.  
  1387. baseURL="";
  1388. ngOnInit() {
  1389.  
  1390. // this.editCalcForm.get('type').disable();
  1391. // this.editCalcForm.get('kurs').setValue('');
  1392. // this.editCalcForm.get('nominal').setValue('');
  1393.  
  1394. let Dta = location.href;
  1395. let splitDta = Dta.split("/");
  1396. this.baseURL = splitDta[0]+splitDta[1];
  1397.  
  1398.  
  1399. $('#datepicker-popup1').datepicker({
  1400. enableOnReadonly: true,
  1401. todayHighlight: true,
  1402. autoclose: true,
  1403. });
  1404.  
  1405. $('#datepicker-popup2').datepicker({
  1406. enableOnReadonly: true,
  1407. todayHighlight: true,
  1408. autoclose: true,
  1409. });
  1410. $('#datepicker-popup5').datepicker({
  1411. enableOnReadonly: true,
  1412. todayHighlight: true,
  1413. autoclose: true,
  1414. });
  1415.  
  1416. $('#datepicker-popup3').datepicker({
  1417. enableOnReadonly: true,
  1418. todayHighlight: true,
  1419. autoclose: true,
  1420. });
  1421.  
  1422. // $('#datepicker-popup4').datepicker({
  1423. // enableOnReadonly: true,
  1424. // todayHighlight: true,
  1425. // autoclose: true,
  1426.  
  1427. // });
  1428.  
  1429.  
  1430. $('#datepicker-popup4').datepicker({
  1431. enableOnReadonly: true,
  1432. format: "dd-mm-yyyy",
  1433. todayHighlight: true,
  1434. autoclose: true,
  1435. });
  1436.  
  1437. $('#datepicker-popup5').datepicker({
  1438. enableOnReadonly: true,
  1439. format: "dd-mm-yyyy",
  1440. todayHighlight: true,
  1441. autoclose: true,
  1442. });
  1443. // this.insertDataModelForm = this.fb.group({
  1444. // periodeInsert:['', Validators.required],
  1445. // // detail:this.fb.array( [this.createItem('')])
  1446. // });
  1447.  
  1448. this.decryptMe.startWatching();
  1449. this.decryptMe.onTimerStart();
  1450.  
  1451. this.jsonDeleteAssetCreditLoss={};
  1452. this.jsonInquiryAssetCreditLoss={};
  1453. this.jsonupdateAssetCreditLoss={};
  1454. this.jsonGenerateAssetCreditLoss={};
  1455.  
  1456. var usercred=this.getUserCred.getUserData();
  1457. this.jsonInquiryAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"InquiryAssetDataECL"));
  1458. this.jsonDeleteAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"DeleteAssetDataECL"));
  1459. this.jsonupdateAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"UpdateAssetDataECL"));
  1460. this.jsonGenerateAssetCreditLoss=JSON.parse(this.checkUserCred.checkUserCred(usercred,"GenerateAssetDataECL"));
  1461. this.roleId = JSON.parse(usercred).roleId;
  1462. this.userId = JSON.parse(usercred).userId;
  1463.  
  1464. this.counter="0";
  1465. console.log('test : ' + this.jsonInquiryAssetCreditLoss['statusAccess']);
  1466. /*if(this.jsonInquiryAssetCreditLoss['statusAccess']=="Y")
  1467. {*/
  1468. //console.log("test: " + this.jsonInquiryAssetCreditLoss['statusAccess']=="Y");
  1469. this.inquirycalculation("","","","","","");
  1470.  
  1471. /*}
  1472. else
  1473. {
  1474. showSwal('access-denied');
  1475. }*/
  1476.  
  1477. }
  1478.  
  1479. today="";
  1480. datetime="";
  1481. generateReport()
  1482. {
  1483.  
  1484. console.log("masuk generate report");
  1485. let tanggal:any;
  1486. let date = new Date();
  1487. let month = date.getMonth();
  1488. let day = date.getDate();
  1489. let hour = date.getHours();
  1490. let minute = date.getMinutes();
  1491. let secon = date.getSeconds();
  1492. var sekarang = new Date(date.getFullYear(),month,day,hour,minute,secon);
  1493. var waktu = new Date(date.getFullYear(),month,day,hour,minute,secon);
  1494. this.today= this.datePipe.transform(sekarang,'yMM');
  1495. this.datetime=this.datePipe.transform(waktu,'dd MMMM y - HH:mm:ss');
  1496. tanggal = this.datetime;
  1497. console.log("tanggal :"+tanggal);
  1498. let jsonForPrint={}
  1499. jsonForPrint['itemList']=this.arrayOfECLlist;
  1500. jsonForPrint['tanggal']=tanggal;
  1501. // jsonForPrint['breaktype']=this.breakType;
  1502.  
  1503. console.log("list ecl " + this.arrayOfECLlist);
  1504.  
  1505. this.printECL.printreportPDF(JSON.stringify(jsonForPrint));
  1506.  
  1507. }
  1508.  
  1509. listRatingNameLGD = [];
  1510. arrayListRatingLGD=[];
  1511. inquiryListRatingLGD()
  1512. {
  1513. this.arrayListRatingLGD = [];
  1514. let body2 = {
  1515. "roleId": this.roleId,
  1516. //"taskCode":this.jsonInquiryListAssetRating.taskCode
  1517. "userId":this.userId,
  1518. "url":"inquiryListAssetRatingLGDService"
  1519. };
  1520.  
  1521.  
  1522. this.callService.getRestResult(body2).subscribe((res) =>{
  1523. this.serviceReturn4=res.json();
  1524.  
  1525. this.statusService4=this.serviceReturn4["0"].serviceContent.status;
  1526. this.listRatingNameLGD=[];
  1527.  
  1528. console.log("hasil status : "+this.statusService4);
  1529.  
  1530. if(this.statusService4=="S")
  1531. {
  1532. if(this.serviceReturn4["0"].serviceContent.assetRatingName.length>0)
  1533. {
  1534. for (let i=0; i<this.serviceReturn4["0"].serviceContent.assetRatingName.length; i++)
  1535. {
  1536. this.listRatingNameLGD.push(this.serviceReturn4["0"].serviceContent.assetRatingName[i].ratingType);
  1537.  
  1538. let jsontemplate = {};
  1539. jsontemplate['rating LGD']=this.serviceReturn4["0"].serviceContent.assetRatingName[i].ratingType;
  1540. this.arrayListRatingLGD.push(jsontemplate);
  1541. }
  1542. }
  1543. else
  1544. {
  1545. this.listRatingNameLGD=[];
  1546. }
  1547. }
  1548. else if(this.statusService4 =="L"){
  1549. this.router.navigateByUrl("/");
  1550. }
  1551. })
  1552. }
  1553.  
  1554. statusService9:any;
  1555. serviceReturn9:any;
  1556.  
  1557.  
  1558. typeFilter=[];
  1559. getType()
  1560. {
  1561. this.typeFilter=[];
  1562. let body2={
  1563. "roleId": this.roleId,
  1564. "taskCode":"inquiryConfigurationAssetTypeService",
  1565. "userId":this.userId,
  1566. "url":"inquiryConfigurationAssetTypeService"
  1567. }
  1568.  
  1569. this.callService.getRestResult(body2).subscribe((res) =>{
  1570. let serviceReturn=res.json();
  1571. console.log("return : "+JSON.stringify(serviceReturn));
  1572.  
  1573. let statusService=serviceReturn["0"].serviceContent.status;
  1574. console.log("hasil status type 1 : "+ statusService);
  1575. console.log("hasil status type 2 : "+ serviceReturn["0"].serviceContent.status);
  1576.  
  1577. if(statusService=="S")
  1578. {
  1579. for(var i = 0; i<serviceReturn["0"].serviceContent.listAssetType.length; i++)
  1580. {
  1581. this.typeFilter.push(serviceReturn["0"].serviceContent.listAssetType[i]);
  1582. // this.typeFil.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i].assetType)
  1583. }
  1584. // this.getCodeType();
  1585.  
  1586. }
  1587. else
  1588. {
  1589. console.log("f get type")
  1590.  
  1591. }
  1592. });
  1593. }
  1594.  
  1595.  
  1596. codeTypeFil=[];
  1597. typeFil=[];
  1598. selectedType="";
  1599. getCodeType(typein: string)
  1600. {
  1601. console.log("masuk get code")
  1602. this.codeTypeFil=[];
  1603. this.typeFil=[];
  1604. this.selectedType=typein;
  1605. console.log("type!!" + this.selectedType)
  1606.  
  1607. let body2 = {
  1608. "roleId": this.roleId,
  1609. "taskCode":"inquiryConfigurationAssetTypeService",
  1610. "userId":this.userId,
  1611. "url":"inquiryConfigurationAssetTypeService"
  1612. };
  1613.  
  1614. this.callService.getRestResult(body2).subscribe((res) =>{
  1615. let serviceReturn=res.json();
  1616. console.log("return : "+JSON.stringify(serviceReturn));
  1617.  
  1618. let statusService=serviceReturn["0"].serviceContent.status;
  1619. console.log("hasil status code type 1 : "+ statusService);
  1620. console.log("hasil status code type 2 : "+ serviceReturn["0"].serviceContent.status);
  1621.  
  1622. console.log("len " + serviceReturn["0"].serviceContent.assetTypeList.length)
  1623. if(statusService=="S")
  1624. {
  1625. for(var i = 0; i<serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList.length; i++)
  1626. {
  1627.  
  1628. this.typeFil.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i].assetType)
  1629. }
  1630.  
  1631. for(let i=0; i<this.typeFil.length;i++){
  1632. console.log("KOTA");
  1633. console.log("compare "+this.typeFil[i]+" vs "+this.selectedType);
  1634. if(this.typeFil[i] == this.selectedType){
  1635. this.codeTypeFil.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i])
  1636. this.editCalcForm.controls.codeType.patchValue(this.codeTypeFil[i]);
  1637.  
  1638. }
  1639. }
  1640.  
  1641. }
  1642. });
  1643. }
  1644.  
  1645. codeTypeFilUp=[];
  1646. typeFilUp=[];
  1647. selectedTypeUp="";
  1648. getCodeTypeUpdate(typein: string)
  1649. {
  1650. console.log("masuk get code up")
  1651. this.codeTypeFilUp=[];
  1652. this.typeFilUp=[];
  1653. this.selectedTypeUp=typein;
  1654. var codeUp=this.updateForm.get("codeTypeUpdate").value;
  1655.  
  1656. console.log("code!!" + codeUp)
  1657. console.log("type!!" + this.selectedTypeUp)
  1658.  
  1659. let body2 = {
  1660. "roleId": this.roleId,
  1661. "taskCode":"inquiryConfigurationAssetTypeService",
  1662. "userId":this.userId,
  1663. "url":"inquiryConfigurationAssetTypeService"
  1664. };
  1665.  
  1666. this.callService.getRestResult(body2).subscribe((res) =>{
  1667. let serviceReturn=res.json();
  1668. console.log("return : "+JSON.stringify(serviceReturn));
  1669.  
  1670. let statusService=serviceReturn["0"].serviceContent.status;
  1671. console.log("hasil status code type 1 : "+ statusService);
  1672. console.log("hasil status code type 2 : "+ serviceReturn["0"].serviceContent.status);
  1673.  
  1674. console.log("len " + serviceReturn["0"].serviceContent.assetTypeList.length)
  1675. if(statusService=="S")
  1676. {
  1677. for(var i = 0; i<serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList.length; i++)
  1678. {
  1679.  
  1680. this.typeFilUp.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i].assetType)
  1681. }
  1682.  
  1683. for(let i=0; i<this.typeFilUp.length;i++){
  1684. console.log("KOTA");
  1685. console.log("compare "+this.typeFilUp[i]+" vs "+this.selectedTypeUp);
  1686. if(this.typeFilUp[i] == this.selectedTypeUp){
  1687. this.codeTypeFilUp.push(serviceReturn["0"].serviceContent.assetTypeList["0"].assetCodeList[i])
  1688. this.updateForm.controls.codeTypeUpdate.patchValue(codeUp);
  1689.  
  1690. }
  1691. }
  1692.  
  1693. // this.updateForm.get("codeTypeUpdate").patchValue(this.listCalculation[i].codeType);
  1694.  
  1695. this.onChangeLembagaUpdate(this.lembagaUp);
  1696. }
  1697. });
  1698. }
  1699. setType;
  1700.  
  1701. // onChangeCodeType(valueCodeType)
  1702. // {
  1703. // console.log("val!! " + this.editCalcForm.get('codeType').value)
  1704. // if(this.editCalcForm.get('codeType').value=="null")
  1705. // {
  1706. // this.editCalcForm.get('type').setValue("");
  1707. // this.editCalcForm.controls['type'].markAsTouched();
  1708. // }
  1709. // else{
  1710. // for(var i = 0; i<this.typeFil.length; i++)
  1711. // {
  1712. // if(this.codeTypeFil[i].assetCode==valueCodeType)
  1713. // {
  1714. // this.setType=this.codeTypeFil[i].assetType;
  1715. // }
  1716.  
  1717. // }
  1718. // this.editCalcForm.get('type').disable();
  1719. // this.editCalcForm.get('type').setValue(this.setType);
  1720. // // console.log("val " + this.editCalcForm.get('codeType').value)
  1721.  
  1722. // }
  1723. // }
  1724.  
  1725. // onChangeCodeTypeUpdate(valueCodeType)
  1726. // {
  1727.  
  1728. // console.log("val2!! " + this.updateForm.get('codeTypeUpdate').value)
  1729. // if(this.updateForm.get('codeTypeUpdate').value=="null")
  1730. // {
  1731. // console.log("val 2 msk null")
  1732. // this.updateForm.controls['typeUpdate'].setValue("");
  1733. // this.updateForm.controls['typeUpdate'].markAsTouched();
  1734. // console.log("value up" + this.updateForm.controls['typeUpdate'].value)
  1735. // }
  1736. // else{
  1737. // console.log("masuk else")
  1738. // for(var i = 0; i<this.typeFil.length; i++)
  1739. // {
  1740. // if(this.codeTypeFil[i].assetCode==valueCodeType)
  1741. // {
  1742. // this.setType=this.codeTypeFil[i].assetType;
  1743. // }
  1744.  
  1745. // }
  1746. // this.updateForm.get('typeUpdate').disable();
  1747. // this.updateForm.get('typeUpdate').setValue(this.setType);
  1748.  
  1749. // }
  1750.  
  1751. // }
  1752.  
  1753. nominalVal="";
  1754. onChangeNominal(valueNominal)
  1755. {
  1756. console.log("nominal " + valueNominal)
  1757. this.nominalVal=valueNominal;
  1758. let nominalKurs;
  1759. nominalKurs = this.kursVal
  1760. let nominalEq;
  1761. if(nominalKurs=="" || this.nominalVal=="")
  1762. {
  1763. this.editCalcForm.get('nominalEqivalen').setValue("Please input nominal and kurs value");
  1764. }
  1765. else
  1766. {
  1767. nominalEq = parseInt(this.nominalVal) * parseInt(nominalKurs);
  1768. console.log("nominal eq " + nominalEq)
  1769. this.editCalcForm.get('nominalEqivalen').setValue(nominalEq);
  1770.  
  1771. }
  1772.  
  1773. }
  1774.  
  1775. nominalValUpdate="";
  1776. onChangeNominalUpdate(valueNominal)
  1777. {
  1778. console.log("nominal " + valueNominal)
  1779. this.nominalValUpdate=valueNominal;
  1780. let nominalKurs;
  1781. nominalKurs = this.kursValUpdate;
  1782. let nominalEq;
  1783. var nominalKursForm = this.updateForm.get('kursUpdate').value
  1784.  
  1785. if(nominalKursForm!="")
  1786. {
  1787. nominalEq = parseInt(this.nominalValUpdate) * parseInt(nominalKursForm);
  1788. this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
  1789. }
  1790.  
  1791. else {
  1792.  
  1793. if(nominalKurs=="" || this.nominalValUpdate=="")
  1794. {
  1795. this.updateForm.get('nominalEqivalenUpdate').setValue("Please input nominal and kurs value");
  1796. }
  1797. else
  1798. {
  1799. nominalEq = parseInt(this.nominalValUpdate) * parseInt(nominalKurs);
  1800. console.log("nominal eq " + nominalEq)
  1801. this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
  1802.  
  1803. }
  1804.  
  1805. }
  1806.  
  1807. }
  1808.  
  1809. kursVal="";
  1810. onChangeKurs(valueKurs)
  1811. {
  1812. console.log("kurs " + valueKurs)
  1813. this.kursVal=valueKurs;
  1814. let nominal;
  1815. let nominalEq;
  1816. nominal = this.nominalVal
  1817. console.log(nominal);
  1818.  
  1819. if(nominal=="" || this.kursVal=="")
  1820. {
  1821. this.editCalcForm.get('nominalEqivalen').setValue("Please input nominal and kurs value");
  1822. }
  1823. else
  1824. {
  1825.  
  1826. nominalEq = parseInt(this.kursVal) * parseInt(nominal);
  1827. console.log("nominal eq 2 " + nominalEq);
  1828. this.editCalcForm.get('nominalEqivalen').setValue(nominalEq);
  1829.  
  1830. }
  1831. console.log(this.kursVal);
  1832. // this.editCalcForm.get('kurs').setValue(this.kursVal);
  1833. }
  1834.  
  1835. kursValUpdate=""
  1836. onChangeKursUpdate(valueKurs)
  1837. {
  1838. console.log("kurs " + valueKurs)
  1839. this.kursValUpdate=valueKurs;
  1840. let nominal;
  1841. let nominalEq;
  1842. var nominalValForm = this.updateForm.get('nominalUpdate').value
  1843. nominal = this.nominalValUpdate
  1844.  
  1845.  
  1846. if(nominalValForm!="")
  1847. {
  1848. nominalEq = parseInt(this.kursValUpdate) * parseInt(nominalValForm);
  1849. this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
  1850. }
  1851.  
  1852. else{
  1853.  
  1854. if(nominal=="" || this.kursValUpdate=="")
  1855. {
  1856. this.updateForm.get('nominalEqivalenUpdate').setValue("Please input nominal and kurs value");
  1857. }
  1858. else
  1859. {
  1860.  
  1861. nominalEq = parseInt(this.kursValUpdate) * parseInt(nominal);
  1862. console.log("nominal eq 2 " + nominalEq);
  1863. this.updateForm.get('nominalEqivalenUpdate').setValue(nominalEq);
  1864.  
  1865. }
  1866.  
  1867. }
  1868.  
  1869. console.log(this.kursValUpdate);
  1870. // this.updateForm.get('kursUpdate').setValue(this.kursValUpdate);
  1871.  
  1872.  
  1873. }
  1874.  
  1875. listAssetType=[];
  1876. // getListAssetType()
  1877.  
  1878. // {
  1879. // console.log("masuk get type")
  1880. // this.listAssetType=[];
  1881.  
  1882. // let body2={
  1883. // "roleId": this.roleId,
  1884. // "taskCode":"inquiryConfigurationAssetTypeService",
  1885. // "userId":this.userId,
  1886. // "url":"inquiryConfigurationAssetTypeService"
  1887. // }
  1888.  
  1889. // }
  1890.  
  1891. // today:any;
  1892. // datetime:any;
  1893.  
  1894. generateReportExcel()
  1895. {
  1896. let data=[];
  1897. let dataTotal=[];
  1898. let dataSummary=[];
  1899. let date = new Date();
  1900. let month = date.getMonth();
  1901. let day = date.getDate();
  1902. let hour = date.getHours();
  1903. let minute = date.getMinutes();
  1904. let secon = date.getSeconds();
  1905. console.log("next : "+(date.getFullYear()));
  1906. var sekarang = new Date(date.getFullYear(),month,day,hour,minute,secon);
  1907. var waktu = new Date(date.getFullYear(),month,day,hour,minute,secon);
  1908. console.log("var : "+waktu);
  1909. var monthArray = ["Januari","Februari","Maret","April","Mei","Juni","Juli",
  1910. "Agustus","September","Oktober","November","Desember"];
  1911. this.today= this.datePipe.transform(sekarang,'yMM');
  1912. this.datetime=this.datePipe.transform(waktu,'yMMdHHmmss');
  1913. console.log("waktunya : "+this.datetime);
  1914. console.log("today : "+this.today);
  1915.  
  1916. let monthString = monthArray[month];
  1917. let yearString = this.datePipe.transform(sekarang,'y');
  1918.  
  1919.  
  1920. let yearMonthString = monthString+" "+yearString;
  1921.  
  1922. let body2 =
  1923. {
  1924. "roleId": this.roleId,
  1925. "userId": this.userId,
  1926. "taskCode": "inquiryAssetCreditLossForPrintService",
  1927. "datetime": this.datetime,
  1928. "url": "inquiryAssetCreditLossForPrintService",
  1929. "randomString": "null",
  1930. "sessionId":"TEST123"
  1931. };
  1932.  
  1933. this.callService.getRestResult(body2).subscribe((res) =>{
  1934. let serviceReturn=res.json();
  1935. let statusService=serviceReturn["0"].serviceContent.status;
  1936.  
  1937. if(statusService=="S")
  1938. {
  1939. let listAsset=[];
  1940. if(serviceReturn["0"].serviceContent.creditLossList.length>0)
  1941. {
  1942. dataTotal=[];
  1943. dataSummary=[];
  1944. for (let i=0; i<serviceReturn["0"].serviceContent.creditLossList.length; i++)
  1945. {
  1946. console.log("DATA STRING : "+JSON.stringify(serviceReturn["0"].serviceContent.creditLossList[i]));
  1947. let jsonTemplateSummary={};
  1948.  
  1949. jsonTemplateSummary['Number']=i+1;
  1950. jsonTemplateSummary['assetType']=serviceReturn["0"].serviceContent.creditLossList[i].typeDist;
  1951. jsonTemplateSummary['transactionType']=serviceReturn["0"].serviceContent.creditLossList[i].transactionType;
  1952. listAsset.push(serviceReturn["0"].serviceContent.creditLossList[i].typeDist);
  1953. data =[];
  1954.  
  1955. let nilaiTercatat = 0;
  1956. let CKPN = 0;
  1957. for(let j=0; j<serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct.length; j++)
  1958. {
  1959. let jsonTemplate={}
  1960. jsonTemplate['jenis']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].type;
  1961. jsonTemplate['kodeParameter']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].codeType;
  1962. jsonTemplate['assetType']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].assetType;
  1963. jsonTemplate['rekening']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].rekening;
  1964. jsonTemplate['assetName']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].assetName;
  1965. jsonTemplate['loanType']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].loanType;
  1966. jsonTemplate['lembaga']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].lembaga;
  1967.  
  1968. jsonTemplate['currency']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].currency;
  1969. jsonTemplate['rating']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].rating;
  1970.  
  1971. jsonTemplate['buyDate']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].buyDate;
  1972. jsonTemplate['maturityDate']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].maturityDate;
  1973. jsonTemplate['eirRate']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].eirRate;
  1974. jsonTemplate['nominal']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].nominal;
  1975. jsonTemplate['kurs']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].kurs;
  1976. jsonTemplate['nominalEqivalen']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].nominalEqivalen;
  1977. jsonTemplate['PD']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].PD;
  1978. jsonTemplate['LGD']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].LGD;
  1979. jsonTemplate['discountFactor']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].discountFactor;
  1980. jsonTemplate['creditLoss']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].creditLoss;
  1981.  
  1982. nilaiTercatat+=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].nominalEqivalen;
  1983. CKPN+=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossDistinct[j].creditLoss;
  1984.  
  1985. data.push(jsonTemplate);
  1986.  
  1987.  
  1988. }
  1989. jsonTemplateSummary['summaryCreditLoss']=serviceReturn["0"].serviceContent.creditLossList[i].assetCreditLossSummary;
  1990. dataSummary.push(jsonTemplateSummary);
  1991.  
  1992. dataTotal.push(data);
  1993.  
  1994. }
  1995. }
  1996.  
  1997. // this.printXLS.exportAsExcelFile(dataTotal,rating, 'Stepwise Regression -');
  1998. this.printECLXLS.generateExcel(dataTotal,listAsset,dataSummary,yearMonthString,serviceReturn["0"].serviceContent, 'Laporan OJK -');
  1999. }
  2000. else if(statusService=="L"){
  2001. this.router.navigateByUrl("/");
  2002. }
  2003. else{
  2004. // this.openModalInformation("Failed","Process Failed",0);
  2005. showSwal('failed-add')
  2006. }
  2007.  
  2008. })
  2009.  
  2010.  
  2011. }
  2012.  
  2013.  
  2014. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement