1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import Utils from '~/utils';
import commonFunctions from '~/mixin/commonFunctions.js';
import BigNumber from "bignumber.js";
import commonDepend from "~/mixin/commonDepend";
import moment from "moment";
export default {
mixins: [commonFunctions, commonDepend],
methods: {
/**
* source:letdrw.0040.script
*/
defaultBedgrpAplN1000(){
// APL address always reset from LE, but reference has to be used from BE, if already set
Utils.copyValueFromVoData(this.model.bedgrp.apl.pts, this.model.ledgrp.apl.pts);
},
/**
* source:letdrw.0044.script
*/
defaultBedgrpBenN1000(){
// always get ben from parent LE
Utils.copyValueFromVoData(this.model.bedgrp.ben.pts, this.model.ledgrp.ben.pts);
if(this.model.bedgrp.rec.docprbrol===''){
this.model.bedgrp.rec.docprbrol = 'BEN';
}
},
/**
* source:letdrw.0045.script
*/
defaultBedgrpIssN1000(){
// always get ISS from parent LE
Utils.copyValueFromVoData(this.model.bedgrp.iss.pts, this.model.ledgrp.iss.pts);
},
/**
* source:letdrw.0046.script
*/
defaultBedgrpRmbN1000(){
// always get RMB from parent LE
Utils.copyValueFromVoData(this.model.bedgrp.rmb.pts, this.model.ledgrp.rmb.pts);
},
max2AmtChange(){
this.model.bedgrp.cbs.opn2.amt = new BigNumber(this.model.oldbedgrp.cbs.opn2.amt)
.plus(new BigNumber(this.model.bedgrp.cbs.max2.amt))
.minus(new BigNumber(this.model.oldbedgrp.cbs.max2.amt)).toFixed(2);
this.defaultBedgrpBlkDocdis();
},
defaultBedgrpBlkDocdis() {
// BEDGRP\BLK\DOCDIS
// it is on purpose that we don`t use translatable literals, because the ultimate
// destination of this text is a foreign bank and usually via SWIFT !
let descr = "";
let CR = '\n';
if (this.model.bedgrp.rec.shpdat != null && this.model.ledgrp.rec.shpdat != null
&& moment(this.model.bedgrp.rec.shpdat).diff(moment(this.model.ledgrp.rec.shpdat), 'days') > 0) {
descr = descr + 'Late shipment' + CR;
}
if (this.model.bedgrp.rec.rcvdat != null && this.model.ledgrp.rec.expdat != null
&& moment(this.model.bedgrp.rec.rcvdat).diff(moment(this.model.ledgrp.rec.expdat), 'days') > 0) {
descr = descr + 'Documents received after expiry of the LC.' + CR;
}
if (this.model.bedgrp.cbs.max.amt != '' && this.model.ledgrp.cbs.opn1.amt != ''
&& new BigNumber(this.model.bedgrp.cbs.max.amt).comparedTo(this.model.ledgrp.cbs.opn1.amt) > 0) {
let exces = this.model.bedgrp.cbs.max.cur + " " + this.formatCurrency(new BigNumber(this.model.bedgrp.cbs.max.amt).minus(this.model.ledgrp.cbs.opn1.amt), this.model.bedgrp.cbs.max.cur)
descr = descr + 'The LC is overdrawn by ' + exces + CR;
}
if (this.model.bedgrp.cbs.max2.amt != '' && this.model.ledgrp.cbs.opn2.amt != ''
&& new BigNumber(this.model.bedgrp.cbs.max2.amt).comparedTo(this.model.ledgrp.cbs.opn2.amt) > 0) {
let exces = this.model.bedgrp.cbs.max.cur + " " + this.formatCurrency(new BigNumber(this.model.bedgrp.cbs.max2.amt).minus(this.model.ledgrp.cbs.opn2.amt), this.model.bedgrp.cbs.max2.cur)
descr = descr + 'The additional amount is overdrawn by ' + exces + CR;
}
if (this.model.ledgrp.rec.shppar === 'N' && (this.model.ledgrp.rec.utlnbr != '' && new BigNumber(this.model.ledgrp.rec.utlnbr).comparedTo(1) >= 0)) {
descr = descr + 'Partial shipment effected.' + CR;
}
if (this.model.bedgrp.rec.doctypcod === 'P') {
if (this.model.ledgrp.rec.avbby === 'A' || this.model.ledgrp.rec.avbby === 'D') {
descr = descr + 'Sight draft presented instead of usance.' + CR;
}
if (this.model.ledgrp.rec.avbby === 'M') {
descr = descr + 'Only sight draft presented instead of mixed payment.' + CR;
}
}
if (this.model.bedgrp.rec.doctypcod === 'A' || this.model.bedgrp.rec.doctypcod === 'D') {
if (this.model.ledgrp.rec.avbby === 'P') {
descr = descr + 'Usance draft presented instead of sight.' + CR;
}
if (this.model.ledgrp.rec.avbby === 'M') {
descr = descr + 'Only usance drafts presented instead of mixed payment.' + CR;
}
}
if (this.model.bedgrp.rec.doctypcod === 'M') {
if (this.model.ledgrp.rec.avbby === 'P') {
descr = descr + 'Mixed payment drafts presented instead of sight.' + CR;
}
if (this.model.ledgrp.rec.avbby === 'A' || this.model.ledgrp.rec.avbby === 'D') {
descr = descr + 'Mixed payment drafts presented instead of usance.' + CR;
}
}
this.model.bedgrp.blk.docdis = descr;
},
formatCurrency(value, cur) {
if (value !== null && value !== undefined && (value === "" || value.toString())) {
if (value === "") {
value = "0";
}
value = value.toString();
let sign = true;
let array = [];
if (value.charAt(0) == "-") {
sign = false;
array = value.slice(1).split(".");
} else {
array = value.split(".");
}
// 增加逗号
var temp = "";
while (array[0].length > 3) {
temp =
"," +
array[0].substring(array[0].length - 3, array[0].length) +
temp;
array[0] = array[0].substring(0, array[0].length - 3);
}
temp = array[0] + temp;
if (this.curPrecision(cur) == 0) {
return sign ? temp : "-" + temp;
}
if (this.curPrecision(cur) <= 0) {
temp = temp;
} else if (array.length === 1) {
// 没有小数位数,补全 0
temp += ".";
for (var i = 0; i < this.curPrecision(cur); i++) {
temp += "0";
}
} else if (array[1].length < this.curPrecision(cur)) {
temp += "." + array[1];
// 精度不足补全 0
for (var i = array[1].length; i < this.curPrecision(cur); i++) {
temp += "0";
}
} else {
temp += "." + array[1].substring(0, this.curPrecision(cur));
}
return sign ? temp : "-" + temp;
}
},
curPrecision(cur) {
if (cur === "KRW" || cur === "JPY") {
return 0;
} else {
return 2;
}
},
defaultFolwupopt() {
// folwupopt is not modified
if (!this.model.betp.modifySet || this.model.betp.modifySet == null || (this.model.betp.modifySet != null && !this.model.betp.modifySet.includes('folwupopt'))) {
if (this.model.bedgrp.blk.docdis!=null && this.model.bedgrp.blk.docdis!='') {
this.model.betp.folwupopt = "S";//# Send Advice of Discrepancy
} else {
this.model.betp.folwupopt = "W"; // # Wait for Response
}
}
},
},
}