Commit 8bc630ae authored by ngadkari's avatar ngadkari

changes in E-INVOICE process

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@217359 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ebcd297a
......@@ -21,7 +21,7 @@ import java.util.UUID;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.json.JsonValue;
import org.apache.commons.io.IOUtils;
import org.bouncycastle.crypto.digests.SHA256Digest;
......@@ -31,9 +31,6 @@ import org.json.JSONArray;
import org.json.JSONObject;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonValue;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
......@@ -151,7 +148,7 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
GSTCommonUtil gstCommonUtil = new GSTCommonUtil();
boolean isError = false;
String sek="" ,gspAuthString = "", gspAuthSignature = "",invoiceID="",sql="",siteCode="", timeStamp="",status="",irn="";
String sek="" ,gspAuthString = "", gspAuthSignature = "",invoiceID="",sql="",siteCode="", timeStamp="",status="",irn="",cancelDateStr="";
Node currDetail = null;
int noOfDetails = 0;
NodeList detailList = null;
......@@ -163,7 +160,7 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
UtilMethods utilMethods = null;
ResultSet rs = null,rs1 = null;
HashMap detailMap=null;
String refNo="",refSer="",custCode="",custGstin="",itemCode="",itemDesc="",unit="";
String refNo="",refSer="",custCode="",custGstin="",itemCode="",itemDesc="",unit="",currDateStr="";
long stcd=0,pin=0,ph=0;
JSONObject jsonObjIRNCan=null,tempObj1=null, errorJSON=null,gstIRNObj=null,object=null,objectData=null,reqBody=null,authTokenReqObj=null,authTokenReqObjData=null;
Date tranDate=null,expDate=null,mfgDate=null;
......@@ -171,16 +168,34 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
double invAmt=0,igst=0,cgst=0,sgst=0,cess=0,assAmt=0,othAmt=0,totAmt=0,discAmt=0,totItemVal=0,rate=0,quantity=0;
List unitList=null;
byte[] respJsonInBytes=null;
SimpleDateFormat sdf = null;
Timestamp currDate=null,cancelDate=null;
try {
conn = getConnection();
FinCommon finCommon = new FinCommon();
utilMethods = new UtilMethods();
sdf = new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
java.util.Date currDate1 = new java.util.Date();
currDateStr = sdf.format(currDate1);
currDate= Timestamp.valueOf(e12GenericUtility.getValidDateString(currDateStr, e12GenericUtility.getApplDateFormat(), e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
userName = e12GenericUtility.getColumnValue("user_name",headerDom);
password = e12GenericUtility.getColumnValue("password",headerDom);
refNo = checkNullandTrim(e12GenericUtility.getColumnValue("ref_no",headerDom));
if(userName==null || userName.trim().length()==0)
{
errString = itmDBAccessEJB.getErrorString("","VTEINVUPA","","",conn);
return errString;
}
if(password==null || password.trim().length()==0)
{
errString = itmDBAccessEJB.getErrorString("","VTEINVUPA","","",conn);
return errString;
}
sql="SELECT count(*) from invoice where invoice_id=? ";
pstmt = conn.prepareStatement(sql);
......@@ -228,12 +243,64 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
if(cnt > 0)
{
refSer="DRCR";
sql="SELECT tran_ser from drcr_rcp where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
rs = pstmt.executeQuery();
if(rs.next())
{
refSer = checkNullandTrim(rs.getString(1));
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs!=null)
{
rs.close();
rs = null;
}
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTMISCREF","","",conn);
return errString;
sql="SELECT count(*) from distord_iss where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs!=null)
{
rs.close();
rs = null;
}
if(cnt > 0)
{
refSer="D-ISS";
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTMISCREF","","",conn);
return errString;
}
}
}
else
......@@ -241,10 +308,40 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
refSer="S-INV";
}
sql="SELECT ir_no from gst_ir_info where ref_id=? and ref_ser =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, refSer);
rs = pstmt.executeQuery();
if(rs.next())
{
irn = rs.getString(1);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs!=null)
{
rs.close();
rs = null;
}
if(irn==null || irn.trim().length()==0)
{
errString = itmDBAccessEJB.getErrorString("","VTIRNNULL","","",conn);
return errString;
}
if("S-INV".equalsIgnoreCase(refSer))
{
sql="SELECT site_code,gst_ir_no from invoice where invoice_id=? ";
sql="SELECT site_code from invoice where invoice_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
......@@ -254,7 +351,7 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
if(rs.next())
{
siteCode = rs.getString(1);
irn = rs.getString(2);
}
if(pstmt != null)
{
......@@ -270,9 +367,9 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
}
if("DRCR".equalsIgnoreCase(refSer))
if("CRNRCP".equalsIgnoreCase(refSer) || "DRNRCP".equalsIgnoreCase(refSer))
{
sql="SELECT site_code,gst_ir_no from drcr_rcp where tran_id=? ";
sql="SELECT site_code from drcr_rcp where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
......@@ -282,7 +379,7 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
if(rs.next())
{
siteCode = rs.getString(1);
irn = rs.getString(2);
}
if(pstmt != null)
{
......@@ -295,13 +392,33 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
rs = null;
}
}
if(irn==null || irn.trim().length()==0)
if("D-ISS".equalsIgnoreCase(refSer))
{
errString = itmDBAccessEJB.getErrorString("","VTIRNNULL","","",conn);
return errString;
sql="SELECT site_code from distord_iss where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
rs = pstmt.executeQuery();
if(rs.next())
{
siteCode = rs.getString(1);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs!=null)
{
rs.close();
rs = null;
}
}
sql="SELECT REG_NO FROM SITEREGNO WHERE SITE_CODE= ? AND ref_code='GSTIN_NO' ";
pstmt = conn.prepareStatement(sql);
......@@ -329,16 +446,7 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
return errString;
}
if(userName==null || userName.trim().length()==0)
{
errString = itmDBAccessEJB.getErrorString("","VTEINVUPA","","",conn);
return errString;
}
if(password==null || password.trim().length()==0)
{
errString = itmDBAccessEJB.getErrorString("","VTEINVUPA","","",conn);
return errString;
}
gstnPublicKeyName = finCommon.getFinparams("999999", "GSTN_PUB_KEY_NAME", conn);
......@@ -562,38 +670,28 @@ public class EInvoiceIRNCancelPrc extends ProcessEJB {
System.out.println("IRNjson :" + gstIRNObj.toString());
irn=gstIRNObj.getString("Irn");
cancelDateStr=gstIRNObj.getString("CancelDate");
cancelDate=Timestamp.valueOf(cancelDateStr);
if("S-INV".equalsIgnoreCase(refSer))
{
sql = "update invoice set GST_IR_NO=? where invoice_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, irn);
pstmt.setString(2, refNo);
cnt= pstmt.executeUpdate();
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
}
else
{
sql = "update drcr_rcp set GST_IR_NO=? where tran_id = ? ";
sql = " insert into gst_ir_info (tran_date,tran_type,ref_ser,ref_id,ack_no,ack_date,ir_no,reg_stat)" +
" values (?,?,?,?,?,?,?,?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, irn);
pstmt.setString(2, refNo);
cnt= pstmt.executeUpdate();
pstmt.setTimestamp(1, currDate);
pstmt.setString(2, "C");
pstmt.setString(3, refSer);
pstmt.setString(4, refNo);
pstmt.setString(5, "");
pstmt.setTimestamp(6,cancelDate);
pstmt.setString(7, irn);
pstmt.setString(8, "1");
pstmt.executeUpdate();
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
}
}
else
{
......
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