Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <reference path="./../../../../../../nes-app/app/scripts/references.d.ts" />
- /// <reference path="./../services/line.ts" />
- import {
- Screen,
- Scr,
- ScrView,
- ScreenOptions
- } from 'nes2/screen';
- import {NesKendoDataSource, ConfigService } from 'nes2/services';
- import {LifecycleEvent} from 'angular2/angular2';
- import app from 'nes2/app';
- import {tllrTxn} from '../services/tllrTxn';
- import {TllrLdTxn} from '../services/tllrLdTxn';
- import { ld } from 'screens/LD-B/services/ld';
- import {TmwSv} from '../../TMW-M/services/tmwSv';
- @Scr({
- type: TLLRA354,
- selector: 'TLLR-A-354'
- })
- @ScrView({
- templateUrl: "TLLR-A-354"
- })
- export default class TLLRA354 extends Screen {
- tllrTxn: tllrTxn = new tllrTxn(this);
- isEnableTxn: boolean = false;
- ldTxn: TllrLdTxn = new TllrLdTxn(this);
- tmwSv: TmwSv = new TmwSv();
- config = new ConfigService();
- ld: ld = new ld();
- model: any = { txnAmount: 0, contAmount: 0, princ: 0 };
- dealCode: string;
- operation: number = 0;
- isGetAcntInfo: boolean = false;
- //13600703 өөрчлөх !!!
- size: number = 12;
- extraCode: number;
- txnCode: string = "LD_EXEC_DEAL";
- office: string;
- ddlAction: NesDropDown;
- dealStatus: string;
- rateType: string;
- filterStatus: string = "";
- contCurCode: string;
- dialogResult: any;
- isDescRequired: number = 0;
- isChange: number = 1;
- sourceType: string = 'TLLR';
- cashBankNote: any = [];
- changeBankNotes: any = [];
- sumTotalAmount: number = 0;
- correctionAmt: number = -1;
- isGetAcntInfo1: boolean = false;
- curCode: string;
- brwsTxnAcntCode: NesBrowse;
- brwsContAcntCode: NesBrowse;
- ddlAcntType: NesDropdown;
- ddlCurCode: NesDropdown;
- ddlContCurCode: NesDropdown;
- ddlRateType: NesDropdown;
- numContAmount: NesNumeric;
- numContRate: NesNumeric;
- numRate: NesNumeric;
- numTxnAmount: NesNumeric;
- rdNonCash: NesRadio;
- rdCash: NesRadio;
- constructor(options: ScreenOptions) {
- super(options);
- }
- onControlsInit() {
- this.ddlAction = <NesDropDown>this.getControl('formTLLRA354/dropdownAction');
- if (this.param != undefined && !this.param.empty) {
- let paramObj = this.param.get(0);
- this.sourceType = paramObj.sourceType;
- if (this.sourceType == 'TMWM120') {
- this.formDisabled(true);
- this.isChange = 0;
- this.tllrTxn.detailPendJrnl(paramObj.jrno)
- .then((data) => {
- data.addParams = JSON.parse(data.addParams);
- data.addition = JSON.parse(data.addition);
- data.dealCode = data.addParams.DEALCODE;
- data.action = data.addition.action;
- this.model = data;
- }, (err) => { this.error(err); });
- } else {
- if (this.param.get(0).dealCode !== undefined){
- this.findControl("browseDealCode").value = this.param.get(0).dealcode;
- this.model.dealCode = this.param.get(0).dealCode;
- this.findControl("browseDealCode").disabled = true;
- }
- if(this.param.get(0).action !== undefined){
- this.model.action = this.param.get(0).action;
- this.ddlAction.disabled = true;
- this.changeAction();
- }
- }
- }
- }
- afterInit() {
- this.checkRequired();
- if (!this.param.empty && this.param.get(0).dealCode)
- this.model.dealCode = this.param.get(0).dealCode;
- }
- doTran(isPreview: number, e: any) {
- if (e)
- e.preventDefault();
- if (this.controls.formTLLRA354.valid) {
- this.tllrTxn.disableTxnBtn(this, true);
- if (!isPreview && !confirm("Гүйлгээ хийхдээ итгэлтэй байна уу?")){
- this.tllrTxn.disableTxnBtn(this, false);
- return false;
- }
- if(this.ddlAction.value === "START")
- if (this.model.type === "M") {
- if (this.model.prodType == 'PLACEMENT')
- this.operation = 13600274;
- else
- this.operation = 13600700;
- this.doTransaction(isPreview);
- }
- else {
- this.operation = 13600712;
- this.ldTxn.getMmRollTxnAmt(this.model.rollOrdId, this.model.dealCode)
- .then((txnAmount) => {
- if ((this.model.prodType == 'PLACEMENT' && txnAmount > 0)
- || (this.model.prodType == 'BORROWING' && txnAmount < 0)) {
- this.operation = 13600279;
- }
- this.doTransaction(isPreview);
- }, (err) => { this.error(err); });
- }
- if(this.ddlAction.value === "CLOSE")
- if(this.dealStatus === "D") {
- if (this.model.prodType == 'PLACEMENT')
- this.operation = 13600282;
- else
- this.operation = 13600703;
- this.doTransaction(isPreview);
- }
- else{
- this.warn("Хэлцлийн төлөв хийгдсэн үед л хэлцэл хаана.");
- return;
- }
- if(this.ddlAction.value === "CANCEL"){
- this.operation = 13600701;
- if(this.dealStatus != "O") {
- this.warn("Хэлцлийн нээлттэй үед л цуцлана.");
- return;
- }
- this.doTransaction(isPreview);
- }
- }
- }
- doTransaction(isPreview: number) {
- let data = this.controls.formTLLRA354.value;
- var txnParam = {
- txnAcntCode: this.model.acntNo,
- isPreview: isPreview,
- isTmw: 1,
- txnDesc: this.model.txnDesc,
- txnDefCode: this.model.txnDefCode,
- addParams: {
- dealCode: this.model.dealCode,
- action: this.ddlAction.value
- }
- };
- txnParam.addition = txnParam.addParams;
- let isPreviewFee = this.config.get(this.scrCode, this.extraCode + "_fee");
- txnParam.isPreviewFee = isPreviewFee ? isPreviewFee : 0;
- if(this.operation === 0)
- {
- this.warn("Гүйлгээ хийж чадсангүй.");
- return;
- }
- this.extraCode = this.operation;
- this.tllrTxn.executeDealTxn(txnParam, this.operation)
- .then((response) => {
- if (txnParam.isPreviewFee) {
- this.showFee(txnParam, response.txnPreview, response.feesPreview);
- return;
- }
- if (response.isPreview) {
- txnParam.isPreview = 0;
- this.showTran([{ operCode: this.operation,
- txnParam: txnParam,
- txnPreview: response.txnPreview,
- txnAcntCode: this.model.acntNo,
- isSupervisor: response.isSupervisor,
- pendReason: response.pendReason,
- cfgPrefix: this.scrCode,
- isDescRequired: this.isDescRequired
- }]);
- }
- else{
- switch (response.isSupervisor) {
- case 1: {
- let data = [];
- data.push(response.txnJrno);
- data.push(response.pendReason);
- data.push('TLLR');
- if(response.unDelegated)
- data.push(response.unDelegated);
- this.success("Хүлээлгэх гүйлгээ бүртгэгдлээ (" + response.txnJrno +")");
- this.tmwSv.showSv(data).then((dialogResult) => {
- if(dialogResult)
- this.clear();
- }, (err) => {
- this.error(err);
- });
- break;
- }
- case 0: {
- if(response.warningMsg)
- this.warn(response.warningMsg + " ("+ response.txnJrno + ")");
- else
- {
- this.tllrTxn.disableTxnBtn(this, false);
- this.success("Амжилттай (" + response.txnJrno + ")");
- }
- this.dialogResult = response.txnJrno;
- if (this.config.get(this.scrCode, this.txnCode) == 1) {
- app.screen({
- name: "DOT-S-113",
- parameter: {
- sysNo: 1360,
- txnCode: this.operation,
- descRequired: this.isDescRequired,
- expType: "HTML",
- data: [{
- paramType: 0,
- paramCode: "TXN_JRNO",
- value: response.txnJrno
- }]
- },
- parent: this,
- onClose: (dialogResult) => {
- if (dialogResult)
- {
- this.clear();
- }
- }
- });
- }
- else
- this.clear();
- }
- }
- }
- }, (err) => { this.tllrTxn.disableTxnBtn(this, false); this.error(err); });
- }
- showTran(data: any) {
- this.tllrTxn.disableTxnBtn(this, false);
- app.screen({
- name: "TLLR-A-600",
- parameter: data,
- parent: this,
- parentScreen: this,
- onClose: (dialogResult) => { this.tllrTxn.disableTxnBtn(this, false);
- if (dialogResult)
- {
- this.clear();
- }
- }
- });
- }
- browseDeal() {
- app.screen({
- name: "MM-B-112",
- parameter: [{status: this.filterStatus}],
- parent: this,
- parentScreen: this,
- onClose: (dialogResult) => {
- if (dialogResult) {
- this.isGetAcntInfo = true;
- this.model.dealCode = dialogResult.get("dealCode");
- this.model.type = dialogResult.get("type");
- this.model.prodType = dialogResult.get('prodType');
- this.model.rollOrdId = dialogResult.get('rollOrdId');
- document.getElementById('dealName').innerHTML = dialogResult.get("name");
- this.findControl("browseDealCode").value = dialogResult.get("dealCode");
- this.isGetAcntInfo = false;
- this.findControl("browseDealCode").trigger("change");
- }
- }
- });
- }
- isChanged() {
- if (!this.isGetAcntInfo && !this.model.txnJrno) {
- if (this.findControl("browseDealCode") && this.findControl("browseDealCode").value)
- this.tllrTxn.getLdDealDetail(this.findControl("browseDealCode").value)
- .then((data) => {
- this.office = data.office;
- this.dealStatus = data.status;
- this.isGetAcntInfo = true;
- this.model.acntNo = data.ldAcntCode;
- this.model.dealCode = data.dealCode;
- this.model.type = data.type;
- this.model.prodType = data.prodType;
- this.model.rollOrdId = data.rollOrdId;
- this.findControl("browseDealCode").value = data.dealCode;
- document.getElementById('dealName').innerHTML = data.name;
- this.isGetAcntInfo = false;
- },
- (err) => {
- this.error(err);
- });
- }
- this.isGetAcntInfo = false;
- }
- changeAction() {
- if(this.model.action === "START" || this.model.action === "CANCEL")
- this.filterStatus = "O";
- if(this.model.action === "CLOSE")
- this.filterStatus = "D";
- }
- formDisabled(disabled: boolean) {
- $('.btn-tran').prop("disabled", true);
- $('.btn-cancel').prop("disabled", true);
- this.findControl("browseDealCode").disabled = true;
- this.findControl("textareaTxnDesc").disabled = true;
- this.findControl("dropDownAction").disabled = true;
- let params = [this.sourceType];
- let paramSrc = params[0];
- _.each(this.controls.formTLLRA354.controls, function (control, idx) {
- if ("disabled" in control) {
- if(paramSrc == 'TKT' && (control.name == 'cancel' || control.name == 'doTran' || control.name == 'doTxn' || control.name == 'txnDesc' || control.name == 'getSig'))
- control.disabled = false;
- else
- control.disabled = disabled;
- }
- }, params); this.tllrTxn.disableTxnBtn(this, false);
- }
- dealDetail(e) {
- e.preventDefault();
- app.screen({
- name: "TLLR-A-610",
- parameter: ["",this.model.dealCode],
- parent: this
- });
- }
- clear() {
- this.office = "";
- this.model = {};
- document.getElementById('dealName').innerHTML = "";
- }
- clickSettings() {
- app.screen({
- name: "TLLR-A-200",
- parameter: [this.txnCode, "Хэлцлийн гүйлгээ хийх", 1315, 1],
- parent: this
- });
- }
- showFee(txnParam: any, txnPreview: any, fees: any) {
- this.tllrTxn.disableTxnBtn(this, false);
- app.screen({
- name: "TLLR-A-337",
- parameter: [{ txnAcntCode: txnParam.txnAcntCode, txnParam: txnParam, txnPreview: txnPreview, fees: fees, cfgPrefix: this.scrCode, operCode: this.extraCode, isDescRequired: this.isDescRequired }],
- parent: this,
- onClose: (dialogResult) => {
- if (dialogResult)
- this.clear();
- }
- });
- }
- checkRequired() {
- var param;
- param = [
- [{
- _iField: "SCR_CODE",
- _iOperation: "=",
- _iValue: this.scrCode,
- _iType: 3
- }], 0, -1
- ];
- this.tllrTxn.selectScrCfg(param)
- .then((data) => {
- if (data) {
- data.forEach((m) => {
- switch (m.fieldCode) {
- case 'TCUSTREGISTER':
- if (!m.isRequired) {
- this.controls.formTLLRA354.disableValidity("tcustRegisterMask");
- this.controls.formTLLRA354.disableValidity("tcustRegister");
- }
- break;
- case 'TXNDEFCODE':
- if (!m.isRequired) {
- this.controls.formTLLRA354.disableValidity("txnDefCode");
- }
- break;
- case 'TEMPDESCREQUIRED':
- this.isDescRequired = m.isRequired;
- break;
- default:
- break;
- }
- });
- }
- },
- (err) => {
- this.error(err);
- });
- }
- curCodeBound(isTxnCurCode: boolean) {
- let ddlCurCode = isTxnCurCode ? this.ddlCurCode : this.ddlContCurCode;
- if (this.curCode && !ddlCurCode.value) {
- ddlCurCode.value = this.curCode;
- ddlCurCode.trigger("change");
- }
- }
- radioChange(isCash: boolean) {
- if (this.isChange) {
- this.ddlCurCode.disabled = !isCash;
- this.ddlContCurCode.disabled = !isCash;
- }
- this.setOperCode();
- if (isCash) {
- this.rdNonCash.checked = "false";
- if (this.isChange && this.ddlContCurCode.value !== this.contCurCode)
- this.ddlCurCode.disabled = true;
- }
- else {
- this.rdCash.checked = "false";
- if (this.isChange && this.brwsTxnAcntCode.value && this.model.prodType)
- this.getCssiAcnt(this.brwsTxnAcntCode.value);
- }
- this.toggleContAcnt(!isCash);
- }
- toggleContAcnt(isShow: boolean) {
- if (isShow) {
- $('.cont-acnt').show();
- $("#lblTxnAcnt").text("Хүлээн авах данс");
- this.toggleContAmount(true);
- }
- else {
- $('.cont-acnt').hide();
- $("#lblTxnAcnt").text("Данс");
- this.showOrHide(false);
- this.toggleContAmount(this.ddlContCurCode.value !== this.ddlCurCode.value);
- }
- if(!this.isChange)
- return;
- this.ddlAcntType.disabled = this.rdCash.checked;
- this.ddlAcntType.value = null;
- this.ddlAcntType.trigger("change");
- this.controls.formTLLRA354.updateValidity();
- }
- toggleContAmount(isShow: boolean) {
- if (this.isChange) {
- this.ddlContCurCode.disabled = !isShow;
- this.numContRate.disabled = !isShow;
- this.ddlRateType.disabled = !isShow;
- }
- if (isShow) {
- $('.cont-amount').show();
- $('#lblTxn').text(this.rdCash.checked ? "Кассын гүйлгээний дүн" : "Гүйлгээний дүн");
- if (this.isChange && this.rdNonCash.checked) {
- this.ddlCurCode.disabled = true;
- this.ddlContCurCode.disabled = this.model.acntType != "4";
- }
- }
- else
- $('.cont-amount').hide();
- this.controls.formTLLRA354.updateValidity();
- }
- showOrHide(isBuyCurCode: boolean) {
- if (this.isChange && ((isBuyCurCode && !this.model.txnAmount)
- || (!isBuyCurCode && !this.model.contAmount))) {
- // this.numTxnAmount.value = 0;
- this.model.contAmount = 0;
- this.numContAmount.value = 0;
- }
- if (this.rdCash.checked) {
- if (isBuyCurCode) {
- if (this.ddlCurCode.value !== this.contCurCode) {
- this.model.contCurCode = this.ddlCurCode.value;
- this.ddlContCurCode.value = this.ddlCurCode.value;
- this.model.curCode = this.contCurCode;
- this.ddlCurCode.value = this.contCurCode;
- this.changeRate(false);
- }
- this.ddlCurCode.disabled = !this.isChange || this.ddlContCurCode.value !== this.ddlCurCode.value;
- this.changeRate(true);
- }
- else {
- if (this.ddlContCurCode.value === this.contCurCode) {
- this.model.curCode = this.contCurCode;
- this.ddlCurCode.value = this.contCurCode;
- this.ddlRateType.value = this.rateType;
- this.model.contAmount = this.model.txnAmount;
- this.model.contRate = this.model.rate;
- }
- this.ddlCurCode.disabled = !this.isChange || this.ddlContCurCode.value !== this.contCurCode;
- this.changeRate(this.ddlContCurCode.value === this.contCurCode);
- }
- this.controls.formTLLRA354.updateValidity();
- this.toggleContAmount(this.ddlCurCode.value !== this.ddlContCurCode.value);
- }
- else {
- if (!this.ddlRateType.value)
- for (var i = 0; i < this.ddlRateType.dataSource._pristineData.length; i++) {
- if (this.ddlRateType.dataSource._pristineData[i].extra == "1") {
- this.ddlRateType.value = this.ddlRateType.dataSource._pristineData[i].id;
- this.ddlRateType.trigger("change");
- break;
- }
- }
- this.toggleContAmount(true);
- this.changeRate(isBuyCurCode);
- }
- this.clearBankNotes();
- }
- clearBankNotes() {
- this.sumTotalAmount = 0;
- this.cashBankNote = [];
- this.changeBankNotes = [];
- }
- changeRate(isBuyRate: boolean) {
- if (!this.isChange)
- return;
- if (this.rdCash.checked) {
- this.changeRateCash(isBuyRate);
- }
- else {
- this.changeRateNonCash(isBuyRate);
- }
- }
- changeRateCash(isBuyRate: boolean) {
- if (!isBuyRate) {
- if (!this.ddlContCurCode.value || !this.ddlRateType.value)
- return;
- else {
- this.tllrTxn.getBuyRate(this.ddlRateType.value, this.ddlContCurCode.value)
- .then((response) => {
- this.model.contRate = response;
- this.numContRate.value = response;
- this.changeAmount();
- }, (err) => { this.error(err); });
- }
- }
- if (isBuyRate || this.ddlCurCode.value != this.ddlContCurCode.value) {
- if (!this.ddlCurCode.value || !this.ddlRateType.value)
- return;
- this.tllrTxn.getSellRate(this.ddlRateType.value, this.ddlCurCode.value)
- .then((response) => {
- this.model.rate = response;
- this.numRate.value = response;
- if (this.ddlCurCode.value == this.ddlContCurCode.value) {
- this.model.contRate = this.model.rate;
- this.numContRate.value = this.numRate.value;
- this.changeAmount();
- }
- this.changeAmount();
- }, (err) => { this.error(err); });
- }
- }
- changeRateNonCash(isBuyRate: boolean) {
- if (!isBuyRate || !this.numContRate.value) {
- if (!this.ddlContCurCode.value || !this.ddlRateType.value)
- return;
- else {
- this.tllrTxn.getBuyRate(this.ddlRateType.value, this.ddlContCurCode.value)
- .then((response) => {
- this.model.contRate = response;
- this.numContRate.value = response;
- if (this.ddlCurCode.value == this.ddlContCurCode.value) {
- this.model.rate = this.model.contRate;
- this.numRate.value = this.numContRate.value;
- }
- this.changeAmount();
- }, (err) => { this.error(err); });
- }
- }
- if (isBuyRate || this.ddlCurCode.value != this.ddlContCurCode.value) {
- if (!this.ddlCurCode.value || !this.ddlRateType.value)
- return;
- else if (this.ddlCurCode.value == this.ddlContCurCode.value && this.numContRate.value) {
- this.model.rate = this.model.contRate;
- this.numRate.value = this.numContRate.value;
- this.changeAmount();
- }
- else {
- this.tllrTxn.getSellRate(this.ddlRateType.value, this.ddlCurCode.value)
- .then((response) => {
- this.model.rate = response;
- this.numRate.value = response;
- this.changeAmount();
- // this.changeAmount(false);
- }, (err) => { this.error(err); });
- }
- }
- }
- changeAmount() {
- if (this.numRate.value && this.numContRate.value)
- this.model.contAmount = Math.round((this.model.txnAmount - this.model.discountAmount) * this.numRate.value * 100 / this.numContRate.value) / 100;
- else
- this.model.contAmount = 0;
- this.clearBankNotes();
- this.correctionAmt = -1;
- }
- setOperCode() {
- let option = "BORR_";
- if (this.model.prodType === 'PLACEMENT') {
- option = 'PL_';
- }
- if (!this.rdCash.checked) {
- option += 'NON';
- }
- option += 'CASH';
- this.extraCode = this.ldTxn.opStartAcnt[option];
- }
- getCssiAcnt(acntCode: string) {
- this.ld.getCssiAcnt(acntCode, this.model.prodType == "BORROWING" ? "F" : "T", this.module)
- .then((data) => {
- if (data) {
- this.isGetAcntInfo1 = true;
- if (data.typeCode == "LOCALBANK_GB" || data.typeCode == "LOCALBANK" || data.typeCode == "CENTRAL_BANK")
- this.model.contBankCode = data.bankCode;
- if (data.typeCode == "LOCALBANK_GB" || data.typeCode == "LOCALBANK") {
- this.model.contBankAcntCode = data.acntCode;``
- this.model.rcvBankBrchCode = data.bankBrchCode;
- this.model.contBankAcntName = data.benName;
- this.model.contAcntName = null;
- }
- if (data.typeCode != "LOCALBANK_GB" && data.typeCode != "LOCALBANK" && data.typeCode != "CENTRAL_BANK") {
- this.model.contAcntCode = data.acntCode;
- this.model.contAcntName = data.acntName;
- this.brwsContAcntCode.disabled = false;
- }
- this.isGetAcntInfo1 = false;
- switch (data.typeCode) {
- case "LOCALBANK_GB":
- case "LOCALBANK":
- this.model.sysNo = 1318;
- break;
- case "CENTRAL_BANK":
- this.model.sysNo = 1368;
- break;
- default:
- this.model.sysNo = Number(data.acntSysNo);
- break;
- }
- this.setAcntType(this.model.sysNo.toString());
- this.ddlContCurCode.value = data.acntCurCode;
- this.ddlContCurCode.trigger("change");
- this.model.contCurCode = data.acntCurCode;
- }
- else {
- this.ddlAcntType.value = null;
- this.ddlAcntType.trigger("change");
- }
- }, (err) => {
- this.error(err);
- this.ddlAcntType.value = null;
- this.ddlAcntType.trigger("change");
- });
- }
- setAcntType(sysNo: string) {
- this.model.acntType = this.acntType[sysNo];
- this.setSysNo(this.model.acntType);
- if (!this.model.acntType)
- this.warn("Хүлээн авах данс буруу байна");
- this.controls.formTLLRA354.updateValidity();
- }
- setSysNo(acntType: string) {
- switch (acntType) {
- case "1":
- this.model.sysNo = 1305;
- break;
- case "3":
- this.model.sysNo = 1301;
- break;
- case "4":
- this.model.sysNo = 1318;
- break;
- case "5":
- this.model.sysNo = 1368;
- break;
- default:
- this.model.sysNo = null;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement