Commit bd1b3e6b by lixinyi

新增拟报业务规则

parent a99b8dd7
......@@ -96,7 +96,7 @@ export default function validator(obj) {
}
if(!RelatedPresentWhenCopyDupl(obj)){
return false;
}
}
return true;
......
......@@ -79,6 +79,34 @@ export default function validator(obj) {
!CBPR_Agent_Name_Postal_Address_FormalRule(element.intrmyAgt.finInstnId,`Item[`+ (index + 1) +`]/Intermediary Agent/Financial Institution Identification`)){
return false;
}
if(!AccountAndCurrencyRule(obj.ntfctn,element)){
return false;
}
if(!TotalAmountAndAmount1Rule(obj.ntfctn,element)){
return false;
}
if(!DebtorAgentRule(obj.ntfctn,element)){
return false;
}
if(!DebtorRule(obj.ntfctn,element)){
return false;
}
if(!IntermediaryAgentRule(obj.ntfctn,element)){
return false;
}
if(!RelatedAccountRule(obj.ntfctn,element)){
return false;
}
if(!IntermediaryAgentAndDebtorAgentRule(element)){
return false;
}
}
if(!IntermediaryAgentAndDebtorAgentRule(obj.ntfctn)){
return false;
}
if(!MandatoryDebtorRule(obj.ntfctn)){
return false;
}
if(isNotEmpty(obj.grpHdr.msgSndr.pty)){
......@@ -203,6 +231,114 @@ export default function validator(obj) {
}
return true;
}
//Cross Element Complex Rule : Account And Currency Rule
function AccountAndCurrencyRule(obj,itm) {
const msg = "If Account is present, then all occurrences of Item/Amount must have the same currency.";
var acct = obj.acct;
var ccy = itm.amt.ccy;
if(isNotEmpty(acct)){
if(acct.ccy != ccy){
message("Item/Amount", msg);
return false;
}
}
return true;
}
//Cross Element Complex Rule : Total Amount And Amount 1Rule
function TotalAmountAndAmount1Rule(obj,itm) {
const msg = "If TotalAmount is present, then all occurrences of Item/Amount must have the same currency as the currency of TotalAmount.";
var ttlAmt = obj.ttlAmt;
var ccy = itm.amt.ccy;
if(isNotEmpty(ttlAmt)){
if(ttlAmt.ccy != ccy){
message("Item/Amount", msg);
return false;
}
}
return true;
}
//Cross Element Complex Rule : Debtor Agent Rule
function DebtorAgentRule(obj,itm) {
const msg = "Either DebtorAgent or Item/DebtorAgent may be present but not both.";
var dbtrAgt = obj.dbtrAgt;
var idbtrAgt = itm.dbtrAgt;
if(isNotEmpty(dbtrAgt)&&isNotEmpty(idbtrAgt)){
message("Debtor Agent", msg);
return false;
}
return true;
}
//Cross Element Complex Rule : Debtor Rule
function DebtorRule(obj,itm) {
const msg = "Either Debtor or Item/Debtor may be present but not both.";
var dbtr = obj.dbtr;
var idbtr = itm.dbtr;
if(isNotEmpty(dbtr)&&isNotEmpty(idbtr)){
message("Debtor", msg);
return false;
}
return true;
}
//Cross Element Complex Rule : Mandatory Debtor Rule
function MandatoryDebtorRule(obj) {
const msg = "Either Debtor must be present or Item/Debtor must be present.";
var dbtr = obj.dbtr;
var flag = true;
if(isEmpty(dbtr)){
var itm = obj.itm;
for (var index = 0; index < itm.length; index++) {
const element = itm[index];
var idbtr = element.dbtr;
if(isNotEmpty(idbtr)){
flag = false;
}
}
if(flag){
message("Debtor", msg);
return false;
}
}
return true;
}
//Cross Element Complex Rule : Intermediary Agent And Debtor Agent Rule
function IntermediaryAgentAndDebtorAgentRule(obj) {
const msg = "If IntermediaryAgent is present then DebtorAgent must be present.";
var intrmyAgt = obj.intrmyAgt;
var dbtrAgt = obj.dbtrAgt;
if(isNotEmpty(intrmyAgt)){
if(isEmpty(dbtrAgt)){
message("Debtor Agent", msg);
return false;
}
}
return true;
}
//Cross Element Complex Rule : Intermediary Agent Rule
function IntermediaryAgentRule(obj,itm) {
const msg = "Either IntermediaryAgent or Item/IntermediaryAgent may be present but not both.";
var intrmyAgt = obj.intrmyAgt;
var iintrmyAgt = itm.intrmyAgt;
if(isNotEmpty(intrmyAgt)&&isNotEmpty(iintrmyAgt)){
message("Intermediary Agent", msg);
return false;
}
return true;
}
//Cross Element Complex Rule : Related Account Rule
function RelatedAccountRule(obj,itm) {
const msg = "Either RelatedAccount or Item/RelatedAccount may be present but not both.";
var rltdAcct = obj.rltdAcct;
var irltdAcct = itm.rltdAcct;
if(isNotEmpty(rltdAcct)&&isNotEmpty(irltdAcct)){
message("Related Account", msg);
return false;
}
return true;
}
// Cross Element Complex Rule : Related Present When Copy Dupl
function RelatedPresentWhenCopyDupl(obj) {
......
......@@ -345,8 +345,62 @@ export default function validator(obj) {
if(!RelatedPresentWhenCopyDupl(obj)){
return false;
}
if(!ReturnedInstructedAmountAndExchangeRate1Rule(obj)){
return false;
}
if(!ReturnedInstructedAmountAndExchangeRate2Rule(obj)){
return false;
}
if(!ReturnReasonRule(obj.txInf.rtrRsnInf)){
return false;
}
return true;
}
// 如果Reason/Code == NARR,则必须提供附加信息。
function ReturnReasonRule(obj) {
const msg = "If Reason/Code is equal to Narrative, then AdditionalInformation must be present.";
const position = "Transaction Details/Return Information/Reason";
if (isNotEmpty(obj)) {
if (isNotEmpty(obj.rsn)) {
if (obj.rsn.cd == 'NARR') {
if (isEmpty(obj.addtlInf)) {
message(position, msg);
return false;
}
}
}
}
return true;
}
// CrossElementComplexRule Returned Instructed Amount And Exchange Rate 1Rule
function ReturnedInstructedAmountAndExchangeRate1Rule(obj) {
const msg = "If ReturnedInstructedAmount is present and the currency is different from the currency in ReturnedInterbankSettlementAmount, then ExchangeRate must be present.";
var rtrdIntrBkSttlmAmt = obj.txInf.rtrdIntrBkSttlmAmt;
var instdAmt = obj.txInf.rtrdInstdAmt;
var xchgRate = obj.txInf.xchgRate;
if(isNotEmpty(instdAmt)){
if(instdAmt.ccy != rtrdIntrBkSttlmAmt.ccy && isEmpty(xchgRate)){
message("Exchange Rate", msg);
return false;
}
}
return true;
}
// CrossElementComplexRule Returned Instructed Amount And Exchange Rate 2Rule
function ReturnedInstructedAmountAndExchangeRate2Rule(obj) {
const msg = "If ReturnedInstructedAmount is present and the currency is the same as the currency in ReturnedInterbankSettlementAmount, then ExchangeRate is not allowed.";
var rtrdIntrBkSttlmAmt = obj.txInf.rtrdIntrBkSttlmAmt;
var instdAmt = obj.txInf.rtrdInstdAmt;
var xchgRate = obj.txInf.xchgRate;
if(isNotEmpty(instdAmt)){
if(instdAmt.ccy == rtrdIntrBkSttlmAmt.ccy && isNotEmpty(xchgRate)){
message("Exchange Rate", msg);
return false;
}
}
return true;
}
......
<!doctype html><html lang=""><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="favicon.ico"/><title>ISO手工拟报</title><script defer="defer" src="js/chunk-vendors.23ee7bd5.js"></script><script defer="defer" src="js/app.c92c0280.js"></script><script defer="defer" src="js/main.59945214.js"></script><link href="css/chunk-vendors.77489a8d.css" rel="stylesheet"><link href="css/app.d2831041.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but swiftiso-editor doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file
<!doctype html><html lang=""><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="favicon.ico"/><title>ISO手工拟报</title><script defer="defer" src="js/chunk-vendors.23ee7bd5.js"></script><script defer="defer" src="js/app.7af1ce20.js"></script><script defer="defer" src="js/main.59945214.js"></script><link href="css/chunk-vendors.77489a8d.css" rel="stylesheet"><link href="css/app.d2831041.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but swiftiso-editor doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment