Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.69 KB | None | 0 0
  1. /// <reference path="./../../../../../../nes-app/app/scripts/references.d.ts" />
  2. /// <reference path="./../services/LD.ts" />
  3.  
  4. import {
  5. Screen,
  6. Scr,
  7. ScrView,
  8. ScreenOptions
  9. } from 'nes2/screen';
  10. import {NesKendoDataSource, ConfigService } from 'nes2/services';
  11. import {LifecycleEvent} from 'angular2/angular2';
  12. import app from 'nes2/app';
  13. import {tllrTxn} from '../services/tllrTxn';
  14. import {TllrLdTxn} from '../services/tllrLdTxn';
  15. import { ld } from 'screens/LD-B/services/ld';
  16. import {TmwSv} from '../../TMW-M/services/tmwSv';
  17. import { Asp } from '../../ASP-C/services/asp';
  18. @Scr({
  19. type: TLLRA354,
  20. selector: 'TLLR-A-354'
  21. })
  22.  
  23. @ScrView({
  24. templateUrl: "TLLR-A-354"
  25. })
  26. export default class TLLRA354 extends Screen {
  27.  
  28. config = new ConfigService();
  29. tllrTxn: tllrTxn = new tllrTxn(this);
  30. isEnableTxn: boolean = false;
  31. ldTxn: TllrLdTxn = new TllrLdTxn(this);
  32. tmwSv: TmwSv = new TmwSv();
  33. asp: Asp = new Asp();
  34. ld: ld = new ld();
  35. operation: number = 0;
  36.  
  37. model: any = { txnAmount: 0, contAmount: 0, princ: 0 };
  38. acntCode: string;
  39. paymentType: string;
  40. isGetAcntInfo: boolean = false;
  41. isGetAcntInfo1: boolean = false;
  42. txnCode: string = "LD_START_ACNT";
  43. curCode: string;
  44. contCurCode: string;
  45. rateType: string;
  46. size: number = 12;
  47. cashRequireBanknote: number = 0;
  48. extraCode: number = this.ldTxn.opStartAcnt["BORR_NONCASH"];
  49. dialogResult: any;
  50. isDescRequired: number = 0;
  51. acntType: any = {
  52. "1305": "1",
  53. "1301": "3",
  54. "1318": "4",
  55. "1368": "5"
  56. };
  57.  
  58. extAcntType: any = {
  59. "1": "GB3DP",
  60. "3": "GB3BA"
  61. }
  62. //for stored value
  63. svKey: string;
  64. extSystem: any = {
  65. // "1": "INTERNAL_GB", // CASA
  66. // "3": "INTERNAL_GB" // BAC
  67. }; // Гадны системүүдийн дугаар
  68. cashBankNote: any = [];
  69. changeBankNotes: any = [];
  70. txnAmtCorrDiff: boolean = false;
  71. correctionAmt: number = -1;
  72. txnClearAmount: number;
  73. sumTotalAmount: number = 0;
  74. txnType: string;
  75. sourceType: string;
  76. useRadioCash: boolean = true;
  77. isChange: number = 1;
  78. module: string = "MM";
  79. camData: any = {};
  80.  
  81. brwsDealCode: NesBrowse;
  82. brwsContAcntCode: NesBrowse;
  83. ddlAcntType: NesDropdown;
  84. ddlCurCode: NesDropdown;
  85. ddlContCurCode: NesDropdown;
  86. ddlRateType: NesDropdown;
  87. numContAmount: NesNumeric;
  88. numContRate: NesNumeric;
  89. numRate: NesNumeric;
  90. numTxnAmount: NesNumeric;
  91. rdNonCash: NesRadio;
  92. rdCash: NesRadio;
  93.  
  94. constructor(options: ScreenOptions) {
  95. super(options);
  96. }
  97.  
  98. afterInit() {
  99. this.checkRequired();
  100. this.brwsDealCode = <NesBrowse>this.getControl("formTLLRA354/browseDealCode");
  101. this.brwsContAcntCode = <NesBrowse>this.getControl("formTLLRA354/browseContAcntCode");
  102. this.ddlAcntType = <NesDropdown>this.getControl("formTLLRA354/dropdownAcntType");
  103. this.ddlCurCode = <NesDropdown>this.getControl("formTLLRA354/dropdownCurCode");
  104. this.ddlContCurCode = <NesDropdown>this.getControl("formTLLRA354/dropdownContCurCode");
  105. this.ddlRateType = <NesDropdown>this.getControl("formTLLRA354/dropdownRateTypeId");
  106. this.numContAmount = <NesNumeric>this.getControl("formTLLRA354/numericContAmount");
  107. this.numContRate = <NesNumeric>this.getControl("formTLLRA354/numericContRate");
  108. this.numTxnAmount = <NesNumeric>this.getControl("formTLLRA354/numericTxnAmount");
  109. this.numRate = <NesNumeric>this.getControl("formTLLRA354/numericRate");
  110. this.rdNonCash = <NesRadio>this.getControl("formTLLRA354/radioNonCash");
  111. this.rdCash = <NesRadio>this.getControl("formTLLRA354/radioCash");
  112.  
  113. this.getExtSystem(1412, "0"); //CASH
  114. this.getExtSystem(1301, "3");
  115. this.getExtSystem(1305, "1");
  116. this.getExtSystem(1318, "4");
  117. this.getExtSystem(1368, "5");
  118.  
  119. this.tllrTxn.getConfigValue("CASH_REQUIRE_BANKNOTE")
  120. .then((response) => {
  121. if (parseInt(response)) {
  122. this.cashRequireBanknote = 1;
  123. }
  124. else {
  125. this.cashRequireBanknote = 0;
  126. }
  127. }, (err) => { this.error(err); });
  128.  
  129. this.ddlRateType.bind('dataBound', (data) => {
  130. if (this.ddlRateType.dataSource.data().length) {
  131. if (this.ddlRateType.dataSource.data().find(obj => obj.extra == 1)) {
  132. this.rateType = this.ddlRateType.dataSource.data().find(obj => obj.extra == 1).id;
  133. this.ddlRateType.value = this.rateType;
  134. }
  135. else
  136. this.ddlRateType.value = this.ddlRateType.dataSource.data()[0].id;
  137. this.ddlRateType.trigger("change");
  138. }
  139. });
  140.  
  141. this.tllrTxn.GetBaseCur()
  142. .then((response) => {
  143. this.curCode = response;
  144. this.contCurCode = response;
  145.  
  146. if (this.ddlContCurCode.dataSource.data().length > 0) {
  147. this.model.contCurCode = response;
  148. this.ddlContCurCode.value = response;
  149. }
  150.  
  151. if (this.ddlCurCode.dataSource.data().length > 0) {
  152. this.model.curCode = response;
  153. this.ddlCurCode.value = response;
  154. }
  155.  
  156. if (this.ddlContCurCode.value && this.ddlRateType.value)
  157. this.ddlRateType.trigger("change");
  158. }, (err) => {
  159. this.error(err);
  160. });
  161.  
  162. if (this.param != undefined && !this.param.empty) {
  163. let paramObj = this.param.get(0);
  164. this.sourceType = paramObj.sourceType;
  165. if (this.sourceType == 'TMWM120') {
  166. this.formDisabled(true);
  167.  
  168. this.isChange = 0;
  169. this.tllrTxn.detailPendJrnl(paramObj.jrno)
  170. .then((data) => {
  171. data.addParams = JSON.parse(data.addParams);
  172. this.model = data;
  173. if (data.contSysNo == 1412)
  174. this.rdCash.checked = "true";
  175. else if (data.contSysNo == 1301 && data.addParams && data.addParams.HASIK) {
  176. this.model.contSysNo = data.addParams.ISFITOFI == "true" ? 1368 : 1318;
  177. this.model.rcvBankBrchCode = data.addParams.RCVBANKBRCHCODE;
  178. this.model.camRecieve = data.addParams.CAMRECIEVE;
  179. this.model.aliasType = data.contBankAliasType;
  180. this.model.alias = data.contBankAlias;
  181. this.setAcntType(this.model.contSysNo);
  182. this.ddlAcntType.value = this.model.acntType;
  183. this.changeAcntType();
  184. }
  185.  
  186. this.radioChange(data.contSysNo == 1412);
  187. this.detectChanges();
  188. }, (err) => { this.error(err); });
  189. } else {
  190. if (this.param.get(0).acntCode) {
  191. // this.brwsDealCode.value = this.param.get(0).acntCode;
  192. this.model.txnAcntCode = this.param.get(0).acntCode;
  193. this.model.acntCode = this.param.get(0).acntCode;
  194. }
  195. else {
  196. // this.brwsDealCode.value = this.param.get(0);
  197. this.model.txnAcntCode = this.param.get(0);
  198. }
  199. this.checkDefaultRadio();
  200. }
  201.  
  202. // this.isChanged();
  203. this.brwsDealCode.disabled = true;
  204. } else this.checkDefaultRadio();
  205. }
  206.  
  207. doTran(isPreview: number, e: any) {
  208. this.checkTxn(isPreview, e)
  209. }
  210. checkTxn(isPreview: number, e: any){
  211. if (e)
  212. e.preventDefault();
  213.  
  214. if (!this.controls.formTLLRA354.valid)
  215. return;
  216.  
  217. if (this.model.prodType === "BORROWING" && this.model.acntType === "4") {
  218. this.warn("Эх үүсвэр татах гүйлгээг банк хооронд хийх боломжгүй!");
  219. return;
  220. }
  221.  
  222. this.tllrTxn.disableTxnBtn(this, true);
  223. if (!isPreview && !confirm("Гүйлгээ хийхдээ итгэлтэй байна уу?")){
  224. this.tllrTxn.disableTxnBtn(this, false);
  225. return;
  226. }
  227.  
  228. // let data = this.controls.formTLLRA354.value;
  229. let txnParam = {
  230. txnAcntCode: this.model.txnAcntCode,
  231. txnAmount: this.model.txnAmount - this.model.discountAmount,
  232. txnClearAmount: this.txnClearAmount,
  233. rate: this.model.rate,
  234. curCode: this.model.curCode,
  235. rateTypeId: this.model.rateTypeId,
  236. contSysNo: this.rdNonCash.checked ? this.model.sysNo : 1412,
  237. contAmount: this.model.contAmount,
  238. contRate: this.model.contRate,
  239. contCurCode: this.model.contCurCode,
  240. txnDesc: this.model.txnDesc,
  241. txnDefCode: this.model.txnDefCode,
  242. banknotes: this.rdCash.checked && this.cashRequireBanknote ? this.cashBankNote : [],
  243. changeBanknotes: this.rdCash.checked && this.cashRequireBanknote ? this.changeBankNotes : [],
  244. sourceType: this.tllrTxn.sourceType,
  245. isPreview: isPreview,
  246. isPreviewFee: this.config.get(this.scrCode, this.txnCode + "_fee"),
  247. isTmw: 1,
  248. operCode: this.extraCode,
  249. dealCode: this.model.dealCode
  250. };
  251.  
  252. if (txnParam.contSysNo == 1318 || txnParam.contSysNo == 1368)
  253. txnParam.addParams = {
  254. hasIk: 1,
  255. isFiToFi: txnParam.contSysNo == 1368
  256. };
  257.  
  258. if (txnParam.contSysNo == 1318) {
  259. txnParam.contCheckMsgId = this.camData.msgId;
  260. txnParam.addParams.camRecieve = this.model.camRecieve;
  261. if (this.model.camRecieve == "ALIAS") {
  262. txnParam.contBankCode = this.camData.bankId;
  263. txnParam.contBankAcntCode = this.camData.acntCode;
  264. txnParam.contBankAcntName = this.camData.name;
  265. } else {
  266. txnParam.contBankCode = this.model.contBankCode;
  267. txnParam.contBankAcntCode = this.model.contBankAcntCode;
  268. txnParam.contBankAcntName = this.model.contBankAcntName;
  269. txnParam.addParams.rcvBankBrchCode = this.model.rcvBankBrchCode;
  270. }
  271.  
  272. txnParam.addition = txnParam.addParams;
  273.  
  274. } else if (txnParam.contSysNo == 1368) {
  275. txnParam.contBankCode = this.model.contBankCode;
  276. txnParam.addParams.rcvBankBrchCode = this.model.rcvBankBrchCode;
  277. txnParam.addition = txnParam.addParams;
  278. }
  279. else {
  280. txnParam.contAcntCode = this.rdNonCash.checked ? this.model.contAcntCode : null;
  281. }
  282.  
  283. var aspParam = [[{
  284. acntCode: txnParam.txnAcntCode,
  285. acntType: "INCOME",
  286. }],
  287. this.extraCode
  288. ];
  289. txnParam.aspParam = aspParam;
  290.  
  291. if (this.rdCash.checked && this.cashRequireBanknote == 1 && this.sumTotalAmount !=1) { // sumtotalAmount guilgeeni devsgert oruulsan eseh
  292. this.doTranPreview(isPreview,e, txnParam);
  293. return;
  294. }
  295.  
  296. if(isPreview == 1){
  297. this.doTransaction(isPreview, e, txnParam);
  298. }
  299. else
  300. this.asp.checkRule(aspParam)
  301. .then((response) => {
  302. if (response) {
  303. app.screen({
  304. name: "ASP-C-001",
  305. parameter: aspParam,
  306. parent: this,
  307. // parentScreen: this,
  308. onClose: (dialogResult) => {
  309. if (dialogResult[1]) {
  310. if (dialogResult[0])
  311. txnParam.chequeNo = dialogResult[0];
  312. txnParam.aspTan = dialogResult[1];
  313. this.doTransaction(isPreview, e, txnParam);
  314. }
  315. else {
  316. this.error("Дансанд хандах эрхийн шалгалт амжилтгүй. Гүйлгээний мэдээллээ дахин шалгана уу.");
  317. }
  318. }
  319. });
  320. }
  321. else {
  322. this.doTransaction(isPreview, e, txnParam);
  323. }
  324. }, (err) => { this.error(err); });
  325. }
  326.  
  327. doTransaction(isPreview: number, e: any, txnParam:any) {
  328. this.ldTxn.ldStartAcnt(txnParam)
  329. this.tllrTxn.executeDealTxn(txnParam, this.operation)
  330. .then((response) => {
  331. this.warnMsg = response.warningMsg;
  332. if (txnParam.isPreviewFee) {
  333. this.showFee(txnParam, response.txnPreview, response.feesPreview);
  334. return;
  335. }
  336.  
  337. if (response.isPreview) {
  338. txnParam.isPreview = 0;
  339. this.showTran([{
  340. operCode: this.extraCode,
  341. txnParam: txnParam,
  342. txnAcntCode: this.model.txnAcntCode,
  343. txnPreview: response.txnPreview,
  344. isSupervisor: response.isSupervisor,
  345. pendReason: response.pendReason,
  346. cfgPrefix: this.scrCode,
  347. cfgScrName: this.txnCode,
  348. isDescRequired: this.isDescRequired
  349. }]);
  350. }
  351. else {
  352. switch (response.isSupervisor) {
  353. case 1: {
  354. let data = [];
  355. data.push(response.txnJrno);
  356. data.push(response.pendReason);
  357. data.push('TLLR');
  358. if(response.unDelegated)
  359. data.push(response.unDelegated);
  360. this.success("Хүлээлгэх гүйлгээ бүртгэгдлээ (" + response.txnJrno +")");
  361. this.tmwSv.showSv(data).then((dialogResult) => {
  362. if(dialogResult)
  363. this.clear();
  364. }, (err) => {
  365. this.error(err);
  366. });
  367.  
  368. this.getControl('formTLLRA354/buttonDoTxn').disabled = true;
  369. break;
  370. }
  371. case 0: {
  372. this.tllrTxn.disableTxnBtn(this, false);
  373. if(this.warnMsg) {
  374. this.warn("Амжилттай (" + response.txnJrno + "). " + this.warnMsg+"!");;
  375. } else {
  376. this.success("Амжилттай (" + response.txnJrno + ")");
  377. }
  378. this.dialogResult = response.txnJrno;
  379.  
  380. if (this.config.get(this.scrCode, this.txnCode) == 1) {
  381. app.screen({
  382. name: "DOT-S-113",
  383. parameter: {
  384. sysNo: 1360,
  385. txnCode: this.ldTxn.operLdStartAcnt,
  386. descRequired: this.isDescRequired,
  387. expType: "HTML",
  388. data: [{
  389. paramType: 0,
  390. paramCode: "TXN_JRNO",
  391. value: response.txnJrno
  392. }]
  393. },
  394. parent: this
  395. });
  396. }
  397.  
  398. this.clear();
  399. break;
  400. }
  401. }
  402. }
  403. }, (err) => {
  404. this.sumTotalAmount = 0;
  405. this.tllrTxn.disableTxnBtn(this, false);
  406. this.error(err);
  407. });
  408. }
  409.  
  410. showTran(data: any) {
  411. this.tllrTxn.disableTxnBtn(this, false);
  412. app.screen({
  413. name: "TLLR-A-600",
  414. parameter: data,
  415. parent: this,
  416. onClose: (dialogResult) => {
  417. if (dialogResult) {
  418. this.dialogResult = dialogResult.txnJrno;
  419. this.clear();
  420. }
  421. }
  422. });
  423. }
  424.  
  425. browseAcnt(isTxnAcntCode: boolean) {
  426. if (isTxnAcntCode)
  427. app.screen({
  428. name: "MM-B-112",
  429. parameter: [{status: this.filterStatus}],
  430. parent: this,
  431. parentScreen: this,
  432. onClose: (dialogResult) => {
  433. if (dialogResult) {
  434. this.isGetAcntInfo = true;
  435. this.brwsDealCode.value = dialogResult.get("ldAcntCode");
  436. this.model.dealCode = dialogResult.get("dealCode");
  437. //this.brwsDealCode.value = dialogResult.get("dealCode");
  438. this.model.acntName = dialogResult.get("name");
  439. this.isGetAcntInfo = false;
  440. this.model.custCode = dialogResult.get("custCode");
  441. // this.model.princ = dialogResult.get("principalAmount");
  442. this.model.txnAmount = dialogResult.get("principalAmount");
  443. this.model.discountAmount = dialogResult.get("discountAmount") ? parseFloat(dialogResult.get("discountAmount")) : 0;
  444. this.paymentType = dialogResult.get("paymentType");
  445.  
  446. this.ddlCurCode.value = dialogResult.get("curCode");
  447. this.contCurCode = dialogResult.get("curCode");
  448. this.ddlCurCode.trigger("change");
  449. this.model.curCode = dialogResult.get("curCode");
  450. this.model.prodType = dialogResult.get("prodType");
  451. this.txnType = this.model.prodType === "BORROWING" ? "CR" : "DR";
  452. this.setOperCode();
  453.  
  454. if (this.rdNonCash.checked)
  455. this.getCssiAcnt(dialogResult.get("ldAcntCode"));
  456. else {
  457. this.model.contCurCode = dialogResult.get("curCode");
  458. this.ddlContCurCode.value = dialogResult.get("curCode");
  459. this.ddlCurCode.trigger("change");
  460. }
  461.  
  462. if(this.paymentType == "BEARING"){
  463. $(".discount").hide();
  464. }
  465. else{
  466. $(".discount").show();
  467. }
  468. }
  469. }
  470. });
  471. else {
  472. app.screen({
  473. name: "BCOM-C-122",
  474. parameter: [{
  475. sysNo: this.model.sysNo ? this.model.sysNo : ["1301", "1305"],
  476. custCode: this.model.custCode,
  477. changeCust: 1,
  478. // curCode: this.model.curCode,
  479. status: "O",
  480. showClosed: false
  481. }],
  482. parent: this,
  483. onClose: (dialogResult) => {
  484. if (dialogResult) {
  485. this.model.sysNo = Number(dialogResult.get("sysNo"));
  486. this.isGetAcntInfo1 = true;
  487. // this.brwsContAcntCode.value = dialogResult.get("acntCode");
  488. this.model.contAcntCode = dialogResult.get("acntCode");
  489. // this.model.contAcntCode = dialogResult.get("acntCode");
  490. this.model.contAcntName = dialogResult.get("name");
  491. this.isGetAcntInfo1 = false;
  492.  
  493. this.ddlContCurCode.value = dialogResult.get("curCode");
  494. this.ddlContCurCode.trigger("change");
  495. this.model.contCurCode = dialogResult.get("curCode");
  496. }
  497. }
  498. });
  499. }
  500. }
  501.  
  502. isChanged(isTxnAcntCode: boolean) {
  503. if (isTxnAcntCode && !this.isGetAcntInfo) {
  504. if (this.brwsDealCode && this.brwsDealCode.value) {
  505. this.ld.getAcntDetail(this.brwsDealCode.value)
  506. .then((data) => {
  507. this.model.discountAmount = data.discountAmount ? parseFloat(data.discountAmount) : 0;
  508. this.model.txnAmount = data.principalAmount;
  509. // this.model.princ = data.principalAmount;
  510. this.model.acntName = data.name;
  511. this.paymentType = data.paymentType;
  512. this.model.custCode = data.custCode;
  513.  
  514. this.ddlCurCode.value = data.curCode;
  515. this.contCurCode = data.curCode;
  516. this.ddlCurCode.trigger("change");
  517. this.model.curCode = data.curCode;
  518. this.model.prodType = data.prodType;
  519. this.txnType = this.model.prodType === "BORROWING" ? "CR" : "DR";
  520. this.setOperCode();
  521.  
  522. if (!this.sourceType) {
  523. if (this.rdNonCash.checked)
  524. this.getCssiAcnt(data.acntCode);
  525. else {
  526. this.model.contCurCode = data.curCode;
  527. this.ddlContCurCode.value = data.curCode;
  528. this.ddlCurCode.trigger("change");
  529. }
  530. }
  531.  
  532. if(this.paymentType == "BEARING"){
  533. $(".discount").hide();
  534. }
  535. else{
  536. $(".discount").show();
  537. }
  538. },
  539. (err) => {
  540. this.error(err);
  541. });
  542. }
  543. this.isGetAcntInfo = false;
  544. }
  545. else if (!isTxnAcntCode && !this.isGetAcntInfo1) {
  546. if (!this.isChange && this.model.contSysNo == 1412)
  547. return;
  548.  
  549. if (this.model.contAcntCode) {
  550. if (this.extSystem[this.model.acntType]) {
  551. this.tllrTxn.detailExtSystemAcnt(this.extAcntType[this.model.acntType], this.model.contAcntCode)
  552. .then((data) => {
  553. if (data.CUSTNAME)
  554. this.model.contAcntName = data.CUSTNAME;
  555.  
  556. if (data.ACNTNAME)
  557. this.model.contAcntName = data.ACNTNAME;
  558.  
  559. this.ddlContCurCode.value = data.CURCODE;
  560. this.ddlContCurCode.trigger("change");
  561. this.model.contCurCode = data.CURCODE;
  562. }, (err) => {
  563. this.error(err);
  564. });
  565. }
  566. else {
  567. this.tllrTxn.getDetailBcomAcnt(this.brwsContAcntCode.value)
  568. .then((data) => {
  569. this.model.sysNo = Number(data.sysNo);
  570. this.model.contAcntName = data.name;
  571.  
  572. this.ddlContCurCode.value = data.curCode;
  573. this.ddlContCurCode.trigger("change");
  574. this.model.contCurCode = data.curCode;
  575.  
  576. this.setAcntType(data.sysNo);
  577. }, (err) => {
  578. this.error(err);
  579. });
  580. }
  581. }
  582.  
  583. this.isGetAcntInfo1 = false;
  584. }
  585. }
  586.  
  587. getCssiAcnt(acntCode: string) {
  588. this.ld.getCssiAcnt(acntCode, this.model.prodType == "BORROWING" ? "F" : "T", this.module)
  589. .then((data) => {
  590. if (data) {
  591. this.isGetAcntInfo1 = true;
  592.  
  593. // if (data.typeCode == "LOCALBANK_GB" || data.typeCode == "LOCALBANK" || data.typeCode == "CENTRAL_BANK")
  594. // this.model.contBankCode = data.bankCode;
  595.  
  596. // if (data.typeCode == "LOCALBANK_GB" || data.typeCode == "LOCALBANK") {
  597. // this.model.contBankAcntCode = data.acntCode;
  598. // this.model.rcvBankBrchCode = data.bankBrchCode;
  599. // this.model.contBankAcntName = data.benName;
  600. // this.model.contAcntName = null;
  601. // }
  602.  
  603. if (data.typeCode == "CENTRAL_BANK")
  604. this.model.contBankCode = data.bankCode;
  605.  
  606. if (data.typeCode == "LOCALBANK_GB" || data.typeCode == "LOCALBANK") {
  607. this.model.camRecieve = data.useAlias == 1 ? "ALIAS" : "ACNT";
  608. if (data.useAlias == 1) {
  609. this.model.aliasType = data.aliasType;
  610. this.model.alias = data.alias;
  611. } else {
  612. this.model.contBankAcntCode = data.acntCode;
  613. this.model.rcvBankBrchCode = data.bankBrchCode;
  614. this.model.contBankAcntName = data.benName;
  615. this.model.contAcntName = null;
  616. }
  617. }
  618.  
  619. if (data.typeCode != "LOCALBANK_GB" && data.typeCode != "LOCALBANK" && data.typeCode != "CENTRAL_BANK") {
  620. this.model.contAcntCode = data.acntCode;
  621. this.model.contAcntName = data.acntName;
  622. this.brwsContAcntCode.disabled = false;
  623. }
  624.  
  625. this.isGetAcntInfo1 = false;
  626.  
  627. switch (data.typeCode) {
  628. case "LOCALBANK_GB":
  629. case "LOCALBANK":
  630. this.model.sysNo = 1318;
  631. break;
  632. case "CENTRAL_BANK":
  633. this.model.sysNo = 1368;
  634. break;
  635. default:
  636. this.model.sysNo = Number(data.acntSysNo);
  637. break;
  638. }
  639.  
  640. this.setAcntType(this.model.sysNo.toString());
  641.  
  642. this.ddlContCurCode.value = data.acntCurCode;
  643. this.ddlContCurCode.trigger("change");
  644. this.model.contCurCode = data.acntCurCode;
  645. }
  646. else {
  647. this.ddlAcntType.value = null;
  648. this.ddlAcntType.trigger("change");
  649. }
  650. }, (err) => {
  651. this.error(err);
  652. this.ddlAcntType.value = null;
  653. this.ddlAcntType.trigger("change");
  654. });
  655. }
  656.  
  657. formDisabled(disabled: boolean) {
  658. let params = [this.sourceType];
  659. let paramSrc = params[0];
  660. _.each(this.controls.formTLLRA354.controls, function (control, idx) {
  661. if ("disabled" in control) {
  662. if(paramSrc == 'TKT' && (control.name == 'cancel' || control.name == 'doTran' || control.name == 'doTxn' || control.name == 'txnDesc' || control.name == 'getSig'))
  663. control.disabled = false;
  664. else
  665. control.disabled = disabled;
  666. }
  667. }, params); this.tllrTxn.disableTxnBtn(this, false);
  668. }
  669.  
  670. acntDetail(e, isTxnAcntCode: boolean) {
  671. e.preventDefault();
  672. var scrCode;
  673. var acntCode = isTxnAcntCode ? this.brwsDealCode.value : this.brwsContAcntCode.value;
  674. if (isTxnAcntCode)
  675. scrCode = "TLLR-A-606";
  676. else {
  677. switch(this.model.sysNo) {
  678. case 1305:
  679. scrCode = "TLLR-A-601";
  680. break;
  681. case 1301:
  682. scrCode = "TLLR-A-608";
  683. break;
  684. }
  685. }
  686.  
  687. if (scrCode && acntCode)
  688. app.screen({
  689. name: scrCode,
  690. parameter: [acntCode],
  691. parent: this
  692. });
  693. }
  694.  
  695. changeRate(isBuyRate: boolean) {
  696. if (!this.isChange)
  697. return;
  698.  
  699. if (this.rdCash.checked) {
  700. this.changeRateCash(isBuyRate);
  701. }
  702. else {
  703. this.changeRateNonCash(isBuyRate);
  704. }
  705. }
  706.  
  707. changeRateCash(isBuyRate: boolean) {
  708. if (!isBuyRate) {
  709. if (!this.ddlContCurCode.value || !this.ddlRateType.value)
  710. return;
  711. else {
  712. this.tllrTxn.getBuyRate(this.ddlRateType.value, this.ddlContCurCode.value)
  713. .then((response) => {
  714. this.model.contRate = response;
  715. this.numContRate.value = response;
  716. this.changeAmount();
  717. }, (err) => { this.error(err); });
  718. }
  719. }
  720. if (isBuyRate || this.ddlCurCode.value != this.ddlContCurCode.value) {
  721. if (!this.ddlCurCode.value || !this.ddlRateType.value)
  722. return;
  723.  
  724. this.tllrTxn.getSellRate(this.ddlRateType.value, this.ddlCurCode.value)
  725. .then((response) => {
  726. this.model.rate = response;
  727. this.numRate.value = response;
  728.  
  729. if (this.ddlCurCode.value == this.ddlContCurCode.value) {
  730. this.model.contRate = this.model.rate;
  731. this.numContRate.value = this.numRate.value;
  732. this.changeAmount();
  733. }
  734. this.changeAmount();
  735. }, (err) => { this.error(err); });
  736. }
  737. }
  738.  
  739. changeRateNonCash(isBuyRate: boolean) {
  740. if (!isBuyRate || !this.numContRate.value) {
  741. if (!this.ddlContCurCode.value || !this.ddlRateType.value)
  742. return;
  743. else {
  744. this.tllrTxn.getBuyRate(this.ddlRateType.value, this.ddlContCurCode.value)
  745. .then((response) => {
  746. this.model.contRate = response;
  747. this.numContRate.value = response;
  748. if (this.ddlCurCode.value == this.ddlContCurCode.value) {
  749. this.model.rate = this.model.contRate;
  750. this.numRate.value = this.numContRate.value;
  751. }
  752. this.changeAmount();
  753. }, (err) => { this.error(err); });
  754. }
  755. }
  756. if (isBuyRate || this.ddlCurCode.value != this.ddlContCurCode.value) {
  757. if (!this.ddlCurCode.value || !this.ddlRateType.value)
  758. return;
  759. else if (this.ddlCurCode.value == this.ddlContCurCode.value && this.numContRate.value) {
  760. this.model.rate = this.model.contRate;
  761. this.numRate.value = this.numContRate.value;
  762. this.changeAmount();
  763. }
  764. else {
  765. this.tllrTxn.getSellRate(this.ddlRateType.value, this.ddlCurCode.value)
  766. .then((response) => {
  767. this.model.rate = response;
  768. this.numRate.value = response;
  769. this.changeAmount();
  770. // this.changeAmount(false);
  771. }, (err) => { this.error(err); });
  772. }
  773. }
  774. }
  775.  
  776. fillGrid() {
  777. this.showOrHide(false);
  778. }
  779.  
  780. showOrHide(isBuyCurCode: boolean) {
  781. if (this.isChange && ((isBuyCurCode && !this.model.txnAmount)
  782. || (!isBuyCurCode && !this.model.contAmount))) {
  783. // this.numTxnAmount.value = 0;
  784. this.model.contAmount = 0;
  785. this.numContAmount.value = 0;
  786. }
  787.  
  788. if (this.rdCash.checked) {
  789. if (isBuyCurCode) {
  790. if (this.ddlCurCode.value !== this.contCurCode) {
  791. this.model.contCurCode = this.ddlCurCode.value;
  792. this.ddlContCurCode.value = this.ddlCurCode.value;
  793. this.model.curCode = this.contCurCode;
  794. this.ddlCurCode.value = this.contCurCode;
  795. this.changeRate(false);
  796. }
  797.  
  798. this.ddlCurCode.disabled = !this.isChange || this.ddlContCurCode.value !== this.ddlCurCode.value;
  799. this.changeRate(true);
  800. }
  801. else {
  802. if (this.ddlContCurCode.value === this.contCurCode) {
  803. this.model.curCode = this.contCurCode;
  804. this.ddlCurCode.value = this.contCurCode;
  805. this.ddlRateType.value = this.rateType;
  806. this.model.contAmount = this.model.txnAmount;
  807. this.model.contRate = this.model.rate;
  808. }
  809. this.ddlCurCode.disabled = !this.isChange || this.ddlContCurCode.value !== this.contCurCode;
  810. this.changeRate(this.ddlContCurCode.value === this.contCurCode);
  811. }
  812.  
  813.  
  814. this.controls.formTLLRA354.updateValidity();
  815. this.toggleContAmount(this.ddlCurCode.value !== this.ddlContCurCode.value);
  816. }
  817. else {
  818. if (!this.ddlRateType.value)
  819. for (var i = 0; i < this.ddlRateType.dataSource._pristineData.length; i++) {
  820. if (this.ddlRateType.dataSource._pristineData[i].extra == "1") {
  821. this.ddlRateType.value = this.ddlRateType.dataSource._pristineData[i].id;
  822. this.ddlRateType.trigger("change");
  823. break;
  824. }
  825. }
  826. this.toggleContAmount(true);
  827. this.changeRate(isBuyCurCode);
  828. }
  829. this.clearBankNotes();
  830. }
  831.  
  832. changeAmount() {
  833. if (this.numRate.value && this.numContRate.value)
  834. this.model.contAmount = Math.round((this.model.txnAmount - this.model.discountAmount) * this.numRate.value * 100 / this.numContRate.value) / 100;
  835. else
  836. this.model.contAmount = 0;
  837. // if (this.rdCash.checked && this.ddlContCurCode.value !== this.curCode) {
  838. // this.numContAmount.value = this.model.princ;
  839.  
  840. // if (this.numRate.value && this.numContRate.value)
  841. // this.model.txnAmount = this.numContAmount.value * this.numContRate.value / this.numRate.value;
  842. // else
  843. // this.model.txnAmount = 0;
  844. // }
  845. // else {
  846. // this.numTxnAmount.value = this.model.princ;
  847.  
  848. // if (this.numRate.value && this.numContRate.value)
  849. // this.model.contAmount = this.numTxnAmount.value * this.numRate.value / this.numContRate.value;
  850. // else
  851. // this.model.contAmount = 0;
  852. // }
  853. this.clearBankNotes();
  854. this.correctionAmt = -1;
  855. }
  856.  
  857. radioChange(isCash: boolean) {
  858. if (this.isChange) {
  859. this.ddlCurCode.disabled = !isCash;
  860. this.ddlContCurCode.disabled = !isCash;
  861. }
  862.  
  863. this.setOperCode();
  864.  
  865. if (isCash) {
  866. this.rdNonCash.checked = "false";
  867.  
  868. if (this.isChange && this.ddlContCurCode.value !== this.contCurCode)
  869. this.ddlCurCode.disabled = true;
  870. }
  871. else {
  872. this.rdCash.checked = "false";
  873.  
  874. if (this.isChange && this.brwsDealCode.value && this.model.prodType)
  875. this.getCssiAcnt(this.brwsDealCode.value);
  876. }
  877. this.toggleContAcnt(!isCash);
  878. }
  879.  
  880. toggleContAcnt(isShow: boolean) {
  881.  
  882. if (isShow) {
  883. $('.cont-acnt').show();
  884. $("#lblTxnAcnt").text("Хэлцлийн дугаар");
  885. this.toggleContAmount(true);
  886. }
  887. else {
  888. $('.cont-acnt').hide();
  889. $("#lblTxnAcnt").text("Данс");
  890. this.showOrHide(false);
  891. this.toggleContAmount(this.ddlContCurCode.value !== this.ddlCurCode.value);
  892. }
  893.  
  894. if(!this.isChange)
  895. return;
  896.  
  897. this.ddlAcntType.disabled = this.rdCash.checked;
  898. this.ddlAcntType.value = null;
  899. this.ddlAcntType.trigger("change");
  900.  
  901. this.controls.formTLLRA354.updateValidity();
  902. }
  903.  
  904. toggleContAmount(isShow: boolean) {
  905. if (this.isChange) {
  906. this.ddlContCurCode.disabled = !isShow;
  907. this.numContRate.disabled = !isShow;
  908. this.ddlRateType.disabled = !isShow;
  909. }
  910.  
  911. if (isShow) {
  912. $('.cont-amount').show();
  913. $('#lblTxn').text(this.rdCash.checked ? "Кассын гүйлгээний дүн" : "Гүйлгээний дүн");
  914. if (this.isChange && this.rdNonCash.checked) {
  915. this.ddlCurCode.disabled = true;
  916. this.ddlContCurCode.disabled = this.model.acntType != "4";
  917. }
  918. }
  919. else
  920. $('.cont-amount').hide();
  921.  
  922. this.controls.formTLLRA354.updateValidity();
  923. }
  924.  
  925. clickSettings() {
  926. app.screen({
  927. name: "TLLR-A-200",
  928. parameter: [this.txnCode, "Данс эхлүүлэх", 1315, 1],
  929. parent: this
  930. });
  931. }
  932.  
  933. clear() {
  934. this.model = {
  935. curCode: this.curCode,
  936. contCurCode: this.curCode,
  937. txnAmount: 0,
  938. contAmount: 0,
  939. princ: 0,
  940. rateTypeId: this.rateType,
  941. discountAmount: 0
  942. };
  943.  
  944. this.clearBankNotes();
  945. this.correctionAmt = -1;
  946. this.contCurCode = this.curCode;
  947. this.ddlCurCode.value = this.curCode;
  948. this.ddlContCurCode.value = this.curCode;
  949. this.ddlRateType.value = this.rateType;
  950.  
  951. this.brwsDealCode.value = null;
  952. this.checkDefaultRadio();
  953. }
  954.  
  955. changeAcntType() {
  956. this.setSysNo(this.ddlAcntType.value);
  957.  
  958. if (this.isChange) {
  959. this.model.contAcntCode = null;
  960. this.model.contAcntName = null;
  961. this.ddlContCurCode.disabled = this.ddlAcntType.value != "4";
  962. }
  963.  
  964. this.controls.formTLLRA354.updateValidity();
  965.  
  966. switch (this.ddlAcntType.value) {
  967. case "1":
  968. this.svKey = this.tllrTxn.svCasaAcnt;
  969. break;
  970. case "3":
  971. this.svKey = this.tllrTxn.svBacAcnt;
  972. break;
  973. default:
  974. this.svKey = "";
  975. break;
  976. }
  977. }
  978.  
  979. setAcntType(sysNo: string) {
  980.  
  981. this.model.acntType = this.acntType[sysNo];
  982. this.setSysNo(this.model.acntType);
  983.  
  984. if (!this.model.acntType)
  985. this.warn("Хүлээн авах данс буруу байна");
  986. this.controls.formTLLRA354.updateValidity();
  987. }
  988.  
  989. setSysNo(acntType: string) {
  990. switch (acntType) {
  991. case "1":
  992. this.model.sysNo = 1305;
  993. break;
  994. case "3":
  995. this.model.sysNo = 1301;
  996. break;
  997. case "4":
  998. this.model.sysNo = 1318;
  999. break;
  1000. case "5":
  1001. this.model.sysNo = 1368;
  1002. break;
  1003. default:
  1004. this.model.sysNo = null;
  1005. break;
  1006. }
  1007. }
  1008.  
  1009. bindAcntType() {
  1010. var data = this.ddlAcntType.dataSource.data();
  1011. data.forEach((m) => {
  1012. if (m)
  1013. if (m.id == "2")
  1014. data.remove(m);
  1015. });
  1016. }
  1017.  
  1018. curCodeBound(isTxnCurCode: boolean) {
  1019. let ddlCurCode = isTxnCurCode ? this.ddlCurCode : this.ddlContCurCode;
  1020. if (this.curCode && !ddlCurCode.value) {
  1021. ddlCurCode.value = this.curCode;
  1022. ddlCurCode.trigger("change");
  1023. }
  1024. }
  1025.  
  1026. getExtSystem(sysNo: number, itemCode: string) {
  1027. this.tllrTxn.getCompanyExtSystem(sysNo)
  1028. .then((data) => {
  1029. this.extSystem[itemCode] = data;
  1030.  
  1031. if (this.change && sysNo == 1412) {
  1032. this.useRadioCash = data ? false : true;
  1033. this.checkDefaultRadio();
  1034. }
  1035. }, (err) => {
  1036. this.error(err);
  1037. this.extSystem[itemCode] = "";
  1038.  
  1039. if (this.change && sysNo == 1412) {
  1040. this.checkDefaultRadio();
  1041. }
  1042. });
  1043. }
  1044.  
  1045. checkDefaultRadio() {
  1046. if (this.isChange) {
  1047. this.rdCash.disabled = !this.useRadioCash;
  1048. // if (this.useRadioCash) {
  1049. // this.rdCash.checked = "true";
  1050. // }
  1051. // else {
  1052. // this.rdNonCash.checked = "true";
  1053. // }
  1054. this.rdNonCash.checked = "true";
  1055. this.radioChange(false);
  1056. }
  1057. }
  1058.  
  1059. showFee(txnParam: any, txnPreview: any, fees: any) {
  1060. this.tllrTxn.disableTxnBtn(this, false);
  1061. app.screen({
  1062. name: "TLLR-A-337",
  1063. parameter: [{ txnAcntCode: txnParam.txnAcntCode, txnParam: txnParam, txnPreview: txnPreview, fees: fees, cfgPrefix: this.scrCode, operCode: this.extraCode, cfgScrName: this.txnCode, cashRequireBanknote: this.cashRequireBanknote, txnType: this.txnType, corrAmt: this.correctionAmt > 0 ? this.correctionAmt: this.model.contAmount , warningMsg: this.warnMsg, isDescRequired: this.isDescRequired }],
  1064. parent: this,
  1065. onClose: (dialogResult) => {
  1066. if (dialogResult)
  1067. this.clear();
  1068. }
  1069. });
  1070. }
  1071.  
  1072. showBankNote(isPreview: number, e: any){
  1073. let data = {
  1074. curCode: this.model.contCurCode,
  1075. txnAmount: this.txnAmtCorrDiff ? this.correctionAmt : this.model.contAmount,
  1076. cashNote: this.cashBankNote,
  1077. changeBankNotes: this.changeBankNotes,
  1078. txnType: this.txnType,
  1079. isChangeAmount: this.txnAmtCorrDiff
  1080. };
  1081.  
  1082. if (isPreview != 2) {
  1083. this.tllrTxn.disableTxnBtn(this, false);
  1084. }
  1085.  
  1086. app.screen({
  1087. name: "TLLR-A-801",
  1088. parameter: [data],
  1089. parent: this,
  1090. // parentScreen: this,
  1091. onClose: (dialogResult) => {
  1092. if (dialogResult) {
  1093. this.cashBankNote = dialogResult;
  1094.  
  1095. if (isPreview !== 2) {
  1096. this.checkTxn(isPreview, e);
  1097. }
  1098. }
  1099. }
  1100. });
  1101. }
  1102.  
  1103. doTranPreview(isPreview: number, e: any, txnParam: any){
  1104. txnParam.isPreview = 1;
  1105. txnParam.isPreviewFee = 0;
  1106. this.ldTxn.ldStartAcnt(txnParam)
  1107. .then((response) => {
  1108. if(response && response.txnToAmount != undefined){
  1109. if(parseFloat(response.txnToAmount) == parseFloat(txnParam.contAmount.toFixed(2)))
  1110. this.txnAmtCorrDiff = false;
  1111. else
  1112. this.txnAmtCorrDiff = true;
  1113. }
  1114. this.correctionAmt = response.txnToAmount;
  1115. txnParam.txnClearAmount = this.correctionAmt;
  1116. this.txnClearAmount = this.correctionAmt;
  1117. this.showBankNote(isPreview, e);
  1118. }, (err) => {
  1119. this.tllrTxn.disableTxnBtn(this, false);
  1120. this.error(err);
  1121. });
  1122. }
  1123.  
  1124. clearBankNotes() {
  1125. this.sumTotalAmount = 0;
  1126. this.cashBankNote = [];
  1127. this.changeBankNotes = [];
  1128. }
  1129. checkRequired() {
  1130. var param;
  1131. param = [
  1132. [{
  1133. _iField: "SCR_CODE",
  1134. _iOperation: "=",
  1135. _iValue: this.scrCode,
  1136. _iType: 3
  1137. }], 0, -1
  1138. ];
  1139.  
  1140. this.tllrTxn.selectScrCfg(param)
  1141. .then((data) => {
  1142. if (data) {
  1143. data.forEach((m) => {
  1144. switch (m.fieldCode) {
  1145. case 'TCUSTREGISTER':
  1146. if (!m.isRequired) {
  1147. this.controls.formTLLRA354.disableValidity("tcustRegisterMask");
  1148. this.controls.formTLLRA354.disableValidity("tcustRegister");
  1149. }
  1150. break;
  1151. case 'TXNDEFCODE':
  1152. if (!m.isRequired) {
  1153. this.controls.formTLLRA354.disableValidity("txnDefCode");
  1154. }
  1155. break;
  1156. case 'TEMPDESCREQUIRED':
  1157. this.isDescRequired = m.isRequired;
  1158. break;
  1159. default:
  1160. break;
  1161. }
  1162. });
  1163. }
  1164. },
  1165. (err) => {
  1166. this.error(err);
  1167. });
  1168. }
  1169.  
  1170. setOperCode() {
  1171. let option = "BORR_";
  1172. if (this.model.prodType === 'PLACEMENT') {
  1173. option = 'PL_';
  1174. }
  1175. if (!this.rdCash.checked) {
  1176. option += 'NON';
  1177. }
  1178. option += 'CASH';
  1179.  
  1180. this.extraCode = this.ldTxn.opStartAcnt[option];
  1181. }
  1182.  
  1183. keypressMail(e) {
  1184. var allowedChars, str;
  1185. allowedChars = new RegExp('^[a-zA-Z0-9_.@-]');
  1186. str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
  1187. if (allowedChars.test(str)) {
  1188. return true;
  1189. }
  1190. if (
  1191. e.keyCode === 8 ||
  1192. e.keyCode === 46 ||
  1193. e.keyCode === 37 ||
  1194. e.keyCode === 39 ||
  1195. e.charCode === 32
  1196. ) {
  1197. return true;
  1198. }
  1199. e.preventDefault();
  1200. return false;
  1201. }
  1202.  
  1203. validateEmail(email: String) {
  1204. let filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  1205. if (!filter.test(email)) {
  1206. this.error('Зөв имэйл хаяг оруулна уу');
  1207. this.emailValid = 0;
  1208. return false;
  1209. } else return true;
  1210. }
  1211.  
  1212. changeAliasType() {
  1213. if (this.isChange) {
  1214. this.model.alias = "";
  1215. }
  1216. }
  1217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement