Commit bad47a3a authored by steurwadkar's avatar steurwadkar

F17ABAS001 source code commit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106451 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c3b3d2e5
package ibase.webitm.bean.gst;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import ibase.webitm.util.gst.GSTR3BSerailizer;
@JsonSerialize(using = GSTR3BSerailizer.class)
public class GSTR3B
{
@JsonProperty("gstin")
public String gstin;
@JsonProperty("fp")
public String financialPeriod;
@JsonProperty("sup_details")
public SuppliesDetails supplyDetails;
@JsonProperty("inter_sup")
public InterStateSupplies interStateSupplies;
@JsonProperty("itc_elg")
public ITCEligibilty itcEligibility;
@JsonProperty("inward_sup")
public InwardSupplies inwardSupplies;
@JsonProperty("intr_ltfee")
public InterestLateFeeData interestLateFeeData;
}
package ibase.webitm.bean.gst;
public class GSTR3BCommonData
{
public String type;
public String placeOfSupply;
public double taxableAmount;
public double igstAmount;
public double cgstAmount;
public double sgstAmount;
public double cessAmount;
public double interSuppliesAmount;
public double intraSuppliesAmount;
}
package ibase.webitm.bean.gst;
public class ITCData extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
import java.util.List;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import ibase.webitm.util.gst.ITCEligibiltySerailizer;
@JsonSerialize(using = ITCEligibiltySerailizer.class)
public class ITCEligibilty
{
public List<ITCData> itcAvailable;
public List<ITCData> itcReversed;
public ITCData netITCAvailable;
public List<ITCData> itcIneligible;
}
package ibase.webitm.bean.gst;
import java.util.List;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import ibase.webitm.util.gst.InterStateSuppliesSerailizer;
@JsonSerialize(using = InterStateSuppliesSerailizer.class)
public class InterStateSupplies
{
public List<InterStateSuppliesData> interUnregisterSuppliesData;
public List<InterStateSuppliesData> compositionSuppliesData;
public List<InterStateSuppliesData> uinSuppliesData;
}
package ibase.webitm.bean.gst;
public class InterStateSuppliesData extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import ibase.webitm.util.gst.InterestLateFeeDataSerailizer;
@JsonSerialize(using = InterestLateFeeDataSerailizer.class)
public class InterestLateFeeData extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
import java.util.List;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import ibase.webitm.util.gst.InwardSuppliesSerailizer;
@JsonSerialize(using = InwardSuppliesSerailizer.class)
public class InwardSupplies
{
public List<InwardSuppliesDetails> inwardSuppliesDetails;
}
package ibase.webitm.bean.gst;
public class InwardSuppliesDetails extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
public class InwardSuppliesUnderRevCharge extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
public class OutwardExempetedSupplies extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
public class OutwardNonGSTSupplies extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
public class OutwardSuppliesDetails extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
public class OutwardZeroRatedSupplies extends GSTR3BCommonData
{
}
package ibase.webitm.bean.gst;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import ibase.webitm.util.gst.SuppliesDetailsSerailizer;
@JsonSerialize(using = SuppliesDetailsSerailizer.class)
public class SuppliesDetails
{
public OutwardSuppliesDetails outwardSuppliesDetails;
public OutwardZeroRatedSupplies outwardZeroRatedSupplies;
public OutwardExempetedSupplies outwardExempetedSupplies;
public InwardSuppliesUnderRevCharge inwardSuppliesUnderRevCharge;
public OutwardNonGSTSupplies outwardNonGSTSupplies;
}
......@@ -50,6 +50,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
private String GSTR2_URL_V2 = "";
private String GSTR1_URL_V3 = "";
private String GSTR2_URL_V3 = "";
private String GSTR3B_URL_V3 = "";
private final String APPLICATION_JSON = "application/json";
private String appKey = "";
String ipAddress = "";
......@@ -130,6 +131,11 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
GSTR2_URL_V3 = rs.getString("SERVICE_URI");
}
break;
case "gstr3b_url_v3" :
{
GSTR3B_URL_V3 = rs.getString("SERVICE_URI");
}
break;
}
}
if(pstmt!=null)
......@@ -149,6 +155,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
System.out.println("GSTR2_URL_V2["+GSTR2_URL_V2+"]");
System.out.println("GSTR1_URL_V3["+GSTR1_URL_V3+"]");
System.out.println("GSTR2_URL_V3["+GSTR2_URL_V3+"]");
System.out.println("GSTR3B_URL_V3["+GSTR3B_URL_V3+"]");
}
catch (Exception e)
......@@ -329,86 +336,32 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
recType = "1";
if("SUBMIT".equalsIgnoreCase(action.trim()))
{
boolean isPendingDataFound = false;
retXML = "<pending_data>";
sql = "SELECT DOC_NO, DOC_DATE, AMOUNT FROM GST_DATA_HDR WHERE REC_TYPE = '1' AND SUBMIT_STATUS = 'P' AND PRD_CODE = ? AND SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, periodCode);
pstmt.setString(2, siteCode);
rs = pstmt.executeQuery();
while(rs.next())
{
isPendingDataFound = true;
retXML += "<data>";
retXML += "<doc_no><![CDATA["+checkNull(rs.getString("DOC_NO"))+"]]></doc_no>";
retXML += "<doc_date><![CDATA["+checkNull(rs.getString("DOC_DATE"))+"]]></doc_date>";
retXML += "<amount><![CDATA["+rs.getDouble("AMOUNT")+"]]></amount>";
retXML += "</data>";
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
retXML += "</pending_data>";
if(!isPendingDataFound)
{
retXML = "";
}
retXML += getPendingData(recType, siteCode, periodCode, conn);
}
else if("FILE".equalsIgnoreCase(action.trim()))
{
boolean isSignConfigFound = false;
signDataXML = "<sign_data>";
sql = "SELECT SIGN_METHOD,DOC_TYPE FROM USER_SIGN_ACC WHERE USER_ID = ? AND DOC_TYPE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
pstmt.setString(2, returnType.trim());
rs = pstmt.executeQuery();
while(rs.next())
{
isSignConfigFound = true;
signDataXML += "<data>";
signDataXML += "<sign_method><![CDATA["+checkNull(rs.getString("SIGN_METHOD"))+"]]></sign_method>";
signDataXML += "<doc_type><![CDATA["+checkNull(rs.getString("DOC_TYPE"))+"]]></doc_type>";
signDataXML += "</data>";
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
signDataXML += "</sign_data>";
if(!isSignConfigFound)
{
signDataXML = "";
}
signDataXML = getSignConfig(loginCode, returnType, conn);
}
}
else if("GSTR2".equalsIgnoreCase(returnType))
{
recType = "2";
if("SUBMIT".equalsIgnoreCase(action.trim()))
{
retXML += getPendingData(recType, siteCode, periodCode, conn);
}
else if("FILE".equalsIgnoreCase(action.trim()))
{
signDataXML = getSignConfig(loginCode, returnType, conn);
}
}
else if("GSTR3".equalsIgnoreCase(returnType))
else if("GSTR3".equalsIgnoreCase(returnType) || "GSTR3B".equalsIgnoreCase(returnType))
{
recType = "3";
if("FILE".equalsIgnoreCase(action.trim()))
{
signDataXML = getSignConfig(loginCode, returnType, conn);
}
}
transactionId = UUID.randomUUID().toString().replaceAll("-", "");
......@@ -576,6 +529,33 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
retXML += downloadGstr2Data(gstinNo, periodCode, authToken, userName, stateCode, appKeyEncryptedAndCoded, xtraParams, authSEK);
}
}
if("GSTR3B".equalsIgnoreCase(returnType))
{
if("SUBMIT".equalsIgnoreCase(action))
{
summaryDataJsonStr += getGstr3bSummary(authToken, stateCode, userName, gstinNo, periodCode, authSEK, appKeyEncryptedAndCoded, xtraParams, conn);
if(summaryDataJsonStr!= null && summaryDataJsonStr.trim().length() > 0 && summaryDataJsonStr.indexOf("Message :") == -1)
{
retXML += "<summary_data>" + XML.toString(new JSONObject(summaryDataJsonStr)) + "</summary_data>";
}
else if(summaryDataJsonStr.indexOf("Message :") >= 0)
{
retXML += summaryDataJsonStr;
}
}
else if("FILE".equalsIgnoreCase(action))
{
summaryDataJsonStr += getGstr3bSummary(authToken, stateCode, userName, gstinNo, periodCode, authSEK, appKeyEncryptedAndCoded, xtraParams, conn);
if(summaryDataJsonStr!= null && summaryDataJsonStr.trim().length() > 0 && summaryDataJsonStr.indexOf("Message :") == -1)
{
retXML += "<summary_data>" + XML.toString(new JSONObject(summaryDataJsonStr)) + "</summary_data>";
}
else if(summaryDataJsonStr.indexOf("Message :") >= 0)
{
retXML += summaryDataJsonStr;
}
}
}
}
valueXmlString.append("<Detail2 domID='1'>");
......@@ -2031,6 +2011,231 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
return retString;
}
private String getGstr3bSummary(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSek, String appKeyEncryptedAndCoded, String xtraParams, Connection conn) throws ITMException
{
String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
String siteCode = "", loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= "";
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
HttpRequest getGstr3bSumryReq = Unirest.get(String.format("%s%s", GSP_API_URL, GSTR3B_URL_V3))
.queryString("action","RETSUM")
.queryString("gstin", gstin)
.queryString("ret_period", periodCode)
.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", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.getHttpRequest();
System.out.println("get GSTR3B summary url["+getGstr3bSumryReq.getUrl()+"]");
System.out.println("get GSTR3B summary method["+getGstr3bSumryReq.getHttpMethod()+"]");
System.out.println("get GSTR3B summary invoices request header["+getGstr3bSumryReq.getHeaders()+"]");
HttpResponse<JsonNode> getGstr3bSumryResp = getGstr3bSumryReq.asJson();
System.out.println(String.format("getGstr3bSumryResp Request : Status[%s] Response[%s]", getGstr3bSumryResp.getStatus(), getGstr3bSumryResp.getBody()));
if (getGstr3bSumryResp.getStatus() == 200)
{
JSONObject getGstr3bSumryRespObj = getGstr3bSumryResp.getBody().getObject();
if(getGstr3bSumryRespObj.has("data") && getGstr3bSumryRespObj.has("rek"))
{
callStatus = "1";
String gstr3bSumrydata = getGstr3bSumryRespObj.getString("data");
String gstr3bSumryrek = getGstr3bSumryRespObj.getString("rek");
byte[] apiEK = aesEncryption.decrypt(gstr3bSumryrek, authSek);
String respJsoninBase64 = new String(aesEncryption.decrypt(gstr3bSumrydata, apiEK));
byte[] respJsonInBytes = aesEncryption.decodeBase64StringTOByte(respJsoninBase64);
JSONObject gstr3bSumryJsonObj = new JSONObject(new String(respJsonInBytes));
retString = gstr3bSumryJsonObj.toString();
System.out.println("retString in getGstr3bSummary["+retString+"]");
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr3bSumryResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
//retString = getError(errMsg, "GSTAPIERR", conn);
retString = errMsg;
}
}
else if(getGstr3bSumryResp.getStatus() == 500)
{
callStatus = "2";
errMsg = "Message : Error occurred at GSTN server \nResponse code : "+getGstr3bSumryResp.getStatus();
responseJsonStr = errMsg;
//retString = getError(errMsg, "GSTAPIERR", conn);
retString = errMsg;
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr3bSumryResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
//retString = getError(errMsg, "GSTAPIERR", conn);
retString = errMsg;
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSUM");
apiCallData.setRecType("3");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
catch(Exception e)
{
System.out.println("GSTDataSubmitWiz.getGstr3bSummary()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private String getPendingData(String recType, String siteCode, String periodCode, Connection conn) throws ITMException
{
String retString = "";
boolean isPendingDataFound = false;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
retString = "<pending_data>";
sql = "SELECT DOC_NO, DOC_DATE, AMOUNT FROM GST_DATA_HDR WHERE REC_TYPE = ? AND SUBMIT_STATUS = 'P' AND PRD_CODE = ? AND SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, recType);
pstmt.setString(2, periodCode);
pstmt.setString(3, siteCode);
rs = pstmt.executeQuery();
while(rs.next())
{
isPendingDataFound = true;
retString += "<data>";
retString += "<doc_no><![CDATA["+checkNull(rs.getString("DOC_NO"))+"]]></doc_no>";
retString += "<doc_date><![CDATA["+checkNull(rs.getString("DOC_DATE"))+"]]></doc_date>";
retString += "<amount><![CDATA["+rs.getDouble("AMOUNT")+"]]></amount>";
retString += "</data>";
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
retString += "</pending_data>";
if(!isPendingDataFound)
{
retString = "";
}
}
catch(Exception e)
{
System.out.println("GSTDataSubmitWizEJB.getPendingData()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private String getSignConfig(String loginCode, String returnType, Connection conn) throws ITMException
{
String retString = "";
boolean isSignConfigFound = false;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
retString = "<sign_data>";
sql = "SELECT SIGN_METHOD,DOC_TYPE FROM USER_SIGN_ACC WHERE USER_ID = ? AND DOC_TYPE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
pstmt.setString(2, returnType.trim());
rs = pstmt.executeQuery();
while(rs.next())
{
isSignConfigFound = true;
retString += "<data>";
retString += "<sign_method><![CDATA["+checkNull(rs.getString("SIGN_METHOD"))+"]]></sign_method>";
retString += "<doc_type><![CDATA["+checkNull(rs.getString("DOC_TYPE"))+"]]></doc_type>";
retString += "</data>";
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
retString += "</sign_data>";
if(!isSignConfigFound)
{
retString = "";
}
}
catch(Exception e)
{
System.out.println("GSTDataSubmitWizEJB.getSignConfig()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private String checkNull(String input)
{
if (input==null)
......
......@@ -57,16 +57,30 @@ import ibase.webitm.bean.gst.DocIssued;
import ibase.webitm.bean.gst.EXP;
import ibase.webitm.bean.gst.GSTR1;
import ibase.webitm.bean.gst.GSTR2;
import ibase.webitm.bean.gst.GSTR3B;
import ibase.webitm.bean.gst.HSN;
import ibase.webitm.bean.gst.HSNDetails;
import ibase.webitm.bean.gst.IMPG;
import ibase.webitm.bean.gst.IMPS;
import ibase.webitm.bean.gst.ITCData;
import ibase.webitm.bean.gst.ITCEligibilty;
import ibase.webitm.bean.gst.InterNilSupplies;
import ibase.webitm.bean.gst.InterStateSupplies;
import ibase.webitm.bean.gst.InterStateSuppliesData;
import ibase.webitm.bean.gst.InterestLateFeeData;
import ibase.webitm.bean.gst.IntraNilSupplies;
import ibase.webitm.bean.gst.InvLineItem;
import ibase.webitm.bean.gst.Invoice;
import ibase.webitm.bean.gst.InwardSupplies;
import ibase.webitm.bean.gst.InwardSuppliesDetails;
import ibase.webitm.bean.gst.InwardSuppliesUnderRevCharge;
import ibase.webitm.bean.gst.Nil;
import ibase.webitm.bean.gst.NilInwardSupplies;
import ibase.webitm.bean.gst.OutwardExempetedSupplies;
import ibase.webitm.bean.gst.OutwardNonGSTSupplies;
import ibase.webitm.bean.gst.OutwardSuppliesDetails;
import ibase.webitm.bean.gst.OutwardZeroRatedSupplies;
import ibase.webitm.bean.gst.SuppliesDetails;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
......@@ -89,6 +103,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
private String GSTR1_URL_V3 = "";
private String GSTR2_URL_V3 = "";
private String GSTR2A_URL_V3 = "";
private String GSTR3B_URL_V3 = "";
private final String APPLICATION_JSON = "application/json";
private String appKey = "";
String ipAddress = "";
......@@ -179,6 +194,11 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
GSTR2A_URL_V3 = rs.getString("SERVICE_URI");
}
break;
case "gstr3b_url_v3" :
{
GSTR3B_URL_V3 = rs.getString("SERVICE_URI");
}
break;
}
}
if(pstmt!=null)
......@@ -198,6 +218,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
System.out.println("GSTR2_URL_V2["+GSTR2_URL_V2+"]");
System.out.println("GSTR1_URL_V3["+GSTR1_URL_V3+"]");
System.out.println("GSTR2_URL_V3["+GSTR2_URL_V3+"]");
System.out.println("GSTR2A_URL_V3["+GSTR2A_URL_V3+"]");
System.out.println("GSTR3B_URL_V3["+GSTR3B_URL_V3+"]");
}
catch (Exception e)
{
......@@ -491,14 +513,14 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{
retString = saveGstr1(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, currentYearTurnover, authSEK, xtraParams, conn);
}
else if ("FILE".equalsIgnoreCase(action))
{
retString = fileGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, summaryData, signedData, panNo, aadhaarNo, signMethod, xtraParams, conn);
}
else if ("SUBMIT".equalsIgnoreCase(action))
{
retString = submitGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, xtraParams, conn);
}
else if ("FILE".equalsIgnoreCase(action))
{
retString = fileGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, summaryData, signedData, panNo, aadhaarNo, signMethod, xtraParams, conn);
}
}
else if("GSTR2A".equalsIgnoreCase(returnsType))
{
......@@ -513,13 +535,28 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{
retString = saveGstr2(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, currentYearTurnover, authSEK, xtraParams, conn);
}
else if ("SUBMIT".equalsIgnoreCase(action))
{
retString = submitGstr2(authToken, stateCode, userName, gstin, periodCode, authSEK, xtraParams, conn);
}
else if ("FILE".equalsIgnoreCase(action))
{
retString = fileGstr2(authToken, stateCode, userName, gstin, periodCode, authSEK, summaryData, signedData, panNo, aadhaarNo, signMethod, xtraParams, conn);
}
else if ("SUBMIT".equalsIgnoreCase(action))
}
else if("GSTR3B".equalsIgnoreCase(returnsType))
{
if("SAVE".equalsIgnoreCase(action))
{
retString = submitGstr2(authToken, stateCode, userName, gstin, periodCode, authSEK, xtraParams, conn);
retString = saveGstr3b(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, currentYearTurnover, authSEK, xtraParams, conn);
}
else if("SUBMIT".equalsIgnoreCase(action))
{
retString = submitGstr3b(authToken, stateCode, userName, gstin, periodCode, authSEK, xtraParams, conn);
}
else if("FILE".equalsIgnoreCase(action))
{
retString = fileGstr3b(authToken, stateCode, userName, gstin, periodCode, authSEK, summaryData, signedData, panNo, aadhaarNo, signMethod, xtraParams, conn);
}
}
}
......@@ -3499,6 +3536,458 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
return retString;
}
private String saveGstr3b(String authToken, String siteCode, String stateCode, String userName, String gstin, String periodCode, String grossTurnover, String currentYearTurnover, byte[] authSek, String xtraParams, Connection conn) throws ITMException
{
String retString = "";
GSTR3B gstr3b = null;
List<InterStateSuppliesData> interStateSuppliesDataList = new ArrayList<InterStateSuppliesData>();
List<ITCData> itcAvlDataList = new ArrayList<ITCData>();
List<ITCData> itcRevDataList = new ArrayList<ITCData>();
List<ITCData> itcInelgDataList = new ArrayList<ITCData>();
List<InwardSuppliesDetails> inwardSuppliesList = new ArrayList<InwardSuppliesDetails>();
try
{
OutwardSuppliesDetails outwardSuppliesDetails = new OutwardSuppliesDetails();
outwardSuppliesDetails.taxableAmount = 25000;
outwardSuppliesDetails.igstAmount = 1200;
outwardSuppliesDetails.cgstAmount = 1000;
outwardSuppliesDetails.sgstAmount = 1000;
outwardSuppliesDetails.cessAmount = 200;
OutwardZeroRatedSupplies outwardZeroRatedSupplies = new OutwardZeroRatedSupplies();
outwardZeroRatedSupplies.taxableAmount = 12000;
outwardZeroRatedSupplies.igstAmount = 1000;
outwardZeroRatedSupplies.cessAmount = 250;
OutwardExempetedSupplies outwardExempetedSupplies = new OutwardExempetedSupplies();
outwardExempetedSupplies.taxableAmount = 60000;
InwardSuppliesUnderRevCharge inwardSuppliesUnderRevCharge = new InwardSuppliesUnderRevCharge();
inwardSuppliesUnderRevCharge.taxableAmount = 25000;
inwardSuppliesUnderRevCharge.igstAmount = 1200;
inwardSuppliesUnderRevCharge.cgstAmount = 1000;
inwardSuppliesUnderRevCharge.sgstAmount = 1000;
inwardSuppliesUnderRevCharge.cessAmount = 200;
OutwardNonGSTSupplies outwardNonGSTSupplies = new OutwardNonGSTSupplies();
outwardNonGSTSupplies.taxableAmount = 35000;
SuppliesDetails suppliesDetails = new SuppliesDetails();
suppliesDetails.outwardSuppliesDetails = outwardSuppliesDetails;
suppliesDetails.outwardZeroRatedSupplies = outwardZeroRatedSupplies;
suppliesDetails.outwardExempetedSupplies = outwardExempetedSupplies;
suppliesDetails.inwardSuppliesUnderRevCharge = inwardSuppliesUnderRevCharge;
suppliesDetails.outwardNonGSTSupplies = outwardNonGSTSupplies;
InterStateSuppliesData interStateSuppliesData = new InterStateSuppliesData();
interStateSuppliesData.placeOfSupply = "01";
interStateSuppliesData.taxableAmount = 12000;
interStateSuppliesData.igstAmount = 1200;
interStateSuppliesDataList.add(interStateSuppliesData);
interStateSuppliesData = new InterStateSuppliesData();
interStateSuppliesData.placeOfSupply = "27";
interStateSuppliesData.taxableAmount = 150000;
interStateSuppliesData.igstAmount = 12000;
interStateSuppliesDataList.add(interStateSuppliesData);
interStateSuppliesData = new InterStateSuppliesData();
interStateSuppliesData.placeOfSupply = "29";
interStateSuppliesData.taxableAmount = 18000;
interStateSuppliesData.igstAmount = 1000;
interStateSuppliesDataList.add(interStateSuppliesData);
InterStateSupplies interStateSupplies = new InterStateSupplies();
interStateSupplies.interUnregisterSuppliesData = interStateSuppliesDataList;
interStateSupplies.compositionSuppliesData = interStateSuppliesDataList;
interStateSupplies.uinSuppliesData = interStateSuppliesDataList;
ITCData itcData = new ITCData();
itcData.type = "IMPG";
itcData.igstAmount = 136.53;
itcData.cgstAmount = 274;
itcData.sgstAmount = 162.99;
itcData.cessAmount = 103;
itcAvlDataList.add(itcData);
itcData = new ITCData();
itcData.type = "IMPS";
itcData.igstAmount = 136.53;
itcData.cgstAmount = 274;
itcData.sgstAmount = 162.99;
itcData.cessAmount = 103;
itcAvlDataList.add(itcData);
itcData = new ITCData();
itcData.type = "ISRC";
itcData.igstAmount = 136.53;
itcData.cgstAmount = 274;
itcData.sgstAmount = 162.99;
itcData.cessAmount = 103;
itcAvlDataList.add(itcData);
itcData = new ITCData();
itcData.type = "OTH";
itcData.igstAmount = 136.53;
itcData.cgstAmount = 274;
itcData.sgstAmount = 162.99;
itcData.cessAmount = 103;
itcAvlDataList.add(itcData);
itcRevDataList.add(itcData);
itcInelgDataList.add(itcData);
itcData = new ITCData();
itcData.type = "RUL";
itcData.igstAmount = 136.53;
itcData.cgstAmount = 274;
itcData.sgstAmount = 162.99;
itcData.cessAmount = 103;
itcRevDataList.add(itcData);
itcInelgDataList.add(itcData);
ITCData netITCData = new ITCData();
netITCData.igstAmount = 136.53;
netITCData.cgstAmount = 274;
netITCData.sgstAmount = 162.99;
netITCData.cessAmount = 103;
ITCEligibilty itcEligibility = new ITCEligibilty();
itcEligibility.itcAvailable = itcAvlDataList;
itcEligibility.itcReversed = itcRevDataList;
itcEligibility.netITCAvailable = netITCData;
itcEligibility.itcIneligible = itcInelgDataList;
InwardSuppliesDetails inwardSuppliesDetails = new InwardSuppliesDetails();
inwardSuppliesDetails.type = "GST";
inwardSuppliesDetails.interSuppliesAmount = 1000;
inwardSuppliesDetails.intraSuppliesAmount = 2000;
inwardSuppliesList.add(inwardSuppliesDetails);
inwardSuppliesDetails = new InwardSuppliesDetails();
inwardSuppliesDetails.type = "NONGST";
inwardSuppliesDetails.interSuppliesAmount = 1000;
inwardSuppliesDetails.intraSuppliesAmount = 2000;
inwardSuppliesList.add(inwardSuppliesDetails);
InwardSupplies inwardSupplies = new InwardSupplies();
inwardSupplies.inwardSuppliesDetails = inwardSuppliesList;
InterestLateFeeData interestLateFeeData = new InterestLateFeeData();
interestLateFeeData.igstAmount = 10;
interestLateFeeData.cgstAmount = 20;
interestLateFeeData.sgstAmount = 30;
interestLateFeeData.cessAmount = 40;
gstr3b = new GSTR3B();
gstr3b.gstin = gstin;
gstr3b.financialPeriod = periodCode;
gstr3b.supplyDetails = suppliesDetails;
gstr3b.interStateSupplies = interStateSupplies;
gstr3b.itcEligibility = itcEligibility;
gstr3b.inwardSupplies = inwardSupplies;
gstr3b.interestLateFeeData = interestLateFeeData;
ObjectMapper objectMapper = new ObjectMapper();
String gstr3bJsonPayloadStr = objectMapper.writeValueAsString(gstr3b);
System.out.println("gstr3bJsonPayloadStr["+gstr3bJsonPayloadStr+"]");
}
catch(Exception e)
{
System.out.println("GSTDataSubmitWizPos.saveGstr3b()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private String submitGstr3b(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSEK, String xtraParams,Connection conn) throws ITMException
{
String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
String loginCode = "", chgTerm = "", siteCode = "", callStatus = "", responseJsonStr = "", responseId = "";
String sql = "";
PreparedStatement pstmt = null;
int updateCnt = 0;
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
String json = "{\"gstin\":\""+gstin+"\",\"ret_period\":\""+periodCode+"\"}";
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 reqBody = new JSONObject();
reqBody.put("action", "RETSUBMIT");
reqBody.put("data", encryptedPayload);
reqBody.put("hmac", new String(Base64.getEncoder().encode(resBuf)));
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
HttpRequest gstr3bSubmitReq = Unirest.post(String.format("%s%s", GSP_API_URL, GSTR3B_URL_V3))
.header("Content-Type", APPLICATION_JSON)
.header("action", "RETSUBMIT")
.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", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(reqBody.toString()))
.getHttpRequest();
System.out.println("RETSUBMIT GSTR3B url["+gstr3bSubmitReq.getUrl()+"]");
System.out.println("RETSUBMIT GSTR3B method["+gstr3bSubmitReq.getHttpMethod()+"]");
System.out.println("RETSUBMIT GSTR3B request header["+gstr3bSubmitReq.getHeaders()+"]");
System.out.println("RETSUBMIT GSTR3B request payload["+IOUtils.toString(gstr3bSubmitReq.getBody().getEntity().getContent())+"]");
HttpResponse<JsonNode> gstr3bSubmitResp = gstr3bSubmitReq.asJson();
System.out.println(String.format("gstr3bSubmitResp Request : Status[%s] Response[%s]", gstr3bSubmitResp.getStatus(), gstr3bSubmitResp.getBody()));
if (gstr3bSubmitResp.getStatus() == 200)
{
JSONObject gstr3bSubmitRespObj = gstr3bSubmitResp.getBody().getObject();
if(gstr3bSubmitRespObj.has("data") && gstr3bSubmitRespObj.has("rek"))
{
callStatus = "1";
String gstr3bSubmitdata = gstr3bSubmitRespObj.getString("data");
String gstr3bSubmitrek = gstr3bSubmitRespObj.getString("rek");
byte[] apiEK = aesEncryption.decrypt(gstr3bSubmitrek, authSEK);
String respJsoninBase64 = new String(aesEncryption.decrypt(gstr3bSubmitdata, apiEK));
byte[] respJsonInBytes = aesEncryption.decodeBase64StringTOByte(respJsoninBase64);
JSONObject gstr3bSubmitObj = new JSONObject(new String(respJsonInBytes));
String transId = gstr3bSubmitObj.getString("reference_id");
responseId = transId;
System.out.println("transId to getStatus after SUBMIT call["+transId+"]");
//TODO need to check
/*sql = "UPDATE GST_DATA_HDR SET SUBMIT_STATUS = ? AND SUBMIT_DATE = ? WHERE PRD_CODE = ? AND SITE_CODE = ? AND REC_TYPE = '1'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "S");
pstmt.setTimestamp(2, java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(new Date(), e12GenericUtility.getDBDateTimeFormat())));
pstmt.setString(3, periodCode);
pstmt.setString(4, siteCode);
updateCnt = pstmt.executeUpdate();
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
System.out.println("submit status updated of ["+siteCode+"] for ["+periodCode+"] update count ["+updateCnt+"]");*/
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr3bSubmitResp.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(gstr3bSubmitResp.getStatus() == 500)
{
callStatus = "2";
errMsg = "Message : Error occurred at GSTN server \nResponse code : "+gstr3bSubmitResp.getStatus();
responseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr3bSubmitResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSUBMIT");
apiCallData.setRecType("3");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
catch(Exception e)
{
System.out.println("GSTDataSubmitWizPos.submitGstr3b()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private String fileGstr3b(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSek, String summaryData, String signedData, String panNo, String aadhaarNo, String signMethod, String xtraParams, Connection conn) throws ITMException
{
String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = "", signType = "",signId = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
String loginCode = "", chgTerm = "", siteCode = "", callStatus = "", responseJsonStr = "";
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
byte[] jsonBase64 = Base64.getEncoder().encode(summaryData.toString().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);
if("D".equalsIgnoreCase(signMethod))
{
signType = "DSC";
signId = panNo;
}
else if("E".equalsIgnoreCase(signMethod))
{
signType = "ESIGN";
signId = aadhaarNo;
}
JSONObject fileGstr3bDataJsonObj = new JSONObject();
fileGstr3bDataJsonObj.put("action", "RETFILE");
fileGstr3bDataJsonObj.put("data", encryptedPayload);
fileGstr3bDataJsonObj.put("hmac", new String(Base64.getEncoder().encode(resBuf)));
fileGstr3bDataJsonObj.put("sign", signedData);
fileGstr3bDataJsonObj.put("st", signType);
fileGstr3bDataJsonObj.put("sid", signId);
HttpRequest fileGstr3bReq = Unirest.post(String.format("%s%s", GSP_API_URL, GSTR3B_URL_V3))
.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", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.body(new JsonNode(fileGstr3bDataJsonObj.toString()))
.getHttpRequest();
System.out.println("FILE GSTR3B url["+fileGstr3bReq.getUrl()+"]");
System.out.println("FILE GSTR3B method["+fileGstr3bReq.getHttpMethod()+"]");
System.out.println("FILE GSTR3B request header["+fileGstr3bReq.getHeaders()+"]");
System.out.println("FILE GSTR3B request payload["+IOUtils.toString(fileGstr3bReq.getBody().getEntity().getContent())+"]");
HttpResponse<JsonNode> fileGstr3bResp = fileGstr3bReq.asJson();
System.out.println(String.format("fileGstr3bResp Request : Status[%s] Response[%s]", fileGstr3bResp.getStatus(), fileGstr3bResp.getBody()));
if (fileGstr3bResp.getStatus() == 200)
{
JSONObject fileGstr3bRespObj = fileGstr3bResp.getBody().getObject();
if(fileGstr3bRespObj.has("data") && fileGstr3bRespObj.has("rek"))
{
callStatus = "1";
String fileGstr3bData = fileGstr3bRespObj.getString("data");
String fileGstr3bRek = fileGstr3bRespObj.getString("rek");
byte[] fileGstr3bApiEK = aesEncryption.decrypt(fileGstr3bRek, authSek);
String fileGstr3bJsoninBase64 = new String(aesEncryption.decrypt(fileGstr3bData, fileGstr3bApiEK));
byte[] fileGstr3bJsonInBytes = aesEncryption.decodeBase64StringTOByte(fileGstr3bJsoninBase64);
System.out.println(new String(fileGstr3bJsonInBytes));
}
else
{
callStatus = "2";
JSONObject errorJSON = fileGstr3bResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = fileGstr3bResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETFILE");
apiCallData.setRecType("3");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId("");
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
catch(Exception e)
{
System.out.println("GSTDataSubmitWizPos.fileGstr3b()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private void insertB2BInvoiceData(String stateCode, String periodCode, String siteCode, JSONObject gstr2InvoiceJsonObj, String xtraParams, Connection conn) throws ITMException
{
JSONArray b2bInvArry = new JSONArray();
......
......@@ -47,7 +47,10 @@ public class CDNRSerializer extends JsonSerializer<CDNR>
json.writeStringField("inum", cdnDetails.invoiceNumber);
json.writeStringField("idt", gstFmt.format(cdnDetails.invoiceDate));
json.writeNumberField("val", cdnDetails.val);
json.writeStringField("rsn", cdnDetails.reason);
if(cdnDetails.reason != null && cdnDetails.reason.trim().length()>0)
{
json.writeStringField("rsn", cdnDetails.reason);
}
json.writeStringField("p_gst", cdnDetails.isPreGSTInvoice ? "Y" : "N");
writeCDNLineItems(cdnDetails, json);
......
......@@ -35,7 +35,10 @@ public class CDNURSerializer extends JsonSerializer<CDNUR>
json.writeStringField("inum", cdnur.invoiceNumber);
json.writeStringField("idt", gstFmt.format(cdnur.invoiceDate));
json.writeNumberField("val", cdnur.val);
json.writeStringField("rsn", cdnur.reason);
if(cdnur.reason != null && cdnur.reason.trim().length() > 0)
{
json.writeStringField("rsn", cdnur.reason);
}
json.writeStringField("p_gst", cdnur.isPreGSTInvoice ? "Y" : "N");
writeLineItems(cdnur.items, json);
......
package ibase.webitm.util.gst;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import ibase.webitm.bean.gst.GSTR3B;
public class GSTR3BSerailizer extends JsonSerializer<GSTR3B>
{
@Override
public void serialize(GSTR3B gstr3b, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException
{
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("gstin", gstr3b.gstin);
jsonGenerator.writeStringField("fp", gstr3b.financialPeriod);
if(gstr3b.supplyDetails != null)
{
jsonGenerator.writeObjectField("sup_details", gstr3b.supplyDetails);
}
if(gstr3b.interStateSupplies != null)
{
jsonGenerator.writeObjectField("inter_sup", gstr3b.interStateSupplies);
}
if(gstr3b.itcEligibility != null)
{
jsonGenerator.writeObjectField("itc_elg", gstr3b.itcEligibility);
}
if(gstr3b.inwardSupplies != null)
{
jsonGenerator.writeObjectField("inward_sup", gstr3b.inwardSupplies);
}
if(gstr3b.interestLateFeeData != null)
{
jsonGenerator.writeObjectField("intr_ltfee", gstr3b.interestLateFeeData);
}
jsonGenerator.writeEndObject();
}
}
package ibase.webitm.util.gst;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import ibase.webitm.bean.gst.ITCData;
import ibase.webitm.bean.gst.ITCEligibilty;
public class ITCEligibiltySerailizer extends JsonSerializer<ITCEligibilty>
{
@Override
public void serialize(ITCEligibilty itcEligiblity, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException
{
if(itcEligiblity != null)
{
json.writeStartObject();
if(itcEligiblity.itcAvailable != null)
{
json.writeFieldName("itc_avl");
json.writeStartArray();
for(ITCData eachData : itcEligiblity.itcAvailable)
{
json.writeStartObject();
json.writeStringField("ty", eachData.type);
json.writeNumberField("iamt", eachData.igstAmount);
json.writeNumberField("camt", eachData.cgstAmount);
json.writeNumberField("samt", eachData.sgstAmount);
json.writeNumberField("csamt", eachData.cessAmount);
json.writeEndObject();
}
json.writeEndArray();
}
if(itcEligiblity.itcReversed != null)
{
json.writeFieldName("itc_rev");
json.writeStartArray();
for(ITCData eachData : itcEligiblity.itcReversed)
{
json.writeStartObject();
json.writeStringField("ty", eachData.type);
json.writeNumberField("iamt", eachData.igstAmount);
json.writeNumberField("camt", eachData.cgstAmount);
json.writeNumberField("samt", eachData.sgstAmount);
json.writeNumberField("csamt", eachData.cessAmount);
json.writeEndObject();
}
json.writeEndArray();
}
if(itcEligiblity.netITCAvailable != null)
{
json.writeFieldName("itc_net");
json.writeStartObject();
json.writeNumberField("iamt", itcEligiblity.netITCAvailable.igstAmount);
json.writeNumberField("camt", itcEligiblity.netITCAvailable.cgstAmount);
json.writeNumberField("samt", itcEligiblity.netITCAvailable.sgstAmount);
json.writeNumberField("csamt", itcEligiblity.netITCAvailable.cessAmount);
json.writeEndObject();
}
if(itcEligiblity.itcIneligible != null)
{
json.writeFieldName("itc_inelg");
json.writeStartArray();
for(ITCData eachData : itcEligiblity.itcIneligible)
{
json.writeStartObject();
json.writeStringField("ty", eachData.type);
json.writeNumberField("iamt", eachData.igstAmount);
json.writeNumberField("camt", eachData.cgstAmount);
json.writeNumberField("samt", eachData.sgstAmount);
json.writeNumberField("csamt", eachData.cessAmount);
json.writeEndObject();
}
json.writeEndArray();
}
json.writeEndObject();
}
}
}
package ibase.webitm.util.gst;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import ibase.webitm.bean.gst.InterStateSupplies;
import ibase.webitm.bean.gst.InterStateSuppliesData;
public class InterStateSuppliesSerailizer extends JsonSerializer<InterStateSupplies>
{
@Override
public void serialize(InterStateSupplies interStateSupplies, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException
{
if(interStateSupplies != null)
{
json.writeStartObject();
if(interStateSupplies.interUnregisterSuppliesData!=null)
{
json.writeFieldName("unreg_details");
json.writeStartArray();
for(InterStateSuppliesData eachData : interStateSupplies.interUnregisterSuppliesData)
{
json.writeStartObject();
json.writeStringField("pos", eachData.placeOfSupply);
json.writeNumberField("txval", eachData.taxableAmount);
json.writeNumberField("iamt", eachData.igstAmount);
json.writeNumberField("csamt", eachData.cessAmount);
json.writeEndObject();
}
json.writeEndArray();
}
if(interStateSupplies.compositionSuppliesData!=null)
{
json.writeFieldName("comp_details");
json.writeStartArray();
for(InterStateSuppliesData eachData : interStateSupplies.compositionSuppliesData)
{
json.writeStartObject();
json.writeStringField("pos", eachData.placeOfSupply);
json.writeNumberField("txval", eachData.taxableAmount);
json.writeNumberField("iamt", eachData.igstAmount);
json.writeNumberField("csamt", eachData.cessAmount);
json.writeEndObject();
}
json.writeEndArray();
}
if(interStateSupplies.uinSuppliesData!=null)
{
json.writeFieldName("uin_details");
json.writeStartArray();
for(InterStateSuppliesData eachData : interStateSupplies.uinSuppliesData)
{
json.writeStartObject();
json.writeStringField("pos", eachData.placeOfSupply);
json.writeNumberField("txval", eachData.taxableAmount);
json.writeNumberField("iamt", eachData.igstAmount);
json.writeNumberField("csamt", eachData.cessAmount);
json.writeEndObject();
}
json.writeEndArray();
}
json.writeEndObject();
}
}
}
package ibase.webitm.util.gst;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import ibase.webitm.bean.gst.InterestLateFeeData;
public class InterestLateFeeDataSerailizer extends JsonSerializer<InterestLateFeeData>
{
@Override
public void serialize(InterestLateFeeData interstLateFeeData, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException
{
if(interstLateFeeData != null)
{
json.writeStartObject();
json.writeFieldName("intr_details");
json.writeStartObject();
json.writeNumberField("iamt", interstLateFeeData.igstAmount);
json.writeNumberField("camt", interstLateFeeData.cgstAmount);
json.writeNumberField("samt", interstLateFeeData.sgstAmount);
json.writeNumberField("csamt", interstLateFeeData.cessAmount);
json.writeEndObject();
json.writeEndObject();
}
}
}
package ibase.webitm.util.gst;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import ibase.webitm.bean.gst.InwardSupplies;
import ibase.webitm.bean.gst.InwardSuppliesDetails;
public class InwardSuppliesSerailizer extends JsonSerializer<InwardSupplies>
{
@Override
public void serialize(InwardSupplies inwardSupplies, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException
{
if(inwardSupplies != null)
{
json.writeStartObject();
json.writeFieldName("isup_details");
if(inwardSupplies.inwardSuppliesDetails != null)
{
json.writeStartArray();
for(InwardSuppliesDetails eachData : inwardSupplies.inwardSuppliesDetails)
{
json.writeStartObject();
json.writeStringField("ty", eachData.type);
json.writeNumberField("inter", eachData.interSuppliesAmount);
json.writeNumberField("intra", eachData.intraSuppliesAmount);
json.writeEndObject();
}
json.writeEndArray();
}
json.writeEndObject();
}
}
}
package ibase.webitm.util.gst;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import ibase.webitm.bean.gst.SuppliesDetails;
public class SuppliesDetailsSerailizer extends JsonSerializer<SuppliesDetails>
{
@Override
public void serialize(SuppliesDetails suppliesDetails, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException
{
if(suppliesDetails!= null)
{
json.writeStartObject();
if(suppliesDetails.outwardSuppliesDetails != null)
{
json.writeFieldName("osup_det");
json.writeStartObject();
json.writeNumberField("txval", suppliesDetails.outwardSuppliesDetails.taxableAmount);
json.writeNumberField("iamt", suppliesDetails.outwardSuppliesDetails.igstAmount);
json.writeNumberField("camt", suppliesDetails.outwardSuppliesDetails.cgstAmount);
json.writeNumberField("samt", suppliesDetails.outwardSuppliesDetails.sgstAmount);
json.writeNumberField("csamt", suppliesDetails.outwardSuppliesDetails.cessAmount);
json.writeEndObject();
}
if(suppliesDetails.outwardZeroRatedSupplies != null)
{
json.writeFieldName("osup_zero");
json.writeStartObject();
json.writeNumberField("txval", suppliesDetails.outwardZeroRatedSupplies.taxableAmount);
json.writeNumberField("iamt", suppliesDetails.outwardZeroRatedSupplies.igstAmount);
json.writeNumberField("csamt", suppliesDetails.outwardZeroRatedSupplies.cessAmount);
json.writeEndObject();
}
if(suppliesDetails.outwardExempetedSupplies != null)
{
json.writeFieldName("osup_nil_exmp");
json.writeStartObject();
json.writeNumberField("txval", suppliesDetails.outwardExempetedSupplies.taxableAmount);
json.writeEndObject();
}
if(suppliesDetails.inwardSuppliesUnderRevCharge != null)
{
json.writeFieldName("isup_rev");
json.writeStartObject();
json.writeNumberField("txval", suppliesDetails.inwardSuppliesUnderRevCharge.taxableAmount);
json.writeNumberField("iamt", suppliesDetails.inwardSuppliesUnderRevCharge.igstAmount);
json.writeNumberField("camt", suppliesDetails.inwardSuppliesUnderRevCharge.cgstAmount);
json.writeNumberField("samt", suppliesDetails.inwardSuppliesUnderRevCharge.sgstAmount);
json.writeNumberField("csamt", suppliesDetails.inwardSuppliesUnderRevCharge.cessAmount);
json.writeEndObject();
}
if(suppliesDetails.outwardNonGSTSupplies != null)
{
json.writeFieldName("osup_nongst");
json.writeStartObject();
json.writeNumberField("txval", suppliesDetails.outwardNonGSTSupplies.taxableAmount);
json.writeEndObject();
}
json.writeEndObject();
}
}
}
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