Commit ebfc1eac authored by steurwadkar's avatar steurwadkar

F17ABAS001 source code commit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@105900 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3cdc1431
...@@ -8,6 +8,7 @@ import java.sql.Connection; ...@@ -8,6 +8,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.Date; import java.util.Date;
...@@ -32,6 +33,7 @@ import com.mashape.unirest.http.HttpResponse; ...@@ -32,6 +33,7 @@ import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode; import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest; import com.mashape.unirest.http.Unirest;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.bean.gst.AT; import ibase.webitm.bean.gst.AT;
import ibase.webitm.bean.gst.ATA; import ibase.webitm.bean.gst.ATA;
...@@ -44,6 +46,8 @@ import ibase.webitm.bean.gst.B2CSA; ...@@ -44,6 +46,8 @@ import ibase.webitm.bean.gst.B2CSA;
import ibase.webitm.bean.gst.CDNDetails; import ibase.webitm.bean.gst.CDNDetails;
import ibase.webitm.bean.gst.CDNR; import ibase.webitm.bean.gst.CDNR;
import ibase.webitm.bean.gst.CDNRA; import ibase.webitm.bean.gst.CDNRA;
import ibase.webitm.bean.gst.EXP;
import ibase.webitm.bean.gst.EXPA;
import ibase.webitm.bean.gst.GSTR1; import ibase.webitm.bean.gst.GSTR1;
import ibase.webitm.bean.gst.InvLineItem; import ibase.webitm.bean.gst.InvLineItem;
import ibase.webitm.bean.gst.Invoice; import ibase.webitm.bean.gst.Invoice;
...@@ -53,6 +57,7 @@ import ibase.webitm.ejb.fin.FinCommon; ...@@ -53,6 +57,7 @@ import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.util.gst.AESEncryption; import ibase.webitm.util.gst.AESEncryption;
import ibase.webitm.util.gst.PubKeyEncryption; import ibase.webitm.util.gst.PubKeyEncryption;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
@javax.ejb.Stateless @javax.ejb.Stateless
public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWizPosLocal, GSTDataSubmitWizPosRemote public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWizPosLocal, GSTDataSubmitWizPosRemote
...@@ -295,7 +300,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -295,7 +300,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{ {
if("GETINV".equalsIgnoreCase(action)) if("GETINV".equalsIgnoreCase(action))
{ {
retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, authSEK, conn); retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, siteCode, authSEK, conn);
} }
} }
} }
...@@ -357,6 +362,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -357,6 +362,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
ArrayList<CDNRA> cdnraList = new ArrayList<CDNRA>(); ArrayList<CDNRA> cdnraList = new ArrayList<CDNRA>();
ArrayList<AT> atList = new ArrayList<AT>(); ArrayList<AT> atList = new ArrayList<AT>();
ArrayList<ATA> ataList = new ArrayList<ATA>(); ArrayList<ATA> ataList = new ArrayList<ATA>();
ArrayList<EXP> expInvoiceList = new ArrayList<EXP>();
ArrayList<EXPA> expaInvoiceList = new ArrayList<EXPA>();
ArrayList<InvLineItem> invLineItems = null; ArrayList<InvLineItem> invLineItems = null;
ArrayList<Invoice> invoices = null; ArrayList<Invoice> invoices = null;
...@@ -376,6 +383,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -376,6 +383,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
CDNDetails cdnDetails = null; CDNDetails cdnDetails = null;
AT at = null; AT at = null;
ATA ata = null; ATA ata = null;
EXP exp = null;
EXPA expa = null;
try try
{ {
...@@ -969,7 +978,22 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -969,7 +978,22 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
//tran_type : 10 = Exports and tran_type : 11 = Exports amendments //tran_type : 10 = Exports and tran_type : 11 = Exports amendments
if("10".equalsIgnoreCase(tranType) || "11".equalsIgnoreCase(tranType)) if("10".equalsIgnoreCase(tranType) || "11".equalsIgnoreCase(tranType))
{ {
/*invoices = new ArrayList<Invoice>();
invoice = new Invoice();
invLineItems = new ArrayList<InvLineItem>();
if("10".equalsIgnoreCase(tranType))
{
exp = new EXP();
exp.isReverseCharge = false;
exp.exportType = checkNullandTrim(rs.getString("DOC_TYPE"));
exp.invoices = invoices;
expInvoiceList.add(exp);
}*/
} }
//tran_type : 12 = Advance Tax and tran_type : 13 = Adv. Tax amendments //tran_type : 12 = Advance Tax and tran_type : 13 = Adv. Tax amendments
if("12".equalsIgnoreCase(tranType) || "13".equalsIgnoreCase(tranType)) if("12".equalsIgnoreCase(tranType) || "13".equalsIgnoreCase(tranType))
...@@ -1536,7 +1560,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1536,7 +1560,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
return retString; return retString;
} }
private String getGstr2Invoices(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSEK, Connection conn) private String getGstr2Invoices(String authToken, String stateCode, String userName, String gstin, String periodCode, String siteCode, byte[] authSEK, Connection conn)
{ {
String retString = ""; String retString = "";
String errMsg = ""; String errMsg = "";
...@@ -1579,6 +1603,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1579,6 +1603,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject gstr2InvoiceJsonObj = new JSONObject(new String(respJsonInBytes)); JSONObject gstr2InvoiceJsonObj = new JSONObject(new String(respJsonInBytes));
System.out.println("respJsonInBytes["+new String(respJsonInBytes)+"]"); System.out.println("respJsonInBytes["+new String(respJsonInBytes)+"]");
saveDownloadedData(siteCode, gstr2InvoiceJsonObj, conn);
} }
else else
...@@ -1604,6 +1630,124 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1604,6 +1630,124 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
return retString; return retString;
} }
private void saveDownloadedData(String siteCode,JSONObject gstr2InvoiceJsonObj, Connection conn)
{
JSONArray b2bInvArry = new JSONArray();
JSONObject b2bJsonObj = new JSONObject();
JSONArray b2bInvJsonArry = new JSONArray();
JSONObject b2bInvJsonObj = new JSONObject();
JSONArray b2bInvLineItmsArry = new JSONArray();
JSONObject b2bInvLineItemObj = new JSONObject();
String tranId, cptyGSTIN, iNum, iDate, reversCharge, docCheckSum, stateCode;
String lineType, hsnSC;
int lineNo;
double amount, lineAmt, irt, iamt, crt, camt, srt, samt, csrt, csamt;
String hdrSql, detSql;
PreparedStatement hdrPstmt, detPstmt;
try
{
b2bInvArry = gstr2InvoiceJsonObj.getJSONArray("b2b");
for(int i = 0; i < b2bInvArry.length(); i++)
{
b2bJsonObj = b2bInvArry.getJSONObject(i);
cptyGSTIN = b2bJsonObj.getString("ctin");
b2bInvJsonArry = b2bJsonObj.getJSONArray("inv");
for(int j=0; j<b2bInvJsonArry.length(); j++)
{
b2bInvJsonObj = b2bInvJsonArry.getJSONObject(j);
iNum = b2bInvJsonObj.getString("inum");
iDate = b2bInvJsonObj.getString("idt");
amount = b2bInvJsonObj.getDouble("val");
docCheckSum = b2bInvJsonObj.getString("chksum");
reversCharge = b2bInvJsonObj.getString("rchrg");
stateCode = b2bInvJsonObj.getString("pos");
tranId = generateTranId("w_gstr_purc","","",conn);
hdrSql = "INSERT INTO GST_DATA_HDR (TRAN_ID, TRAN_DATE, REC_TYPE, TRAN_TYPE, STATE_CODE, SUBMISSION_TYPE, DOC_CHECKSUM, DOC_NO, DOC_DATE, AMOUNT, REVERSE_CHRG, TAX_REG_NO, SITE_CODE) "
+ "VALUES (?,?,'2','01',?,'D',?,?,?,?,?,?,?)";
hdrPstmt = conn.prepareStatement(hdrSql);
hdrPstmt.setString(1, tranId);
hdrPstmt.setString(2, new SimpleDateFormat(new E12GenericUtility().getApplDateFormat()).format(new Date()));
hdrPstmt.setString(3, stateCode);
hdrPstmt.setString(4, docCheckSum);
hdrPstmt.setString(5, iNum);
hdrPstmt.setString(6, iDate);
hdrPstmt.setDouble(7, amount);
hdrPstmt.setString(8, reversCharge);
hdrPstmt.setString(9, cptyGSTIN);
hdrPstmt.setString(10, siteCode);
int hdrCnt = hdrPstmt.executeUpdate();
System.out.println("560101.hdrCnt["+hdrCnt+"]");
b2bInvLineItmsArry = b2bInvJsonObj.getJSONArray("itms");
detSql = "INSERT INTO GST_DATA_DET (TRAN_ID, LINE_NO, LINE_TYPE, GS_CODE, TAXABLE_AMT, IGST_PERC, IGST_AMT, CGST_PERC, CGST_AMT, SGST_PERC, SGST_AMT, CESS_PERC, CESS_AMT) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
detPstmt = conn.prepareStatement(detSql);
for(int k=0; k<b2bInvLineItmsArry.length(); k++)
{
b2bInvLineItemObj = b2bInvLineItmsArry.getJSONObject(k);
lineNo = b2bInvLineItemObj.getInt("num");
JSONObject tempJSONObj = b2bInvLineItemObj.getJSONObject("itm_det");
lineType = tempJSONObj.getString("ty");
lineAmt = tempJSONObj.getDouble("txval");
hsnSC = tempJSONObj.getString("hsn_sc");
irt = tempJSONObj.getDouble("irt");
iamt = tempJSONObj.getDouble("iamt");
crt = tempJSONObj.getDouble("crt");
camt = tempJSONObj.getDouble("camt");
srt = tempJSONObj.getDouble("srt");
samt = tempJSONObj.getDouble("samt");
csrt = tempJSONObj.getDouble("csrt");
csamt = tempJSONObj.getDouble("csamt");
detPstmt.setString(1, tranId);
detPstmt.setInt(2, lineNo);
detPstmt.setString(3, lineType);
detPstmt.setString(4, hsnSC);
detPstmt.setDouble(5, lineAmt);
detPstmt.setDouble(6, irt);
detPstmt.setDouble(7, iamt);
detPstmt.setDouble(8, crt);
detPstmt.setDouble(9, camt);
detPstmt.setDouble(10, srt);
detPstmt.setDouble(11, samt);
detPstmt.setDouble(12, csrt);
detPstmt.setDouble(13, csamt);
detPstmt.addBatch();
detPstmt.clearParameters();
}
int[] detCnt = detPstmt.executeBatch();
System.out.println("560101.detCnt["+detCnt+"]");
}
}
}
catch (Exception e)
{
System.out.println("GSTDataSubmitWizPos.saveDownloadedData()["+e.getMessage()+"]");
e.printStackTrace();
}
}
private String getError(String errMsg, String Code, Connection conn) throws ITMException, Exception private String getError(String errMsg, String Code, Connection conn) throws ITMException, Exception
{ {
String mainStr =""; String mainStr ="";
...@@ -1714,5 +1858,77 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1714,5 +1858,77 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
} }
return input.trim(); return input.trim();
} }
private String generateTranId( String windowName, String siteCode, String tranDateStr, Connection conn )throws ITMException,Exception
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
try
{
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + tranDateStr + "</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
return tranId;
}
} }
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