Commit 96cee21e authored by dpawar's avatar dpawar

added functionality of auto confirmation Debit note


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93417 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 027a677b
...@@ -5,6 +5,7 @@ import ibase.system.config.ConnDriver; ...@@ -5,6 +5,7 @@ import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB; import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal; import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.fin.MiscDrCrRcpConf;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
...@@ -13,13 +14,15 @@ import java.sql.PreparedStatement; ...@@ -13,13 +14,15 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.HashMap;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.naming.InitialContext; import javax.naming.InitialContext;
@Stateless @Stateless
public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeliveryConfLocal,ProofOfDeliveryConfRemote public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeliveryConfLocal,ProofOfDeliveryConfRemote
{ {
String debitNoteTranID="";
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 ------------- : ");
...@@ -42,12 +45,14 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -42,12 +45,14 @@ 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-----------");
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=""; String errString="",sql="",loginSite="",wfStatus="",itemCode="",regulatedPrice="";
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 invRate=0.0,invQty=0.0,PODrate=0.0,PODqty=0.0,allowedAmt=0.0,stockistAmt=0.0,debitNoteAmtAct=0.0;
int updCnt=0,lineNo=0; int updCnt=0,lineNo=0;
ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB(); ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB();
...@@ -94,7 +99,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -94,7 +99,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
if(wfStatus.trim().equalsIgnoreCase("S")) if(wfStatus.trim().equalsIgnoreCase("S"))
{ {
String invoiceId="",custCode="",siteCode="",currCode="",loginCode=""; String invoiceId="",custCode="",siteCode="",currCode="",loginCode="";
double ExchRate=0.0; double ExchRate=0.0,actualDBamount=0.0;
boolean isRegPrice=false; boolean isRegPrice=false;
GenericUtility genericUtility=new GenericUtility(); GenericUtility genericUtility=new GenericUtility();
loginCode=genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"); loginCode=genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
...@@ -113,16 +118,17 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -113,16 +118,17 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
if (updCnt > 0) if (updCnt > 0)
{ {
sql=""; sql="";
sql="select 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);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
custCode=rs.getString(1)==null ? "" : rs.getString(1); invoiceId=rs.getString(1);
siteCode=rs.getString(2)==null ? "" : rs.getString(2); custCode=rs.getString(2)==null ? "" : rs.getString(2);
currCode=rs.getString(3)==null ? "" : rs.getString(3); siteCode=rs.getString(3)==null ? "" : rs.getString(3);
ExchRate=rs.getDouble(4); currCode=rs.getString(4)==null ? "" : rs.getString(4);
ExchRate=rs.getDouble(5);
} }
if(rs != null) if(rs != null)
{ {
...@@ -136,7 +142,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -136,7 +142,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
} }
sql=""; sql="";
sql="select item_code,rate__inv,quantity__inv,rate__resale,quantity__resale,line_no from spl_sales_por_det where tran_id = ?"; 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 = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
...@@ -148,40 +154,55 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -148,40 +154,55 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
PODrate=rs.getDouble(4); PODrate=rs.getDouble(4);
PODqty=rs.getDouble(5); PODqty=rs.getDouble(5);
lineNo=rs.getInt(6); lineNo=rs.getInt(6);
System.out.println("Line NO :"+lineNo+"------->> invRate : "+invRate+" invQty : "+invQty+" PODrate : "+PODrate+ " PODqty : "+PODqty); lotNo=rs.getString(7)== null ? "" : 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); regulatedPrice=getColumnDescr(conn,"regulated_price","item","item_code",itemCode);
//regulatedPrice if null then //regulatedPrice if null then
//isRegPrice=;
if(isRegulatePriceNull(conn,tranId)) if(isRegulatePriceNull(conn,tranId))
{ {
//Error : Regulated price is Null //Error : Regulated price is Null
errString = itmdbAccess.getErrorString("", "VTREGPRCN", "", "", conn); errString = itmdbAccess.getErrorString("", "VTREGPRCN", "", "", conn);
System.out.println("---------Error : Regulated price is Null----------"); System.out.println("---------Error : Regulated price is Null----------");
return errString; return errString;
} }
else else
{ {
debitNoteAmtAct=debitNoteCalculation(conn,regulatedPrice,invRate,invQty,PODrate,PODqty); debitNoteAmtAct=debitNoteCalculation(conn,regulatedPrice,invRate,invQty,PODrate,PODqty,itemCode);
System.out.println("Line no -->"+lineNo+" --debitNoteAmtAct ------->>"+debitNoteAmtAct); actualDBamount=actualDBamount + debitNoteAmtAct;
if (debitNoteAmtAct > 0) detail2xmlString=detail2xmlString + getDetail2xmlString(debitNoteAmtAct,itemCode,PODrate,PODqty,lotNo,lotSl,lineNo,conn);
{ System.out.println("itemCode : "+itemCode+" Line no -->"+lineNo+" --debitNoteAmtAct ------->>"+debitNoteAmtAct);
System.out.println("-----Debit note generation condition----------"); }
errString=genDebitNote(tranId,custCode,siteCode,xtraParams,debitNoteAmtAct,currCode,ExchRate, conn);
conn.commit();
errString = itmdbAccess.getErrorString("", "VTCONSUCF", "", "", conn);
System.out.println("------@@@Debit Note Generated successfully------------------");
}
else
{
System.out.println("--------Debit note not generated------------- ");
conn.commit();
}
}
} } //end while
System.out.println("Final actualDBamount---------->> : "+actualDBamount);
if ( actualDBamount > 0)
{
System.out.println("-----Debit note generation condition----------"+actualDBamount);
errString=genDebitNote(tranId,invoiceId,custCode,siteCode,xtraParams,actualDBamount,currCode,ExchRate,detail2xmlString, conn);
System.out.println("------@@@Debit Note Generated successfully for amount : "+actualDBamount);
//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)
{
conn.commit();
errString = itmdbAccess.getErrorString("", "VTCONSUCF", "", "", conn);
System.out.println("------@@@Debit Note Generated successfully for amount : "+actualDBamount);
System.out.println("Confirmation of Debit note done successfully----------");
}
else
conn.rollback();
}
else
{
System.out.println("--------Debit note not generated------------- ");
conn.commit();
}
} }
} }
...@@ -244,7 +265,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -244,7 +265,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
return errString; return errString;
} }
private String genDebitNote(String tranId,String custCode,String siteCode ,String xtraParams,double relAmt,String currencyCode,double exchRate, 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----------->");
...@@ -255,13 +276,9 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -255,13 +276,9 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
SimpleDateFormat sdf=null; SimpleDateFormat sdf=null;
String currAppdate =""; String currAppdate ="";
java.sql.Timestamp currDate = null; java.sql.Timestamp currDate = null;
//String siteCode=""; String itemSer="";
String finEntity=""; String finEntity="",acctCode="",cctrCode="",acctCodetotAR="",cctrCodetotAR="",miscDebitNoteTranID="";
String acctCode=""; String acctCodeUDF1="",acctCodeUDF2="";
String cctrCode="";
String acctCodetotAR="";
String cctrCodetotAR="";
String miscDebitNoteTranID="";
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ResultSet rs=null;
int count=0; int count=0;
...@@ -292,13 +309,15 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -292,13 +309,15 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ; currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdate = sdf.format(currDate); currAppdate = sdf.format(currDate);
//siteCode =(genutility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode")); itemSer =getColumnDescr(conn, "item_ser","invoice","invoice_id", invoiceId);
finEntity = getColumnDescr(conn, "fin_entity","site","site_code", siteCode); finEntity = getColumnDescr(conn, "fin_entity","site","site_code", siteCode);
acctCode = getColumnDescr(conn,"acct_code__ar", "customer", "cust_code", custCode); acctCode = getColumnDescr(conn,"acct_code__ar", "customer", "cust_code", custCode);
cctrCode = getColumnDescr(conn,"cctr_code__ar", "customer", "cust_code", custCode); cctrCode = getColumnDescr(conn,"cctr_code__ar", "customer", "cust_code", custCode);
//acctCodetotAR=findValue(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=findValue(conn,"CCTR_CODE__TOT_AR", "item_acct_detr", "item_ser", itemser); //cctrCodetotAR=getColumnDescr(conn,"CCTR_CODE__TOT_AR", "item_acct_detr", "item_ser", itemSer);
System.out.println("-------FinEntity : "+finEntity+" acctCode : "+acctCode+ " cctrCode : "+cctrCode); cctrCodetotAR = cctrCodetotAR== null ? " " :cctrCodetotAR;
xmlBuffer.append("<Detail1 objContext =\"1\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">"); xmlBuffer.append("<Detail1 objContext =\"1\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">");
xmlBuffer.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>"); xmlBuffer.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
...@@ -315,11 +334,11 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -315,11 +334,11 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
xmlBuffer.append("<curr_code>").append("<![CDATA[" + currencyCode + "]]>").append("</curr_code>"); xmlBuffer.append("<curr_code>").append("<![CDATA[" + currencyCode + "]]>").append("</curr_code>");
xmlBuffer.append("<amount>").append("<![CDATA[").append(relAmt).append("]]></amount>\r\n"); xmlBuffer.append("<amount>").append("<![CDATA[").append(relAmt).append("]]></amount>\r\n");
xmlBuffer.append("<drcr_flag>").append("<![CDATA[").append("D").append("]]></drcr_flag>\r\n"); xmlBuffer.append("<drcr_flag>").append("<![CDATA[").append("D").append("]]></drcr_flag>\r\n");
//xmlBuffer.append("<item_ser>").append("<![CDATA[").append(itemser).append("]]></item_ser>\r\n"); xmlBuffer.append("<item_ser>").append("<![CDATA[").append(itemSer).append("]]></item_ser>\r\n");
xmlBuffer.append("<exch_rate>").append("<![CDATA[").append(exchRate).append("]]></exch_rate>\r\n"); xmlBuffer.append("<exch_rate>").append("<![CDATA[").append(exchRate).append("]]></exch_rate>\r\n");
xmlBuffer.append("<confirmed>").append("<![CDATA[").append("N").append("]]></confirmed>\r\n"); xmlBuffer.append("<confirmed>").append("<![CDATA[").append("N").append("]]></confirmed>\r\n");
//xmlBuffer.append("<acct_code__tot_ar>").append("<![CDATA[").append(acctCodetotAR).append("]]></acct_code__tot_ar>\r\n"); xmlBuffer.append("<acct_code__tot_ar>").append("<![CDATA[").append(acctCodetotAR).append("]]></acct_code__tot_ar>\r\n");
//xmlBuffer.append("<cctr_code__tot_ar>").append("<![CDATA[").append(cctrCodetotAR).append("]]></cctr_code__tot_ar>\r\n"); xmlBuffer.append("<cctr_code__tot_ar>").append("<![CDATA[").append(cctrCodetotAR).append("]]></cctr_code__tot_ar>\r\n");
//xmlBuffer.append("<milestone_id>").append("<![CDATA[").append(mileStoneId).append("]]></milestone_id>\r\n"); //xmlBuffer.append("<milestone_id>").append("<![CDATA[").append(mileStoneId).append("]]></milestone_id>\r\n");
// xmlBuffer.append("<proj_code>").append("<![CDATA[").append(projCode).append("]]></proj_code>\r\n"); // xmlBuffer.append("<proj_code>").append("<![CDATA[").append(projCode).append("]]></proj_code>\r\n");
//xmlBuffer.append("<sale_order>").append("<![CDATA[").append(saleOrder).append("]]></sale_order>\r\n"); //xmlBuffer.append("<sale_order>").append("<![CDATA[").append(saleOrder).append("]]></sale_order>\r\n");
...@@ -328,31 +347,38 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -328,31 +347,38 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
xmlBuffer.append("<chg_user/>\r\n"); xmlBuffer.append("<chg_user/>\r\n");
xmlBuffer.append("<chg_term/>\r\n"); xmlBuffer.append("<chg_term/>\r\n");
xmlBuffer.append("<chg_date>").append("<![CDATA[").append(currAppdate).append("]]></chg_date>\r\n"); xmlBuffer.append("<chg_date>").append("<![CDATA[").append(currAppdate).append("]]></chg_date>\r\n");
xmlBuffer.append("</Detail1>\r\n"); xmlBuffer.append("</Detail1>\r\n");
System.out.println("Detail 2 cml String ---->>[[ "+detail2xmlString+" ]]");
/*xmlBuffer.append("<Detail2 objContext =\"2\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">"); xmlBuffer.append(detail2xmlString);
xmlBuffer.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuffer.append("<tran_id/>"); /*xmlBuffer.append("<Detail2 objContext =\"2\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">");
xmlBuffer.append("<line_no>").append("<![CDATA[").append(1).append("]]></line_no>"); xmlBuffer.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuffer.append("<net_amt>").append("<![CDATA[").append(relAmt).append("]]></net_amt>"); xmlBuffer.append("<tran_id/>");
xmlBuffer.append("<amount>").append("<![CDATA[").append(relAmt).append("]]></amount>"); xmlBuffer.append("<line_no>").append("<![CDATA[").append(1).append("]]></line_no>");
xmlBuffer.append("<acct_code>").append("<![CDATA[").append(acctCodetotAR).append("]]></acct_code>"); xmlBuffer.append("<net_amt>").append("<![CDATA[").append(relAmt).append("]]></net_amt>");
xmlBuffer.append("<cctr_code>").append("<![CDATA[").append(cctrCodetotAR).append("]]></cctr_code>"); xmlBuffer.append("<amount>").append("<![CDATA[").append(relAmt).append("]]></amount>");
xmlBuffer.append("<sundry_type>").append("<![CDATA[").append("C").append("]]></sundry_type>\r\n"); xmlBuffer.append("<acct_code>").append("<![CDATA[").append(acctCodeUDF1).append("]]></acct_code>");
xmlBuffer.append("<tax_class>").append("<![CDATA[").append(taxClass).append("]]></tax_class>\r\n"); xmlBuffer.append("<cctr_code>").append("<![CDATA[").append(acctCodeUDF2).append("]]></cctr_code>");
xmlBuffer.append("<tax_chap>").append("<![CDATA[").append(taxChap).append("]]></tax_chap>\r\n"); xmlBuffer.append("<sundry_type>").append("<![CDATA[").append("C").append("]]></sundry_type>\r\n");
xmlBuffer.append("<tax_env>").append("<![CDATA[").append(taxEnv).append("]]></tax_env>\r\n");
xmlBuffer.append("<item_code>").append("<![CDATA[").append(itmCodeDt2).append("]]></item_code>\r\n");
xmlBuffer.append("</Detail2>");*/ xmlBuffer.append("<rate>").append("<![CDATA[").append(rateDt2).append("]]></rate>\r\n");
xmlBuffer.append("<quantity>").append("<![CDATA[").append(qtyDt2).append("]]></quantity>\r\n");
xmlBuffer.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]></lot_no>\r\n");
xmlBuffer.append("<lot_sl>").append("<![CDATA[").append(lotSl).append("]]></lot_sl>\r\n");
xmlBuffer.append("</Detail2>");*/
xmlBuffer.append("</Header0>"); xmlBuffer.append("</Header0>");
xmlBuffer.append("</group0>"); xmlBuffer.append("</group0>");
xmlBuffer.append("</DocumentRoot>"); xmlBuffer.append("</DocumentRoot>");
System.out.println("^^^^^^After document root end^^^^^^^^"); System.out.println("^^^^^^After document root end^^^^^^^^");
xmlString=xmlBuffer.toString(); xmlString=xmlBuffer.toString();
System.out.println("xmlString of Debit Note --->>: [["+xmlString+"]]"); System.out.println("xmlString of Debit Note --->>139: [["+xmlString+"]]");
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 successfully123------------------"); System.out.println("debit Note Data saved successfully. retString : [["+retString+"]]");
if (retString.indexOf("Success") > -1) if (retString.indexOf("Success") > -1)
{ {
System.out.println("retString.indexOf(Success) > -1)"); System.out.println("retString.indexOf(Success) > -1)");
...@@ -371,6 +397,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -371,6 +397,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
pstmt.setString(2, tranId); pstmt.setString(2, tranId);
pstmt.executeUpdate(); pstmt.executeUpdate();
System.out.println("tran_id__drn updated successfully----------"); System.out.println("tran_id__drn updated successfully----------");
debitNoteTranID=miscDebitNoteTranID;
} }
} }
...@@ -386,6 +413,56 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -386,6 +413,56 @@ 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)
{
System.out.println("in getDetail2xmlString -->> itemCode: "+itemCode+" LineNo : "+LineNo);
StringBuffer detail2xml=new StringBuffer();
PreparedStatement pstmt1=null;
ResultSet rs1=null;
String acctCodeUDF1="",acctCodeUDF2="",sql="";
try
{
sql="select UDF_STR1,UDF_STR2 from gencodes where FLD_NAME = ? AND MOD_NAME = ? AND FLD_VALUE = ? ";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, "REAS_CODE");
pstmt1.setString(2, "W_MISC_DRCR_RCP_DR");
pstmt1.setString(3, "PODDBTNOTE");
rs1=pstmt1.executeQuery();
if(rs1.next())
{
acctCodeUDF1=rs1.getString(1)==null ? "" :rs1.getString(1);
acctCodeUDF2=rs1.getString(2)==null ? "" :rs1.getString(2);
}
rs1.close();rs1=null;
pstmt1.close();pstmt1=null;
System.out.println("acctCodeUDF1 : "+acctCodeUDF1+" acctCodeUDF2 : "+acctCodeUDF2);
}
catch(Exception e)
{
System.out.println("Exception :getDetail2xmlString method :==>");
e.printStackTrace();
}
detail2xml.append("<Detail2 objContext =\"2\"").append(" objName=\"misc_drcr_rcp_dr\" domID=\"1\" dbID=\"\">");
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("DOZ").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
{ {
...@@ -452,7 +529,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -452,7 +529,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
} }
private double debitNoteCalculation(Connection conn,String regulaPrice,double rateInvoice,double qtyInvoice,double podRate,double podQty) throws ITMException, RemoteException private double debitNoteCalculation(Connection conn,String regulaPrice,double rateInvoice,double qtyInvoice,double podRate,double podQty,String itemCode) throws ITMException, RemoteException
{ {
System.out.println("----------in debitNoteCalculation method----------"); System.out.println("----------in debitNoteCalculation method----------");
double debitNoteAmount=0.0; double debitNoteAmount=0.0;
...@@ -470,19 +547,8 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -470,19 +547,8 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty); debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty);
/*allowPercentage=allowPercentage==null ? "0.0" :allowPercentage; System.out.println("Item code wise debit note :[ItemCode] :["+itemCode+"] :"+debitNoteAmount);
allowPercentageD=Double.parseDouble(allowPercentage); //actualDBamount=actualDBamount + debitNoteAmount;
invoiceAmt= rateInvoice * qtyInvoice;//10 *100
percentageAmtInv= invoiceAmt * allowPercentageD/100; //1000 * 10/100
actualAllowAmt= invoiceAmt + percentageAmtInv; //1100
stockistAmt= podRate * podQty; //12 * 100 = 1200
if(stockistAmt > actualAllowAmt)
debitNoteAmount= stockistAmt - actualAllowAmt;
else
debitNoteAmount=0.0; */
System.out.println("Actual Debit note Amount : "+debitNoteAmount);
return debitNoteAmount; return debitNoteAmount;
} }
else if(regulaPrice.equalsIgnoreCase("N")) else if(regulaPrice.equalsIgnoreCase("N"))
...@@ -494,20 +560,8 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -494,20 +560,8 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty); debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty);
/*allowPercentage=allowPercentage==null ? "0.0" :allowPercentage; System.out.println("Item code wise debit note :[ItemCode] :["+itemCode+"] :"+debitNoteAmount);
allowPercentageD=Double.parseDouble(allowPercentage); //actualDBamount=actualDBamount + debitNoteAmount;
invoiceAmt= rateInvoice * qtyInvoice;//10 *100
percentageAmtInv= invoiceAmt * allowPercentageD/100; //1000 * 10/100
actualAllowAmt= invoiceAmt + percentageAmtInv; //1100
stockistAmt= podRate * podQty; //12 * 100 = 1200
if(stockistAmt > actualAllowAmt)
debitNoteAmount= stockistAmt - actualAllowAmt;
else
debitNoteAmount=0.0;*/
System.out.println("Actual Debit note Amount : "+debitNoteAmount);
return debitNoteAmount; return debitNoteAmount;
} }
...@@ -519,24 +573,11 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -519,24 +573,11 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
allowPercentage=getColumnDescr(conn,"100-var_value","disparm","var_name",varName); allowPercentage=getColumnDescr(conn,"100-var_value","disparm","var_name",varName);
debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty); debitNoteAmount=getDebitNoteAmount(allowPercentage,rateInvoice,qtyInvoice,podRate,podQty);
System.out.println("Actual Debit note Amount : "+debitNoteAmount); System.out.println("Item code wise debit note :[ItemCode] :["+itemCode+"] :"+debitNoteAmount);
/*invoiceAmt= rateInvoice * qtyInvoice;//10 *100 //actualDBamount=actualDBamount + debitNoteAmount;
percentageAmtInv= invoiceAmt * allowPercentageD/100; //1000 * 10/100 return debitNoteAmount;
actualAllowAmt= invoiceAmt + percentageAmtInv; //1100
stockistAmt= podRate * podQty; //12 * 100 = 1200
if(stockistAmt > actualAllowAmt)
debitNoteAmount= stockistAmt - actualAllowAmt; //1200 -1100 =100
else
debitNoteAmount=0.0;*/
return debitNoteAmount;
} }
return debitNoteAmount; return debitNoteAmount;
} }
...@@ -598,4 +639,5 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -598,4 +639,5 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
return false; return false;
} }
} }
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