function C526(PAY_HIST_PROFILE ,EXTRACT_DT,OPEN_DT){
	
	if(PAY_HIST_PROFILE == ""){
		return "error"
	}
	if(EXTRACT_DT == "01010401" || OPEN_DT == "01010401"){
		return "error"
	}
	
	var extrDateObj = toDate(EXTRACT_DT)
	var openDtObj = toDate(EXTRACT_DT)
	
	var extrDtOpenDtDiff = extrDateObj.getMonth - openDtObj.getMonth
	var calculatedDiff = ""
	if(extrDtOpenDtDiff > 24)
	{	
		calculatedDiff  = 24	
	}else{
		calculatedDiff = extrDtOpenDtDiff - 1
	}
	var pymtHistProfile = PAY_HIST_PROFILE.substring(0,PAY_HIST_PROFILE).split('');
	for(i = 0;i<=calculatedDiff;i++){
		if(pymtHistProfile(i) != "N" || pymtHistProfile("_") || pymtHistProfile(" ")) {
			return "error"
		}}
}

function validateC526(PAY_HIST_PROFILE ,EXTRACT_DT,OPEN_DT){
	var returnVar = "S"
	if(PAY_HIST_PROFILE == ""){
		returnVar =  "E"
	}
	if(EXTRACT_DT == "01010401" || OPEN_DT == "01010401"){
		returnVar =  "E"
	}
	
	var extrDateObj = toDate(EXTRACT_DT)
	var openDtObj = toDate(EXTRACT_DT)
	
	var extrDtOpenDtDiff = extrDateObj.getMonth - openDtObj.getMonth
	var calculatedDiff = ""
	if(extrDtOpenDtDiff > 24)
	{
	calculatedDiff  = 24	
	}else{
		calculatedDiff = extrDtOpenDtDiff - 1
	}
	var pymtHistProfile = PAY_HIST_PROFILE.substring(0,PAY_HIST_PROFILE).split('');
	for(i = 0;i<=calculatedDiff;i++){
		if(pymtHistProfile(i) != "N" || pymtHistProfile("_") || pymtHistProfile(" ")) {
			returnVar  = "E"
		}}
		return returnVar
}


function toDate(string){
	var sdf = Java.type("java.text.SimpleDateFormat")
    var d1 = new sdf("MMddyyyy")
    var date = d1.parse(dateVal)
	
	return date
}

