Commit 508ba595 authored by steurwadkar's avatar steurwadkar

json parsing logic changed for inserting GSTR2A data to handle null pointer exception

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@172022 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e24052f5
......@@ -5974,13 +5974,13 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
b2bInvJsonObj = b2bInvJsonArry.getJSONObject(j);
iNum = b2bInvJsonObj.getString("inum");
iDate = b2bInvJsonObj.getString("idt");
amount = b2bInvJsonObj.getDouble("val");
docCheckSum = b2bInvJsonObj.getString("chksum");
reversCharge = b2bInvJsonObj.getString("rchrg");
pos = b2bInvJsonObj.getString("pos");
invType = b2bInvJsonObj.getString("inv_typ").trim();
iNum = b2bInvJsonObj.optString("inum");
iDate = b2bInvJsonObj.optString("idt");
amount = b2bInvJsonObj.optDouble("val");
docCheckSum = b2bInvJsonObj.optString("chksum");
reversCharge = b2bInvJsonObj.optString("rchrg");
pos = b2bInvJsonObj.optString("pos");
invType = b2bInvJsonObj.optString("inv_typ").trim();
if(b2bInvJsonObj.has("etin"))
{
ecomOperetorGSTIN = b2bInvJsonObj.getString("etin");
......@@ -6074,7 +6074,10 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
detInsPstmt = localConn.prepareStatement(detInsSql);
if(b2bJsonObj.has("itms"))
{
b2bInvLineItmsArry = b2bInvJsonObj.getJSONArray("itms");
}
for(int k=0; k<b2bInvLineItmsArry.length(); k++)
{
......@@ -6085,23 +6088,23 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject tempJSONObj = b2bInvLineItemObj.getJSONObject("itm_det");
rate = tempJSONObj.getDouble("rt");
lineAmt = tempJSONObj.getDouble("txval");
rate = tempJSONObj.optDouble("rt");
lineAmt = tempJSONObj.optDouble("txval");
if(tempJSONObj.has("iamt"))
{
iamt = tempJSONObj.getDouble("iamt");
iamt = tempJSONObj.optDouble("iamt");
}
if(tempJSONObj.has("camt"))
{
camt = tempJSONObj.getDouble("camt");
camt = tempJSONObj.optDouble("camt");
}
if(tempJSONObj.has("samt"))
{
samt = tempJSONObj.getDouble("samt");
samt = tempJSONObj.optDouble("samt");
}
if(tempJSONObj.has("csamt"))
{
csamt = tempJSONObj.getDouble("csamt");
csamt = tempJSONObj.optDouble("csamt");
}
if(stateCode.trim().equalsIgnoreCase(pos.trim()))
......@@ -6537,15 +6540,20 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
if(gstr2InvoiceJsonObj.has("cdn"))
{
cdnArry = gstr2InvoiceJsonObj.getJSONArray("cdn");
}
for(int i = 0; i < cdnArry.length(); i++)
{
cdnJsonObj = cdnArry.getJSONObject(i);
cptyGSTIN = cdnJsonObj.getString("ctin");
cptyGSTIN = cdnJsonObj.optString("ctin");
if(cdnJsonObj.has("nt"))
{
cdnJsonArry = cdnJsonObj.getJSONArray("nt");
}
for(int j=0; j<cdnJsonArry.length(); j++)
{
......@@ -6560,14 +6568,14 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
cdnDataJsonObj = cdnJsonArry.getJSONObject(j);
creditDebitId = cdnDataJsonObj.getString("nt_num");
creditDebitDate = cdnDataJsonObj.getString("nt_dt");
creditDebitType = cdnDataJsonObj.getString("ntty");
amount = cdnDataJsonObj.getDouble("val");
invoiceId = cdnDataJsonObj.getString("inum");
invoiceDate = cdnDataJsonObj.getString("idt");
docCheckSum = cdnDataJsonObj.getString("chksum");
reason = cdnDataJsonObj.getString("rsn");
creditDebitId = cdnDataJsonObj.optString("nt_num");
creditDebitDate = cdnDataJsonObj.optString("nt_dt");
creditDebitType = cdnDataJsonObj.optString("ntty");
amount = cdnDataJsonObj.optDouble("val");
invoiceId = cdnDataJsonObj.optString("inum");
invoiceDate = cdnDataJsonObj.optString("idt");
docCheckSum = cdnDataJsonObj.optString("chksum");
reason = cdnDataJsonObj.optString("rsn");
if("C".equalsIgnoreCase(creditDebitType))
{
......@@ -6638,7 +6646,10 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
detInsPstmt = localConn.prepareStatement(detInsSql);
if(cdnDataJsonObj.has("itms"))
{
cdnInvLineItmsArry = cdnDataJsonObj.getJSONArray("itms");
}
for(int k=0; k<cdnInvLineItmsArry.length(); k++)
{
......@@ -6648,23 +6659,23 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
lineNo++;
JSONObject tempJSONObj = cdnInvLineItemObj.getJSONObject("itm_det");
rate = tempJSONObj.getDouble("rt");
lineAmt = tempJSONObj.getDouble("txval");
rate = tempJSONObj.optDouble("rt");
lineAmt = tempJSONObj.optDouble("txval");
if(tempJSONObj.has("iamt"))
{
iamt = tempJSONObj.getDouble("iamt");
iamt = tempJSONObj.optDouble("iamt");
}
if(tempJSONObj.has("camt"))
{
camt = tempJSONObj.getDouble("camt");
camt = tempJSONObj.optDouble("camt");
}
if(tempJSONObj.has("samt"))
{
samt = tempJSONObj.getDouble("samt");
samt = tempJSONObj.optDouble("samt");
}
if(tempJSONObj.has("csamt"))
{
csamt = tempJSONObj.getDouble("csamt");
csamt = tempJSONObj.optDouble("csamt");
}
if(iamt > 0)
......
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