NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.iflex.fcat.site.nedbank.services.apps.auth.module;

import com.iflex.fcat.infra.JFException;
import com.iflex.fcat.infra.JFGlobalFunctions;
import com.iflex.fcat.infra.JFGlobalMessages;
import com.iflex.fcat.infra.JFProperties;
import com.iflex.fcat.services.RequestDTO;
import com.iflex.fcat.services.apps.AppHelper;
import com.iflex.fcat.services.apps.TimezoneHelper;
import com.iflex.fcat.services.apps.auth.ApplicationInitAuthModule;
import com.iflex.fcat.services.apps.auth.module.GetNextWorkingDate;
import com.iflex.fcat.services.apps.auth.module.ValueDateCheckModule;
import com.iflex.fcat.services.apps.dtos.AuthorizationData;
import com.iflex.fcat.services.apps.dtos.ResultDTO;
import com.iflex.fcat.services.apps.dtos.TransactionDTO;
import com.iflex.fcat.services.apps.dtos.UserContextDTO;
import com.iflex.fcat.services.apps.dtos.UserDTO;
import com.iflex.fcat.services.apps.dtos.UserTypeDTO;
import com.iflex.fcat.services.apps.endpoints.AuthorizationHelper;
import com.iflex.fcat.tools.FCATLogger;
import com.iflex.fcat.xjava.jdbc.JDBCEngine;
import com.iflex.fcat.xjava.jdbc.JDBCResultSet;
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class BulkValueDateCheckModule extends ApplicationInitAuthModule {
public static final String VERSION_INFO = "";
public static final String THIS_COMPONENT_NAME = ValueDateCheckModule.class.getName();
private static final String GRACE_RULE_OPTION_A = "1";
private static final String GRACE_RULE_OPTION_B = "2";
private static final int CUTOFF_WORKDAYNOTSTARTED = 1;
private static final int CUTOFF_WORKDAYENDED = 2;
private static final int CUTOFF_NOT_DEFINED = 3;
private static String ENTITYTIMEZONE = "+0:00";
private static final String QRY_VALUEDATE_CHK_AUTH = " and t? <= (NVL(datvalue , ? ) + ?)";
private static final String QRY_SEL_CUSTAUTHPAYPREF = " select graceperiod from Mstcustomerprofile where id_cust =? and id_entity =? and typeuser= ?";
private static final String QRY_SEL_TXNCUTOFFDATA_DATE = " select b.starttime, b.endtime, to_number(to_char (convert_time(? ) ,'HH24MI') ) as postingtime from txncutofftime a,TXNCUTOFFTIMEDETAILS b WHERE a.cutoffseq = b.cutoffseq and id_entity = ? and idchannel = ? and usertype = ? and idtxn = ? and workingdate is not null and (trunc(workingdate) = trunc(fn_conv_dt_as_per_timezone(?,'*',sysdate)))";
private static final String QRY_SEL_TXNCUTOFFDATA_DAY = " select b.starttime, b.endtime, to_number(to_char (convert_time(?),'HH24MI') ) as postingtime from txncutofftime a,TXNCUTOFFTIMEDETAILS b WHERE a.cutoffseq = b.cutoffseq and id_entity = ? and idchannel = ? and usertype = ? and idtxn = ? and workingday is not null and a.effectivedate = (select max(effectivedate) from txncutofftime where idtxn = ? and fn_conv_dt_as_per_timezone(?,'*',sysdate) >= effectivedate and id_entity = ? and usertype=? and idchannel= ? ) and (trim(to_char(fn_conv_dt_as_per_timezone(?,'*',sysdate),'DAY')) = workingday)";
private static final String QRY_SEL_ENTITYDATE = " select to_date (to_char(convert_time(? ), 'dd-mm-yyyy') , 'dd-mm-yyyy') as entitydate from dual ";
private static final String QRY_SEL_DBTIMEZONE = " select SESSIONTIMEZONE as dbtimezone from dual";
private int WORK_STARTTIME = 0;
private int WORK_ENDTIME = 0;

public void reset(Connection p_conn) throws JFException {
}

public void initializeInstance(Connection p_conn) throws JFException {
}

public String validateTxn(AuthorizationData p_data, Connection p_con) throws JFException {
Date l_valueDate = null;
Date l_businessDate = null;
Date l_authorizationDate = null;
TransactionDTO l_txn = null;
SimpleDateFormat l_date_format = null;
String l_appError = null;
ResultDTO l_result = null;
StringBuffer l_multiCurrency = new StringBuffer("");
try {
AuthorizationHelper.getLogger().info("p_data.valueDate=========== " + p_data.valueDate);
System.out.println("p_data.valueDate=========== " + p_data.valueDate);
if (p_data.valueDate == null) {
p_data.postingDate = (l_valueDate = new Date(
GetNextWorkingDate.getCurrentValueDate(p_data, p_con).getTime()));

l_txn = AppHelper.getChannelTransactionDTO(p_data.userContext.idDevice, p_data.userContext.idTxn,
p_data.userContext.user.userTypeInfo.channels);
if (!l_txn.isCutOffAllowed) {
return null;
}
} else {
p_data.postingDate = (l_valueDate = new Date(p_data.valueDate.getTime()));
}
if ((!AppHelper.isNullOrBlank(p_data.token1)) && (p_data.token1.equals("Y"))) {
return null;
}
AuthorizationHelper.getLogger().info("Will check Value Date and action" + p_data.action);
System.out.println("Will check Value Date and action" + p_data.action);

l_multiCurrency.append(p_data.codCurrency);
l_multiCurrency.append((p_data.codAccountCurrMultiple != null)
&& (!AppHelper.isNullOrBlank(p_data.codAccountCurrMultiple[0]))
? "," + p_data.codAccountCurrMultiple[0]
: "");

AuthorizationHelper.getLogger().info("l_multiCurrency ============== " + l_multiCurrency);
System.out.println("l_multiCurrency ============== " + l_multiCurrency);
if ((p_data.action.equals("A")) || (p_data.action.equals("VA")) || (p_data.action.equals("VI"))
|| (p_data.action.equals("I")) || (p_data.action.equals("M"))) {
AuthorizationHelper.getLogger().info("Auth or Semi auth");
System.out.println("Auth or Semi auth");
l_date_format = JFGlobalFunctions.getSimpleDateFormatter();

l_authorizationDate = TimezoneHelper.convertOnlyDatetoTZ(
p_data.srcaccountIdEntity != null ? p_data.srcaccountIdEntity : p_data.userContext.refIdEntity,
"*", null, p_con);
try {
ENTITYTIMEZONE = AppHelper.getEntityTimeZone(p_con,
p_data.srcaccountIdEntity != null ? p_data.srcaccountIdEntity
: p_data.userContext.refIdEntity);

AuthorizationHelper.getLogger().info("~~~~~~~~~~~ ENTITYTIMEZONE ~~~~~~~~~~~~~~" + ENTITYTIMEZONE);
System.out.println("~~~~~~~~~~~ ENTITYTIMEZONE ~~~~~~~~~~~~~~" + ENTITYTIMEZONE);
} catch (Exception e) {
AuthorizationHelper.getLogger()
.info("~~~~~~~~~~~~~~~~~~~~~~~~~Time Zone at entity level not set ~~~~~~~~~~~~~~~~~~");
AuthorizationHelper.getLogger().info(
"~~~~~~~~~~~~~~~~~~~~~~~~~Considering p_data.valueDate.getTimezoneOffset() ~~~~+GMT +0:00);+~~~~~~~~~~~~~~");
ENTITYTIMEZONE = "+0:00";
}
AuthorizationHelper.getLogger().info("Authorization date(DB System Date) " + l_authorizationDate);
System.out.println("Authorization date(DB System Date) " + l_authorizationDate);
AuthorizationHelper.getLogger().info("Value Date(Txn's Value Date passed) " + l_valueDate);
System.out.println("Value Date(Txn's Value Date passed) " + l_valueDate);

System.out.println(
"Authorization date(Db System Date) is less than Value date.No need to check Cut off ");
System.out.println("p_data.adminCusEntity===== " + p_data.adminCusEntity);
System.out.println("p_data.srcaccountIdEntity===== " + p_data.srcaccountIdEntity);
System.out.println("p_data.codBranch========= " + p_data.codBranch);
System.out.println("p_data.userContext.refIdEntity===== " + p_data.userContext.refIdEntity);
if (l_authorizationDate.before(l_valueDate)) {
AuthorizationHelper.getLogger().info(
"Authorization date(Db System Date) is less than Value date.No need to check Cut off ");

l_businessDate = GetNextWorkingDate.checkHolGetWDay(p_con, l_valueDate,
p_data.adminCusEntity != null ? p_data.adminCusEntity : p_data.userContext.refIdEntity,
l_multiCurrency != null ? l_multiCurrency.toString() : "''", p_data.srcaccountIdEntity,
p_data.codBranch);

System.out.println("l_businessDate=========== " + l_businessDate);
if (l_valueDate.before(l_businessDate)) {
p_data.warningCodes.add(getMessage("25045", p_data.userContext.idLang,
p_data.userContext.idDevice,
JFGlobalFunctions.formatDate(l_businessDate, l_date_format), null, null, null, null));
}
p_data.postingDate = l_businessDate;
} else if (l_authorizationDate.compareTo(l_valueDate) == 0) {
AuthorizationHelper.getLogger()
.info("=========Authorization date and value date are same==========");
System.out.println("=========Authorization date and value date are same==========");
l_businessDate = GetNextWorkingDate.checkHolGetWDay(p_con, l_valueDate,
p_data.adminCusEntity != null ? p_data.adminCusEntity : p_data.userContext.refIdEntity,
l_multiCurrency != null ? l_multiCurrency.toString() : "''", "", p_data.codBranch);

AuthorizationHelper.getLogger().info("l_businessDate============ " + l_businessDate);
System.out.println("l_businessDate============ " + l_businessDate);
AuthorizationHelper.getLogger().info("l_businessDate.compareTo(l_valueDate)========== "
+ l_businessDate.compareTo(l_valueDate));
System.out.println("l_businessDate.compareTo(l_valueDate)========== "
+ l_businessDate.compareTo(l_valueDate));
if (l_businessDate.compareTo(l_valueDate) == 0) {
l_appError = handleFcatCutoff(p_data, l_authorizationDate, l_result, p_con);

AuthorizationHelper.getLogger().info("l_appError============ " + l_appError);
System.out.println("l_appError============ " + l_appError);
if (l_appError != null) {
l_appError = doSimplifiedGracePeriodHandling(p_data, l_authorizationDate, l_result, p_con);
}
AuthorizationHelper.getLogger().info("Inside IF Sneha");
Date l_tempUBSDate = null;

l_tempUBSDate = new Date(GetNextWorkingDate
.getValueDate(p_data.userContext.refIdEntity, p_data.codBranch, 1, p_con).getTime());
if (l_authorizationDate.before(l_tempUBSDate)) {
p_data.postingDate = l_tempUBSDate;
}
} else {
AuthorizationHelper.getLogger().info(
"Next Business date is not same as Value date. Transaction will not take place the same day in Pay Now Case and hence no need to check for cut off.");
System.out.println(
"Next Business date is not same as Value date. Transaction will not take place the same day in Pay Now Case and hence no need to check for cut off.");
AuthorizationHelper.getLogger().info("Inside Else Sneha");
Date l_tempUBSDate = null;

l_tempUBSDate = new Date(GetNextWorkingDate
.getValueDate(p_data.userContext.refIdEntity, p_data.codBranch, 1, p_con).getTime());
if (l_authorizationDate.before(l_tempUBSDate)) {
p_data.postingDate = l_tempUBSDate;
}
p_data.warningCodes
.add(getMessage("25051", p_data.userContext.idLang, p_data.userContext.idDevice,
JFGlobalFunctions.formatDate(l_businessDate, l_date_format), p_data.codCurrency,
(p_data.codAccountCurrMultiple != null)
&& (!AppHelper.isNullOrBlank(p_data.codAccountCurrMultiple[0]))
? p_data.codAccountCurrMultiple[0]
: "",
null, null));
}
} else if ((p_data.action.equals("VI")) || (p_data.action.equals("I")) || (p_data.action.equals("M"))) {
AuthorizationHelper.getLogger().info(
"Authorization date is after valuedate and action is initaite so next value date willbe authorization date : datprocess");
System.out.println(
"Authorization date is after valuedate and action is initaite so next value date willbe authorization date : datprocess");

p_data.postingDate = new Date(
GetNextWorkingDate.getNextValueDate(p_data, p_con, p_data.codBranch).getTime());

p_data.warningCodes.add(getMessage("900618", p_data.userContext.idLang, p_data.userContext.idDevice,
JFGlobalFunctions.formatDate(p_data.postingDate, l_date_format), null, null, null, null));
} else {
AuthorizationHelper.getLogger().info(
"Authorization date is more than Value date and Cut off has reached.Need to check the grace period");
System.out.println(
"Authorization date is more than Value date and Cut off has reached.Need to check the grace period");

l_appError = doSimplifiedGracePeriodHandling(p_data, l_authorizationDate, l_result, p_con);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new JFException("10001", THIS_COMPONENT_NAME, e.getMessage());
}
AuthorizationHelper.getLogger().info("p_data.postingDate===== " + p_data.postingDate);
System.out.println("p_data.postingDate====== " + p_data.postingDate);
AuthorizationHelper.getLogger().info("l_appError================ " + l_appError);
System.out.println("l_appError================ " + l_appError);
return l_appError;
}

public void appendViewQueryFilters(AuthorizationData p_data, RequestDTO p_request, StringBuffer l_qryBuf,
ArrayList l_queryValues, Connection p_con) throws Exception {
Date l_authorizationDate = null;
ArrayList<String> l_paramArray = new ArrayList();
JDBCResultSet l_rs = null;
long l_gracePeriod = 0L;

AuthorizationHelper.getLogger().info("~~~~~~~~~~~~~~~~~~~~~~~~Start ValueDate Check Module ~~~~~~~~~~~~~~~~~~");
try {
if ((p_data.typeStatistic.equals("A")) || (p_data.typeStatistic.equals("R"))) {
if ((p_data.userContext.user.userTypeInfo.hasCustID.equals("N")) && (p_data.adminCusEntity != null)) {
l_authorizationDate = AppHelper.getHostProcessingDate(p_data.adminCusEntity, p_con);
} else {
l_authorizationDate = AppHelper.getHostProcessingDate(p_data.userContext.refIdEntity, p_con);
}
if (p_data.userContext.user.userTypeInfo.hasCustID.equals("N")) {
l_paramArray.add(p_data.userContext.user.userTypeInfo.userType + "ADMIN");
} else {
l_paramArray.add(p_data.userContext.user.customers[0].idCustomer);
}
l_paramArray.add(p_data.userContext.idEntity);
l_paramArray.add(p_data.userContext.userType);
l_rs = JDBCEngine.executeQuery(
" select graceperiod from Mstcustomerprofile where id_cust =? and id_entity =? and typeuser= ?",
l_paramArray.size(), l_paramArray, p_con);
if ((l_rs.next()) && (!p_data.typeStatistic.equals("R"))) {
l_gracePeriod = l_rs.getInt("graceperiod");
l_qryBuf.append(" and t? <= (NVL(datvalue , ? ) + ?)");

l_queryValues.add(l_authorizationDate);
l_queryValues.add(GetNextWorkingDate.getCurrentValueDate(p_data, p_con));
l_queryValues.add(new Integer(String.valueOf(l_gracePeriod)));
} else {
l_qryBuf.append(" and t? <= (NVL(datvalue , ? ) + ?)");

l_queryValues.add(l_authorizationDate);
l_queryValues.add(GetNextWorkingDate.getCurrentValueDate(p_data, p_con));
l_queryValues.add(new Integer(String.valueOf(0)));
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
AuthorizationHelper.getLogger()
.info("~~~~~~~~~~~~~~~~~~~~~~~~Exit ValueDate Check Module ~~~~~~~~~~~~~~~~~~");
}
}

private int isFcatCutoffDone(AuthorizationData p_data, Date p_auth_date, Connection p_con) throws Exception {
ArrayList<String> l_paramArr = new ArrayList();
JDBCResultSet l_rs = null;
JDBCResultSet l_rs1 = null;
int l_startTime = 0;
int l_postingtime = 0;
JDBCResultSet l_rs2 = null;
ArrayList<String> l_array = new ArrayList();
Date l_entityDate = null;
String l_entity_Id = null;
String l_timezzone = null;
try {
l_entity_Id = p_data.srcaccountIdEntity != null ? p_data.srcaccountIdEntity
: p_data.userContext.refIdEntity;

l_paramArr.add(ENTITYTIMEZONE);
l_rs2 = JDBCEngine.executeQuery(
" select to_date (to_char(convert_time(? ), 'dd-mm-yyyy') , 'dd-mm-yyyy') as entitydate from dual ",
l_paramArr.size(), l_paramArr, p_con);

l_paramArr.clear();
if (l_rs2.next()) {
l_entityDate = l_rs2.getDate("entitydate");
if (l_entityDate.before(p_auth_date)) {
AuthorizationHelper.getLogger().info(
" t Entity date is behind authorization date and will check cutoff with session time zone. ");
l_rs = JDBCEngine.executeQuery(" select SESSIONTIMEZONE as dbtimezone from dual", l_array.size(),
l_array, p_con);
if (l_rs.next()) {
l_paramArr.add(l_rs.getString("dbtimezone"));
l_timezzone = l_rs.getString("dbtimezone");
}
} else {
l_paramArr.add(ENTITYTIMEZONE);
l_timezzone = ENTITYTIMEZONE;
}
}
l_paramArr.add(l_entity_Id);
l_paramArr.add(p_data.userContext.idDevice);
l_paramArr.add(p_data.userContext.userType);
l_paramArr.add(p_data.idTxn);
l_paramArr.add(l_entity_Id);
AuthorizationHelper.getLogger().info(
"Txn cutoff date check query: select b.starttime, b.endtime, to_number(to_char (convert_time(? ) ,'HH24MI') ) as postingtime from txncutofftime a,TXNCUTOFFTIMEDETAILS b WHERE a.cutoffseq = b.cutoffseq and id_entity = ? and idchannel = ? and usertype = ? and idtxn = ? and workingdate is not null and (trunc(workingdate) = trunc(fn_conv_dt_as_per_timezone(?,'*',sysdate))) arguments: "
+ l_paramArr);
l_rs = JDBCEngine.executeQuery(
" select b.starttime, b.endtime, to_number(to_char (convert_time(? ) ,'HH24MI') ) as postingtime from txncutofftime a,TXNCUTOFFTIMEDETAILS b WHERE a.cutoffseq = b.cutoffseq and id_entity = ? and idchannel = ? and usertype = ? and idtxn = ? and workingdate is not null and (trunc(workingdate) = trunc(fn_conv_dt_as_per_timezone(?,'*',sysdate)))",
l_paramArr.size(), l_paramArr, p_con);
if (l_rs.next()) {
this.WORK_STARTTIME = l_rs.getInt("starttime");
this.WORK_ENDTIME = l_rs.getInt("endtime");
l_postingtime = l_rs.getInt("postingtime");
AuthorizationHelper.getLogger().info("Posting time: " + l_postingtime);
AuthorizationHelper.getLogger().info("Work Start Time: " + this.WORK_STARTTIME);
AuthorizationHelper.getLogger().info("Work End Time: " + this.WORK_ENDTIME);
if (l_postingtime < this.WORK_STARTTIME) {
AuthorizationHelper.getLogger()
.info("~~~~~~~~~~~~~~~~~~~~~~~~~Working time before working day start ~~~~~~~~~~~~~~~~~~");
AuthorizationHelper.getLogger().info(
"~~~~~~~~~~~~~~~~~~~~~~~~Working time before working day start ~~~~~~~~~~~~~~~~~~");
l_startTime = 1;
} else if (l_postingtime > this.WORK_ENDTIME) {
AuthorizationHelper.getLogger()
.info("~~~~~~~~~~~~~~~~~~~~~~~~~Working time crossed for working day ~~~~~~~~~~~~~~~~~~");
AuthorizationHelper.getLogger()
.info("~~~~~~~~~~~~~~~~~~~~~~~~Working time crossed for working day ~~~~~~~~~~~~~~~~~~");
l_startTime = 2;
}
} else {
l_paramArr.clear();
l_paramArr.add(l_timezzone);
l_paramArr.add(l_entity_Id);
l_paramArr.add(p_data.userContext.idDevice);
l_paramArr.add(p_data.userContext.userType);
l_paramArr.add(p_data.idTxn);
l_paramArr.add(p_data.idTxn);
l_paramArr.add(l_entity_Id);
l_paramArr.add(l_entity_Id);
l_paramArr.add(p_data.userContext.userType);
l_paramArr.add(p_data.userContext.idDevice);
l_paramArr.add(l_entity_Id);
AuthorizationHelper.getLogger().info(
"Txn cutoff day check query: select b.starttime, b.endtime, to_number(to_char (convert_time(?),'HH24MI') ) as postingtime from txncutofftime a,TXNCUTOFFTIMEDETAILS b WHERE a.cutoffseq = b.cutoffseq and id_entity = ? and idchannel = ? and usertype = ? and idtxn = ? and workingday is not null and a.effectivedate = (select max(effectivedate) from txncutofftime where idtxn = ? and fn_conv_dt_as_per_timezone(?,'*',sysdate) >= effectivedate and id_entity = ? and usertype=? and idchannel= ? ) and (trim(to_char(fn_conv_dt_as_per_timezone(?,'*',sysdate),'DAY')) = workingday) arguments: "
+ l_paramArr);
l_rs1 = JDBCEngine.executeQuery(
" select b.starttime, b.endtime, to_number(to_char (convert_time(?),'HH24MI') ) as postingtime from txncutofftime a,TXNCUTOFFTIMEDETAILS b WHERE a.cutoffseq = b.cutoffseq and id_entity = ? and idchannel = ? and usertype = ? and idtxn = ? and workingday is not null and a.effectivedate = (select max(effectivedate) from txncutofftime where idtxn = ? and fn_conv_dt_as_per_timezone(?,'*',sysdate) >= effectivedate and id_entity = ? and usertype=? and idchannel= ? ) and (trim(to_char(fn_conv_dt_as_per_timezone(?,'*',sysdate),'DAY')) = workingday)",
l_paramArr.size(), l_paramArr, p_con);
if (l_rs1.next()) {
this.WORK_STARTTIME = l_rs1.getInt("starttime");
this.WORK_ENDTIME = l_rs1.getInt("endtime");
l_postingtime = l_rs1.getInt("postingtime");
AuthorizationHelper.getLogger().info("Posting time: " + l_postingtime);
AuthorizationHelper.getLogger().info("Work Start Time: " + this.WORK_STARTTIME);
AuthorizationHelper.getLogger().info("Work End Time: " + this.WORK_ENDTIME);
if (l_postingtime < this.WORK_STARTTIME) {
AuthorizationHelper.getLogger()
.info("~~~~~~~~~~~~~~~~~~~~~~~~~Working time before working day ~~~~~~~~~~~~~~~~~~");
AuthorizationHelper.getLogger().info(
"~~~~~~~~~~~~~~~~~~~~~~~~Working time before working day start ~~~~~~~~~~~~~~~~~~");
l_startTime = 1;
} else if (l_postingtime > this.WORK_ENDTIME) {
AuthorizationHelper.getLogger().info(
"~~~~~~~~~~~~~~~~~~~~~~~~~Working time crossed for working day ~~~~~~~~~~~~~~~~~~");
AuthorizationHelper.getLogger().info(
"~~~~~~~~~~~~~~~~~~~~~~~~Working time crossed for working day ~~~~~~~~~~~~~~~~~~");
l_startTime = 2;
}
} else {
AuthorizationHelper.getLogger()
.info("~~~~~~~~~~~~~~~~~~~~~~~~~Working time crossed for working day ~~~~~~~~~~~~~~~~~~");
AuthorizationHelper.getLogger().info(
"~~~~~~~~~~~~~~No Cut off window maintained for this txn today....Its a holiday ~~~~~~~~~~");
l_startTime = 3;
}
}
AuthorizationHelper.getLogger().info("Value of starttime returned by isFcatCutoffDone: " + l_startTime);
} catch (Exception e) {
e.printStackTrace();
}
return l_startTime;
}

private String handleFcatCutoff(AuthorizationData p_data, Date p_auth_date, ResultDTO p_result, Connection p_con)
throws Exception {
Date l_dat_send = null;
SimpleDateFormat l_date_format = null;
String l_appError = null;
int l_fcatCutoffChk = 0;
if (!AppHelper.getChannelTransactionDTO(p_data.userContext.idDevice, p_data.idTxn,
p_data.userContext.user.userTypeInfo.channels).isCutOffAllowed) {
return null;
}
l_date_format = JFGlobalFunctions.getSimpleDateFormatter();
l_dat_send = new Date(GetNextWorkingDate.getNextValueDate(p_data, p_con, p_data.codBranch).getTime());

AuthorizationHelper.getLogger().info("l_dat_send============ " + l_dat_send);
System.out.println("l_dat_send============ " + l_dat_send);
System.out.println("p_auth_date=========== " + p_auth_date);

AuthorizationHelper.getLogger().info(" t Check EOD Condition before cuoff check for Entity: "
+ p_data.srcaccountIdEntity + " and Branch: " + p_data.codBranch);
System.out.println(" t Check EOD Condition before cuoff check for Entity: " + p_data.srcaccountIdEntity
+ " and Branch: " + p_data.codBranch);
if (!checkEODRunning(p_data, l_dat_send, p_con)) {
l_fcatCutoffChk = isFcatCutoffDone(p_data, p_auth_date, p_con);
System.out.println("l_fcatCutoffChk====== " + l_fcatCutoffChk);
switch (l_fcatCutoffChk) {
case 0:
AuthorizationHelper.getLogger().info(
" t Authorization date(LDB System Date) is same as Value date.Cut off has either been not crossed or no cut off is defined for this transaction ");
AuthorizationHelper.getLogger().info("");
AuthorizationHelper.getLogger()
.info("p_data.postingDate changes by Awadhesh ============ " + p_data.postingDate);
break;
case 1:
AuthorizationHelper.getLogger().info(
" t The transaction will be authorized with the given Value date as authorization date(LDB System Date) is same as the value date and Working day for Txn has not yet started. ");
handleCutOffActions(p_con, p_data, 1, "900617", JFGlobalFunctions.formatDate(l_dat_send, l_date_format),
null, null, null, null);
break;
case 2:
AuthorizationHelper.getLogger().info(
" t The transaction will be authorized with the Value date same as working day as authorization date(LDB System Date) is same as the value date and FCAT cutoff for the transaction has been crossed. ");
handleCutOffActions(p_con, p_data, 2, "25031", JFGlobalFunctions.formatDate(l_dat_send, l_date_format),
ENTITYTIMEZONE, null, null, null);

p_data.postingDate = l_dat_send;
AuthorizationHelper.getLogger().info("t Value of datsend would be updated to "
+ JFGlobalFunctions.formatDate(l_dat_send, l_date_format));
break;
case 3:
AuthorizationHelper.getLogger().info(" t Cutoff not defined for this transaction. ");

handleCutOffActions(p_con, p_data, 3, "25043", JFGlobalFunctions.formatDate(l_dat_send, l_date_format),
ENTITYTIMEZONE, null, null, null);

p_data.postingDate = l_dat_send;
}
}
return l_appError;
}

private String doGracePeriodHandling(AuthorizationData p_data, Date p_auth_date, ResultDTO p_result,
Connection p_con) throws Exception {
String l_app_error = null;
SimpleDateFormat l_date_format = null;
JDBCResultSet l_rs = null;
Timestamp l_gracePeriodDateTime = null;
ArrayList<String> l_arr_list = new ArrayList();
String l_grace_req = null;
String l_grace_rule = null;
Date l_gracePeriodDate = null;
Date l_dat_send = null;
long l_grace_period = 0L;

l_arr_list.add(0, p_data.idCustomer);
l_rs = JDBCEngine.executeQuery(
" select graceperiod from Mstcustomerprofile where id_cust =? and id_entity =? and typeuser= ?",
l_arr_list.size(), l_arr_list, p_con);
if (l_rs.next()) {
l_grace_req = l_rs.getString("gracerequired");
l_grace_period = l_rs.getInt("graceperiod");
l_grace_rule = l_rs.getString("gracerule");
l_date_format = new SimpleDateFormat("dd-MM-yyyy");
AuthorizationHelper.getLogger().info("Values " + l_grace_req + ":" + l_grace_period + ":" + l_grace_rule);
if (l_grace_req.equalsIgnoreCase("Y")) {
AuthorizationHelper.getLogger().info("Grace Period allowed for this customer");
l_grace_period = l_grace_period * 24L * 60L * 60L * 1000L;
l_gracePeriodDateTime = new Timestamp(p_data.valueDate.getTime() + l_grace_period);
l_gracePeriodDate = new Date(p_data.valueDate.getTime() + l_grace_period);
if (p_auth_date.before(l_gracePeriodDate)) {
AuthorizationHelper.getLogger().info("Authorization date is before the grace period");
if (l_grace_rule.equalsIgnoreCase("1")) {
AuthorizationHelper.getLogger().info(
"Authorization date is before the grace period : Option A is selected :datsend = authorization date");
l_dat_send = p_auth_date;
AuthorizationHelper.getLogger().info("Value of datsend would be updated to" + l_dat_send);
l_app_error = "25036";
} else if (l_grace_rule.equalsIgnoreCase("2")) {
AuthorizationHelper.getLogger().info(
"Authorization date is before the grace period : Option B is selected :datsend = valuedate + grace period ");
l_dat_send = l_gracePeriodDate;
AuthorizationHelper.getLogger().info("Value of datsend would be updated to" + l_dat_send);
l_app_error = "25037";
}
if (!AppHelper.isNullOrBlank(l_app_error)) {
p_data.warningCodes.add(getMessage(l_app_error, p_data.userContext.idLang,
p_data.userContext.idDevice, JFGlobalFunctions.formatDate(l_dat_send, l_date_format),
null, null, null, null));
}
p_data.postingDate = l_dat_send;
} else if (p_auth_date.compareTo(l_gracePeriodDate) == 0) {
AuthorizationHelper.getLogger()
.info("Authorization date is same as the grace period.Need to check the cutoff");
handleFcatCutoff(p_data, p_auth_date, p_result, p_con);
} else {
l_app_error = "25033";
p_data.errorCodes
.add(getMessage(l_app_error, p_data.userContext.idLang, p_data.userContext.idDevice,
JFGlobalFunctions.formatDate(p_auth_date, l_date_format), null, null, null, null));

p_data.postingDate = p_auth_date;
}
} else {
l_app_error = "25034";
p_data.errorCodes.add(getMessage(l_app_error, p_data.userContext.idLang, p_data.userContext.idDevice,
null, null, null, null, null));
}
} else {
l_app_error = "25034";
p_data.errorCodes.add(getMessage(l_app_error, p_data.userContext.idLang, p_data.userContext.idDevice, null,
null, null, null, null));

return l_app_error;
}
return null;
}

public static String getMessage(String p_error_code, String p_lang_id, String p_device_id, String p_args_0,
String p_args_1, String p_args_2, String p_args_3, String p_args_4) throws Exception {
return JFGlobalMessages.getMessage("A1", p_error_code, p_lang_id, p_device_id, p_args_0, p_args_1, p_args_2,
p_args_3, p_args_4);
}

private String doSimplifiedGracePeriodHandling(AuthorizationData p_data, Date p_auth_date, ResultDTO p_result,
Connection p_con) throws Exception {
String l_app_error = null;
SimpleDateFormat l_date_format = null;
JDBCResultSet l_rs = null;
Timestamp l_gracePeriodDateTime = null;
ArrayList<String> l_arr_list = new ArrayList();
String l_grace_req = null;
String l_grace_rule = null;
Date l_gracePeriodDate = null;
Date l_tempDate = null;
long l_grace_period = 0L;
l_date_format = new SimpleDateFormat("dd-MM-yyyy");
l_arr_list.add(l_arr_list.size(), p_data.idCustomer);
l_arr_list.add(l_arr_list.size(), p_data.userContext.idEntity);
l_arr_list.add(l_arr_list.size(), p_data.userContext.userType);
AuthorizationHelper.getLogger().info(
"Grace Period Check Query : select graceperiod from Mstcustomerprofile where id_cust =? and id_entity =? and typeuser= ? Arguments: "
+ l_arr_list);
l_rs = JDBCEngine.executeQuery(
" select graceperiod from Mstcustomerprofile where id_cust =? and id_entity =? and typeuser= ?",
l_arr_list.size(), l_arr_list, p_con);
if (l_rs.next()) {
AuthorizationHelper.getLogger().info("Grace Period allowed for this customer");

l_tempDate = new Date(GetNextWorkingDate
.getValueDate(p_data.userContext.refIdEntity, p_data.codBranch, 1, p_con).getTime());

p_data.postingDate = l_tempDate;

p_data.warningCodes.add(getMessage("25046", p_data.userContext.idLang, p_data.userContext.idDevice,
JFGlobalFunctions.formatDate(l_tempDate, l_date_format), null, null, null, null));

l_grace_period = l_rs.getInt("graceperiod");

AuthorizationHelper.getLogger().info("Values " + l_grace_req + ":" + l_grace_period + ":" + l_grace_rule);
l_grace_period = l_grace_period * 24L * 60L * 60L * 1000L;
l_gracePeriodDateTime = new Timestamp(p_data.valueDate.getTime() + l_grace_period);

l_gracePeriodDate = new Date(p_data.valueDate.getTime() + l_grace_period);
if (p_auth_date.before(l_gracePeriodDate)) {
AuthorizationHelper.getLogger()
.info("Authorization date is before the grace period.Need to check the cutoff for today");

handleFcatCutoff(p_data, p_auth_date, p_result, p_con);
} else if (p_auth_date.compareTo(l_gracePeriodDate) == 0) {
AuthorizationHelper.getLogger()
.info("Authorization date is same as the grace period.Need to check the cutoff");
handleFcatCutoff(p_data, p_auth_date, p_result, p_con);
} else {
AuthorizationHelper.getLogger().info(
"The transaction can not be authorized as authorization date is greater than the valuedate + grace period.");
l_app_error = "25033";
p_data.errorCodes.add(getMessage(l_app_error, p_data.userContext.idLang, p_data.userContext.idDevice,
JFGlobalFunctions.formatDate(p_auth_date, l_date_format), null, null, null, null));

p_data.postingDate = p_auth_date;
return l_app_error;
}
}
return null;
}

private void handleCutOffActions(Connection p_conn, AuthorizationData p_data, int p_situation, String p_messageCode,
String p_param3, String p_param4, String p_param5, String p_param6, String p_param7) throws Exception {
TransactionDTO l_dto = null;
String l_starttime = null;
String l_endtime = null;
l_dto = AppHelper.getTransaction(p_data.idTxn, p_conn, p_data.userContext.idLang, p_data.userContext.idDevice,
false);
switch (l_dto.actionForCutoff) {
case 0:
if (p_situation == 3) {
p_data.warningCodes.add(getMessage("25031", p_data.userContext.idLang, p_data.userContext.idDevice,
p_param3, p_param4, p_param5, p_param6, p_param7));
} else {
p_data.warningCodes.add(getMessage(p_messageCode, p_data.userContext.idLang,
p_data.userContext.idDevice, p_param3, p_param4, p_param5, p_param6, p_param7));
}
break;
case 1:
if (p_situation == 3) {
p_data.errorCodes.add(getMessage("25043", p_data.userContext.idLang, p_data.userContext.idDevice, null,
null, null, null, null));
} else {
l_starttime = String
.valueOf(this.WORK_STARTTIME / 100 == 0 ? "00" : Integer.valueOf(this.WORK_STARTTIME / 100));
l_starttime = l_starttime.concat(":");
l_starttime = l_starttime.concat(String
.valueOf(this.WORK_STARTTIME % 100 == 0 ? "00" : Integer.valueOf(this.WORK_STARTTIME % 100)));

l_endtime = String
.valueOf(this.WORK_ENDTIME / 100 == 0 ? "00" : Integer.valueOf(this.WORK_ENDTIME / 100));
l_endtime = l_endtime.concat(":");
l_endtime = l_endtime.concat(
String.valueOf(this.WORK_ENDTIME % 100 == 0 ? "00" : Integer.valueOf(this.WORK_ENDTIME % 100)));

p_data.errorCodes.add(getMessage("225020", p_data.userContext.idLang, p_data.userContext.idDevice,
l_starttime, l_endtime, ". [GMT ("
.concat(AppHelper.getEntityTimeZone(p_conn, p_data.userContext.idEntity)).concat(")]"),
p_param6, p_param7));
}
break;
}
}

private boolean checkEODRunning(AuthorizationData p_data, Date p_dat_send, Connection p_con) throws Exception {
String l_fcateodflag = null;
SimpleDateFormat l_date_format = null;
l_date_format = JFGlobalFunctions.getSimpleDateFormatter();
boolean eodStatus;
if ((eodStatus = GetNextWorkingDate.isEODRunning(p_data.srcaccountIdEntity, p_data.codBranch, p_con))) {
l_fcateodflag = JFProperties.getProperty(p_data.srcaccountIdEntity != null
? String.valueOf(p_data.srcaccountIdEntity) + "." + "FCAT_ISEOD_DATECHANGE"
: "FCAT_ISEOD_DATECHANGE", "Y");

AuthorizationHelper.getLogger()
.info(" t EOD is Running and the FCAT_ISEOD_DATECHANGE flag is : " + l_fcateodflag);
if (l_fcateodflag.equals("Y")) {
p_data.warningCodes.add(getMessage("25044", p_data.userContext.idLang, p_data.userContext.idDevice,
JFGlobalFunctions.formatDate(p_dat_send, l_date_format), null, null, null, null));

p_data.postingDate = p_dat_send;
} else if (l_fcateodflag.equals("N")) {
p_data.errorCodes.add(getMessage("25047", p_data.userContext.idLang, p_data.userContext.idDevice, null,
null, null, null, null));
}
}
return eodStatus;
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.