Commit 660eb315 authored by steurwadkar's avatar steurwadkar

F17ABAS001 source code commit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106661 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 46fc35b5
...@@ -1505,15 +1505,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1505,15 +1505,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
gstr1.docIssued = docIssued; gstr1.docIssued = docIssued;
} }
/*String gspAuthString = "", gspAuthSignature = "", gspAuthStringRet = "", gspAuthSignatureRet = "";
APICallData apiRetStatsCallData = null;
List<APICallData> retStatAPICallList = new ArrayList<APICallData>();
int retStatusCallCnt = 0;
Date restSaveEndTime = null;
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
*/
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(gstr1); String json = objectMapper.writeValueAsString(gstr1);
...@@ -1531,310 +1522,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -1531,310 +1522,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
System.out.println("DIFFERANCE IN TIME FOR PAYLOAD CREATION GSTR1 IN HH:MM:SS ["+payloadDiffHours +":"+payloadDiffMinutes+":"+payloadDiffSeconds+"]"); System.out.println("DIFFERANCE IN TIME FOR PAYLOAD CREATION GSTR1 IN HH:MM:SS ["+payloadDiffHours +":"+payloadDiffMinutes+":"+payloadDiffSeconds+"]");
retString = saveGSTRData(json, noOfRecords, tranIdList, "1", conn, xtraParams); retString = saveGSTRData(json, noOfRecords, tranIdList, "1", conn, xtraParams);
/*byte[] jsonBase64 = Base64.getEncoder().encode(json.getBytes());
String encryptedPayload = aesEncryption.encryptEK(jsonBase64, authSEK);
HMac hmac = new HMac(new SHA256Digest());
byte[] resBuf = new byte[hmac.getMacSize()];
hmac.init(new KeyParameter(authSEK));
hmac.update(jsonBase64, 0, jsonBase64.length);
hmac.doFinal(resBuf, 0);
JSONObject gstr1HeaderObj = new JSONObject();
gstr1HeaderObj.put("action", "RETSAVE");
gstr1HeaderObj.put("data", encryptedPayload);
gstr1HeaderObj.put("hmac", new String(Base64.getEncoder().encode(resBuf)));
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
Date startTime = new Date();
HttpRequest saveGstr1Req = Unirest.put(String.format("%s%s", GSP_API_URL, GSTR1_URL_V3))
.header("Content-Type", APPLICATION_JSON)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("txn",transactionId)
.header("state-cd", stateCode)
.header("auth-token", authToken)
.header("gstin", gstin)
.header("username", userName)
.header("ret_period", periodCode)
.header("ip-usr", ipAddress)
.header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(gstr1HeaderObj.toString()))
.getHttpRequest();
System.out.println("SAVE GSTR1 url["+saveGstr1Req.getUrl()+"]");
System.out.println("SAVE GSTR1 method["+saveGstr1Req.getHttpMethod()+"]");
System.out.println("SAVE GSTR1 request header["+saveGstr1Req.getHeaders()+"]");
System.out.println("SAVE GSTR1 request payload["+IOUtils.toString(saveGstr1Req.getBody().getEntity().getContent())+"]");
HttpResponse<JsonNode> gstr1Resp = saveGstr1Req.asJson();
System.out.println(String.format("gstr1Resp Request : Status[%s] Response[%s]", gstr1Resp.getStatus(), gstr1Resp.getBody()));
if (gstr1Resp.getStatus() == 200)
{
JSONObject gstr1RespObj = gstr1Resp.getBody().getObject();
if(gstr1RespObj.has("data") && gstr1RespObj.has("rek"))
{
callStatus = "1";
gstr1Data = gstr1RespObj.getString("data");
gstr1Rek = gstr1RespObj.getString("rek");
byte[] apiEKGstr1 = aesEncryption.decrypt(gstr1Rek, authSEK);
String gstr1RespJsoninBase64 = new String(aesEncryption.decrypt(gstr1Data, apiEKGstr1));
byte[] gstr1RespJsonInBytes = aesEncryption.decodeBase64StringTOByte(gstr1RespJsoninBase64);
JSONObject gstr1TransIdRespObj = new JSONObject(new String(gstr1RespJsonInBytes));
String transId = gstr1TransIdRespObj.getString("reference_id");
responseId = transId;
System.out.println("transId to getStatus["+transId+"]");
restSaveEndTime = new Date();
long retSaveDiff = restSaveEndTime.getTime() - startTime.getTime();
long retSaveDiffSeconds = retSaveDiff / 1000 % 60;
long retSaveDiffMinutes = retSaveDiff / (60 * 1000) % 60;
long retSaveDiffHours = retSaveDiff / (60 * 60 * 1000);
System.out.println("DIFFERANCE IN TIME FOR RETSAVE GSTR1 IN HH:MM:SS ["+retSaveDiffHours +":"+retSaveDiffMinutes+":"+retSaveDiffSeconds+"]");
boolean isRetStatusError = false;
while(true)
{
Thread.sleep(noOfRecords);//TODO NEED TO REMOVE WITH BETTER OPTION
retStatusCallCnt++;
long timeStampRet = new Timestamp().getDateTime();
gspAuthStringRet = clientId + ":" + transactionId + ":" + timeStampRet + ":" + gstin;
gspAuthSignatureRet = gspSignature.sign(gspAuthStringRet, aspPrivateKey);
HttpRequest retStatusReq = Unirest.get(String.format("%s%s", GSP_API_URL, GSTR_URL_V3))
.queryString("action","RETSTATUS")
.queryString("gstin", gstin)
.queryString("ret_period", periodCode)
.queryString("ref_id",transId)
.header("Content-Type", APPLICATION_JSON)
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("txn", transactionId)
.header("ret_period", periodCode)
.header("gstin", gstin)
.header("X-Asp-Auth-Token", gspAuthStringRet)
.header("X-Asp-Auth-Signature", gspAuthSignatureRet)
.getHttpRequest();
System.out.println("RETSTATUS url["+retStatusReq.getUrl()+"]");
System.out.println("RETSTATUS method["+retStatusReq.getHttpMethod()+"]");
System.out.println("RETSTATUS request header["+retStatusReq.getHeaders()+"]");
HttpResponse<JsonNode> retStatusResp = retStatusReq.asJson();
System.out.println(String.format("retStatusResp Request : Status[%s] Response[%s]", retStatusResp.getStatus(), retStatusResp.getBody()));
if (retStatusResp.getStatus() == 200)
{
JSONObject retStatsRespObj = retStatusResp.getBody().getObject();
if(retStatsRespObj.has("data") && retStatsRespObj.has("rek"))
{
retStatsData = retStatsRespObj.getString("data");
retStatsRek = retStatsRespObj.getString("rek");
byte[] apiEKRetstats = aesEncryption.decrypt(retStatsRek, authSEK);
String retStatsRespJsoninBase64 = new String(aesEncryption.decrypt(retStatsData, apiEKRetstats));
byte[] retStatsRespJsonInBytes = aesEncryption.decodeBase64StringTOByte(retStatsRespJsoninBase64);
JSONObject retStatsJsonData = new JSONObject(new String(retStatsRespJsonInBytes));
System.out.println( "retStatsJsonData["+retStatsJsonData+"]");
if("IP".equalsIgnoreCase((String)retStatsJsonData.get("status_cd")))
{
retStatusCallStatus = "0";
retStatusResponseJsonStr = "IP";
}
else if("P".equalsIgnoreCase((String)retStatsJsonData.get("status_cd")))
{
retStatusCallStatus = "1";
if(tranIdList.size() > 0)
{
updateSubmissionStatus(tranIdList, conn);
}
isRetStatusError = true;
}
else if("PE".equalsIgnoreCase((String)retStatsJsonData.get("status_cd")))
{
retStatusCallStatus = "2";
errMsg = getRetStatusErrMsg(retStatsJsonData);
retStatusResponseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
}
else if("ER".equalsIgnoreCase(retStatsJsonData.getString("status_cd")))
{
retStatusCallStatus = "2";
if(retStatsJsonData.has("error_report"))
{
JSONObject errorJSON = retStatsJsonData.getJSONObject("error_report");
if(errorJSON.has("error_msg") && errorJSON.has("error_cd"))
{
errMsg = "Message : "+errorJSON.getString("error_msg")+" \nError code : "+errorJSON.getString("error_cd");
}
}
retStatusResponseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
}
else
{
retStatusCallStatus = "2";
if(retStatsJsonData.has("status_cd"))
{
errMsg = "Message : "+retStatsJsonData.getString("status_cd")+" \nError code : "+retStatsJsonData.getString("status_cd");
}
retStatusResponseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
}
}
else
{
retStatusCallStatus = "2";
JSONObject errorJSON = retStatusResp.getBody().getObject().getJSONObject("error");
retStatusResponseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
}
}
else if(retStatusResp.getStatus() == 500)
{
retStatusCallStatus = "2";
errMsg = "Message : Error occurred at GSTN server \nResponse code : "+retStatusResp.getStatus();
retStatusResponseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
}
else
{
retStatusCallStatus = "2";
JSONObject errorJSON = retStatusResp.getBody().getObject().getJSONObject("error");
retStatusResponseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
}
apiRetStatsCallData = new APICallData();
apiRetStatsCallData.setPeriodCode(periodCode);
apiRetStatsCallData.setCallDate(new Date());
apiRetStatsCallData.setSiteCode(siteCode);
apiRetStatsCallData.setUserId(loginCode);
apiRetStatsCallData.setCallType("RETSTATUS");
apiRetStatsCallData.setRecType("1");
apiRetStatsCallData.setNoOfRecords(0);
apiRetStatsCallData.setCallStatus(retStatusCallStatus);
apiRetStatsCallData.setResponseId("");
apiRetStatsCallData.setResponseJsonStr(retStatusResponseJsonStr);
apiRetStatsCallData.setChgUser(loginCode);
apiRetStatsCallData.setChgDate(new Date());
apiRetStatsCallData.setChgTerm(chgTerm);
retStatAPICallList.add(apiRetStatsCallData);
if(isRetStatusError)
{
break;
}
else
{
continue;
}
}
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr1Resp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else if(gstr1Resp.getStatus() == 500)
{
callStatus = "2";
errMsg = "Message : Error occurred at GSTN server \nResponse code : "+gstr1Resp.getStatus();
responseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr1Resp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
System.out.println("total retStatusCallCnt ["+retStatusCallCnt+"]");
Date endTime = new Date();
long diff = endTime.getTime() - startTime.getTime();
long diffSeconds = diff / 1000 % 60;
long diffMinutes = diff / (60 * 1000) % 60;
long diffHours = diff / (60 * 60 * 1000);
long diffStatus = endTime.getTime() - restSaveEndTime.getTime();
long diffStatsSeconds = diffStatus / 1000 % 60;
long diffStatsMinutes = diffStatus / (60 * 1000) % 60;
long diffStatsHours = diffStatus / (60 * 60 * 1000);
System.out.println("DIFFERANCE IN TIME FOR RETSTATUS GSTR1 IN HH:MM:SS ["+diffStatsHours +":"+diffStatsMinutes+":"+diffStatsSeconds+"]");
System.out.println("DIFFERANCE IN TIME FOR SAVE GSTR1 IN HH:MM:SS ["+diffHours +":"+diffMinutes+":"+diffSeconds+"]");
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSAVE");
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(noOfRecords);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
if(retStatAPICallList.size()>0)
{
for(APICallData eachAPICallData : retStatAPICallList)
{
gstCommonUtil.updateAPICallLogHistory(eachAPICallData, null);
}
}*/
} }
} }
catch (Exception e) catch (Exception e)
...@@ -2460,10 +2147,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2460,10 +2147,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
} }
private String createGstr2Json(String siteCode, String xtraParams, Connection conn) throws ITMException private String createGstr2Json(String siteCode, String xtraParams, Connection conn) throws ITMException
{ {
String retString = "", errMsg = ""; String retString = "";
String gstr2Data = "", gstr2Rek = "";
String retStatsData = "", retStatsRek = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
int num = 0, noOfRecords = 0; int num = 0, noOfRecords = 0;
boolean isDataFound = false; boolean isDataFound = false;
...@@ -2474,7 +2158,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2474,7 +2158,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
ResultSet rs = null, lineRs = null; ResultSet rs = null, lineRs = null;
String tranId = "", tranType = "", tranIdRef = "", ctin = "", posStateCode = ""; String tranId = "", tranType = "", tranIdRef = "", ctin = "", posStateCode = "";
String loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= "", retStatusCallStatus = "", retStatusResponseJsonStr = "";
ArrayList<String> tranIdList = new ArrayList<String>(); ArrayList<String> tranIdList = new ArrayList<String>();
...@@ -2586,7 +2269,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2586,7 +2269,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
invLineItem.camt = lineRs.getDouble("CGST_AMT"); invLineItem.camt = lineRs.getDouble("CGST_AMT");
invLineItem.samt = lineRs.getDouble("SGST_AMT"); invLineItem.samt = lineRs.getDouble("SGST_AMT");
invLineItem.csamt = lineRs.getDouble("CESS_AMT"); invLineItem.csamt = lineRs.getDouble("CESS_AMT");
invLineItem.itcType = lineRs.getString("ITC_TYPE"); invLineItem.itcType = checkNullandTrim(lineRs.getString("ITC_TYPE")).toLowerCase();
invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST"); invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST");
invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST"); invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST");
invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST"); invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST");
...@@ -2664,7 +2347,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2664,7 +2347,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
invLineItem.camt = lineRs.getDouble("CGST_AMT"); invLineItem.camt = lineRs.getDouble("CGST_AMT");
invLineItem.samt = lineRs.getDouble("SGST_AMT"); invLineItem.samt = lineRs.getDouble("SGST_AMT");
invLineItem.csamt = lineRs.getDouble("CESS_AMT"); invLineItem.csamt = lineRs.getDouble("CESS_AMT");
invLineItem.itcType = lineRs.getString("ITC_TYPE"); invLineItem.itcType = checkNullandTrim(lineRs.getString("ITC_TYPE")).toLowerCase();
invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST"); invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST");
invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST"); invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST");
invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST"); invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST");
...@@ -2691,7 +2374,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2691,7 +2374,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
invoice.supplyType = stateCode.trim().equalsIgnoreCase(posStateCode.trim())?"INTRA":"INTER"; invoice.supplyType = stateCode.trim().equalsIgnoreCase(posStateCode.trim())?"INTRA":"INTER";
invoices.add(invoice); invoices.add(invoice);
if("B2B".equalsIgnoreCase(udfStr1)) if("B2BUR".equalsIgnoreCase(udfStr1))
{ {
b2bur = new B2BUR(); b2bur = new B2BUR();
b2bur.invoices = invoices; b2bur.invoices = invoices;
...@@ -2725,7 +2408,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2725,7 +2408,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
invLineItem.camt = lineRs.getDouble("CGST_AMT"); invLineItem.camt = lineRs.getDouble("CGST_AMT");
invLineItem.samt = lineRs.getDouble("SGST_AMT"); invLineItem.samt = lineRs.getDouble("SGST_AMT");
invLineItem.csamt = lineRs.getDouble("CESS_AMT"); invLineItem.csamt = lineRs.getDouble("CESS_AMT");
invLineItem.itcType = lineRs.getString("ITC_TYPE"); invLineItem.itcType = checkNullandTrim(lineRs.getString("ITC_TYPE")).toLowerCase();
invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST"); invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST");
invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST"); invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST");
invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST"); invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST");
...@@ -2794,7 +2477,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2794,7 +2477,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
invLineItem.camt = lineRs.getDouble("CGST_AMT"); invLineItem.camt = lineRs.getDouble("CGST_AMT");
invLineItem.samt = lineRs.getDouble("SGST_AMT"); invLineItem.samt = lineRs.getDouble("SGST_AMT");
invLineItem.csamt = lineRs.getDouble("CESS_AMT"); invLineItem.csamt = lineRs.getDouble("CESS_AMT");
invLineItem.itcType = lineRs.getString("ITC_TYPE"); invLineItem.itcType = checkNullandTrim(lineRs.getString("ITC_TYPE")).toLowerCase();
invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST"); invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST");
invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST"); invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST");
invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST"); invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST");
...@@ -2853,7 +2536,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2853,7 +2536,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
invLineItem.camt = lineRs.getDouble("CGST_AMT"); invLineItem.camt = lineRs.getDouble("CGST_AMT");
invLineItem.samt = lineRs.getDouble("SGST_AMT"); invLineItem.samt = lineRs.getDouble("SGST_AMT");
invLineItem.csamt = lineRs.getDouble("CESS_AMT"); invLineItem.csamt = lineRs.getDouble("CESS_AMT");
invLineItem.itcType = lineRs.getString("ITC_TYPE"); invLineItem.itcType = checkNullandTrim(lineRs.getString("ITC_TYPE")).toLowerCase();
invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST"); invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST");
invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST"); invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST");
invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST"); invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST");
...@@ -2996,464 +2679,173 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -2996,464 +2679,173 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
invLineItem.camt = lineRs.getDouble("CGST_AMT"); invLineItem.camt = lineRs.getDouble("CGST_AMT");
invLineItem.samt = lineRs.getDouble("SGST_AMT"); invLineItem.samt = lineRs.getDouble("SGST_AMT");
invLineItem.csamt = lineRs.getDouble("CESS_AMT"); invLineItem.csamt = lineRs.getDouble("CESS_AMT");
invLineItem.itcType = lineRs.getString("ITC_TYPE"); invLineItem.itcType = checkNullandTrim(lineRs.getString("ITC_TYPE")).toLowerCase();
invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST"); invLineItem.igstInputTax = lineRs.getDouble("ITC_IGST");
invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST"); invLineItem.cgstInputTax = lineRs.getDouble("ITC_CGST");
invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST"); invLineItem.sgstInputTax = lineRs.getDouble("ITC_SGST");
invLineItem.cessInputTax = lineRs.getDouble("ITC_CESS"); invLineItem.cessInputTax = lineRs.getDouble("ITC_CESS");
invLineItems.add(invLineItem);
}
if(linePstmt != null)
{
linePstmt.close();
linePstmt = null;
}
if(lineRs != null)
{
lineRs.close();
lineRs = null;
}
cdnur = new CDNUR();
cdnur.isReverseCharge = false;
cdnur.recType = "2";
cdnur.receiverGSTIN = checkNullandTrim(rs.getString("TAX_REG_NO"));
cdnur.cdnNoteType = udfStr2;
cdnur.cdNoteNumber = checkNullandTrim(rs.getString("DOC_NO"));
cdnur.cdNoteDate = rs.getDate("DOC_DATE");
cdnur.invoiceNumber = checkNullandTrim(rs.getString("REF_ID__INV"));
cdnur.invoiceDate = rs.getDate("REF_DATE__INV");
cdnur.val = rs.getDouble("AMOUNT");
cdnur.reason = checkNullandTrim(rs.getString("REAS_CODE"));
if(rs.getDate("REF_DATE__INV").before(gstStartDate))
{
cdnur.isPreGSTInvoice = true;
}
cdnur.items = invLineItems;
cdnurList.add(cdnur);
}
tranIdList.add(tranId);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(isDataFound)
{
//HSN summary data will be sent every time
sql = " SELECT GDD.GS_CODE, GDD.GS_DESCR, GDD.UNIT, SUM(GDD.QUANTITY) AS TOT_QTY, SUM(GDD.TAXABLE_AMT) AS TOT_TAXVAL,"
+ " SUM(GDD.IGST_AMT) AS TOT_IAMT, SUM(CGST_AMT) AS TOT_CAMT, SUM(SGST_AMT) AS TOT_SAMT, SUM(CESS_AMT) AS TOT_CSAMT"
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD"
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDD.GS_CODE IS NOT NULL AND GDH.REC_TYPE='2'"
+ " AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ?"
+ " GROUP BY GDD.GS_CODE, GDD.GS_DESCR, GDD.UNIT";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, periodCode);
rs = pstmt.executeQuery();
while (rs.next())
{
hsnDetails = new HSNDetails();
hsnDetails.num = ++num;
hsnDetails.itemOrServiceCode = checkNullandTrim(rs.getString("GS_CODE"));
hsnDetails.description = checkNullandTrim(rs.getString("GS_DESCR"));
hsnDetails.unitOfMeasure = checkNullandTrim(rs.getString("UNIT"));
hsnDetails.quantity = rs.getDouble("TOT_QTY");
hsnDetails.totalAmount = rs.getDouble("TOT_TAXVAL");
hsnDetails.totalTaxableAmount = rs.getDouble("TOT_TAXVAL");
hsnDetails.totalIGSTAmount = rs.getDouble("TOT_IAMT");
hsnDetails.totalCGSTAmount = rs.getDouble("TOT_CAMT");
hsnDetails.totalSGSTAmount = rs.getDouble("TOT_SAMT");
hsnDetails.totalCESSAmount = rs.getDouble("TOT_CSAMT");
hsnList.add(hsnDetails);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(hsnList.size() > 0)
{
hsn = new HSN();
hsn.recType = "2";
hsn.hsnDetails = hsnList;
}
InterNilSupplies interNilSupplies = getInterNilRateSummary("13", "14", "15", "16", siteCode, periodCode, conn);
IntraNilSupplies intraNilSupplies = getIntraNilRateSummary("17", "18", "19", "20", siteCode, periodCode, conn);
if(interNilSupplies != null || intraNilSupplies != null)
{
nilInwardSupplies = new NilInwardSupplies();
nilInwardSupplies.interNilSupplies = interNilSupplies;
nilInwardSupplies.intraNilSupplies = intraNilSupplies;
}
gstr2 = new GSTR2();
gstr2.gstin = gstin;
gstr2.financialPeriod = periodCode;
//Summary of Nil rated inward supplies
if(b2bInvoiceList.size() > 0)
{
gstr2.b2b = b2bInvoiceList;
}
if(b2burInvoiceList.size() > 0)
{
gstr2.b2bur = b2burInvoiceList;
}
if(cdnrList.size() > 0)
{
gstr2.cdnr = cdnrList;
}
if(hsn != null)
{
gstr2.hsn = hsn;
}
if(impgList.size() > 0)
{
gstr2.impg = impgList;
}
if(impsList.size()>0)
{
gstr2.imps = impsList;
}
if(nilInwardSupplies != null)
{
gstr2.nil = nilInwardSupplies;
}
if(txiList.size()>0)
{
gstr2.txi = txiList;
}
if(txpdList.size()>0)
{
gstr2.txpd = txpdList;
}
if(cdnurList.size()>0)
{
gstr2.cdnur = cdnurList;
}
/*String gspAuthString = "", gspAuthSignature = "", gspAuthStringRet = "", gspAuthSignatureRet = "";
APICallData apiRetStatsCallData = null;
List<APICallData> retStatAPICallList = new ArrayList<APICallData>();
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");*/
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(gstr2);
System.out.println("jsonPayload to SAVE GSTR2["+json+"]");
retString = saveGSTRData(json, noOfRecords, tranIdList, "2", conn, xtraParams);
/*byte[] jsonBase64 = Base64.getEncoder().encode(json.getBytes());
String encryptedPayload = aesEncryption.encryptEK(jsonBase64, authSEK);
HMac hmac = new HMac(new SHA256Digest());
byte[] resBuf = new byte[hmac.getMacSize()];
hmac.init(new KeyParameter(authSEK));
hmac.update(jsonBase64, 0, jsonBase64.length);
hmac.doFinal(resBuf, 0);
JSONObject gstr1HeaderObj = new JSONObject();
gstr1HeaderObj.put("action", "RETSAVE");
gstr1HeaderObj.put("data", encryptedPayload);
gstr1HeaderObj.put("hmac", new String(Base64.getEncoder().encode(resBuf)));
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
Date startTime = new Date();
HttpRequest saveGstr2Req = Unirest.put(String.format("%s%s", GSP_API_URL, GSTR2_URL_V3))
.header("Content-Type", APPLICATION_JSON)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("txn",transactionId)
.header("state-cd", stateCode)
.header("auth-token", authToken)
.header("gstin", gstin)
.header("username", userName)
.header("ret_period", periodCode)
.header("ip-usr", ipAddress)
.header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(gstr1HeaderObj.toString()))
.getHttpRequest();
System.out.println("SAVE GSTR2 url["+saveGstr2Req.getUrl()+"]");
System.out.println("SAVE GSTR2 method["+saveGstr2Req.getHttpMethod()+"]");
System.out.println("SAVE GSTR2 request header["+saveGstr2Req.getHeaders()+"]");
System.out.println("SAVE GSTR2 request payload["+IOUtils.toString(saveGstr2Req.getBody().getEntity().getContent())+"]");
HttpResponse<JsonNode> gstr2Resp = saveGstr2Req.asJson();
System.out.println(String.format("gstr2Resp Request : Status[%s] Response[%s]", gstr2Resp.getStatus(), gstr2Resp.getBody()));
if (gstr2Resp.getStatus() == 200)
{
JSONObject gstr2RespObj = gstr2Resp.getBody().getObject();
if(gstr2RespObj.has("data") && gstr2RespObj.has("rek"))
{
callStatus = "1";
gstr2Data = gstr2RespObj.getString("data");
gstr2Rek = gstr2RespObj.getString("rek");
byte[] apiEKGstr2 = aesEncryption.decrypt(gstr2Rek, authSEK);
String gstr2RespJsoninBase64 = new String(aesEncryption.decrypt(gstr2Data, apiEKGstr2));
byte[] gstr2RespJsonInBytes = aesEncryption.decodeBase64StringTOByte(gstr2RespJsoninBase64);
JSONObject gstr2TransIdRespObj = new JSONObject(new String(gstr2RespJsonInBytes));
String transId = gstr2TransIdRespObj.getString("reference_id");
responseId = transId;
System.out.println("transId to getStatus["+transId+"]");
boolean isRetStatusError = false;
while(true)
{
long timeStampRet = new Timestamp().getDateTime();
gspAuthStringRet = clientId + ":" + transactionId + ":" + timeStampRet + ":" + gstin;
gspAuthSignatureRet = gspSignature.sign(gspAuthStringRet, aspPrivateKey);
HttpRequest retStatusReq = Unirest.get(String.format("%s%s", GSP_API_URL, GSTR_URL_V3))
.queryString("action","RETSTATUS")
.queryString("gstin", gstin)
.queryString("ret_period", periodCode)
.queryString("ref_id",transId)
.header("Content-Type", APPLICATION_JSON)
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("txn", transactionId)
.header("ret_period", periodCode)
.header("gstin", gstin)
.header("X-Asp-Auth-Token", gspAuthStringRet)
.header("X-Asp-Auth-Signature", gspAuthSignatureRet)
.getHttpRequest();
System.out.println("RETSTATUS url["+retStatusReq.getUrl()+"]");
System.out.println("RETSTATUS method["+retStatusReq.getHttpMethod()+"]");
System.out.println("RETSTATUS request header["+retStatusReq.getHeaders()+"]");
HttpResponse<JsonNode> retStatusResp = retStatusReq.asJson();
System.out.println(String.format("retStatusResp Request : Status[%s] Response[%s]", retStatusResp.getStatus(), retStatusResp.getBody()));
if (retStatusResp.getStatus() == 200) invLineItems.add(invLineItem);
}
if(linePstmt != null)
{ {
JSONObject retStatsRespObj = retStatusResp.getBody().getObject(); linePstmt.close();
if(retStatsRespObj.has("data") && retStatsRespObj.has("rek")) linePstmt = null;
}
if(lineRs != null)
{ {
retStatsData = retStatsRespObj.getString("data"); lineRs.close();
retStatsRek = retStatsRespObj.getString("rek"); lineRs = null;
}
byte[] apiEKRetstats = aesEncryption.decrypt(retStatsRek, authSEK);
String retStatsRespJsoninBase64 = new String(aesEncryption.decrypt(retStatsData, apiEKRetstats));
byte[] retStatsRespJsonInBytes = aesEncryption.decodeBase64StringTOByte(retStatsRespJsoninBase64);
JSONObject retStatsJsonData = new JSONObject(new String(retStatsRespJsonInBytes)); cdnur = new CDNUR();
System.out.println( "retStatsJsonData["+retStatsJsonData+"]"); cdnur.isReverseCharge = false;
if("IP".equalsIgnoreCase((String)retStatsJsonData.get("status_cd"))) cdnur.recType = "2";
cdnur.receiverGSTIN = checkNullandTrim(rs.getString("TAX_REG_NO"));
cdnur.cdnNoteType = udfStr2;
cdnur.cdNoteNumber = checkNullandTrim(rs.getString("DOC_NO"));
cdnur.cdNoteDate = rs.getDate("DOC_DATE");
cdnur.invoiceNumber = checkNullandTrim(rs.getString("REF_ID__INV"));
cdnur.invoiceDate = rs.getDate("REF_DATE__INV");
cdnur.val = rs.getDouble("AMOUNT");
cdnur.reason = checkNullandTrim(rs.getString("REAS_CODE"));
if(rs.getDate("REF_DATE__INV").before(gstStartDate))
{ {
retStatusCallStatus = "0"; cdnur.isPreGSTInvoice = true;
retStatusResponseJsonStr = "IP";
} }
else if("P".equalsIgnoreCase((String)retStatsJsonData.get("status_cd"))) cdnur.items = invLineItems;
{
retStatusCallStatus = "1"; cdnurList.add(cdnur);
if(tranIdList.size() > 0)
{
updateSubmissionStatus(tranIdList, conn);
} }
isRetStatusError = true;
tranIdList.add(tranId);
} }
else if("PE".equalsIgnoreCase((String)retStatsJsonData.get("status_cd"))) if(pstmt != null)
{ {
retStatusCallStatus = "2"; pstmt.close();
errMsg = getRetStatusErrMsg(retStatsJsonData); pstmt = null;
retStatusResponseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
} }
else if("ER".equalsIgnoreCase(retStatsJsonData.getString("status_cd"))) if(rs != null)
{
retStatusCallStatus = "2";
if(retStatsJsonData.has("error_report"))
{
JSONObject errorJSON = retStatsJsonData.getJSONObject("error_report");
if(errorJSON.has("error_msg") && errorJSON.has("error_cd"))
{ {
errMsg = "Message : "+errorJSON.getString("error_msg")+" \nError code : "+errorJSON.getString("error_cd"); rs.close();
} rs = null;
} }
retStatusResponseJsonStr = errMsg; if(isDataFound)
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
}
else
{ {
retStatusCallStatus = "2"; //HSN summary data will be sent every time
if(retStatsJsonData.has("status_cd")) sql = " SELECT GDD.GS_CODE, GDD.GS_DESCR, GDD.UNIT, SUM(GDD.QUANTITY) AS TOT_QTY, SUM(GDD.TAXABLE_AMT) AS TOT_TAXVAL,"
+ " SUM(GDD.IGST_AMT) AS TOT_IAMT, SUM(CGST_AMT) AS TOT_CAMT, SUM(SGST_AMT) AS TOT_SAMT, SUM(CESS_AMT) AS TOT_CSAMT"
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD"
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDD.GS_CODE IS NOT NULL AND GDH.REC_TYPE='2'"
+ " AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ?"
+ " GROUP BY GDD.GS_CODE, GDD.GS_DESCR, GDD.UNIT";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, periodCode);
rs = pstmt.executeQuery();
while (rs.next())
{ {
errMsg = "Message : "+retStatsJsonData.getString("status_cd")+" \nError code : "+retStatsJsonData.getString("status_cd"); hsnDetails = new HSNDetails();
}
retStatusResponseJsonStr = errMsg; hsnDetails.num = ++num;
retString = getError(errMsg, "GSTAPIERR", conn); hsnDetails.itemOrServiceCode = checkNullandTrim(rs.getString("GS_CODE"));
isRetStatusError = true; hsnDetails.description = checkNullandTrim(rs.getString("GS_DESCR"));
} hsnDetails.unitOfMeasure = checkNullandTrim(rs.getString("UNIT"));
hsnDetails.quantity = rs.getDouble("TOT_QTY");
hsnDetails.totalAmount = rs.getDouble("TOT_TAXVAL");
hsnDetails.totalTaxableAmount = rs.getDouble("TOT_TAXVAL");
hsnDetails.totalIGSTAmount = rs.getDouble("TOT_IAMT");
hsnDetails.totalCGSTAmount = rs.getDouble("TOT_CAMT");
hsnDetails.totalSGSTAmount = rs.getDouble("TOT_SAMT");
hsnDetails.totalCESSAmount = rs.getDouble("TOT_CSAMT");
hsnList.add(hsnDetails);
} }
else if(pstmt != null)
{ {
retStatusCallStatus = "2"; pstmt.close();
JSONObject errorJSON = retStatusResp.getBody().getObject().getJSONObject("error"); pstmt = null;
retStatusResponseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
} }
if(rs != null)
{
rs.close();
rs = null;
} }
else if(retStatusResp.getStatus() == 500)
if(hsnList.size() > 0)
{ {
retStatusCallStatus = "2"; hsn = new HSN();
errMsg = "Message : Error occurred at GSTN server \nResponse code : "+retStatusResp.getStatus(); hsn.recType = "2";
retStatusResponseJsonStr = errMsg; hsn.hsnDetails = hsnList;
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
} }
else
InterNilSupplies interNilSupplies = getInterNilRateSummary("13", "14", "15", "16", siteCode, periodCode, conn);
IntraNilSupplies intraNilSupplies = getIntraNilRateSummary("17", "18", "19", "20", siteCode, periodCode, conn);
if(interNilSupplies != null || intraNilSupplies != null)
{ {
retStatusCallStatus = "2"; nilInwardSupplies = new NilInwardSupplies();
JSONObject errorJSON = retStatusResp.getBody().getObject().getJSONObject("error"); nilInwardSupplies.interNilSupplies = interNilSupplies;
retStatusResponseJsonStr = errorJSON.toString(); nilInwardSupplies.intraNilSupplies = intraNilSupplies;
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
isRetStatusError = true;
} }
apiRetStatsCallData = new APICallData(); gstr2 = new GSTR2();
apiRetStatsCallData.setPeriodCode(periodCode); gstr2.gstin = gstin;
apiRetStatsCallData.setCallDate(new Date()); gstr2.financialPeriod = periodCode;
apiRetStatsCallData.setSiteCode(siteCode);
apiRetStatsCallData.setUserId(loginCode);
apiRetStatsCallData.setCallType("RETSTATUS");
apiRetStatsCallData.setRecType("2");
apiRetStatsCallData.setNoOfRecords(0);
apiRetStatsCallData.setCallStatus(retStatusCallStatus);
apiRetStatsCallData.setResponseId("");
apiRetStatsCallData.setResponseJsonStr(retStatusResponseJsonStr);
apiRetStatsCallData.setChgUser(loginCode);
apiRetStatsCallData.setChgDate(new Date());
apiRetStatsCallData.setChgTerm(chgTerm);
retStatAPICallList.add(apiRetStatsCallData); //Summary of Nil rated inward supplies
if(isRetStatusError) if(b2bInvoiceList.size() > 0)
{ {
break; gstr2.b2b = b2bInvoiceList;
} }
else if(b2burInvoiceList.size() > 0)
{ {
continue; gstr2.b2bur = b2burInvoiceList;
} }
if(cdnrList.size() > 0)
{
gstr2.cdnr = cdnrList;
} }
if(hsn != null)
{
gstr2.hsn = hsn;
} }
else if(impgList.size() > 0)
{ {
callStatus = "2"; gstr2.impg = impgList;
JSONObject errorJSON = gstr2Resp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
} }
if(impsList.size()>0)
{
gstr2.imps = impsList;
} }
else if(gstr2Resp.getStatus() == 500) if(nilInwardSupplies != null)
{ {
callStatus = "2"; gstr2.nil = nilInwardSupplies;
errMsg = "Message : Error occurred at GSTN server \nResponse code : "+gstr2Resp.getStatus();
responseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
} }
else if(txiList.size()>0)
{ {
callStatus = "2"; gstr2.txi = txiList;
JSONObject errorJSON = gstr2Resp.getBody().getObject().getJSONObject("error"); }
responseJsonStr = errorJSON.toString(); if(txpdList.size()>0)
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd"); {
retString = getError(errMsg, "GSTAPIERR", conn); gstr2.txpd = txpdList;
}
if(cdnurList.size()>0)
{
gstr2.cdnur = cdnurList;
} }
Date endTime = new Date(); ObjectMapper objectMapper = new ObjectMapper();
long diff = startTime.getTime() - endTime.getTime();
long diffSeconds = diff / 1000 % 60;
long diffMinutes = diff / (60 * 1000) % 60;
long diffHours = diff / (60 * 60 * 1000);
System.out.println("DIFFERANCE IN TIME FOR SAVE GSTR2 IN HH:MM:SS ["+diffHours +":"+diffMinutes+":"+diffSeconds+"]"); String json = objectMapper.writeValueAsString(gstr2);
APICallData apiCallData = new APICallData(); System.out.println("jsonPayload to SAVE GSTR2["+json+"]");
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSAVE");
apiCallData.setRecType("2");
apiCallData.setNoOfRecords(noOfRecords);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null); retString = saveGSTRData(json, noOfRecords, tranIdList, "2", conn, xtraParams);
if(retStatAPICallList.size()>0)
{
for(APICallData eachAPICallData : retStatAPICallList)
{
gstCommonUtil.updateAPICallLogHistory(eachAPICallData, null);
}
}*/
} }
} }
catch(Exception e) catch(Exception e)
...@@ -5656,12 +5048,19 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -5656,12 +5048,19 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{ {
eachInvErrorJsonArry = errorJsonObj.getJSONArray("ata"); eachInvErrorJsonArry = errorJsonObj.getJSONArray("ata");
} }
else if(errorJsonObj.has("b2bur"))
{
eachInvErrorJsonArry = errorJsonObj.getJSONArray("b2bur");
}
for(int i=0; i<eachInvErrorJsonArry.length(); i++) for(int i=0; i<eachInvErrorJsonArry.length(); i++)
{ {
JSONObject tempJsonObj = eachInvErrorJsonArry.getJSONObject(i); JSONObject tempJsonObj = eachInvErrorJsonArry.getJSONObject(i);
if(tempJsonObj.has("error_msg"))
{
retString += tempJsonObj.getString("error_msg")+"\n"; retString += tempJsonObj.getString("error_msg")+"\n";
}
if(tempJsonObj.has("ty") && tempJsonObj.has("hsn_sc")) if(tempJsonObj.has("ty") && tempJsonObj.has("hsn_sc"))
{ {
retString += " Line Type : "+tempJsonObj.optString("ty")+ " Item/Service Code : "+tempJsonObj.optString("hsn_sc")+"\n"; retString += " Line Type : "+tempJsonObj.optString("ty")+ " Item/Service Code : "+tempJsonObj.optString("hsn_sc")+"\n";
...@@ -5674,6 +5073,10 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -5674,6 +5073,10 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{ {
retString += " Doc No. : "+tempJsonObj.optString("doc_num")+ " Doc Dt. : "+tempJsonObj.optString("doc_dt")+ " Inv Type : "+tempJsonObj.optString("typ")+"\n"; retString += " Doc No. : "+tempJsonObj.optString("doc_num")+ " Doc Dt. : "+tempJsonObj.optString("doc_dt")+ " Inv Type : "+tempJsonObj.optString("typ")+"\n";
} }
else if(tempJsonObj.has("inum") && tempJsonObj.has("idt"))
{
retString += " Invoice No. : "+tempJsonObj.optString("inum")+ " Invoice Dt. : "+tempJsonObj.optString("idt")+"\n";
}
else if(tempJsonObj.has("inv")) else if(tempJsonObj.has("inv"))
{ {
JSONArray tempInvJsonArry = tempJsonObj.getJSONArray("inv"); JSONArray tempInvJsonArry = tempJsonObj.getJSONArray("inv");
......
...@@ -74,6 +74,10 @@ abstract class BaseSerializer<T extends BaseData> extends JsonSerializer<T> ...@@ -74,6 +74,10 @@ abstract class BaseSerializer<T extends BaseData> extends JsonSerializer<T>
{ {
json.writeStringField("inv_typ", inv.invoiceType); json.writeStringField("inv_typ", inv.invoiceType);
} }
if(inv.supplyType != null)
{
json.writeStringField("sply_ty", inv.supplyType);
}
writeLineItems(genericInvoice, json, inv); writeLineItems(genericInvoice, json, inv);
} }
...@@ -144,7 +148,7 @@ abstract class BaseSerializer<T extends BaseData> extends JsonSerializer<T> ...@@ -144,7 +148,7 @@ abstract class BaseSerializer<T extends BaseData> extends JsonSerializer<T>
json.writeEndObject(); json.writeEndObject();
} }
if(li.itcType != null && (li.igstInputTax > 0.0 || li.cgstInputTax > 0.0 || li.sgstInputTax > 0.0) || li.cessInputTax > 0.0) if(li.itcType != null)
{ {
json.writeFieldName("itc"); json.writeFieldName("itc");
json.writeStartObject(); json.writeStartObject();
......
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