Commit 9a41c097 authored by dpawar's avatar dpawar

generating debit note


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93938 ce508802-f39f-4f6c-b175-0d175dae99d5
parent fcdd74a6
...@@ -15,15 +15,26 @@ import java.sql.ResultSet; ...@@ -15,15 +15,26 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
@Stateless @Stateless
public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeliveryConfLocal,ProofOfDeliveryConfRemote public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeliveryConfLocal,ProofOfDeliveryConfRemote
{ {
String debitNoteTranID=""; String debitNoteTranID="";
boolean isRegPriceNotFound=false; boolean isRegPriceNotFound=false;
double debitNoteHeader=0.0;
boolean isError = false;
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{ {
System.out.println("--------------confirm method of ProofOfDeliveryConf ------------- : "); System.out.println("--------------confirm method of ProofOfDeliveryConf ------------- : ");
...@@ -47,16 +58,17 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -47,16 +58,17 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
private String confirmPOD(String tranId,String xtraParams,String forcedFlag) private String confirmPOD(String tranId,String xtraParams,String forcedFlag)
{ {
System.out.println("---------Class : ProofOfDeliveryConf-->> confirm method called-----------"); System.out.println("---------Class : ProofOfDeliveryConf-->> confirm method called-----------");
tranId=tranId==null ? "" :tranId.trim();
ResultSet rs=null; ResultSet rs=null;
Connection conn=null; Connection conn=null;
ConnDriver ConnDriver = new ConnDriver(); ConnDriver ConnDriver = new ConnDriver();
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
String errString="",sql="",loginSite="",wfStatus="",itemCode="",regulatedPrice="",itemActive=""; String errString="",sql="",loginSite="",wfStatus="",itemCode="",regulatedPrice="",itemActive="";
String itmCodeDt2="",lotNo="",lotSl="", detail2xmlString=""; String itmCodeDt2="",lotNo="",lotSl="", detail2xmlString="";
double invRate=0.0,invQty=0.0,PODrate=0.0,PODqty=0.0,allowedAmt=0.0,stockistAmt=0.0,debitNoteAmtAct=0.0; double aprvRate=0.0,PODrate=0.0,PODqty=0.0,allowedAmt=0.0,stockistAmt=0.0,debitNoteAmtDetail=0.0;
int updCnt=0,lineNo=0; int updCnt=0,lineNo=0;
ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB(); ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB();
HashMap<Integer,Double> mapDebitNoteAmt=new HashMap<Integer,Double>();
try try
{ {
ConnDriver connDriver = null; ConnDriver connDriver = null;
...@@ -108,20 +120,10 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -108,20 +120,10 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
String invoiceId="",custCode="",siteCode="",currCode="",loginCode=""; String invoiceId="",custCode="",siteCode="",currCode="",loginCode="";
double ExchRate=0.0,actualDBamount=0.0; double ExchRate=0.0,actualDBamount=0.0;
loginCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"); loginCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
System.out.println("Login Code ------->> "+loginCode); System.out.println("Login Code ------->> "+loginCode);
sql="";
//emp_code__aprv login code BASE not available in Employee Master
sql="update spl_sales_por_hdr set confirmed = ?,conf_date = ?, emp_code__aprv = ? where tran_id = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y");
pstmt.setDate(2, new java.sql.Date(System.currentTimeMillis()));
pstmt.setString(3,loginCode); //loginCode //"E10808"
pstmt.setString(4, tranId);
updCnt=pstmt.executeUpdate();
if (updCnt > 0)
{
sql=""; sql="";
sql="select invoice_id,cust_code,site_code,curr_code,exch_rate from spl_sales_por_hdr where tran_id = ?"; sql="select invoice_id,cust_code,site_code,curr_code,exch_rate from spl_sales_por_hdr where tran_id = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
...@@ -147,96 +149,73 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -147,96 +149,73 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
} }
sql=""; sql="";
sql="select item_code,rate__inv,quantity__inv,rate__resale,quantity__resale,line_no,lot_no,lot_sl from spl_sales_por_det where tran_id = ?"; sql="select item_code,rate__resale,quantity__resale,aprv_rate,line_no,lot_no,lot_sl " +
"from spl_sales_por_det where tran_id = ? order by line_no";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while(rs.next()) while(rs.next())
{ {
itemCode=rs.getString(1)==null ? "" :rs.getString(1); itemCode=rs.getString(1);
invRate=rs.getDouble(2); PODrate=rs.getDouble(2);
invQty=rs.getDouble(3); PODqty=rs.getDouble(3);
PODrate=rs.getDouble(4); aprvRate=rs.getDouble(4);
PODqty=rs.getDouble(5); lineNo=rs.getInt(5);
lineNo=rs.getInt(6); lotNo=rs.getString(6);
lotNo=rs.getString(7)== null ? "" : rs.getString(7); lotSl=rs.getString(7);
lotSl=rs.getString(8)== null ? "" : rs.getString(8);
System.out.println("lotNo :"+lotNo+"------->> invRate : "+invRate+" invQty : "+invQty+" PODrate : "+PODrate+ " PODqty : "+PODqty);
regulatedPrice=getColumnDescr(conn,"regulated_price","item","item_code",itemCode);
itemActive=getColumnDescr(conn,"active","item","item_code",itemCode);
itemActive =itemActive==null ? "N" : itemActive.trim();
System.out.println("item active -------->>["+itemActive+"]");
//if item code is not active in item master then show error message
if(itemActive.equalsIgnoreCase("N"))
{
errString = itmdbAccess.getErrorString("", "VTITMCNAC", "", "", conn);
System.out.println("---------Error : item code["+itemCode+"] is not active in item master (Transaction Rollback)----------");
conn.rollback();
return errString;
}
//regulatedPrice if null then itemCode=itemCode==null ? "" :itemCode.trim();
if(isRegulatePriceNull(conn,tranId)) lotNo=lotNo==null ? "" :lotNo.trim();
{ lotSl=lotSl==null ? "" :lotSl.trim();
//Error : Regulated price is Null
errString = itmdbAccess.getErrorString("", "VTREGPRCN", "", "", conn);
System.out.println("---------Error : Regulated price is Null (Transaction Rollback)----------"); debitNoteAmtDetail=getDebitNoteAmount(conn, tranId, lineNo,aprvRate,PODrate,PODqty);
conn.rollback(); mapDebitNoteAmt.put(lineNo, debitNoteAmtDetail);
return errString; detail2xmlString=getDetailsXmlString(conn, xtraParams, invoiceId, aprvRate, debitNoteAmtDetail);
}
else
{
System.out.println("isRegPriceNotFound----->> : ["+!(isRegPriceNotFound)+"]");
if (!(isRegPriceNotFound))
{
System.out.println("-----calculation of debit note condition--------");
debitNoteAmtAct=debitNoteCalculation(conn,regulatedPrice,invRate,invQty,PODrate,PODqty,itemCode);
actualDBamount=actualDBamount + debitNoteAmtAct;
detail2xmlString=detail2xmlString + getDetail2xmlString(debitNoteAmtAct,itemCode,PODrate,PODqty,lotNo,lotSl,lineNo,conn);
System.out.println("itemCode : "+itemCode+" Line no -->"+lineNo+" --debitNoteAmtAct ------->>"+debitNoteAmtAct);
}
else
{
errString = itmdbAccess.getErrorString("", "VTDISRPND", "", "", conn);
System.out.println("---------Error : Regulated price not found (Transaction Rollback)----------");
conn.rollback();
return errString;
}
}
} //end while } //end while-------------------@@@@@@@@@@---------------------------------------
System.out.println("Final actualDBamount---------->> : "+actualDBamount); System.out.println("Final actualDBamount---------->> : "+actualDBamount);
if ( actualDBamount > 0) //debitNoteAmtDetail=100.10;
{
System.out.println("-----Debit note generation condition----------"+actualDBamount); System.out.println("-----Debit note generation condition----------"+actualDBamount);
errString=genDebitNote(tranId,invoiceId,custCode,siteCode,xtraParams,actualDBamount,currCode,ExchRate,detail2xmlString, conn); errString=genDebitNote(tranId,invoiceId,custCode,siteCode,xtraParams,actualDBamount,currCode,ExchRate,detail2xmlString, conn);
System.out.println("------@@@Debit Note Generated successfully for amount : "+actualDBamount); System.out.println("------Error string after DN save--->>["+errString+"]");
//conn.commit();
System.out.println("Confirmation of Debit note1212112----------");
MiscDrCrRcpConf confDebitNote=new MiscDrCrRcpConf();
errString=confDebitNote.confirm(debitNoteTranID,xtraParams,"",conn);
System.out.println("Error String on DB Confirmation21212112 : "+errString);
if (errString.indexOf("Success") > -1) if (errString.indexOf("Success") > -1)
{
System.out.println("---COMMITTING--------------");
conn.commit();
System.out.println("Confirmation of Debit note1212112 COMMITED----------");
//MiscDrCrRcpConf confDebitNote=new MiscDrCrRcpConf();
//errString=confDebitNote.confirm(debitNoteTranID,xtraParams,"",conn);
errString = confirmDebitNote("drcrrcp_dr",debitNoteTranID,xtraParams,"",conn);
System.out.println("Error String on DB Confirmation21212112 : "+errString);
if((errString != null ) && errString.indexOf("VTSUCC1") > -1)
{ {
updCnt=updateDebitNoteAmounts(conn,tranId,loginCode,mapDebitNoteAmt);
System.out.println("return count from updateDebitNoteAmounts--->["+updCnt+"]");
if(updCnt > 0){
conn.commit(); conn.commit();
errString = itmdbAccess.getErrorString("", "VTCONSUCF", "", "", conn); errString = itmdbAccess.getErrorString("", "VTCONSUCF", "", "", conn);
System.out.println("------@@@Debit Note Generated successfully for amount : "+actualDBamount); System.out.println("------@@@Debit Note Generated successfully for amount : "+actualDBamount);
System.out.println("Confirmation of Debit note done successfully----------"); System.out.println("Confirmation of Debit note done successfully----------");
}else{
errString = itmdbAccess.getErrorString("", "VTNCONFT", "", "", conn);
conn.rollback();
System.out.println("transaction not confirmed----------");
}
} }
else else{
conn.rollback(); errString = itmdbAccess.getErrorString("", "VTNCONFT", "", "", conn);
conn.rollback();
} }
else }
{ else{
System.out.println("--------Debit note not generated------------- "); errString = itmdbAccess.getErrorString("", "VTNCONFT", "", "", conn);
conn.commit(); conn.rollback();
}
}
}
}
} // end condition for wfstatus ='S'
else else
{ {
conn.rollback(); conn.rollback();
...@@ -250,6 +229,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -250,6 +229,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
se.printStackTrace(); se.printStackTrace();
try try
{ {
isError=true;
conn.rollback(); conn.rollback();
} }
catch(Exception e){ catch(Exception e){
...@@ -260,6 +240,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -260,6 +240,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
{ {
try try
{ {
isError=true;
conn.rollback(); conn.rollback();
} }
catch (Exception e1) catch (Exception e1)
...@@ -284,6 +265,10 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -284,6 +265,10 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
conn.close(); conn.close();
conn=null; conn=null;
} }
if(isError)
{
errString = itmdbAccess.getErrorString("", "VTNCONFT", "", "", conn);
}
} }
catch(Exception e) catch(Exception e)
...@@ -299,9 +284,8 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -299,9 +284,8 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
private String genDebitNote(String tranId,String invoiceId,String custCode,String siteCode ,String xtraParams,double relAmt,String currencyCode,double exchRate,String detail2xmlString, Connection conn) throws ITMException private String genDebitNote(String tranId,String invoiceId,String custCode,String siteCode ,String xtraParams,double relAmt,String currencyCode,double exchRate,String detail2xmlString, Connection conn) throws ITMException
{ {
System.out.println("<--------Inside genDebitNote11----------->"); System.out.println("<--------Inside genDebitNote11----------->");
StringBuffer xmlBuffer = new StringBuffer(); StringBuffer xmlBuff = new StringBuffer();
String xmlString = "", sql="", refNo="", procCode=""; String xmlString = "", sql="", refNo="", procCode="";
String retString=""; String retString="";
GenericUtility genutility=null; GenericUtility genutility=null;
...@@ -309,31 +293,11 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -309,31 +293,11 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
String currAppdate =""; String currAppdate ="";
java.sql.Timestamp currDate = null; java.sql.Timestamp currDate = null;
String itemSer=""; String itemSer="";
String finEntity="",acctCode="",cctrCode="",acctCodetotAR="",cctrCodetotAR="",miscDebitNoteTranID=""; String finEntity="",acctCode="",cctrCode="",acctCodetotAR="",cctrCodetotAR="",dbTranID="";
String acctCodeUDF1="",acctCodeUDF2=""; String acctCodeUDF1="",acctCodeUDF2="",crTerm="";
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ResultSet rs=null;
int count=0; int count=0;
xmlBuffer.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuffer.append("<DocumentRoot>");
xmlBuffer.append("<description>").append("Datawindow Root").append("</description>");
xmlBuffer.append("<group0>");
xmlBuffer.append("<description>").append("Group0 description").append("</description>");
xmlBuffer.append("<Header0>");
xmlBuffer.append("<objName><![CDATA[").append("misc_drcr_rcp_dr").append("]]></objName>");
xmlBuffer.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuffer.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuffer.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuffer.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuffer.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuffer.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuffer.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuffer.append("<taxKeyValue><![CDATA[").append(" ").append("]]></taxKeyValue>");
xmlBuffer.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuffer.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuffer.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuffer.append("<description>").append("Header0 members").append("</description>");
try try
{ {
genutility=GenericUtility.getInstance(); genutility=GenericUtility.getInstance();
...@@ -347,65 +311,75 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -347,65 +311,75 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
cctrCode = getColumnDescr(conn,"cctr_code__ar", "customer", "cust_code", custCode); cctrCode = getColumnDescr(conn,"cctr_code__ar", "customer", "cust_code", custCode);
//acctCodetotAR=getColumnDescr(conn,"ACCT_CODE__TOT_AR", "item_acct_detr", "item_ser", itemSer); //acctCodetotAR=getColumnDescr(conn,"ACCT_CODE__TOT_AR", "item_acct_detr", "item_ser", itemSer);
//cctrCodetotAR=getColumnDescr(conn,"CCTR_CODE__TOT_AR", "item_acct_detr", "item_ser", itemSer); //cctrCodetotAR=getColumnDescr(conn,"CCTR_CODE__TOT_AR", "item_acct_detr", "item_ser", itemSer);
cctrCodetotAR = cctrCodetotAR== null ? " " :cctrCodetotAR; cctrCodetotAR = cctrCodetotAR== null ? " " :cctrCodetotAR;
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuffer.append("<Detail1 objContext =\"1\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">"); xmlBuff.append("<DocumentRoot>\r\n");
xmlBuffer.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>"); xmlBuff.append("<description>").append("Datawindow Root").append("</description>\r\n");
xmlBuffer.append("<tran_id/>"); xmlBuff.append("<group0>\r\n");
xmlBuffer.append("<tran_ser>").append("<![CDATA[").append("MDRCRD").append("]]></tran_ser>\r\n"); xmlBuff.append("<description>").append("Group0 description").append("</description>\r\n");
xmlBuffer.append("<tran_date>").append("<![CDATA[").append(currAppdate).append("]]></tran_date>\r\n"); xmlBuff.append("<Header0>\r\n");
xmlBuffer.append("<eff_date>").append("<![CDATA[").append(currAppdate).append("]]></eff_date>\r\n"); xmlBuff.append("<objName><![CDATA[").append("drcrrcp_dr").append("]]></objName>\r\n");
xmlBuffer.append("<fin_entity>").append("<![CDATA[").append(finEntity).append("]]></fin_entity>\r\n"); xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>\r\n");
xmlBuffer.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]></site_code>\r\n"); xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>\r\n");
xmlBuffer.append("<cctr_code>").append("<![CDATA[").append(cctrCode).append("]]></cctr_code>\r\n"); xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>\r\n");
xmlBuffer.append("<sundry_type>").append("<![CDATA[").append("C").append("]]></sundry_type>\r\n"); xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>\r\n");
xmlBuffer.append("<sundry_code>").append("<![CDATA[").append(custCode).append("]]></sundry_code>\r\n"); xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>\r\n");
xmlBuffer.append("<acct_code>").append("<![CDATA[").append(acctCode).append("]]></acct_code>\r\n"); xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>\r\n");
xmlBuffer.append("<curr_code>").append("<![CDATA[" + currencyCode + "]]>").append("</curr_code>"); xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>\r\n");
xmlBuffer.append("<amount>").append("<![CDATA[").append(relAmt).append("]]></amount>\r\n"); xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>\r\n");
xmlBuffer.append("<drcr_flag>").append("<![CDATA[").append("D").append("]]></drcr_flag>\r\n"); xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>\r\n");
xmlBuffer.append("<item_ser>").append("<![CDATA[").append(itemSer).append("]]></item_ser>\r\n"); xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>\r\n");
xmlBuffer.append("<exch_rate>").append("<![CDATA[").append(exchRate).append("]]></exch_rate>\r\n"); xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>\r\n");
xmlBuffer.append("<confirmed>").append("<![CDATA[").append("N").append("]]></confirmed>\r\n"); xmlBuff.append("<description>").append("Header0 members").append("</description>\r\n");
xmlBuffer.append("<acct_code__tot_ar>").append("<![CDATA[").append(acctCodetotAR).append("]]></acct_code__tot_ar>\r\n"); xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"drcrrcp_dr\" objContext=\"1\">\r\n");
xmlBuffer.append("<cctr_code__tot_ar>").append("<![CDATA[").append(cctrCodetotAR).append("]]></cctr_code__tot_ar>\r\n"); xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n");
//xmlBuffer.append("<milestone_id>").append("<![CDATA[").append(mileStoneId).append("]]></milestone_id>\r\n"); xmlBuff.append("<tran_id/>\r\n");
// xmlBuffer.append("<proj_code>").append("<![CDATA[").append(projCode).append("]]></proj_code>\r\n"); xmlBuff.append("<tran_ser><![CDATA[DRNRCP]]></tran_ser>\r\n");
//xmlBuffer.append("<sale_order>").append("<![CDATA[").append(saleOrder).append("]]></sale_order>\r\n"); xmlBuff.append("<drcr_flag>").append("<![CDATA[").append("D").append("]]></drcr_flag>\r\n");
xmlBuffer.append("<tran_type>").append("<![CDATA[").append("HO").append("]]></tran_type>\r\n");
xmlBuffer.append("<remarks>").append("<![CDATA[").append("Auto Generated Debit Note for POD").append("]]></remarks>\r\n"); xmlBuff.append("<tran_date><![CDATA["+currAppdate +"]]></tran_date>\r\n");
xmlBuffer.append("<chg_user/>\r\n"); xmlBuff.append("<eff_date><![CDATA["+currAppdate+"]]></eff_date>\r\n");
xmlBuffer.append("<chg_term/>\r\n"); //xmlBuff.append("<tran_type><![CDATA["+ tranType +"]]></tran_type>");
xmlBuffer.append("<chg_date>").append("<![CDATA[").append(currAppdate).append("]]></chg_date>\r\n"); xmlBuff.append("<item_ser><![CDATA["+ itemSer +"]]></item_ser>\r\n");
xmlBuffer.append("</Detail1>\r\n"); xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>\r\n");
System.out.println("Detail 2 cml String ---->>[[ "+detail2xmlString+" ]]"); xmlBuff.append("<cust_code><![CDATA["+ custCode +"]]></cust_code>\r\n");
xmlBuffer.append(detail2xmlString); xmlBuff.append("<invoice_id><![CDATA["+ invoiceId +"]]></invoice_id>\r\n");
crTerm=getColumnDescr(conn, "cr_term","invoice","invoice_id", invoiceId);
/*xmlBuffer.append("<Detail2 objContext =\"2\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">"); System.out.println("crTerm---->>["+crTerm+"]");
xmlBuffer.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>"); xmlBuff.append("<cr_term><![CDATA["+ crTerm +"]]></cr_term>");
xmlBuffer.append("<tran_id/>"); xmlBuff.append("<remarks>").append("<![CDATA[").append("Auto Generated Debit Note for POD").append("]]></remarks>\r\n");
xmlBuffer.append("<line_no>").append("<![CDATA[").append(1).append("]]></line_no>"); //xmlBuff.append("<due_date><![CDATA["+ (dueDate==null?"":sdf.format(dueDate).toString()) +"]]></due_date>");
xmlBuffer.append("<net_amt>").append("<![CDATA[").append(relAmt).append("]]></net_amt>"); xmlBuff.append("<fin_entity><![CDATA["+ finEntity +"]]></fin_entity>\r\n");
xmlBuffer.append("<amount>").append("<![CDATA[").append(relAmt).append("]]></amount>"); xmlBuff.append("<curr_code><![CDATA["+ currencyCode +"]]></curr_code>\r\n");
xmlBuffer.append("<acct_code>").append("<![CDATA[").append(acctCodeUDF1).append("]]></acct_code>"); xmlBuff.append("<exch_rate><![CDATA["+ exchRate +"]]></exch_rate>\r\n");
xmlBuffer.append("<cctr_code>").append("<![CDATA[").append(acctCodeUDF2).append("]]></cctr_code>"); //xmlBuff.append("<round_adj><![CDATA["+ roundAdj +"]]></round_adj>");
xmlBuffer.append("<sundry_type>").append("<![CDATA[").append("C").append("]]></sundry_type>\r\n"); //xmlBuff.append("<anal_code><![CDATA["+ analCode +"]]></anal_code>");
xmlBuff.append("<acct_code><![CDATA["+ acctCode +"]]></acct_code>\r\n");
xmlBuffer.append("<item_code>").append("<![CDATA[").append(itmCodeDt2).append("]]></item_code>\r\n"); xmlBuff.append("<cctr_code><![CDATA["+ cctrCode +"]]></cctr_code>\r\n");
xmlBuffer.append("<rate>").append("<![CDATA[").append(rateDt2).append("]]></rate>\r\n"); //xmlBuff.append("<gp_no><![CDATA["+ gpNo +"]]></gp_no>");
xmlBuffer.append("<quantity>").append("<![CDATA[").append(qtyDt2).append("]]></quantity>\r\n"); //xmlBuff.append("<gp_date><![CDATA["+ (gpDate==null?"":sdf.format(gpDate).toString()) +"]]></gp_date>");
xmlBuffer.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]></lot_no>\r\n"); xmlBuff.append("</Detail1>\r\n");
xmlBuffer.append("<lot_sl>").append("<![CDATA[").append(lotSl).append("]]></lot_sl>\r\n");
xmlBuff.append(detail2xmlString);
xmlBuffer.append("</Detail2>");*/
/*xmlBuff.append("<Detail3 dbID='' domID='"+lineNo+"' objName=\"drcrrcp_dr\" objContext=\"2\">");
xmlBuffer.append("</Header0>"); xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuffer.append("</group0>"); xmlBuff.append("<tran_id/>");
xmlBuffer.append("</DocumentRoot>"); xmlBuff.append("<line_no><![CDATA["+lineNo+"]]></line_no>\r\n");
System.out.println("^^^^^^After document root end^^^^^^^^"); xmlBuff.append("<acct_code><![CDATA["+acctCode+"]]></acct_code>\r\n");
xmlString=xmlBuffer.toString(); xmlBuff.append("<cctr_code><![CDATA["+cctrCode+"]]></cctr_code>\r\n");
System.out.println("xmlString of Debit Note --->>139: [["+xmlString+"]]"); xmlBuff.append("<amount><![CDATA[100.10]]></amount>\r\n");
xmlBuff.append("</Detail3>");*/
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString=xmlBuff.toString();
System.out.println("All XML String --->>[["+xmlBuff.toString()+"]]");
System.out.println("------ debit Note Data saving------------------"); System.out.println("------ debit Note Data saving------------------");
retString=saveData(siteCode, xmlString, conn); retString=saveData(siteCode, xmlString, conn);
System.out.println("debit Note Data saved successfully. retString : [["+retString+"]]"); System.out.println("debit Note Data saved successfully. retString : [["+retString+"]]");
...@@ -415,26 +389,24 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -415,26 +389,24 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
String[] arrayForTranId = retString.split("<TranID>"); String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>"); int endIndex = arrayForTranId[1].indexOf("</TranID>");
miscDebitNoteTranID = arrayForTranId[1].substring(0,endIndex); dbTranID = arrayForTranId[1].substring(0,endIndex);
//retString =""; //retString ="";
System.out.println("@@@@@@3: retString"+retString); System.out.println("@@@@@@3: retString"+retString);
System.out.println("miscDebitNoteTranID : "+miscDebitNoteTranID); System.out.println("DebitNoteTranID------>>>["+dbTranID+"]");
if(miscDebitNoteTranID != null && miscDebitNoteTranID.trim().length() > 0) if(dbTranID != null && dbTranID.trim().length() > 0)
{ {
sql="update spl_sales_por_hdr set tran_id__drn = ? where tran_id = ?";
pstmt = conn.prepareStatement(sql); System.out.println("tran_id__drn generated successfully----------");
pstmt.setString(1,miscDebitNoteTranID); debitNoteTranID=dbTranID;
pstmt.setString(2, tranId); }
pstmt.executeUpdate();
System.out.println("tran_id__drn updated successfully----------");
debitNoteTranID=miscDebitNoteTranID;
}
} }
}catch(Exception e) }catch(Exception e)
{ {
isError=true;
retString = e.getMessage(); retString = e.getMessage();
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
...@@ -443,58 +415,172 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -443,58 +415,172 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
return retString; return retString;
} }
private String getDetail2xmlString(double debitNoteAmtItem, String itemCode, double PODrate,double PODqty,String lotNo, String lotSl,int LineNo,Connection conn) private String getDetailsXmlString(Connection conn,String xtraParams,String invoiceId,double rate,double debitNoteAmt)
{ {
System.out.println("in getDetail2xmlString -->> itemCode: "+itemCode+" LineNo : "+LineNo); invoiceId=invoiceId==null ? "" : invoiceId.trim();
StringBuffer detail2xml=new StringBuffer(); System.out.println("in getDetailsXmlString -->> invoiceId--->>["+invoiceId+"]");
StringBuffer detailsXml=new StringBuffer();
PreparedStatement pstmt1=null; PreparedStatement pstmt1=null;
ResultSet rs1=null; ResultSet rs1=null;
String acctCodeUDF1="",acctCodeUDF2="",sql="",itemUnit=""; int lineNo = 0,invoiceLine = 0,invTraceLine = 0;
double quantity = 0,rateStd = 0, rateClg = 0,discount = 0,costRate = 0;
double exchRate = 0,roundAdj = 0, quantityStduom=0,totAmt=0;
String itemCode = "", taxClass = "",taxChapter = "",taxEnv = "",lotNo = "",lotSl = "";
String acctCode="",cctrCode="",loginSiteCode="",sql="";
GenericUtility genericUtility = GenericUtility.getInstance();
try try
{ {
sql="select UDF_STR1,UDF_STR2 from gencodes where FLD_NAME = ? AND MOD_NAME = ? AND FLD_VALUE = ? "; sql = "select invoice_id,line_no,inv_line_no,item_code,tax_class,tax_chap,tax_env,cost_rate,rate__std,quantity,quantity__stduom," +
pstmt1=conn.prepareStatement(sql); "rate__clg,discount,lot_no,lot_sl from invoice_trace where invoice_id = ? order by line_no " ;
pstmt1.setString(1, "REAS_CODE"); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(2, "W_MISC_DRCR_RCP_DR"); pstmt1.setString(1,invoiceId);
pstmt1.setString(3, "PODDBTNOTE"); rs1 = pstmt1.executeQuery();
rs1=pstmt1.executeQuery(); while(rs1.next())
if(rs1.next()) {
{ lineNo ++;
acctCodeUDF1=rs1.getString(1)==null ? "" :rs1.getString(1); invTraceLine = rs1.getInt("line_no");
acctCodeUDF2=rs1.getString(2)==null ? "" :rs1.getString(2); invoiceLine = rs1.getInt("inv_line_no");
} itemCode = rs1.getString("item_code");
rs1.close();rs1=null; taxClass = rs1.getString("tax_class");
pstmt1.close();pstmt1=null; taxChapter = rs1.getString("tax_chap");
System.out.println("acctCodeUDF1 : "+acctCodeUDF1+" acctCodeUDF2 : "+acctCodeUDF2); taxEnv = rs1.getString("tax_env");
costRate = rs1.getDouble("cost_rate");
rateStd = rs1.getDouble("rate__std");
quantity = rs1.getDouble("quantity");
quantityStduom = rs1.getDouble("quantity__stduom");
//rate = rs1.getDouble("rate");
rateClg = rs1.getDouble("rate__clg");
discount = rs1.getDouble("discount");
lotNo = rs1.getString("lot_no");
lotSl = rs1.getString("lot_sl");
if(rateClg==0)
{
rateClg=rate;
}
itemCode=itemCode==null ? "" : itemCode.trim();
taxClass=taxClass==null ? "" : taxClass.trim();
taxChapter=taxChapter==null ? "" : taxChapter.trim();
taxEnv=taxEnv==null ? "" : taxEnv.trim();
lotNo=lotNo==null ? "" : lotNo.trim();
lotSl=lotSl==null ? "" : lotSl.trim();
detailsXml.append("<Detail2 dbID='' domID='"+lineNo+"' objName=\"drcrrcp_dr\" objContext=\"2\">");
detailsXml.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
detailsXml.append("<tran_id/>");
detailsXml.append("<line_no><![CDATA["+lineNo+"]]></line_no>\r\n");
detailsXml.append("<invoice_id><![CDATA["+invoiceId+"]]></invoice_id>\r\n");
detailsXml.append("<line_no__invtrace><![CDATA["+invTraceLine+"]]></line_no__invtrace>\r\n");
detailsXml.append("<line_no__inv><![CDATA["+invoiceLine+"]]></line_no__inv>\r\n");
detailsXml.append("<item_code><![CDATA["+itemCode+"]]></item_code>\r\n");
detailsXml.append("<rate><![CDATA["+rate+"]]></rate>\r\n");
detailsXml.append("<rate__std><![CDATA["+rateStd+"]]></rate__std>\r\n");
detailsXml.append("<quantity><![CDATA["+quantityStduom+"]]></quantity>\r\n");
detailsXml.append("<lot_no><![CDATA["+lotNo+"]]></lot_no>\r\n");
detailsXml.append("<lot_sl><![CDATA["+lotSl+"]]></lot_sl>\r\n");
detailsXml.append("<discount><![CDATA["+discount+"]]></discount>\r\n");
detailsXml.append("<tax_class><![CDATA["+taxClass+"]]></tax_class>\r\n");
detailsXml.append("<tax_chap><![CDATA["+taxChapter+"]]></tax_chap>\r\n");
detailsXml.append("<tax_env><![CDATA["+taxEnv+"]]></tax_env>\r\n");
detailsXml.append("<cost_rate><![CDATA["+costRate+"]]></cost_rate>\r\n");
detailsXml.append("<rate__clg><![CDATA["+rateClg+"]]></rate__clg>\r\n");
//String debitNoteAmt1="100.10";
detailsXml.append("<drcr_amt><![CDATA["+debitNoteAmt+"]]></drcr_amt>\r\n");
detailsXml.append("<net_amt><![CDATA["+debitNoteAmt+"]]></net_amt>\r\n");
//detailsXml.append("<reas_code><![CDATA["+reasCode+"]]></reas_code>");
detailsXml.append("</Detail2>");
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :getDetail2xmlString method :==>"); System.out.println("Exception :getDetail2xmlString method :==>");
isError=true;
e.printStackTrace();
}
System.out.println("@@@@@2: xmlString detail2 + detail3--->>[["+detailsXml.toString()+"]]");
return detailsXml.toString();
}
private int updateDebitNoteAmounts(Connection conn,String tranId,String loginCode,HashMap <Integer,Double> mapDBamount)
{
String sql="";
int lineNo=0,count=0;
double dbAmt=0.0;
PreparedStatement pstmt=null;
//ResultSet rs=null;
Iterator iter = mapDBamount.entrySet().iterator();
try{
while(iter.hasNext())
{
Map.Entry mEntry = (Map.Entry) iter.next();
lineNo=(Integer)mEntry.getKey();
dbAmt=(Double)mEntry.getValue();
System.out.println("Line NO--->>["+lineNo+"]");
System.out.println("dbAmt----->>["+dbAmt+"]");
if(lineNo > 0 && dbAmt > 0 ){
debitNoteHeader=debitNoteHeader + dbAmt;
sql="update spl_sales_por_det set debit_note_amt = ? where tran_id = ? and line_no = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, dbAmt);
pstmt.setString(2, tranId);
pstmt.setInt(3, lineNo);
count=pstmt.executeUpdate();
pstmt.close();
pstmt=null;
} //end condition
}// end while
System.out.println("spl_sales_por_det updated successfully but not commit yet------");
System.out.println("Final debitNote amt Header----->>["+debitNoteHeader+"]");
sql="update spl_sales_por_hdr set debit_note_amt = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, debitNoteHeader);
pstmt.setString(2, tranId);
count=pstmt.executeUpdate();
pstmt.close();
pstmt=null;
System.out.println("spl_sales_por_hdr (debit note amount) updated successfully but not commit yet------");
sql="update spl_sales_por_hdr set tran_id__drn = ? where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,debitNoteTranID);
pstmt.setString(2, tranId);
count=pstmt.executeUpdate();
System.out.println("spl_sales_por_hdr (tran_id__drn) updated successfully but not commit yet------");
sql="update spl_sales_por_hdr set confirmed = ?,conf_date = ?, emp_code__aprv = ? where tran_id = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y");
pstmt.setDate(2, new java.sql.Date(System.currentTimeMillis()));
pstmt.setString(3,loginCode); //loginCode //"E10808"
pstmt.setString(4, tranId);
count=pstmt.executeUpdate();
System.out.println("spl_sales_por_hdr(confirmed) updated successfully but not commit yet------");
}//end try
catch(Exception e){
e.printStackTrace(); e.printStackTrace();
return 0;
} }
itemUnit =getColumnDescr(conn, "unit","item","item_code", itemCode);
System.out.println("Item Code : "+itemCode+" itemCode Unit : "+itemUnit); System.out.println("update count@@@----->>["+count+"]");
detail2xml.append("<Detail2 objContext =\"2\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">"); return count;
detail2xml.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
detail2xml.append("<tran_id/>");
detail2xml.append("<line_no>").append("<![CDATA[").append(LineNo).append("]]></line_no>");
detail2xml.append("<net_amt>").append("<![CDATA[").append(debitNoteAmtItem).append("]]></net_amt>");
detail2xml.append("<amount>").append("<![CDATA[").append(debitNoteAmtItem).append("]]></amount>");
detail2xml.append("<acct_code>").append("<![CDATA[").append(acctCodeUDF1).append("]]></acct_code>");
detail2xml.append("<cctr_code>").append("<![CDATA[").append(acctCodeUDF2).append("]]></cctr_code>");
detail2xml.append("<sundry_type>").append("<![CDATA[").append("C").append("]]></sundry_type>\r\n");
detail2xml.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]></item_code>\r\n");
detail2xml.append("<rate>").append("<![CDATA[").append(PODrate).append("]]></rate>\r\n");
detail2xml.append("<quantity>").append("<![CDATA[").append(PODqty).append("]]></quantity>\r\n");
detail2xml.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]></lot_no>\r\n");
detail2xml.append("<lot_sl>").append("<![CDATA[").append(lotSl).append("]]></lot_sl>\r\n");
detail2xml.append("<unit>").append("<![CDATA[").append(itemUnit).append("]]></unit>\r\n");
detail2xml.append("</Detail2>");
System.out.println("Detail 2 xml string for line no--->>"+LineNo);
return detail2xml.toString();
} }
private String saveData(String siteCode, String xmlString, Connection conn) throws ITMException private String saveData(String siteCode, String xmlString, Connection conn) throws ITMException
{ {
...@@ -511,9 +597,10 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -511,9 +597,10 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
String [] authencate = new String[2]; String [] authencate = new String[2];
authencate[0] = ""; authencate[0] = "";
authencate[1] = ""; authencate[1] = "";
System.out.println("xmlString :::: " + xmlString); System.out.println("xmlString in masterStateful :::: " + xmlString);
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn); retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
masterStateful = null; masterStateful = null;
} }
catch(ITMException itme) catch(ITMException itme)
{ {
...@@ -522,6 +609,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -522,6 +609,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
} }
catch(Exception e) catch(Exception e)
{ {
isError=true;
System.out.println("Exception :PosConfirm :saveData :==>"); System.out.println("Exception :PosConfirm :saveData :==>");
throw new ITMException(e); throw new ITMException(e);
} }
...@@ -560,117 +648,17 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -560,117 +648,17 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
} }
private double debitNoteCalculation(Connection conn,String regulaPrice,double rateInvoice,double qtyInvoice,double podRate,double podQty,String itemCode) throws ITMException, RemoteException private double getDebitNoteAmount (Connection conn,String tranId,int lineNo,double apprvRate,double podRate,double podQty)
{
System.out.println("----------in debitNoteCalculation method----------");
double debitNoteAmount=0.0;
PreparedStatement pstmt1 = null ;
ResultSet rs1 = null ;
String sql = "";
if(regulaPrice.equalsIgnoreCase("Y"))
{
System.out.println("Regulated price-------->> "+regulaPrice);
//double allowPercentageD=0.0,invoiceAmt=0.0,stockistAmt=0.0,actualAllowAmt=0.0,percentageAmtInv=0.0;
String varName="AML_REG_PER",allowPercentage="";
int cnt= getDBRowCount(conn,"disparm","var_name",varName);
System.out.println("Regulated price var name count --->>["+cnt+"] for item code : "+itemCode);
if(cnt > 0)
allowPercentage=getColumnDescr(conn,"100-var_value","disparm","var_name",varName);
else
{
System.out.println("----Count condition is false--------- :"+debitNoteAmount);
isRegPriceNotFound=true;
return debitNoteAmount;
//isRegPrice=true;
}
debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty);
System.out.println("Item code wise debit note :[ItemCode] :["+itemCode+"] :"+debitNoteAmount);
//actualDBamount=actualDBamount + debitNoteAmount;
return debitNoteAmount;
}
else if(regulaPrice.equalsIgnoreCase("N"))
{
System.out.println("Regulated price-------->> "+regulaPrice);
//double allowPercentageD=0.0,invoiceAmt=0.0,stockistAmt=0.0,actualAllowAmt=0.0,percentageAmtInv=0.0;
String varName="AML_NONREG_PER",allowPercentage="";
int cnt= getDBRowCount(conn,"disparm","var_name",varName);
System.out.println("Regulated price var name count --->>["+cnt+"] for item code : "+itemCode);
if(cnt > 0)
allowPercentage=getColumnDescr(conn,"100-var_value","disparm","var_name",varName);
else
{
System.out.println("----Count condition is false--------- :"+debitNoteAmount);
isRegPriceNotFound=true;
return debitNoteAmount;
//isRegPrice=true;
}
debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty);
System.out.println("Item code wise debit note :[ItemCode] :["+itemCode+"] :"+debitNoteAmount);
//actualDBamount=actualDBamount + debitNoteAmount;
return debitNoteAmount;
}
else if (regulaPrice.equalsIgnoreCase("D"))
{
System.out.println("Regulated price-------->> "+regulaPrice);
//double allowPercentageD=0.0,invoiceAmt=0.0,stockistAmt=0.0,actualAllowAmt=0.0,percentageAmtInv=0.0;
String varName="AML_DPCO_PER",allowPercentage="";
int cnt= getDBRowCount(conn,"disparm","var_name",varName);
System.out.println("Regulated price var name count --->>["+cnt+"] for item code : "+itemCode);
if(cnt > 0)
allowPercentage=getColumnDescr(conn,"100-var_value","disparm","var_name",varName);
else
{
System.out.println("----Count condition is false--------- :"+debitNoteAmount);
isRegPriceNotFound=true;
return debitNoteAmount;
//isRegPrice=true;
}
debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty);
System.out.println("Item code wise debit note :[ItemCode] :["+itemCode+"] :"+debitNoteAmount);
//actualDBamount=actualDBamount + debitNoteAmount;
return debitNoteAmount;
}
return debitNoteAmount;
}
private double getDebitNoteAmount (String allowPercentage,double rateInvoice,double qtyInvoice,double podRate,double podQty)
{ {
System.out.println("-------- in getDebitNoteAmount method -------------"); System.out.println("-------- in getDebitNoteAmount method -------------");
double allowPercentageD=0.0,invoiceAmt=0.0,stockistAmt=0.0,actualAllowAmt=0.0,percentageAmtInv=0.0,debitNoteCaclAmount=0.0; double debitNoteAmount=0,aprvRate=0;
System.out.println("apprvRate-->>["+apprvRate+"]");
System.out.println("podRate-->>["+podRate+"]");
allowPercentage=allowPercentage==null ? "0.0" :allowPercentage; System.out.println("podQty-->>["+podQty+"]");
allowPercentageD=Double.parseDouble(allowPercentage); debitNoteAmount= (podRate - apprvRate) * podQty;
/*invoiceAmt= rateInvoice * qtyInvoice;//10 *100 System.out.println("debitNoteAmount-->>["+debitNoteAmount+"]");
percentageAmtInv= invoiceAmt * allowPercentageD/100; //1000 * 10/100 return debitNoteAmount;
actualAllowAmt= invoiceAmt + percentageAmtInv; //1100
System.out.println("getDebitNoteAmount -->> actualAllowAmt---------->> "+actualAllowAmt);
stockistAmt= podRate * podQty; //12 * 100 = 1200 */
invoiceAmt= rateInvoice * podQty;//10 * 60 = 600
percentageAmtInv= invoiceAmt * allowPercentageD/100; //600 * 10/100=60
actualAllowAmt= invoiceAmt + percentageAmtInv; //660
System.out.println("getDebitNoteAmount -->> actualAllowAmt---------->> "+actualAllowAmt);
stockistAmt= podRate * podQty; //12 * 60 = 720
if(stockistAmt > actualAllowAmt)
debitNoteCaclAmount= stockistAmt - actualAllowAmt; //720 - 660=60
else
debitNoteCaclAmount=0.0;
System.out.println("--------debitNoteCaclAmount------ :Debit note amount "+debitNoteCaclAmount);
return debitNoteCaclAmount;
} }
private boolean isRegulatePriceNull(Connection conn,String tranId) private boolean isRegulatePriceNull(Connection conn,String tranId)
...@@ -707,63 +695,215 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -707,63 +695,215 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
} }
private int getDBRowCount(Connection conn, String table_name, String whrCondCol, String whrCondVal)
public String confirmDebitNote(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) throws ITMException
{ {
int count=-1; String methodName = "";
String compName = "";
if(conn!=null){ String retString = "";
String serviceCode = "";
ResultSet rs=null; String serviceURI = "";
PreparedStatement pstmt = null; String actionURI = "";
String sql = "";
String sql="select count(1) from "+table_name+" where "+whrCondCol+" = ?"; PreparedStatement pstmt = null;
System.out.println("SQL in getDBRowCount method : "+sql); ResultSet rs = null;
try try
{ {
pstmt = conn.prepareStatement(sql); //ConnDriver connDriver = new ConnDriver();
pstmt.setString(1,whrCondVal); //conn = connDriver.getConnectDB("DriverITM");
rs = pstmt.executeQuery(); System.out.println("-------in confirmDebitNote mothod----------------");
if(rs.next()) tranIdFr=tranIdFr==null ? "" :tranIdFr.trim();
{ System.out.println("Tran id for debit note--->>"+tranIdFr+"]");
count = rs.getInt(1); methodName = "gbf_post";
} actionURI = "http://NvoServiceurl.org/" + methodName;
}
catch(SQLException e) sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'pre_confirm' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,businessObj);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
}
compName=compName==null ? "" :compName.trim();
System.out.println("serviceCode = ["+serviceCode+"] compName ["+compName+"]");
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceURI = rs.getString("SERVICE_URI");
}
serviceURI=serviceURI==null ? "" :serviceURI.trim();
System.out.println("serviceURI = ["+serviceURI+"]---> compName = ["+compName+"]");
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[4];
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tran_id"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "forced_flag"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compName);
aobj[1] = new String(tranIdFr);
aobj[2] = new String(xtraParams);
aobj[3] = new String(forcedFlag);
//System.out.println("@@@@@@@@@@loginEmpCode:" +genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode")+":");
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
System.out.println("Confirm Complete @@@@@@@@@@@ Return string from NVO is:==>["+retString+"]");
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (pstmt != null )
{ {
System.out.println("SQL Exception In getDBRowCount method of SalesEnquiry Class : "+e.getMessage()); pstmt.close();
e.printStackTrace(); pstmt = null;
} }
catch(Exception ex) /*if( conn != null ){
conn.close();
conn = null;
}*/
}
catch(Exception e)
{
System.out.println("Exception inCalling confirmed");
e.printStackTrace();
try{
conn.rollback();
}catch (Exception s)
{ {
System.out.println("Exception In getDBRowCount method of SalesEnquiry Class : "+ex.getMessage()); System.out.println("Unable to rollback");
ex.printStackTrace(); s.printStackTrace();
}finally{
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
}
}else{
try {
throw new SQLException("Connection passed to SalesEnquiry.getDBRowCount() method is null");
} catch (SQLException e) {
e.printStackTrace();
} }
throw new ITMException(e);
} }
return count; }
} return retString;
}//end confirmCreditNote
public String confirmConsOrder(String businessObj, String tranIdFr,String xtraParams, Connection conn) throws ITMException
{
String methodName = "";
String compName = "";
String retString = "";
String serviceCode = "";
String serviceURI = "";
String actionURI = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
System.out.println("confirmSaleOrder(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) called >>><!@#>");
try
{
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
System.out.println("enter in confirm method [[[[[[[[[[[]]]]]]]]]]] >>>>>");
methodName = "gbf_post";
actionURI = "http://NvoServiceurl.org/" + methodName;
sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'pre_confirm' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,businessObj);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
}
System.out.println("serviceCode = "+serviceCode+" compName "+compName);
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceURI = rs.getString("SERVICE_URI");
}
System.out.println("serviceURI = "+serviceURI+" compName = "+compName);
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org",methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[4];
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org","component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org","tran_id"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org","xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org","forced_flag"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compName);
aobj[1] = new String(tranIdFr);
aobj[2] = new String(xtraParams);
//aobj[3] = new String(forcedFlag);
//System.out.println("@@@@@@@@@@loginEmpCode:"+genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode")+":");
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
System.out.println("Confirm Complete @@@@@@@@@@@ Return string from NVO is:==>["+retString+"]");
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
/*if( conn != null ){
conn.close();
conn = null;
}*/
}
catch(Exception e)
{
System.out.println("Exception inCalling confirmed");
e.printStackTrace();
try{
conn.rollback();
}catch (Exception s)
{
System.out.println("Unable to rollback");
s.printStackTrace();
}
throw new ITMException(e);
}
}
return retString;
}
} }
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