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/LD.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';
- import { Asp } from '../../ASP-C/services/asp';
- @Scr({
- type: TLLRA354,
- selector: 'TLLR-A-354'
- })
- @ScrView({
- templateUrl: "TLLR-A-354"
- })
- export default class TLLRA354 extends Screen {
- config = new ConfigService();
- tllrTxn: tllrTxn = new tllrTxn(this);
- isEnableTxn: boolean = false;
- ldTxn: TllrLdTxn = new TllrLdTxn(this);
- tmwSv: TmwSv = new TmwSv();
- asp: Asp = new Asp();
- ld: ld = new ld();
- operation: number = 0;
- model: any = { txnAmount: 0, contAmount: 0, princ: 0 };
- acntCode: string;
- paymentType: string;
- isGetAcntInfo: boolean = false;
- isGetAcntInfo1: boolean = false;
- txnCode: string = "LD_START_ACNT";
- curCode: string;
- contCurCode: string;
- rateType: string;
- size: number = 12;
- cashRequireBanknote: number = 0;
- extraCode: number = this.ldTxn.opStartAcnt["BORR_NONCASH"];
- dialogResult: any;
- isDescRequired: number = 0;
- acntType: any = {
- "1305": "1",
- "1301": "3",
- "1318": "4",
- "1368": "5"
- };
- extAcntType: any = {
- "1": "GB3DP",
- "3": "GB3BA"
- }
- //for stored value
- svKey: string;
- extSystem: any = {
- // "1": "INTERNAL_GB", // CASA
- // "3": "INTERNAL_GB" // BAC
- }; // Гадны системүүдийн дугаар
- cashBankNote: any = [];
- changeBankNotes: any = [];
- txnAmtCorrDiff: boolean = false;
- correctionAmt: number = -1;
- txnClearAmount: number;
- sumTotalAmount: number = 0;
- txnType: string;
- sourceType: string;
- useRadioCash: boolean = true;
- isChange: number = 1;
- module: string = "MM";
- camData: any = {};
- brwsDealCode: 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);
- }
- afterInit() {
- this.checkRequired();
- this.brwsDealCode = <NesBrowse>this.getControl("formTLLRA354/browseDealCode");
- this.brwsContAcntCode = <NesBrowse>this.getControl("formTLLRA354/browseContAcntCode");
- this.ddlAcntType = <NesDropdown>this.getControl("formTLLRA354/dropdownAcntType");
- this.ddlCurCode = <NesDropdown>this.getControl("formTLLRA354/dropdownCurCode");
- this.ddlContCurCode = <NesDropdown>this.getControl("formTLLRA354/dropdownContCurCode");
- this.ddlRateType = <NesDropdown>this.getControl("formTLLRA354/dropdownRateTypeId");
- this.numContAmount = <NesNumeric>this.getControl("formTLLRA354/numericContAmount");
- this.numContRate = <NesNumeric>this.getControl("formTLLRA354/numericContRate");
- this.numTxnAmount = <NesNumeric>this.getControl("formTLLRA354/numericTxnAmount");
- this.numRate = <NesNumeric>this.getControl("formTLLRA354/numericRate");
- this.rdNonCash = <NesRadio>this.getControl("formTLLRA354/radioNonCash");
- this.rdCash = <NesRadio>this.getControl("formTLLRA354/radioCash");
- this.getExtSystem(1412, "0"); //CASH
- this.getExtSystem(1301, "3");
- this.getExtSystem(1305, "1");
- this.getExtSystem(1318, "4");
- this.getExtSystem(1368, "5");
- this.tllrTxn.getConfigValue("CASH_REQUIRE_BANKNOTE")
- .then((response) => {
- if (parseInt(response)) {
- this.cashRequireBanknote = 1;
- }
- else {
- this.cashRequireBanknote = 0;
- }
- }, (err) => { this.error(err); });
- this.ddlRateType.bind('dataBound', (data) => {
- if (this.ddlRateType.dataSource.data().length) {
- if (this.ddlRateType.dataSource.data().find(obj => obj.extra == 1)) {
- this.rateType = this.ddlRateType.dataSource.data().find(obj => obj.extra == 1).id;
- this.ddlRateType.value = this.rateType;
- }
- else
- this.ddlRateType.value = this.ddlRateType.dataSource.data()[0].id;
- this.ddlRateType.trigger("change");
- }
- });
- this.tllrTxn.GetBaseCur()
- .then((response) => {
- this.curCode = response;
- this.contCurCode = response;
- if (this.ddlContCurCode.dataSource.data().length > 0) {
- this.model.contCurCode = response;
- this.ddlContCurCode.value = response;
- }
- if (this.ddlCurCode.dataSource.data().length > 0) {
- this.model.curCode = response;
- this.ddlCurCode.value = response;
- }
- if (this.ddlContCurCode.value && this.ddlRateType.value)
- this.ddlRateType.trigger("change");
- }, (err) => {
- this.error(err);
- });
- 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);
- this.model = data;
- if (data.contSysNo == 1412)
- this.rdCash.checked = "true";
- else if (data.contSysNo == 1301 && data.addParams && data.addParams.HASIK) {
- this.model.contSysNo = data.addParams.ISFITOFI == "true" ? 1368 : 1318;
- this.model.rcvBankBrchCode = data.addParams.RCVBANKBRCHCODE;
- this.model.camRecieve = data.addParams.CAMRECIEVE;
- this.model.aliasType = data.contBankAliasType;
- this.model.alias = data.contBankAlias;
- this.setAcntType(this.model.contSysNo);
- this.ddlAcntType.value = this.model.acntType;
- this.changeAcntType();
- }
- this.radioChange(data.contSysNo == 1412);
- this.detectChanges();
- }, (err) => { this.error(err); });
- } else {
- if (this.param.get(0).acntCode) {
- // this.brwsDealCode.value = this.param.get(0).acntCode;
- this.model.txnAcntCode = this.param.get(0).acntCode;
- this.model.acntCode = this.param.get(0).acntCode;
- }
- else {
- // this.brwsDealCode.value = this.param.get(0);
- this.model.txnAcntCode = this.param.get(0);
- }
- this.checkDefaultRadio();
- }
- // this.isChanged();
- this.brwsDealCode.disabled = true;
- } else this.checkDefaultRadio();
- }
- doTran(isPreview: number, e: any) {
- this.checkTxn(isPreview, e)
- }
- checkTxn(isPreview: number, e: any){
- if (e)
- e.preventDefault();
- if (!this.controls.formTLLRA354.valid)
- return;
- if (this.model.prodType === "BORROWING" && this.model.acntType === "4") {
- this.warn("Эх үүсвэр татах гүйлгээг банк хооронд хийх боломжгүй!");
- return;
- }
- this.tllrTxn.disableTxnBtn(this, true);
- if (!isPreview && !confirm("Гүйлгээ хийхдээ итгэлтэй байна уу?")){
- this.tllrTxn.disableTxnBtn(this, false);
- return;
- }
- // let data = this.controls.formTLLRA354.value;
- let txnParam = {
- txnAcntCode: this.model.txnAcntCode,
- txnAmount: this.model.txnAmount - this.model.discountAmount,
- txnClearAmount: this.txnClearAmount,
- rate: this.model.rate,
- curCode: this.model.curCode,
- rateTypeId: this.model.rateTypeId,
- contSysNo: this.rdNonCash.checked ? this.model.sysNo : 1412,
- contAmount: this.model.contAmount,
- contRate: this.model.contRate,
- contCurCode: this.model.contCurCode,
- txnDesc: this.model.txnDesc,
- txnDefCode: this.model.txnDefCode,
- banknotes: this.rdCash.checked && this.cashRequireBanknote ? this.cashBankNote : [],
- changeBanknotes: this.rdCash.checked && this.cashRequireBanknote ? this.changeBankNotes : [],
- sourceType: this.tllrTxn.sourceType,
- isPreview: isPreview,
- isPreviewFee: this.config.get(this.scrCode, this.txnCode + "_fee"),
- isTmw: 1,
- operCode: this.extraCode,
- dealCode: this.model.dealCode
- };
- if (txnParam.contSysNo == 1318 || txnParam.contSysNo == 1368)
- txnParam.addParams = {
- hasIk: 1,
- isFiToFi: txnParam.contSysNo == 1368
- };
- if (txnParam.contSysNo == 1318) {
- txnParam.contCheckMsgId = this.camData.msgId;
- txnParam.addParams.camRecieve = this.model.camRecieve;
- if (this.model.camRecieve == "ALIAS") {
- txnParam.contBankCode = this.camData.bankId;
- txnParam.contBankAcntCode = this.camData.acntCode;
- txnParam.contBankAcntName = this.camData.name;
- } else {
- txnParam.contBankCode = this.model.contBankCode;
- txnParam.contBankAcntCode = this.model.contBankAcntCode;
- txnParam.contBankAcntName = this.model.contBankAcntName;
- txnParam.addParams.rcvBankBrchCode = this.model.rcvBankBrchCode;
- }
- txnParam.addition = txnParam.addParams;
- } else if (txnParam.contSysNo == 1368) {
- txnParam.contBankCode = this.model.contBankCode;
- txnParam.addParams.rcvBankBrchCode = this.model.rcvBankBrchCode;
- txnParam.addition = txnParam.addParams;
- }
- else {
- txnParam.contAcntCode = this.rdNonCash.checked ? this.model.contAcntCode : null;
- }
- var aspParam = [[{
- acntCode: txnParam.txnAcntCode,
- acntType: "INCOME",
- }],
- this.extraCode
- ];
- txnParam.aspParam = aspParam;
- if (this.rdCash.checked && this.cashRequireBanknote == 1 && this.sumTotalAmount !=1) { // sumtotalAmount guilgeeni devsgert oruulsan eseh
- this.doTranPreview(isPreview,e, txnParam);
- return;
- }
- if(isPreview == 1){
- this.doTransaction(isPreview, e, txnParam);
- }
- else
- this.asp.checkRule(aspParam)
- .then((response) => {
- if (response) {
- app.screen({
- name: "ASP-C-001",
- parameter: aspParam,
- parent: this,
- // parentScreen: this,
- onClose: (dialogResult) => {
- if (dialogResult[1]) {
- if (dialogResult[0])
- txnParam.chequeNo = dialogResult[0];
- txnParam.aspTan = dialogResult[1];
- this.doTransaction(isPreview, e, txnParam);
- }
- else {
- this.error("Дансанд хандах эрхийн шалгалт амжилтгүй. Гүйлгээний мэдээллээ дахин шалгана уу.");
- }
- }
- });
- }
- else {
- this.doTransaction(isPreview, e, txnParam);
- }
- }, (err) => { this.error(err); });
- }
- doTransaction(isPreview: number, e: any, txnParam:any) {
- this.ldTxn.ldStartAcnt(txnParam)
- this.tllrTxn.executeDealTxn(txnParam, this.operation)
- .then((response) => {
- this.warnMsg = response.warningMsg;
- if (txnParam.isPreviewFee) {
- this.showFee(txnParam, response.txnPreview, response.feesPreview);
- return;
- }
- if (response.isPreview) {
- txnParam.isPreview = 0;
- this.showTran([{
- operCode: this.extraCode,
- txnParam: txnParam,
- txnAcntCode: this.model.txnAcntCode,
- txnPreview: response.txnPreview,
- isSupervisor: response.isSupervisor,
- pendReason: response.pendReason,
- cfgPrefix: this.scrCode,
- cfgScrName: this.txnCode,
- 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);
- });
- this.getControl('formTLLRA354/buttonDoTxn').disabled = true;
- break;
- }
- case 0: {
- this.tllrTxn.disableTxnBtn(this, false);
- if(this.warnMsg) {
- this.warn("Амжилттай (" + response.txnJrno + "). " + this.warnMsg+"!");;
- } else {
- 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.ldTxn.operLdStartAcnt,
- descRequired: this.isDescRequired,
- expType: "HTML",
- data: [{
- paramType: 0,
- paramCode: "TXN_JRNO",
- value: response.txnJrno
- }]
- },
- parent: this
- });
- }
- this.clear();
- break;
- }
- }
- }
- }, (err) => {
- this.sumTotalAmount = 0;
- 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,
- onClose: (dialogResult) => {
- if (dialogResult) {
- this.dialogResult = dialogResult.txnJrno;
- this.clear();
- }
- }
- });
- }
- browseAcnt(isTxnAcntCode: boolean) {
- if (isTxnAcntCode)
- app.screen({
- name: "MM-B-112",
- parameter: [{status: this.filterStatus}],
- parent: this,
- parentScreen: this,
- onClose: (dialogResult) => {
- if (dialogResult) {
- this.isGetAcntInfo = true;
- this.brwsDealCode.value = dialogResult.get("ldAcntCode");
- this.model.dealCode = dialogResult.get("dealCode");
- //this.brwsDealCode.value = dialogResult.get("dealCode");
- this.model.acntName = dialogResult.get("name");
- this.isGetAcntInfo = false;
- this.model.custCode = dialogResult.get("custCode");
- // this.model.princ = dialogResult.get("principalAmount");
- this.model.txnAmount = dialogResult.get("principalAmount");
- this.model.discountAmount = dialogResult.get("discountAmount") ? parseFloat(dialogResult.get("discountAmount")) : 0;
- this.paymentType = dialogResult.get("paymentType");
- this.ddlCurCode.value = dialogResult.get("curCode");
- this.contCurCode = dialogResult.get("curCode");
- this.ddlCurCode.trigger("change");
- this.model.curCode = dialogResult.get("curCode");
- this.model.prodType = dialogResult.get("prodType");
- this.txnType = this.model.prodType === "BORROWING" ? "CR" : "DR";
- this.setOperCode();
- if (this.rdNonCash.checked)
- this.getCssiAcnt(dialogResult.get("ldAcntCode"));
- else {
- this.model.contCurCode = dialogResult.get("curCode");
- this.ddlContCurCode.value = dialogResult.get("curCode");
- this.ddlCurCode.trigger("change");
- }
- if(this.paymentType == "BEARING"){
- $(".discount").hide();
- }
- else{
- $(".discount").show();
- }
- }
- }
- });
- else {
- app.screen({
- name: "BCOM-C-122",
- parameter: [{
- sysNo: this.model.sysNo ? this.model.sysNo : ["1301", "1305"],
- custCode: this.model.custCode,
- changeCust: 1,
- // curCode: this.model.curCode,
- status: "O",
- showClosed: false
- }],
- parent: this,
- onClose: (dialogResult) => {
- if (dialogResult) {
- this.model.sysNo = Number(dialogResult.get("sysNo"));
- this.isGetAcntInfo1 = true;
- // this.brwsContAcntCode.value = dialogResult.get("acntCode");
- this.model.contAcntCode = dialogResult.get("acntCode");
- // this.model.contAcntCode = dialogResult.get("acntCode");
- this.model.contAcntName = dialogResult.get("name");
- this.isGetAcntInfo1 = false;
- this.ddlContCurCode.value = dialogResult.get("curCode");
- this.ddlContCurCode.trigger("change");
- this.model.contCurCode = dialogResult.get("curCode");
- }
- }
- });
- }
- }
- isChanged(isTxnAcntCode: boolean) {
- if (isTxnAcntCode && !this.isGetAcntInfo) {
- if (this.brwsDealCode && this.brwsDealCode.value) {
- this.ld.getAcntDetail(this.brwsDealCode.value)
- .then((data) => {
- this.model.discountAmount = data.discountAmount ? parseFloat(data.discountAmount) : 0;
- this.model.txnAmount = data.principalAmount;
- // this.model.princ = data.principalAmount;
- this.model.acntName = data.name;
- this.paymentType = data.paymentType;
- this.model.custCode = data.custCode;
- this.ddlCurCode.value = data.curCode;
- this.contCurCode = data.curCode;
- this.ddlCurCode.trigger("change");
- this.model.curCode = data.curCode;
- this.model.prodType = data.prodType;
- this.txnType = this.model.prodType === "BORROWING" ? "CR" : "DR";
- this.setOperCode();
- if (!this.sourceType) {
- if (this.rdNonCash.checked)
- this.getCssiAcnt(data.acntCode);
- else {
- this.model.contCurCode = data.curCode;
- this.ddlContCurCode.value = data.curCode;
- this.ddlCurCode.trigger("change");
- }
- }
- if(this.paymentType == "BEARING"){
- $(".discount").hide();
- }
- else{
- $(".discount").show();
- }
- },
- (err) => {
- this.error(err);
- });
- }
- this.isGetAcntInfo = false;
- }
- else if (!isTxnAcntCode && !this.isGetAcntInfo1) {
- if (!this.isChange && this.model.contSysNo == 1412)
- return;
- if (this.model.contAcntCode) {
- if (this.extSystem[this.model.acntType]) {
- this.tllrTxn.detailExtSystemAcnt(this.extAcntType[this.model.acntType], this.model.contAcntCode)
- .then((data) => {
- if (data.CUSTNAME)
- this.model.contAcntName = data.CUSTNAME;
- if (data.ACNTNAME)
- this.model.contAcntName = data.ACNTNAME;
- this.ddlContCurCode.value = data.CURCODE;
- this.ddlContCurCode.trigger("change");
- this.model.contCurCode = data.CURCODE;
- }, (err) => {
- this.error(err);
- });
- }
- else {
- this.tllrTxn.getDetailBcomAcnt(this.brwsContAcntCode.value)
- .then((data) => {
- this.model.sysNo = Number(data.sysNo);
- this.model.contAcntName = data.name;
- this.ddlContCurCode.value = data.curCode;
- this.ddlContCurCode.trigger("change");
- this.model.contCurCode = data.curCode;
- this.setAcntType(data.sysNo);
- }, (err) => {
- this.error(err);
- });
- }
- }
- this.isGetAcntInfo1 = false;
- }
- }
- 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 == "CENTRAL_BANK")
- this.model.contBankCode = data.bankCode;
- if (data.typeCode == "LOCALBANK_GB" || data.typeCode == "LOCALBANK") {
- this.model.camRecieve = data.useAlias == 1 ? "ALIAS" : "ACNT";
- if (data.useAlias == 1) {
- this.model.aliasType = data.aliasType;
- this.model.alias = data.alias;
- } else {
- 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");
- });
- }
- formDisabled(disabled: boolean) {
- 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);
- }
- acntDetail(e, isTxnAcntCode: boolean) {
- e.preventDefault();
- var scrCode;
- var acntCode = isTxnAcntCode ? this.brwsDealCode.value : this.brwsContAcntCode.value;
- if (isTxnAcntCode)
- scrCode = "TLLR-A-606";
- else {
- switch(this.model.sysNo) {
- case 1305:
- scrCode = "TLLR-A-601";
- break;
- case 1301:
- scrCode = "TLLR-A-608";
- break;
- }
- }
- if (scrCode && acntCode)
- app.screen({
- name: scrCode,
- parameter: [acntCode],
- parent: this
- });
- }
- 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); });
- }
- }
- }
- fillGrid() {
- this.showOrHide(false);
- }
- 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();
- }
- 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;
- // if (this.rdCash.checked && this.ddlContCurCode.value !== this.curCode) {
- // this.numContAmount.value = this.model.princ;
- // if (this.numRate.value && this.numContRate.value)
- // this.model.txnAmount = this.numContAmount.value * this.numContRate.value / this.numRate.value;
- // else
- // this.model.txnAmount = 0;
- // }
- // else {
- // this.numTxnAmount.value = this.model.princ;
- // if (this.numRate.value && this.numContRate.value)
- // this.model.contAmount = this.numTxnAmount.value * this.numRate.value / this.numContRate.value;
- // else
- // this.model.contAmount = 0;
- // }
- this.clearBankNotes();
- this.correctionAmt = -1;
- }
- 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.brwsDealCode.value && this.model.prodType)
- this.getCssiAcnt(this.brwsDealCode.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();
- }
- clickSettings() {
- app.screen({
- name: "TLLR-A-200",
- parameter: [this.txnCode, "Данс эхлүүлэх", 1315, 1],
- parent: this
- });
- }
- clear() {
- this.model = {
- curCode: this.curCode,
- contCurCode: this.curCode,
- txnAmount: 0,
- contAmount: 0,
- princ: 0,
- rateTypeId: this.rateType,
- discountAmount: 0
- };
- this.clearBankNotes();
- this.correctionAmt = -1;
- this.contCurCode = this.curCode;
- this.ddlCurCode.value = this.curCode;
- this.ddlContCurCode.value = this.curCode;
- this.ddlRateType.value = this.rateType;
- this.brwsDealCode.value = null;
- this.checkDefaultRadio();
- }
- changeAcntType() {
- this.setSysNo(this.ddlAcntType.value);
- if (this.isChange) {
- this.model.contAcntCode = null;
- this.model.contAcntName = null;
- this.ddlContCurCode.disabled = this.ddlAcntType.value != "4";
- }
- this.controls.formTLLRA354.updateValidity();
- switch (this.ddlAcntType.value) {
- case "1":
- this.svKey = this.tllrTxn.svCasaAcnt;
- break;
- case "3":
- this.svKey = this.tllrTxn.svBacAcnt;
- break;
- default:
- this.svKey = "";
- break;
- }
- }
- 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;
- }
- }
- bindAcntType() {
- var data = this.ddlAcntType.dataSource.data();
- data.forEach((m) => {
- if (m)
- if (m.id == "2")
- data.remove(m);
- });
- }
- curCodeBound(isTxnCurCode: boolean) {
- let ddlCurCode = isTxnCurCode ? this.ddlCurCode : this.ddlContCurCode;
- if (this.curCode && !ddlCurCode.value) {
- ddlCurCode.value = this.curCode;
- ddlCurCode.trigger("change");
- }
- }
- getExtSystem(sysNo: number, itemCode: string) {
- this.tllrTxn.getCompanyExtSystem(sysNo)
- .then((data) => {
- this.extSystem[itemCode] = data;
- if (this.change && sysNo == 1412) {
- this.useRadioCash = data ? false : true;
- this.checkDefaultRadio();
- }
- }, (err) => {
- this.error(err);
- this.extSystem[itemCode] = "";
- if (this.change && sysNo == 1412) {
- this.checkDefaultRadio();
- }
- });
- }
- checkDefaultRadio() {
- if (this.isChange) {
- this.rdCash.disabled = !this.useRadioCash;
- // if (this.useRadioCash) {
- // this.rdCash.checked = "true";
- // }
- // else {
- // this.rdNonCash.checked = "true";
- // }
- this.rdNonCash.checked = "true";
- this.radioChange(false);
- }
- }
- 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, cfgScrName: this.txnCode, cashRequireBanknote: this.cashRequireBanknote, txnType: this.txnType, corrAmt: this.correctionAmt > 0 ? this.correctionAmt: this.model.contAmount , warningMsg: this.warnMsg, isDescRequired: this.isDescRequired }],
- parent: this,
- onClose: (dialogResult) => {
- if (dialogResult)
- this.clear();
- }
- });
- }
- showBankNote(isPreview: number, e: any){
- let data = {
- curCode: this.model.contCurCode,
- txnAmount: this.txnAmtCorrDiff ? this.correctionAmt : this.model.contAmount,
- cashNote: this.cashBankNote,
- changeBankNotes: this.changeBankNotes,
- txnType: this.txnType,
- isChangeAmount: this.txnAmtCorrDiff
- };
- if (isPreview != 2) {
- this.tllrTxn.disableTxnBtn(this, false);
- }
- app.screen({
- name: "TLLR-A-801",
- parameter: [data],
- parent: this,
- // parentScreen: this,
- onClose: (dialogResult) => {
- if (dialogResult) {
- this.cashBankNote = dialogResult;
- if (isPreview !== 2) {
- this.checkTxn(isPreview, e);
- }
- }
- }
- });
- }
- doTranPreview(isPreview: number, e: any, txnParam: any){
- txnParam.isPreview = 1;
- txnParam.isPreviewFee = 0;
- this.ldTxn.ldStartAcnt(txnParam)
- .then((response) => {
- if(response && response.txnToAmount != undefined){
- if(parseFloat(response.txnToAmount) == parseFloat(txnParam.contAmount.toFixed(2)))
- this.txnAmtCorrDiff = false;
- else
- this.txnAmtCorrDiff = true;
- }
- this.correctionAmt = response.txnToAmount;
- txnParam.txnClearAmount = this.correctionAmt;
- this.txnClearAmount = this.correctionAmt;
- this.showBankNote(isPreview, e);
- }, (err) => {
- this.tllrTxn.disableTxnBtn(this, false);
- this.error(err);
- });
- }
- clearBankNotes() {
- this.sumTotalAmount = 0;
- this.cashBankNote = [];
- this.changeBankNotes = [];
- }
- 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);
- });
- }
- 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];
- }
- keypressMail(e) {
- var allowedChars, str;
- allowedChars = new RegExp('^[a-zA-Z0-9_.@-]');
- str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
- if (allowedChars.test(str)) {
- return true;
- }
- if (
- e.keyCode === 8 ||
- e.keyCode === 46 ||
- e.keyCode === 37 ||
- e.keyCode === 39 ||
- e.charCode === 32
- ) {
- return true;
- }
- e.preventDefault();
- return false;
- }
- validateEmail(email: String) {
- let filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
- if (!filter.test(email)) {
- this.error('Зөв имэйл хаяг оруулна уу');
- this.emailValid = 0;
- return false;
- } else return true;
- }
- changeAliasType() {
- if (this.isChange) {
- this.model.alias = "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement