index.js 8.17 KB
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import Utils from "~/utils/index";
import moment from 'moment';
import { cloneDeep } from "lodash";
import Pts from '~/components/business/commonModel/Pts.js';
export default {
	mixins: [commonFunctions],
	methods: {

		paybrolDefault() {
      let ptsList = [];
			ptsList.push(this.model.ledgrp.adv);
			ptsList.push(this.model.ledgrp.avb);
      ptsList.push(this.model.ledgrp.iss);
      ptsList.push(this.model.ledgrp.con);
      let res = ptsList.find((item) => item.pts.rol == this.model.btdgrp.rec.payrol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.btdgrp.oth = newRes;
        this.model.btdgrp.oth.pts.rol = "OTH";
			}else{
				const objpta = {
					pts : new Pts().data,
				}
				this.model.btdgrp.oth = cloneDeep(objpta);
				this.model.btdgrp.oth.pts.rol = "OTH";

			}
    },
    
    buildPtspta (ptsptaObj) {
      let pts = ptsptaObj.pts;
      let ptspta = {
        rol: pts.rol,
        name: pts.nam,
        ptyinr: pts.ptyinr,
        ptainr: pts.ptainr,
        extkey: pts.extkey,
        dftdsp: pts.dftdsp,
        dftcur: pts.dftcur,
        dftact: pts.dftact,
        dftfeecur: pts.dftfeecur,
        dftactptainr: pts.dftactptainr,
        glggrpflg: pts.glggrpflg,
        adrblk: pts.adrblk,
        pts
      };
      return ptspta;
    },
    docprbrolChange(){
      let ptsptaList = Utils.formatPtspta(this.model.ltdgrp, this.buildPtspta);
      let res = ptsptaList.find((item) => item.pts.rol == this.model.btdgrp.rec.docprbrol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.btdgrp.prb = newRes;
        this.model.btdgrp.prb.pts.rol = "PRB";
			}else{
				const objpta = {
					pts : new Pts().data,
				}
				this.model.btdgrp.prb = cloneDeep(objpta);
				this.model.btdgrp.prb.pts.rol = "PRB";
			}
    },

		benrefDefault() {
			let blkModifyList = this.model.btdgrp.blk.modifySet;
			if (blkModifyList && blkModifyList.includes("benref")) 
			{
				this.model.btdgrp.be1.pts.ref = this.model.btdgrp.blk.benref;
			}
		},

		// docdisDefault(){
		// 	let blkModifyList = this.model.btdgrp.blk.modifySet;
		// 	if (!(blkModifyList && blkModifyList.includes("docdis") && this.model.btdgrp.blk.docdis != ""))
		// 	{
		// 		let descr = "";
		// 		if (moment(this.model.btdgrp.rec.shpdat).diff(moment(this.model.ledgrp.rec.shpdat), 'days') > 0
		// 			&& this.model.ledgrp.rec.shpdat != "" && this.model.ledgrp.rec.shpdat != null)
		// 		{
		// 			descr = descr + "Late shipment." + " ";
		// 		}
		// 		if (moment(this.model.btdgrp.rec.rcvdatbe1).diff(moment(this.model.ledgrp.rec.expdat), 'days') > 0
		// 			|| moment(this.model.btdgrp.rec.rcvdatbe2).diff(moment(this.model.ledgrp.rec.expdat), 'days') > 0)
		// 		{
		// 			descr = descr + "Documents received after expiry of the LC." + " ";
		// 		}
		// 		let exces = "";
		// 		if (this.model.ledgrp.cbs.opn2.amt < 0)	 
		// 		{
		// 			exces = this.model.btdgrp.cbs.mat.cur + " " + this.model.ledgrp.cbs.opn2.amt;
		// 			descr = descr + "The additional amount is overdrawn by " + exces + " ";
		// 		}
		// 		if (this.model.ledgrp.ref.shppar == "N" && this.model.ledgrp.rec.utlnbr >= 1)
		// 		{
		// 			descr = descr + "Partial shipment effected." + " ";
		// 		}
		// 		if (this.model.btdgrp.rec.doctypcod == "P")
		// 		{
		// 			if (this.model.ledgrp.rec.avbby == "A" || this.model.ledgrp.rec.avbby == "D")
		// 			{
		// 				descr = descr + "Sight draft presented in stead of Usance." + " ";
		// 			}
		// 			if (this.model.ledgrp.rec.avbby == "M")
		// 			{
		// 				descr = descr + "Only Sight draft presented instead of mixed payment." + " ";
		// 			}
		// 		}
		// 		if (this.model.btdgrp.rec.doctypcod == "A" || this.model.btdgrp.rec.doctypcod == "D")
		// 		{
		// 			if (this.model.ledgrp.rec.avbby == "P")
		// 			{
		// 				descr = descr + "Usance draft presented instead of Sight." + " ";
		// 			}
		// 			if (this.model.ledgrp.rec.avbby == "M")
		// 			{
		// 				descr = descr + "Only Usance drafts presented instead of mixed payment." + " ";
		// 			}
		// 		}
		// 		if (this.model.btdgrp.rec.doctypcod == "M")
		// 		{
		// 			if (this.model.ledgrp.rec.avbby == "P")
		// 			{
		// 				descr = descr + "Mixed payment drafts presented instead of sight." + " ";
		// 			}
		// 			if (this.model.ledgrp.rec.avbby == "A" || this.model.ledgrp.rec.avbby == "D")
		// 			{
		// 				descr = descr + "Mixed payment drafts presented instead of usance." + " ";
		// 			}
		// 		}
		// 		this.model.btdgrp.blk.docdis = descr;
		// 	}

		// 	if (this.model.btdgrp.blk.docdisflg == "")
		// 	{
		// 		this.model.btdgrp.blk.docdis = "";
		// 	}
		// },
		docstaDefault() {
			if (this.model.btdgrp.rec.advdat != "" && this.model.btdgrp.rec.advdat != null && this.model.btdgrp.rec.advtyp == "754")
			{
				if (this.model.btdgrp.ref.rcvdatbe2 == null || this.model.btdgrp.ref.rcvdatbe2 == "" || this.model.btdgrp.ref.rcvdatbe1 == null || this.model.btdgrp.ref.rcvdatbe1 == "")
				{
					this.model.btdgrp.ref.docsta = "C";
				}else{
					this.model.btdgrp.ref.docsta = "D";
				}
			}
			if (this.model.btdgrp.rec.disdat != "" && this.model.btdgrp.rec.disdat != null && this.model.btdgrp.rec.advtyp == "750")
			{
				if (this.model.btdgrp.ref.rcvdatbe2 == null || this.model.btdgrp.ref.rcvdatbe2 == "" || this.model.btdgrp.ref.rcvdatbe1 == null || this.model.btdgrp.ref.rcvdatbe1 == "")
				{
					this.model.btdgrp.ref.docsta = "E";
				}else{
					this.model.btdgrp.ref.docsta = "F";
				}
			}
			if ((this.model.btdgrp.rec.advdat == "" || this.model.btdgrp.rec.advdat == null) && (this.model.btdgrp.rec.disdat == "" || this.model.btdgrp.rec.disdat == null))
			{
				if ((this.model.btdgrp.ref.rcvdatbe2 != null && this.model.btdgrp.ref.rcvdatbe2 != "") || (this.model.btdgrp.ref.rcvdatbe1 != null && this.model.btdgrp.ref.rcvdatbe1 != "")
					&& this.model.btdgrp.rec.dscinsflg == "" )
				{
					this.model.btdgrp.ref.docsta = "G";
				}
				if ((this.model.btdgrp.ref.rcvdatbe2 != null && this.model.btdgrp.ref.rcvdatbe2 != "") || (this.model.btdgrp.ref.rcvdatbe1 != null && this.model.btdgrp.ref.rcvdatbe1 != "")
					&& this.model.btdgrp.rec.dscinsflg != "" && this.medel.btdgrp.rec.docdis == "")
				{
					this.model.btdgrp.ref.docsta = "H";
				}
				if ((this.model.btdgrp.ref.rcvdatbe2 != null && this.model.btdgrp.ref.rcvdatbe2 != "") || (this.model.btdgrp.ref.rcvdatbe1 != null && this.model.btdgrp.ref.rcvdatbe1 != "")
					&& this.model.btdgrp.rec.dscinsflg != "" && this.medel.btdgrp.rec.docdis != "")
				{
					this.model.btdgrp.ref.docsta = "I";
				}
			}
			if (this,model.btdgrp.rec.approvcod != "")
			{
				this.model.btdgrp.ref.docsta = "L";
			}
			if (this,model.btdgrp.rec.acpnowflg != "")
			{
				this.model.btdgrp.ref.docsta = "M";
			}
			if (this,model.btdgrp.rec.frepayflg != "")
			{
				this.model.btdgrp.ref.docsta = "N";
			}
		},

		cre752flgDefault(){
			if (this.model.bttp.cre752flg == "")
			{
				this.model.btdgrp.rec.disdat = "";
			}
    },

    // changeRmbclmnow(){
    //   if(!!this.model.rmbclmnow){
    //     if(this.model.rmbclm.modifySet !=null && !this.model.rmbclm.modifySet.includes("rmbrol")){
    //       this.model.rmbclm.rmbrol="RMB"
    //     }
    //     // else{
    //     //   this.model.rmbclm.rmbp.pansta="E"
    //     // }
    //   }
    //   // else{
    //   //   this.model.rmbclm.rmbp.pansta="I"
    //   // }
        
    // },

    changeRmbrol(){
      let ptsList = [];
			ptsList.push(this.model.ledgrp.adv);
			ptsList.push(this.model.ledgrp.avb);
      ptsList.push(this.model.ledgrp.iss);
      ptsList.push(this.model.ledgrp.con);
      ptsList.push(this.model.ledgrp.rmb);
      ptsList.push(this.model.btdgrp.oth);
      let res = ptsList.find((item) => item.pts.rol == this.model.rmbclm.rmbrol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.rmbclm.rmbrmb = newRes;
        this.model.rmbclm.rmbrmb.pts.rol = "RMBRMB";
      }else{
        const objpta = {
					pts : new Pts().data,
				}
				this.model.rmbclm.rmbrmb = cloneDeep(objpta);
      }
    },

    changeDocdisflg(){
      if (this.model.btdgrp.blk.docdisflg == "") {
        this.model.btdgrp.blk.docdis =  this.model.oldbtdgrp.blk.docdis;
      }
    }
		
	}
}