function C527(PAY_HIST_PROFILE ,DBT_AMT_30,DBT_AMT_60,DBT_AMT_90,DBT_AMT_120,DBT_AMT_150,DBT_AMT_180,DBT_AMT_181){
	if(PAY_HIST_PROFILE == ""){
		return "error"
	}
	if(!(DBT_AMT_181 > 0  && (DBT_AMT_181 == "6" || DBT_AMT_181 =="7"))){
		return "error"
	}
	if(!(DBT_AMT_180 > 0  && (DBT_AMT_180 == "5" || DBT_AMT_180 == "6" || DBT_AMT_180 =="7"))){
		return "error"
	}
	if(!(DBT_AMT_150 > 0  && (DBT_AMT_150 == "4" || DBT_AMT_150 == "5" || DBT_AMT_150 == "6" || DBT_AMT_150 =="7"))){
		return "error"
	}
	if(!(DBT_AMT_120 > 0  && (DBT_AMT_120 == "3" || DBT_AMT_120 == "4" || DBT_AMT_120 == "5" || DBT_AMT_120 == "6" || DBT_AMT_120 =="7"))){
		return "error"
	}
	if(!(DBT_AMT_90 > 0  && (DBT_AMT_90 == "2" || DBT_AMT_90 == "3" || DBT_AMT_90 == "4" || DBT_AMT_90 == "5" || DBT_AMT_90 == "6" || DBT_AMT_90 =="7"))){
		return "error"
	}
	if(!(DBT_AMT_60 > 0  && (DBT_AMT_60 == "1" ||DBT_AMT_60 == "2" || DBT_AMT_60 == "3" || DBT_AMT_60 == "4" || DBT_AMT_60 == "5" || DBT_AMT_60 == "6" || DBT_AMT_60 =="7"))){
		return "error"
	}
	if(!(DBT_AMT_30 > 0  && (DBT_AMT_30 == "0" || DBT_AMT_30 == "1" ||DBT_AMT_30 == "2" || DBT_AMT_30 == "3" || DBT_AMT_30 == "4" || DBT_AMT_30 == "5" || DBT_AMT_30 == "6" || DBT_AMT_30 =="7"))){
		return "error"
	}
	
	return PAY_HIST_PROFILE
}
function validateC527(PAY_HIST_PROFILE ,DBT_AMT_30,DBT_AMT_60,DBT_AMT_90,DBT_AMT_120,DBT_AMT_150,DBT_AMT_180,DBT_AMT_181){
	var returnStr = "S"
	if(PAY_HIST_PROFILE == ""){
		returnStr = "E"
	}
	if(!(DBT_AMT_181 > 0  && (DBT_AMT_181 == "6" || DBT_AMT_181 =="7"))){
		returnStr = "E"
	}
	if(!(DBT_AMT_180 > 0  && (DBT_AMT_180 == "5" || DBT_AMT_180 == "6" || DBT_AMT_180 =="7"))){
		returnStr = "E"
	}
	if(!(DBT_AMT_150 > 0  && (DBT_AMT_150 == "4" || DBT_AMT_150 == "5" || DBT_AMT_150 == "6" || DBT_AMT_150 =="7"))){
		returnStr = "E"
	}
	if(!(DBT_AMT_120 > 0  && (DBT_AMT_120 == "3" || DBT_AMT_120 == "4" || DBT_AMT_120 == "5" || DBT_AMT_120 == "6" || DBT_AMT_120 =="7"))){
		returnStr = "E"
	}
	if(!(DBT_AMT_90 > 0  && (DBT_AMT_90 == "2" || DBT_AMT_90 == "3" || DBT_AMT_90 == "4" || DBT_AMT_90 == "5" || DBT_AMT_90 == "6" || DBT_AMT_90 =="7"))){
		returnStr = "E"
	}
	if(!(DBT_AMT_60 > 0  && (DBT_AMT_60 == "1" ||DBT_AMT_60 == "2" || DBT_AMT_60 == "3" || DBT_AMT_60 == "4" || DBT_AMT_60 == "5" || DBT_AMT_60 == "6" || DBT_AMT_60 =="7"))){
		returnStr = "E"
	}
	if(!(DBT_AMT_30 > 0  && (DBT_AMT_30 == "0" || DBT_AMT_30 == "1" ||DBT_AMT_30 == "2" || DBT_AMT_30 == "3" || DBT_AMT_30 == "4" || DBT_AMT_30 == "5" || DBT_AMT_30 == "6" || DBT_AMT_30 =="7"))){
		returnStr = "E"
	}
	return returnStr
}
function C539(WS_STATUS_CODE,DBT_AMT_30,DBT_AMT_60,DBT_AMT_90,DBT_AMT_120,DBT_AMT_150,DBT_AMT_180,DBT_AMT_181,TOT_ACCTBAL){
	var save_status = ""
	var cross_reference_field = ""
	if(WS_STATUS_CODE  === "C "){
		if( DBT_AMT_30 != "0" || DBT_AMT_60  != "0" ||   DBT_AMT_90  != "0" || DBT_AMT_120 != "0" ||   DBT_AMT_150 != "0" ||                       	 DBT_AMT_180 != "0" ||	 DBT_AMT_181 != "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  === "1 "){
		if( DBT_AMT_30 == "0" || DBT_AMT_60  != "0" ||   DBT_AMT_90  != "0" || DBT_AMT_120 != "0" ||   DBT_AMT_150 != "0" ||                       	 DBT_AMT_180 != "0" ||	 DBT_AMT_181 != "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  == "2 "){
		if( DBT_AMT_60  == "0" || DBT_AMT_90  != "0" || DBT_AMT_120 != "0" ||   DBT_AMT_150 != "0" || DBT_AMT_180 != "0" ||	 DBT_AMT_181 != "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  == "3 "){
		if( DBT_AMT_90  == "0" || DBT_AMT_120 != "0" ||   DBT_AMT_150 != "0" || DBT_AMT_180 != "0" ||	 DBT_AMT_181 != "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  == "4 "){
		if(DBT_AMT_120 == "0"  || DBT_AMT_150 != "0" || DBT_AMT_180 != "0" ||	 DBT_AMT_181 != "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  == "5 "){
		if(DBT_AMT_150 == "0" || DBT_AMT_180 != "0" ||	 DBT_AMT_181 != "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  == "6 "){
		if(DBT_AMT_180 == "0" ||	 DBT_AMT_181 != "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  == "6 "){
		if( DBT_AMT_181 == "0" )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}
	if(WS_STATUS_CODE  == "0 "){
	if( (DBT_AMT_30 != "0" || DBT_AMT_60  != "0" ||   DBT_AMT_90  != "0" || DBT_AMT_120 != "0" ||   DBT_AMT_150 != "0" ||                       	 DBT_AMT_180 != "0" ||	 DBT_AMT_181 != "0" ) && TOT_ACCTBAL > 0 )       
		 {
			 save_status = " "
			 cross_reference_field =  "error"
		 }
	}

	if(WS_STATUS_CODE  == "H "){
		 if ((DBT_AMT_30   == 0  && DBT_AMT_60 == 0  && DBT_AMT_90 == 0  &&  DBT_AMT_120  == 0  &&   DBT_AMT_150  == 0  &&  DBT_AMT_180  == 0  &&    DBT_AMT_181     == 0)  ||   ((DBT_AMT_30  != 0  &&     DBT_AMT_60  != 0) &&   (DBT_AMT_90   == 0  &&   DBT_AMT_120     == 0  && DBT_AMT_150  == 0  && DBT_AMT_180     == 0  &&  DBT_AMT_181  == 0))){
			  cross_reference_field =  "error"
		 }
	}


if(cross_reference_field == "error"){
	COMMENT_CODE1 == "000"
	COMMENT_CODE2 == "000"
	COMMENT_CODE3 == "000"
}else{
	if(temp_comment_code1 == 0){
		COMMENT_CODE1 == "000"
	}
	if(temp_comment_code2 == 0){
		COMMENT_CODE2 == "000"
	}
	if(temp_comment_code3 == 0){
		COMMENT_CODE3 == "000"
	}
}
//TODO Comment coce logic
/*IF Cross field reference field is error.
    MOVE ZEROS         TO COMMENT_CODE1             
                          COMMENT_CODE2             
                          COMMENT_CODE3             
 ELSE
    If temp_comment_code1 EQUAL ZEROS
       MOVE ZEROS         TO COMMENT_CODE1
    END_IF
    IF  temp_comment_code2 EQUAL ZEROS
       MOVE ZEROS         TO COMMENT_CODE2
    END_IF
    IF  temp_comment_code3 EQUAL ZEROS
       MOVE ZEROS         TO COMMENT_CODE3
    END_IF
 END_IF
 IF SAVE_STATUS EQUAL SPACE
    MOVE SPACE         TO STATUS_CODE               
 END_IF
*/
}
function C528(WS_TOT_DBT,DBT_AMT_30,DBT_AMT_60,DBT_AMT_90,DBT_AMT_120,DBT_AMT_150,DBT_AMT_180,DBT_AMT_181,COMMENT_CODE,extractDt,acquiredDt,totalAccBal,PAY_TERMS){
	
	var returnValue = "COMMENT_CODE"
	var WS_TOT_DBT = WS_TOT_DBT + DBT_AMT_30 + DBT_AMT_60 + DBT_AMT_90 + DBT_AMT_120  + DBT_AMT_150   + DBT_AMT_180 + DBT_AMT_181
	var temp_comment_code = ""
	if(COMMENT_CODE == ""){
		returnValue = ""
	}
	
	if(COMMENT_CODE == "160" || COMMENT_CODE == "161" || COMMENT_CODE == "167" || COMMENT_CODE == "461" || COMMENT_CODE =="401" ||
			COMMENT_CODE == "159" || COMMENT_CODE == "458" || COMMENT_CODE == "472" || COMMENT_CODE  == "460" || COMMENT_CODE == "164" ||
				COMMENT_CODE == "163" || COMMENT_CODE == "355" || COMMENT_CODE == "151" ){
		if(WS_TOT_DBT > 0 ){
			//continue
		}else{
			if(DBT_AMT_30 == 0 && DBT_AMT_60 == 0 && DBT_AMT_90 == 0 && DBT_AMT_120 == 0 && DBT_AMT_150 == 0 && DBT_AMT_180 == 0 && DBT_AMT_181 == 0){
				returnValue = "000"
			}
		}
	}

	if(COMMENT_CODE == "461" || COMMENT_CODE == "401" || COMMENT_CODE == "159" || COMMENT_CODE == "458" || COMMENT_CODE =="472" ||
				COMMENT_CODE == "460"){
			temp_comment_code = "000"
		}

	if(COMMENT_CODE == "102" || COMMENT_CODE == "103" || COMMENT_CODE == "104" ){
			var extrDateObj = toDate(extractDt)
			var acqDateObj = toDate(acquiredDt)
			var NUM_MONTHS = extrDateObj.getMonth - acqDateObj.getMonth
			var NUM_YEARS = extrDateObj.getYear - acqDateObj.getYear
			
			if((COMMENT_CODE = '102' && (NUM_MONTHS >  11 || NUM_YEARS >  1)) ||      
					(COMMENT_CODE = '103' && (NUM_MONTHS >  60 || NUM_YEARS >  5)) ||      
						(COMMENT_CODE = '104' && (NUM_MONTHS >  120 ||  NUM_YEARS <  5 || NUM_YEARS >  10)) ){
				returnValue = "000"
			}
		}
	if(COMMENT_CODE == "309" ){
		if(totalAccBal <= -2147483647){
			returnValue = ""
		}
		if(totalAccBal < 0){
			returnValue = "000"
		}
	}
	if(COMMENT_CODE == "457" || COMMENT_CODE == "453" || COMMENT_CODE == "450" ){
		if(WS_TOT_DBT >0)
		{
			returnValue = "000"
		}	
		else{
			if(DBT_AMT_30 == 0 &&  DBT_AMT_60 == 0 &&  DBT_AMT_90 == 0 &&  DBT_AMT_120 == 0 && DBT_AMT_150 == 0 && DBT_AMT_180 == 0 && DBT_AMT_181 == 0){
				returnValue = ""
			}
		}
	}
	if(COMMENT_CODE == "469" || COMMENT_CODE == "471" || COMMENT_CODE == "470" ||  COMMENT_CODE == "465" ){
		if( DBT_AMT_30  > 0 &&  DBT_AMT_60  == 0 &&  DBT_AMT_90  == 0 &&  DBT_AMT_120 == 0 &&  DBT_AMT_150 == 0 &&                   DBT_AMT_180 == 0 && DBT_AMT_181 == 0   ) {
			//continue
		}                   
		else{
			if(DBT_AMT_30== 0 || DBT_AMT_60> 0 || DBT_AMT_90> 0 || DBT_AMT_120 > 0 || DBT_AMT_150 > 0 || DBT_AMT_180 > 0 || DBT_AMT_181 > 0 ){
				returnValue = "000"
			}else{
				returnValue = ""
			}
		}         
 	}
	if(COMMENT_CODE == "529" || COMMENT_CODE == "530" || COMMENT_CODE == "530" || COMMENT_CODE == "528"  ){
		if(PAY_TERMS == " "){
			returnValue = ""	
		}else{
			if( PAY_TERMS != 'COD' || WS_TOT_DBT > 0 ){
				returnValue = "000"
			}else{
				if(PAY_TERMS == 'COD' && DBT_AMT_30  == 0 &&  DBT_AMT_60  == 0 && DBT_AMT_90  == 0 && DBT_AMT_120 == 0 &&                      DBT_AMT_150 == 0 && DBT_AMT_180 == 0 && DBT_AMT_181 == 0  ){
				//	continue
				}else{
						returnValue = ""
				}
			}
		}
	}
if(COMMENT_CODE == "467"){
	if( DBT_AMT_90  > 0 &&(DBT_AMT_120 == 0 && DBT_AMT_150 == 0 &&   DBT_AMT_180 == 0 &&  DBT_AMT_181 == 0) ){
	//	continue
	} else{
		if(DBT_AMT_90  == 0 || DBT_AMT_120 > 0 || DBT_AMT_150 > 0 ||  DBT_AMT_180 > 0 || DBT_AMT_181 > 0 ){
			returnValue = "000"
		}
	}                
}
if(COMMENT_CODE == "466"){
	if(  DBT_AMT_60  > 0 && DBT_AMT_90  == 0 &&   DBT_AMT_120 == 0 &&  DBT_AMT_150 == 0 && DBT_AMT_180 == 0 &&    DBT_AMT_181 == 0 ){
		continue
	} else{
		if(DBT_AMT_60= 0 || DBT_AMT_90> 0 || DBT_AMT_120 > 0 || DBT_AMT_150 > 0 || DBT_AMT_180 > 0 || DBT_AMT_181 > 0){
			returnValue = "000"
		}else{
			returnValue = ""
		}
	}                
}   
  
if(COMMENT_CODE == "535" || COMMENT_CODE == "536"){
	if(PAY_TERMS = ""){
		returnValue = ""
	}else{
		if(PAY_TERMS == "CIA" || WS_TOT_DBT > 0 ){
			returnValue = "000"
		}else{
			if(PAY_TERMS == 'CIA' && DBT_AMT_30== 0 && DBT_AMT_60== 0 && DBT_AMT_90== 0 && DBT_AMT_120 == 0 && DBT_AMT_150 == 0 && DBT_AMT_180 == 0 && DBT_AMT_181 == 0 ){
				continue
			}else{
				returnValue = ""
			}
		}
	}
}	
return returnValue 


} 
by

Javascript Online Compiler

Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is easy and fast. The editor shows sample boilerplate code when you choose language as Javascript and start coding.

About Javascript

Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. Javascript is required to design the behaviour of the web pages.

Key Features

  • Open-source
  • Just-in-time compiled language
  • Embedded along with HTML and makes web pages alive
  • Originally named as LiveScript.
  • Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc.

Syntax help

STDIN Example

var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', function(line){
    console.log("Hello, " + line);
});

variable declaration

KeywordDescriptionScope
varVar is used to declare variables(old way of declaring variables)Function or global scope
letlet is also used to declare variables(new way)Global or block Scope
constconst is used to declare const values. Once the value is assigned, it can not be modifiedGlobal or block Scope

Backtick Strings

Interpolation

let greetings = `Hello ${name}`

Multi line Strings

const msg = `
hello
world!
`

Arrays

An array is a collection of items or values.

Syntax:

let arrayName = [value1, value2,..etc];
// or
let arrayName = new Array("value1","value2",..etc);

Example:

let mobiles = ["iPhone", "Samsung", "Pixel"];

// accessing an array
console.log(mobiles[0]);

// changing an array element
mobiles[3] = "Nokia";

Arrow functions

Arrow Functions helps developers to write code in concise way, it’s introduced in ES6.
Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well.

Syntax:

() => expression

Example:

const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0)
                                    .map(ele => ele ** 2);
console.log(squaresOfEvenNumbers);

De-structuring

Arrays

let [firstName, lastName] = ['Foo', 'Bar']

Objects

let {firstName, lastName} = {
  firstName: 'Foo',
  lastName: 'Bar'
}

rest(...) operator

 const {
    title,
    firstName,
    lastName,
    ...rest
  } = record;

Spread(...) operator

//Object spread
const post = {
  ...options,
  type: "new"
}
//array spread
const users = [
  ...adminUsers,
  ...normalUsers
]

Functions

function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
  console.log(`Hello ${name}!`);
}
 
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar

Loops

1. If:

IF is used to execute a block of code based on a condition.

Syntax

if(condition){
    // code
}

2. If-Else:

Else part is used to execute the block of code when the condition fails.

Syntax

if(condition){
    // code
} else {
    // code
}

3. Switch:

Switch is used to replace nested If-Else statements.

Syntax

switch(condition){
    case 'value1' :
        //code
        [break;]
    case 'value2' :
        //code
        [break;]
    .......
    default :
        //code
        [break;]
}

4. For

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
//code  
} 

5. While

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
  // code 
}  

6. Do-While

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
  // code 
} while (condition); 

Classes

ES6 introduced classes along with OOPS concepts in JS. Class is similar to a function which you can think like kind of template which will get called when ever you initialize class.

Syntax:

class className {
  constructor() { ... } //Mandatory Class method
  method1() { ... }
  method2() { ... }
  ...
}

Example:

class Mobile {
  constructor(model) {
    this.name = model;
  }
}

mbl = new Mobile("iPhone");